Skip to content

Commit

Permalink
fix(EVM): Zero out frame gas left for underpaid precompiles (#1101)
Browse files Browse the repository at this point in the history
  • Loading branch information
0xVolosnikov committed Dec 2, 2024
1 parent 71626e4 commit cf5e450
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 @@ -839,6 +839,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 := gasToPass // just in case
}

switch isStatic
Expand Down Expand Up @@ -3890,6 +3891,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 := gasToPass // just in case
}

switch isStatic
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -777,6 +777,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 := gasToPass // just in case
}

switch isStatic
Expand Down

0 comments on commit cf5e450

Please sign in to comment.