Skip to content

Commit

Permalink
Fix createEvmInternal system call
Browse files Browse the repository at this point in the history
  • Loading branch information
gianbelinche committed Aug 27, 2024
1 parent 61d1b13 commit 7720d44
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 51 deletions.
22 changes: 5 additions & 17 deletions system-contracts/contracts/EvmInterpreterFunctions.template.yul
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}
Expand Down Expand Up @@ -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)
}
Expand Down Expand Up @@ -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
Expand All @@ -1351,25 +1343,21 @@ 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,
0,
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
Expand All @@ -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)

Expand Down
44 changes: 10 additions & 34 deletions system-contracts/contracts/EvmInterpreterPreprocessed.yul
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}
Expand Down Expand Up @@ -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)
}
Expand Down Expand Up @@ -1420,7 +1413,6 @@ object "EVMInterpreter" {
sp := pushStackItemWithoutCheck(sp, mload(sub(offset, 0x40)))
sp := pushStackItemWithoutCheck(sp, mload(sub(offset, 0x20)))


_pushEVMFrame(gasForTheCall, false)

// Selector
Expand All @@ -1433,25 +1425,21 @@ 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,
0,
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
Expand All @@ -1461,7 +1449,7 @@ object "EVMInterpreter" {
default {
gasLeft := _fetchConstructorReturnGas()
}

let gasUsed := sub(gasForTheCall, gasLeft)
evmGasLeft := chargeGas(evmGasLeftOld, gasUsed)

Expand Down Expand Up @@ -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)
}
}
Expand Down Expand Up @@ -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)
}
Expand Down Expand Up @@ -4506,7 +4487,6 @@ object "EVMInterpreter" {
sp := pushStackItemWithoutCheck(sp, mload(sub(offset, 0x40)))
sp := pushStackItemWithoutCheck(sp, mload(sub(offset, 0x20)))


_pushEVMFrame(gasForTheCall, false)

// Selector
Expand All @@ -4519,25 +4499,21 @@ 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,
0,
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
Expand All @@ -4547,7 +4523,7 @@ object "EVMInterpreter" {
default {
gasLeft := _fetchConstructorReturnGas()
}

let gasUsed := sub(gasForTheCall, gasLeft)
evmGasLeft := chargeGas(evmGasLeftOld, gasUsed)

Expand Down

0 comments on commit 7720d44

Please sign in to comment.