diff --git a/massa-execution-worker/src/execution.rs b/massa-execution-worker/src/execution.rs index 297538ff8e9..c2aacb503f4 100644 --- a/massa-execution-worker/src/execution.rs +++ b/massa-execution-worker/src/execution.rs @@ -1175,10 +1175,19 @@ impl ExecutionState { // load and execute the compiled module // IMPORTANT: do not keep a lock here as `run_function` uses the `get_module` interface - let module = self + let Ok(module) = self .module_cache .write() - .load_module(&bytecode, message.max_gas)?; + .load_module(&bytecode, message.max_gas) + else { + let err = + ExecutionError::RuntimeError("could not load module for async execution".into()); + let mut context = context_guard!(self); + context.reset_to_snapshot(context_snapshot, err.clone()); + context.cancel_async_message(&message); + return Err(err); + }; + let response = massa_sc_runtime::run_function( &*self.execution_interface, module, diff --git a/massa-execution-worker/src/interface_impl.rs b/massa-execution-worker/src/interface_impl.rs index 4dd2f716310..245ea26ef35 100644 --- a/massa-execution-worker/src/interface_impl.rs +++ b/massa-execution-worker/src/interface_impl.rs @@ -1183,6 +1183,16 @@ impl Interface for InterfaceImpl { if validity_end.1 >= self.config.thread_count { bail!("validity end thread exceeds the configuration thread count") } + + if max_gas < self.config.gas_costs.max_instance_cost { + bail!("max gas is lower than the minimum instance cost") + } + + if Slot::new(validity_end.0, validity_end.1) < Slot::new(validity_start.0, validity_start.1) + { + bail!("validity end is earlier than the validity start") + } + let target_addr = Address::from_str(target_address)?; // check that the target address is an SC address @@ -1200,6 +1210,11 @@ impl Interface for InterfaceImpl { let mut execution_context = context_guard!(self); let emission_slot = execution_context.slot; + + if emission_slot > Slot::new(validity_start.0, validity_start.1) { + bail!("validity start is earlier than the current slot") + } + let emission_index = execution_context.created_message_index; let sender = execution_context.get_current_address()?; let coins = Amount::from_raw(raw_coins);