From 2b27d5b2fd8048f5abec1528dba7a60231c029c9 Mon Sep 17 00:00:00 2001 From: rakita Date: Fri, 31 May 2024 12:53:33 +0200 Subject: [PATCH] fix(eof): EOFCREATE spend gas and apply 63/64 rule --- crates/interpreter/src/instructions/contract.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/crates/interpreter/src/instructions/contract.rs b/crates/interpreter/src/instructions/contract.rs index 0bc19f6e87..206891e962 100644 --- a/crates/interpreter/src/instructions/contract.rs +++ b/crates/interpreter/src/instructions/contract.rs @@ -62,6 +62,10 @@ pub fn eofcreate(interpreter: &mut Interpreter, _host: &mut H) .caller .create2(salt.to_be_bytes(), keccak256(sub_container)); + let gas_reduce = max(interpreter.gas.remaining() / 64, 5000); + let gas_limit = interpreter.gas().remaining().saturating_sub(gas_reduce); + gas!(interpreter, gas_limit); + // Send container for execution container is preverified. interpreter.next_action = InterpreterAction::EOFCreate { inputs: Box::new(EOFCreateInput::new( @@ -69,7 +73,7 @@ pub fn eofcreate(interpreter: &mut Interpreter, _host: &mut H) created_address, value, eof, - interpreter.gas().remaining(), + gas_limit, input, )), };