Closed hai-rise closed 4 months ago
Hey, I can work on this. I think we need to rename InMemoryStorage
right?
pub struct InMemoryStorage {
accounts: HashMap<Address, EvmAccount, BuildAddressHasher>,
block_hashes: AHashMap<U256, B256>,
}
@chirag-bgh Thank you for your interest!
This task is all about replacing PlainAccount
with our new EvmAccount
type currently defined here:
https://github.com/risechain/pevm/blob/d7904031711c61b927a703539e7e08784963cdb9/src/storage.rs#L13-L23
I think a good place to start is to change the ChainState
type for tests
and benches
:
diff --git a/tests/common/mod.rs b/tests/common/mod.rs
index 04ac6da..bf7deab 100644
--- a/tests/common/mod.rs
+++ b/tests/common/mod.rs
@@ -7,14 +7,14 @@ use std::{
use ahash::AHashMap;
use alloy_primitives::{Address, Bloom, Bytes, B256, U256};
use alloy_rpc_types::{Block, Header};
-use pevm::InMemoryStorage;
+use pevm::{EvmAccount, InMemoryStorage};
use revm::{db::PlainAccount, primitives::KECCAK_EMPTY};
pub mod runner;
pub use runner::{assert_execution_result, mock_account, test_execute_alloy, test_execute_revm};
pub mod storage;
-pub type ChainState = AHashMap<Address, PlainAccount>;
+pub type ChainState = AHashMap<Address, EvmAccount>;
pub type BlockHashes = AHashMap<U256, B256>;
pub static MOCK_ALLOY_BLOCK_HEADER: Header = Header {
Then run cargo test --release -- --test-threads=1
to get compile errors on where we should replace PlainAccount
s with EvmAccount
s :pray:.
Completed the rest as part of #200 🙏.
We can rename
InMemoryAccount
toAccount
and replace mostPlainAccount
usage with it. Then the only conversion needed is probably in the state test where we would convert ourAccount
toPlainAccount
to call REVM'sstate_merkle_trie_root function
. In the future we can implement that ourselves, too.The end goal is to have consistent types both internally and for library users and minimize leaking underlying types like REVM's anywhere.