From a9cf73db620d07d9684cf07c03e34d18feb1cdde Mon Sep 17 00:00:00 2001 From: Vladislav Volosnikov Date: Mon, 30 Dec 2024 17:16:20 +0100 Subject: [PATCH] Replace hardcoded memory offsets --- system-contracts/contracts/EvmEmulator.yul | 32 +++++++++---------- .../EvmEmulatorFunctions.template.yul | 16 +++++----- 2 files changed, 24 insertions(+), 24 deletions(-) diff --git a/system-contracts/contracts/EvmEmulator.yul b/system-contracts/contracts/EvmEmulator.yul index ba2ad472f..feae08716 100644 --- a/system-contracts/contracts/EvmEmulator.yul +++ b/system-contracts/contracts/EvmEmulator.yul @@ -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 { @@ -3220,35 +3220,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 { diff --git a/system-contracts/evm-emulator/EvmEmulatorFunctions.template.yul b/system-contracts/evm-emulator/EvmEmulatorFunctions.template.yul index a9253a8cd..011693d72 100644 --- a/system-contracts/evm-emulator/EvmEmulatorFunctions.template.yul +++ b/system-contracts/evm-emulator/EvmEmulatorFunctions.template.yul @@ -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 {