Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Prepopulate tstorage for the new version of EvmGasManager #93

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading