Skip to content

Commit

Permalink
feat: Prepopulate tstorage for the new version of EvmGasManager (#93)
Browse files Browse the repository at this point in the history
  • Loading branch information
0xVolosnikov authored Aug 27, 2024
1 parent a440b2f commit 37d6f9f
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions compiler_tester/src/vm/eravm/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -398,6 +398,7 @@ impl EraVM {
calldata: Vec<u8>,
vm_launch_option: Option<zkevm_tester::compiler_tests::VmLaunchOption>,
) -> anyhow::Result<ExecutionResult> {
// legacy EvmGasManager.sol compatibility
// set `evmStackFrames` size to 1
self.storage.insert(
zkevm_tester::compiler_tests::StorageKey {
Expand Down Expand Up @@ -425,6 +426,34 @@ impl EraVM {
web3::types::H256::from_low_u64_be(Self::EVM_CALL_GAS_LIMIT),
);

// updated EvmGasManager.sol compatibility
// set `evmStackFrames` size to 1
self.storage_transient.insert(
zkevm_tester::compiler_tests::StorageKey {
address: web3::types::Address::from_low_u64_be(ADDRESS_EVM_GAS_MANAGER.into()),
key: web3::types::U256::from(Self::EVM_GAS_MANAGER_STACK_FRAME_SLOT),
},
web3::types::H256::from_low_u64_be(1),
);

// set `evmStackFrames[0].passGas` to `EVM_CALL_GAS_LIMIT`
self.storage_transient.insert(
zkevm_tester::compiler_tests::StorageKey {
address: web3::types::Address::from_low_u64_be(ADDRESS_EVM_GAS_MANAGER.into()),
key: web3::types::U256::from(Self::EVM_GAS_MANAGER_STACK_FRAME_SLOT).add(2),
},
web3::types::H256::from_low_u64_be(Self::EVM_CALL_GAS_LIMIT),
);

// set `evmStackFrames[0].isStatic` to false
self.storage_transient.insert(
zkevm_tester::compiler_tests::StorageKey {
address: web3::types::Address::from_low_u64_be(ADDRESS_EVM_GAS_MANAGER.into()),
key: web3::types::U256::from(Self::EVM_GAS_MANAGER_STACK_FRAME_SLOT).add(3),
},
web3::types::H256::zero(),
);

let mut result = self.execute::<M>(
test_name,
entry_address,
Expand Down

0 comments on commit 37d6f9f

Please sign in to comment.