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: Update contracts #36

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion era-contracts
9 changes: 3 additions & 6 deletions evm_tester/src/vm/eravm/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ mod vm2_adapter;

use address_iterator::EraVMAddressIterator;
use era_compiler_common::EVMVersion;
use system_contracts::ADDRESS_EVM_HASHES_STORAGE;
use std::collections::HashMap;
use std::ops::Add;
use std::path::PathBuf;
Expand Down Expand Up @@ -1062,14 +1063,10 @@ impl EraVM {

let evm_hash = keccak256(&bytecode);

let address_as_uint256 = utils::address_to_h256(&address);
let storage_slot_encoding = utils::h256_to_u256(&address_as_uint256)
+ (U256::from(1) << U256::from(Self::CONTRACT_DEPLOYER_EVM_HASH_PREFIX_SHIFT));

self.storage.insert(
zkevm_tester::compiler_tests::StorageKey {
address: web3::types::Address::from_low_u64_be(ADDRESS_CONTRACT_DEPLOYER.into()),
key: storage_slot_encoding,
address: ADDRESS_EVM_HASHES_STORAGE,
key: utils::h256_to_u256(&bytecode_hash),
},
H256::from_slice(&evm_hash),
);
Expand Down
13 changes: 12 additions & 1 deletion evm_tester/src/vm/eravm/system_contracts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,11 @@ use colored::Colorize;
/// The EVMGasManager system contract address.
pub const ADDRESS_EVM_GAS_MANAGER: u16 = 0x8013;

pub const ADDRESS_EVM_HASHES_STORAGE: Address = web3::types::H160([
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x80, 0x15,
]);

#[derive(serde::Serialize, serde::Deserialize)]
pub struct Build {
/// The bytecode.
Expand All @@ -34,7 +39,7 @@ pub struct Build {
pub bytecode_hash: Option<[u8; era_compiler_common::BYTE_LENGTH_FIELD]>,
}

pub static SYSTEM_CONTRACT_LIST: [(&str, &str, Address, ContractLanguage); 26] = [
pub static SYSTEM_CONTRACT_LIST: [(&str, &str, Address, ContractLanguage); 27] = [
(
"",
"AccountCodeStorage",
Expand Down Expand Up @@ -167,6 +172,12 @@ pub static SYSTEM_CONTRACT_LIST: [(&str, &str, Address, ContractLanguage); 26] =
"EvmGasManager",
EVM_GAS_MANAGER_ADDRESS,
ContractLanguage::Yul,
),
(
"",
"EvmHashesStorage",
ADDRESS_EVM_HASHES_STORAGE,
ContractLanguage::Sol,
),
// For now, only zero address and the bootloader address have empty bytecode at the init
// In the future, we might want to set all of the system contracts this way.
Expand Down
Loading