Skip to content

Commit

Permalink
fix(EVM): Replace hardcoded memory offsets (N-01) (#1168)
Browse files Browse the repository at this point in the history
  • Loading branch information
0xVolosnikov authored Dec 30, 2024
1 parent f2677bf commit 34918c3
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 24 deletions.
32 changes: 16 additions & 16 deletions system-contracts/contracts/EvmEmulator.yul
Original file line number Diff line number Diff line change
Expand Up @@ -91,35 +91,35 @@ object "EvmEmulator" {
}

function GASPRICE_CACHE_OFFSET() -> offset {
offset := mul(24, 32)
offset := add(ORIGIN_CACHE_OFFSET(), 32)
}

function COINBASE_CACHE_OFFSET() -> offset {
offset := mul(25, 32)
offset := add(GASPRICE_CACHE_OFFSET(), 32)
}

function BLOCKTIMESTAMP_CACHE_OFFSET() -> offset {
offset := mul(26, 32)
offset := add(COINBASE_CACHE_OFFSET(), 32)
}

function BLOCKNUMBER_CACHE_OFFSET() -> offset {
offset := mul(27, 32)
offset := add(BLOCKTIMESTAMP_CACHE_OFFSET(), 32)
}

function PREVRANDAO_CACHE_OFFSET() -> offset {
offset := mul(28, 32)
offset := add(BLOCKNUMBER_CACHE_OFFSET(), 32)
}

function GASLIMIT_CACHE_OFFSET() -> offset {
offset := mul(29, 32)
offset := add(PREVRANDAO_CACHE_OFFSET(), 32)
}

function CHAINID_CACHE_OFFSET() -> offset {
offset := mul(30, 32)
offset := add(GASLIMIT_CACHE_OFFSET(), 32)
}

function BASEFEE_CACHE_OFFSET() -> offset {
offset := mul(31, 32)
offset := add(CHAINID_CACHE_OFFSET(), 32)
}

function LAST_RETURNDATA_SIZE_OFFSET() -> offset {
Expand Down Expand Up @@ -3219,35 +3219,35 @@ object "EvmEmulator" {
}

function GASPRICE_CACHE_OFFSET() -> offset {
offset := mul(24, 32)
offset := add(ORIGIN_CACHE_OFFSET(), 32)
}

function COINBASE_CACHE_OFFSET() -> offset {
offset := mul(25, 32)
offset := add(GASPRICE_CACHE_OFFSET(), 32)
}

function BLOCKTIMESTAMP_CACHE_OFFSET() -> offset {
offset := mul(26, 32)
offset := add(COINBASE_CACHE_OFFSET(), 32)
}

function BLOCKNUMBER_CACHE_OFFSET() -> offset {
offset := mul(27, 32)
offset := add(BLOCKTIMESTAMP_CACHE_OFFSET(), 32)
}

function PREVRANDAO_CACHE_OFFSET() -> offset {
offset := mul(28, 32)
offset := add(BLOCKNUMBER_CACHE_OFFSET(), 32)
}

function GASLIMIT_CACHE_OFFSET() -> offset {
offset := mul(29, 32)
offset := add(PREVRANDAO_CACHE_OFFSET(), 32)
}

function CHAINID_CACHE_OFFSET() -> offset {
offset := mul(30, 32)
offset := add(GASLIMIT_CACHE_OFFSET(), 32)
}

function BASEFEE_CACHE_OFFSET() -> offset {
offset := mul(31, 32)
offset := add(CHAINID_CACHE_OFFSET(), 32)
}

function LAST_RETURNDATA_SIZE_OFFSET() -> offset {
Expand Down
16 changes: 8 additions & 8 deletions system-contracts/evm-emulator/EvmEmulatorFunctions.template.yul
Original file line number Diff line number Diff line change
Expand Up @@ -31,35 +31,35 @@ function ORIGIN_CACHE_OFFSET() -> offset {
}

function GASPRICE_CACHE_OFFSET() -> offset {
offset := mul(24, 32)
offset := add(ORIGIN_CACHE_OFFSET(), 32)
}

function COINBASE_CACHE_OFFSET() -> offset {
offset := mul(25, 32)
offset := add(GASPRICE_CACHE_OFFSET(), 32)
}

function BLOCKTIMESTAMP_CACHE_OFFSET() -> offset {
offset := mul(26, 32)
offset := add(COINBASE_CACHE_OFFSET(), 32)
}

function BLOCKNUMBER_CACHE_OFFSET() -> offset {
offset := mul(27, 32)
offset := add(BLOCKTIMESTAMP_CACHE_OFFSET(), 32)
}

function PREVRANDAO_CACHE_OFFSET() -> offset {
offset := mul(28, 32)
offset := add(BLOCKNUMBER_CACHE_OFFSET(), 32)
}

function GASLIMIT_CACHE_OFFSET() -> offset {
offset := mul(29, 32)
offset := add(PREVRANDAO_CACHE_OFFSET(), 32)
}

function CHAINID_CACHE_OFFSET() -> offset {
offset := mul(30, 32)
offset := add(GASLIMIT_CACHE_OFFSET(), 32)
}

function BASEFEE_CACHE_OFFSET() -> offset {
offset := mul(31, 32)
offset := add(CHAINID_CACHE_OFFSET(), 32)
}

function LAST_RETURNDATA_SIZE_OFFSET() -> offset {
Expand Down

0 comments on commit 34918c3

Please sign in to comment.