Skip to content

Commit

Permalink
Zero out frame gas left if underpayed precompile call succeded
Browse files Browse the repository at this point in the history
  • Loading branch information
0xVolosnikov committed Nov 28, 2024
1 parent 348e84a commit 57c35d0
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 0 deletions.
2 changes: 2 additions & 0 deletions system-contracts/contracts/EvmEmulator.yul
Original file line number Diff line number Diff line change
Expand Up @@ -831,6 +831,7 @@ object "EvmEmulator" {
let zkVmGasToPass := gas() // pass all remaining gas, precompiles should not call any contracts
if lt(gasToPass, precompileCost) {
zkVmGasToPass := 0 // in EVM precompile should revert consuming all gas in that case
precompileCost := precompileCost // just in case
}

switch isStatic
Expand Down Expand Up @@ -3879,6 +3880,7 @@ object "EvmEmulator" {
let zkVmGasToPass := gas() // pass all remaining gas, precompiles should not call any contracts
if lt(gasToPass, precompileCost) {
zkVmGasToPass := 0 // in EVM precompile should revert consuming all gas in that case
precompileCost := precompileCost // just in case
}

switch isStatic
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -769,6 +769,7 @@ function callPrecompile(addr, precompileCost, gasToPass, value, argsOffset, args
let zkVmGasToPass := gas() // pass all remaining gas, precompiles should not call any contracts
if lt(gasToPass, precompileCost) {
zkVmGasToPass := 0 // in EVM precompile should revert consuming all gas in that case
precompileCost := precompileCost // just in case
}

switch isStatic
Expand Down

0 comments on commit 57c35d0

Please sign in to comment.