Skip to content

Commit

Permalink
fix(EVM): Fix TODOs in EvmGasManager (#1038)
Browse files Browse the repository at this point in the history
  • Loading branch information
0xVolosnikov authored Oct 28, 2024
1 parent 3cb65f6 commit 82aa1a2
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions system-contracts/contracts/EvmGasManager.yul
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ object "EvmGasManager" {
}

function PRECOMPILES_END() -> value {
value := sub(0xffff, 1) // TODO should we exclude system contracts?
value := 0x0a // As in Cancun
}

function EVM_GAS_SLOT() -> value {
Expand Down Expand Up @@ -71,7 +71,9 @@ object "EvmGasManager" {
let notSystemCall := iszero(and(callFlags, 2))

if notSystemCall {
revert(0, 0) // TODO errors?
// error CallerMustBeEvmContract()
mstore(0, 0xBE4BF9E400000000000000000000000000000000000000000000000000000000)
revert(0, 32)
}

// SELFDESTRUCT is not supported, so it is ok to cache here
Expand All @@ -82,7 +84,9 @@ object "EvmGasManager" {
isEVM := eq(shr(248, versionedCodeHash), 2)

if iszero(isEVM) {
revert(0, 0)
// error CallerMustBeEvmContract()
mstore(0, 0xBE4BF9E400000000000000000000000000000000000000000000000000000000)
revert(0, 32)
}

// we will not cache contract if it is being constructed
Expand Down Expand Up @@ -118,7 +122,8 @@ object "EvmGasManager" {

let wasWarm := true

if gt(account, PRECOMPILES_END()) {
// precompiles are always warm
if or(iszero(account), gt(account, PRECOMPILES_END())) {
let transientSlot := or(IS_ACCOUNT_WARM_PREFIX(), account)
wasWarm := tload(transientSlot)

Expand Down Expand Up @@ -223,6 +228,7 @@ object "EvmGasManager" {
}
// We should mark the EVM contract as warm too.
warmAccount(caller())
warmAccount(coinbase()) // and the coinbase too
return(0x0, 0x0)
}
default {
Expand Down

0 comments on commit 82aa1a2

Please sign in to comment.