From 7720d441968e87b6373bd327404a7a6819475037 Mon Sep 17 00:00:00 2001 From: Gianbelinche <39842759+gianbelinche@users.noreply.github.com> Date: Tue, 27 Aug 2024 12:08:03 -0300 Subject: [PATCH] Fix createEvmInternal system call --- .../EvmInterpreterFunctions.template.yul | 22 +++------- .../contracts/EvmInterpreterPreprocessed.yul | 44 +++++-------------- 2 files changed, 15 insertions(+), 51 deletions(-) diff --git a/system-contracts/contracts/EvmInterpreterFunctions.template.yul b/system-contracts/contracts/EvmInterpreterFunctions.template.yul index 42afaa553..bbde6d824 100644 --- a/system-contracts/contracts/EvmInterpreterFunctions.template.yul +++ b/system-contracts/contracts/EvmInterpreterFunctions.template.yul @@ -691,13 +691,9 @@ function incrementNonce(addr) { 1 ) let to := NONCE_HOLDER_SYSTEM_CONTRACT() - printString("PRE VERBATIM") let result := verbatim_6i_1o("system_call", to, farCallAbi, 0, 0, 0, 0) - printString("POST VERBATIM") - if iszero(result) { - printString("FAILED") revert(0, 0) } } @@ -839,13 +835,10 @@ function _pushEVMFrame(_passGas, _isStatic) { ) let to := EVM_GAS_MANAGER_CONTRACT() - printString("PRE VERBATIM EVM FRAME") let success := verbatim_6i_1o("system_call", to, farCallAbi, 0, 0, 0, 0) - printString("POST VERBATIM EVM FRAME") // let success := call(gas(), EVM_GAS_MANAGER_CONTRACT(), 0, 0, 68, 0, 0) if iszero(success) { - printString("FAILED PUSH EVM FRAME") // This error should never happen revert(0, 0) } @@ -1338,7 +1331,6 @@ function $llvm_NoInline_llvm$_genericCreate(addr, offset, size, sp, value, evmGa sp := pushStackItemWithoutCheck(sp, mload(sub(offset, 0x40))) sp := pushStackItemWithoutCheck(sp, mload(sub(offset, 0x20))) - _pushEVMFrame(gasForTheCall, false) // Selector @@ -1351,12 +1343,11 @@ function $llvm_NoInline_llvm$_genericCreate(addr, offset, size, sp, value, evmGa // Length of the init code mstore(sub(offset, 0x20), size) - let farCallAbi := getFarCallABI( 0, 0, - sub(offset, 0x80), - add(size, 0x80), + sub(offset, 0x64), + add(size, 0x64), INF_PASS_GAS(), // Only rollup is supported for now 0, @@ -1364,12 +1355,9 @@ function $llvm_NoInline_llvm$_genericCreate(addr, offset, size, sp, value, evmGa 0, 1 ) - let to := DEPLOYER_SYSTEM_CONTRACT() - printString("PRE VERBATIM CREATE") - let result := verbatim_6i_1o("system_call", to, farCallAbi, 0, 0, 0, 0) - printString("POST VERBATIM CREATE") - printHex(result) + let to := DEPLOYER_SYSTEM_CONTRACT() + result := verbatim_6i_1o("system_call", to, farCallAbi, 0, 0, 0, 0) let gasLeft switch result @@ -1379,7 +1367,7 @@ function $llvm_NoInline_llvm$_genericCreate(addr, offset, size, sp, value, evmGa default { gasLeft := _fetchConstructorReturnGas() } - + let gasUsed := sub(gasForTheCall, gasLeft) evmGasLeft := chargeGas(evmGasLeftOld, gasUsed) diff --git a/system-contracts/contracts/EvmInterpreterPreprocessed.yul b/system-contracts/contracts/EvmInterpreterPreprocessed.yul index 444a575c1..241c17878 100644 --- a/system-contracts/contracts/EvmInterpreterPreprocessed.yul +++ b/system-contracts/contracts/EvmInterpreterPreprocessed.yul @@ -773,13 +773,9 @@ object "EVMInterpreter" { 1 ) let to := NONCE_HOLDER_SYSTEM_CONTRACT() - printString("PRE VERBATIM") let result := verbatim_6i_1o("system_call", to, farCallAbi, 0, 0, 0, 0) - printString("POST VERBATIM") - if iszero(result) { - printString("FAILED") revert(0, 0) } } @@ -921,13 +917,10 @@ object "EVMInterpreter" { ) let to := EVM_GAS_MANAGER_CONTRACT() - printString("PRE VERBATIM EVM FRAME") let success := verbatim_6i_1o("system_call", to, farCallAbi, 0, 0, 0, 0) - printString("POST VERBATIM EVM FRAME") // let success := call(gas(), EVM_GAS_MANAGER_CONTRACT(), 0, 0, 68, 0, 0) if iszero(success) { - printString("FAILED PUSH EVM FRAME") // This error should never happen revert(0, 0) } @@ -1420,7 +1413,6 @@ object "EVMInterpreter" { sp := pushStackItemWithoutCheck(sp, mload(sub(offset, 0x40))) sp := pushStackItemWithoutCheck(sp, mload(sub(offset, 0x20))) - _pushEVMFrame(gasForTheCall, false) // Selector @@ -1433,12 +1425,11 @@ object "EVMInterpreter" { // Length of the init code mstore(sub(offset, 0x20), size) - let farCallAbi := getFarCallABI( 0, 0, - sub(offset, 0x80), - add(size, 0x80), + sub(offset, 0x64), + add(size, 0x64), INF_PASS_GAS(), // Only rollup is supported for now 0, @@ -1446,12 +1437,9 @@ object "EVMInterpreter" { 0, 1 ) - let to := DEPLOYER_SYSTEM_CONTRACT() - printString("PRE VERBATIM CREATE") - let result := verbatim_6i_1o("system_call", to, farCallAbi, 0, 0, 0, 0) - printString("POST VERBATIM CREATE") - printHex(result) + let to := DEPLOYER_SYSTEM_CONTRACT() + result := verbatim_6i_1o("system_call", to, farCallAbi, 0, 0, 0, 0) let gasLeft switch result @@ -1461,7 +1449,7 @@ object "EVMInterpreter" { default { gasLeft := _fetchConstructorReturnGas() } - + let gasUsed := sub(gasForTheCall, gasLeft) evmGasLeft := chargeGas(evmGasLeftOld, gasUsed) @@ -3859,13 +3847,9 @@ object "EVMInterpreter" { 1 ) let to := NONCE_HOLDER_SYSTEM_CONTRACT() - printString("PRE VERBATIM") let result := verbatim_6i_1o("system_call", to, farCallAbi, 0, 0, 0, 0) - printString("POST VERBATIM") - if iszero(result) { - printString("FAILED") revert(0, 0) } } @@ -4007,13 +3991,10 @@ object "EVMInterpreter" { ) let to := EVM_GAS_MANAGER_CONTRACT() - printString("PRE VERBATIM EVM FRAME") let success := verbatim_6i_1o("system_call", to, farCallAbi, 0, 0, 0, 0) - printString("POST VERBATIM EVM FRAME") // let success := call(gas(), EVM_GAS_MANAGER_CONTRACT(), 0, 0, 68, 0, 0) if iszero(success) { - printString("FAILED PUSH EVM FRAME") // This error should never happen revert(0, 0) } @@ -4506,7 +4487,6 @@ object "EVMInterpreter" { sp := pushStackItemWithoutCheck(sp, mload(sub(offset, 0x40))) sp := pushStackItemWithoutCheck(sp, mload(sub(offset, 0x20))) - _pushEVMFrame(gasForTheCall, false) // Selector @@ -4519,12 +4499,11 @@ object "EVMInterpreter" { // Length of the init code mstore(sub(offset, 0x20), size) - let farCallAbi := getFarCallABI( 0, 0, - sub(offset, 0x80), - add(size, 0x80), + sub(offset, 0x64), + add(size, 0x64), INF_PASS_GAS(), // Only rollup is supported for now 0, @@ -4532,12 +4511,9 @@ object "EVMInterpreter" { 0, 1 ) - let to := DEPLOYER_SYSTEM_CONTRACT() - printString("PRE VERBATIM CREATE") - let result := verbatim_6i_1o("system_call", to, farCallAbi, 0, 0, 0, 0) - printString("POST VERBATIM CREATE") - printHex(result) + let to := DEPLOYER_SYSTEM_CONTRACT() + result := verbatim_6i_1o("system_call", to, farCallAbi, 0, 0, 0, 0) let gasLeft switch result @@ -4547,7 +4523,7 @@ object "EVMInterpreter" { default { gasLeft := _fetchConstructorReturnGas() } - + let gasUsed := sub(gasForTheCall, gasLeft) evmGasLeft := chargeGas(evmGasLeftOld, gasUsed)