1use crate::errors::InvokeError;
2use crate::internal_prelude::*;
3use crate::system::system_modules::costing::*;
4use crate::vm::wasm::*;
5use radix_engine_interface::api::actor_api::EventFlags;
6use sbor::rust::vec::Vec;
7
8pub struct NoOpWasmRuntime<'a> {
10 pub fee_reserve: SystemLoanFeeReserve,
11 pub wasm_execution_units_consumed: &'a mut u64,
12 pub fee_table: FeeTable,
13}
14
15impl<'a> NoOpWasmRuntime<'a> {
16 pub fn new(
17 fee_reserve: SystemLoanFeeReserve,
18 wasm_execution_units_consumed: &'a mut u64,
19 ) -> Self {
20 Self {
21 fee_reserve,
22 wasm_execution_units_consumed,
23 fee_table: FeeTable::latest(),
24 }
25 }
26}
27
28#[allow(unused_variables)]
29impl<'a> WasmRuntime for NoOpWasmRuntime<'a> {
30 fn allocate_buffer(
31 &mut self,
32 buffer: Vec<u8>,
33 ) -> Result<Buffer, InvokeError<WasmRuntimeError>> {
34 Err(InvokeError::SelfError(WasmRuntimeError::NotImplemented))
35 }
36
37 fn buffer_consume(
38 &mut self,
39 buffer_id: BufferId,
40 ) -> Result<Vec<u8>, InvokeError<WasmRuntimeError>> {
41 Err(InvokeError::SelfError(WasmRuntimeError::NotImplemented))
42 }
43
44 fn object_call(
45 &mut self,
46 receiver: Vec<u8>,
47 ident: Vec<u8>,
48 args: Vec<u8>,
49 ) -> Result<Buffer, InvokeError<WasmRuntimeError>> {
50 Err(InvokeError::SelfError(WasmRuntimeError::NotImplemented))
51 }
52
53 fn object_call_module(
54 &mut self,
55 receiver: Vec<u8>,
56 module_id: u32,
57 ident: Vec<u8>,
58 args: Vec<u8>,
59 ) -> Result<Buffer, InvokeError<WasmRuntimeError>> {
60 Err(InvokeError::SelfError(WasmRuntimeError::NotImplemented))
61 }
62
63 fn object_call_direct(
64 &mut self,
65 receiver: Vec<u8>,
66 ident: Vec<u8>,
67 args: Vec<u8>,
68 ) -> Result<Buffer, InvokeError<WasmRuntimeError>> {
69 Err(InvokeError::SelfError(WasmRuntimeError::NotImplemented))
70 }
71
72 fn blueprint_call(
73 &mut self,
74 package_address: Vec<u8>,
75 blueprint_name: Vec<u8>,
76 ident: Vec<u8>,
77 args: Vec<u8>,
78 ) -> Result<Buffer, InvokeError<WasmRuntimeError>> {
79 Err(InvokeError::SelfError(WasmRuntimeError::NotImplemented))
80 }
81
82 fn object_new(
83 &mut self,
84 blueprint_name: Vec<u8>,
85 object_states: Vec<u8>,
86 ) -> Result<Buffer, InvokeError<WasmRuntimeError>> {
87 Err(InvokeError::SelfError(WasmRuntimeError::NotImplemented))
88 }
89
90 fn address_allocate(
91 &mut self,
92 package_address: Vec<u8>,
93 blueprint_name: Vec<u8>,
94 ) -> Result<Buffer, InvokeError<WasmRuntimeError>> {
95 Err(InvokeError::SelfError(WasmRuntimeError::NotImplemented))
96 }
97
98 fn address_get_reservation_address(
99 &mut self,
100 node_id: Vec<u8>,
101 ) -> Result<Buffer, InvokeError<WasmRuntimeError>> {
102 Err(InvokeError::SelfError(WasmRuntimeError::NotImplemented))
103 }
104
105 fn globalize_object(
106 &mut self,
107 node_id: Vec<u8>,
108 modules: Vec<u8>,
109 address: Vec<u8>,
110 ) -> Result<Buffer, InvokeError<WasmRuntimeError>> {
111 Err(InvokeError::SelfError(WasmRuntimeError::NotImplemented))
112 }
113
114 fn key_value_store_new(
115 &mut self,
116 schema: Vec<u8>,
117 ) -> Result<Buffer, InvokeError<WasmRuntimeError>> {
118 Err(InvokeError::SelfError(WasmRuntimeError::NotImplemented))
119 }
120
121 fn key_value_store_open_entry(
122 &mut self,
123 node_id: Vec<u8>,
124 offset: Vec<u8>,
125 flags: u32,
126 ) -> Result<SubstateHandle, InvokeError<WasmRuntimeError>> {
127 Err(InvokeError::SelfError(WasmRuntimeError::NotImplemented))
128 }
129
130 fn key_value_entry_get(
131 &mut self,
132 handle: u32,
133 ) -> Result<Buffer, InvokeError<WasmRuntimeError>> {
134 Err(InvokeError::SelfError(WasmRuntimeError::NotImplemented))
135 }
136
137 fn key_value_entry_set(
138 &mut self,
139 handle: u32,
140 data: Vec<u8>,
141 ) -> Result<(), InvokeError<WasmRuntimeError>> {
142 Err(InvokeError::SelfError(WasmRuntimeError::NotImplemented))
143 }
144
145 fn key_value_entry_remove(
146 &mut self,
147 handle: u32,
148 ) -> Result<Buffer, InvokeError<WasmRuntimeError>> {
149 Err(InvokeError::SelfError(WasmRuntimeError::NotImplemented))
150 }
151
152 fn key_value_entry_close(&mut self, handle: u32) -> Result<(), InvokeError<WasmRuntimeError>> {
153 Err(InvokeError::SelfError(WasmRuntimeError::NotImplemented))
154 }
155
156 fn key_value_store_remove_entry(
157 &mut self,
158 node_id: Vec<u8>,
159 key: Vec<u8>,
160 ) -> Result<Buffer, InvokeError<WasmRuntimeError>> {
161 Err(InvokeError::SelfError(WasmRuntimeError::NotImplemented))
162 }
163
164 fn actor_open_field(
165 &mut self,
166 object_handle: u32,
167 field: u8,
168 flags: u32,
169 ) -> Result<u32, InvokeError<WasmRuntimeError>> {
170 Err(InvokeError::SelfError(WasmRuntimeError::NotImplemented))
171 }
172
173 fn field_entry_read(&mut self, handle: u32) -> Result<Buffer, InvokeError<WasmRuntimeError>> {
174 Err(InvokeError::SelfError(WasmRuntimeError::NotImplemented))
175 }
176
177 fn field_entry_write(
178 &mut self,
179 handle: u32,
180 data: Vec<u8>,
181 ) -> Result<(), InvokeError<WasmRuntimeError>> {
182 Err(InvokeError::SelfError(WasmRuntimeError::NotImplemented))
183 }
184
185 fn field_entry_close(&mut self, _handle: u32) -> Result<(), InvokeError<WasmRuntimeError>> {
186 Err(InvokeError::SelfError(WasmRuntimeError::NotImplemented))
187 }
188
189 fn actor_get_node_id(&mut self, _handle: u32) -> Result<Buffer, InvokeError<WasmRuntimeError>> {
190 Err(InvokeError::SelfError(WasmRuntimeError::NotImplemented))
191 }
192
193 fn actor_get_package_address(&mut self) -> Result<Buffer, InvokeError<WasmRuntimeError>> {
194 Err(InvokeError::SelfError(WasmRuntimeError::NotImplemented))
195 }
196
197 fn actor_get_blueprint_name(&mut self) -> Result<Buffer, InvokeError<WasmRuntimeError>> {
198 Err(InvokeError::SelfError(WasmRuntimeError::NotImplemented))
199 }
200
201 fn consume_wasm_execution_units(
202 &mut self,
203 n: u32,
204 ) -> Result<(), InvokeError<WasmRuntimeError>> {
205 self.wasm_execution_units_consumed.add_assign(n as u64);
206 self.fee_reserve
207 .consume_execution(
208 self.fee_table
209 .run_wasm_code_cost(&PACKAGE_PACKAGE, "none", n),
210 )
211 .map_err(|e| InvokeError::SelfError(WasmRuntimeError::FeeReserveError(e)))
212 }
213
214 fn instance_of(
215 &mut self,
216 component_id: Vec<u8>,
217 package_address: Vec<u8>,
218 blueprint_name: Vec<u8>,
219 ) -> Result<u32, InvokeError<WasmRuntimeError>> {
220 Err(InvokeError::SelfError(WasmRuntimeError::NotImplemented))
221 }
222
223 fn blueprint_id(
224 &mut self,
225 component_id: Vec<u8>,
226 ) -> Result<Buffer, InvokeError<WasmRuntimeError>> {
227 Err(InvokeError::SelfError(WasmRuntimeError::NotImplemented))
228 }
229
230 fn get_outer_object(
231 &mut self,
232 node_id: Vec<u8>,
233 ) -> Result<Buffer, InvokeError<WasmRuntimeError>> {
234 Err(InvokeError::SelfError(WasmRuntimeError::NotImplemented))
235 }
236
237 fn actor_emit_event(
238 &mut self,
239 event_name: Vec<u8>,
240 event: Vec<u8>,
241 event_flags: EventFlags,
242 ) -> Result<(), InvokeError<WasmRuntimeError>> {
243 Err(InvokeError::SelfError(WasmRuntimeError::NotImplemented))
244 }
245
246 fn sys_log(
247 &mut self,
248 level: Vec<u8>,
249 message: Vec<u8>,
250 ) -> Result<(), InvokeError<WasmRuntimeError>> {
251 Err(InvokeError::SelfError(WasmRuntimeError::NotImplemented))
252 }
253
254 fn sys_panic(&mut self, message: Vec<u8>) -> Result<(), InvokeError<WasmRuntimeError>> {
255 Err(InvokeError::SelfError(WasmRuntimeError::NotImplemented))
256 }
257
258 fn sys_get_transaction_hash(&mut self) -> Result<Buffer, InvokeError<WasmRuntimeError>> {
259 Err(InvokeError::SelfError(WasmRuntimeError::NotImplemented))
260 }
261
262 fn sys_bech32_encode_address(
263 &mut self,
264 address: Vec<u8>,
265 ) -> Result<Buffer, InvokeError<WasmRuntimeError>> {
266 Err(InvokeError::SelfError(WasmRuntimeError::NotImplemented))
267 }
268
269 fn sys_generate_ruid(&mut self) -> Result<Buffer, InvokeError<WasmRuntimeError>> {
270 Err(InvokeError::SelfError(WasmRuntimeError::NotImplemented))
271 }
272
273 fn costing_get_execution_cost_unit_limit(
274 &mut self,
275 ) -> Result<u32, InvokeError<WasmRuntimeError>> {
276 Err(InvokeError::SelfError(WasmRuntimeError::NotImplemented))
277 }
278
279 fn costing_get_execution_cost_unit_price(
280 &mut self,
281 ) -> Result<Buffer, InvokeError<WasmRuntimeError>> {
282 Err(InvokeError::SelfError(WasmRuntimeError::NotImplemented))
283 }
284
285 fn costing_get_finalization_cost_unit_limit(
286 &mut self,
287 ) -> Result<u32, InvokeError<WasmRuntimeError>> {
288 Err(InvokeError::SelfError(WasmRuntimeError::NotImplemented))
289 }
290
291 fn costing_get_finalization_cost_unit_price(
292 &mut self,
293 ) -> Result<Buffer, InvokeError<WasmRuntimeError>> {
294 Err(InvokeError::SelfError(WasmRuntimeError::NotImplemented))
295 }
296
297 fn costing_get_usd_price(&mut self) -> Result<Buffer, InvokeError<WasmRuntimeError>> {
298 Err(InvokeError::SelfError(WasmRuntimeError::NotImplemented))
299 }
300
301 fn costing_get_tip_percentage(&mut self) -> Result<u32, InvokeError<WasmRuntimeError>> {
302 Err(InvokeError::SelfError(WasmRuntimeError::NotImplemented))
303 }
304
305 fn costing_get_fee_balance(&mut self) -> Result<Buffer, InvokeError<WasmRuntimeError>> {
306 Err(InvokeError::SelfError(WasmRuntimeError::NotImplemented))
307 }
308
309 fn crypto_utils_bls12381_v1_verify(
310 &mut self,
311 message: Vec<u8>,
312 public_key: Vec<u8>,
313 signature: Vec<u8>,
314 ) -> Result<u32, InvokeError<WasmRuntimeError>> {
315 Err(InvokeError::SelfError(WasmRuntimeError::NotImplemented))
316 }
317
318 fn crypto_utils_bls12381_v1_aggregate_verify(
319 &mut self,
320 pub_keys_and_msgs: Vec<u8>,
321 signature: Vec<u8>,
322 ) -> Result<u32, InvokeError<WasmRuntimeError>> {
323 Err(InvokeError::SelfError(WasmRuntimeError::NotImplemented))
324 }
325
326 fn crypto_utils_bls12381_v1_fast_aggregate_verify(
327 &mut self,
328 message: Vec<u8>,
329 public_keys: Vec<u8>,
330 signature: Vec<u8>,
331 ) -> Result<u32, InvokeError<WasmRuntimeError>> {
332 Err(InvokeError::SelfError(WasmRuntimeError::NotImplemented))
333 }
334
335 fn crypto_utils_bls12381_g2_signature_aggregate(
336 &mut self,
337 signatures: Vec<u8>,
338 ) -> Result<Buffer, InvokeError<WasmRuntimeError>> {
339 Err(InvokeError::SelfError(WasmRuntimeError::NotImplemented))
340 }
341
342 fn crypto_utils_keccak256_hash(
343 &mut self,
344 data: Vec<u8>,
345 ) -> Result<Buffer, InvokeError<WasmRuntimeError>> {
346 Err(InvokeError::SelfError(WasmRuntimeError::NotImplemented))
347 }
348
349 fn crypto_utils_blake2b_256_hash(
350 &mut self,
351 data: Vec<u8>,
352 ) -> Result<Buffer, InvokeError<WasmRuntimeError>> {
353 Err(InvokeError::SelfError(WasmRuntimeError::NotImplemented))
354 }
355
356 fn crypto_utils_ed25519_verify(
357 &mut self,
358 message: Vec<u8>,
359 public_key: Vec<u8>,
360 signature: Vec<u8>,
361 ) -> Result<u32, InvokeError<WasmRuntimeError>> {
362 Err(InvokeError::SelfError(WasmRuntimeError::NotImplemented))
363 }
364
365 fn crypto_utils_secp256k1_ecdsa_verify(
366 &mut self,
367 message: Vec<u8>,
368 public_key: Vec<u8>,
369 signature: Vec<u8>,
370 ) -> Result<u32, InvokeError<WasmRuntimeError>> {
371 Err(InvokeError::SelfError(WasmRuntimeError::NotImplemented))
372 }
373
374 fn crypto_utils_secp256k1_ecdsa_verify_and_key_recover(
375 &mut self,
376 message: Vec<u8>,
377 signature: Vec<u8>,
378 ) -> Result<Buffer, InvokeError<WasmRuntimeError>> {
379 Err(InvokeError::SelfError(WasmRuntimeError::NotImplemented))
380 }
381
382 fn crypto_utils_secp256k1_ecdsa_verify_and_key_recover_uncompressed(
383 &mut self,
384 message: Vec<u8>,
385 signature: Vec<u8>,
386 ) -> Result<Buffer, InvokeError<WasmRuntimeError>> {
387 Err(InvokeError::SelfError(WasmRuntimeError::NotImplemented))
388 }
389}