From fec2262db8aa4dc254f27dc848665d5c9b9f5b2e Mon Sep 17 00:00:00 2001 From: jouzo Date: Thu, 7 Sep 2023 13:58:07 +0100 Subject: [PATCH] Cleanup GENESIS_STATE_ROOT --- lib/ain-evm/src/core.rs | 4 ++-- lib/ain-evm/src/evm.rs | 4 +--- lib/ain-evm/src/trie.rs | 8 +++++--- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/lib/ain-evm/src/core.rs b/lib/ain-evm/src/core.rs index 67e6d9810b..bcc3128095 100644 --- a/lib/ain-evm/src/core.rs +++ b/lib/ain-evm/src/core.rs @@ -15,7 +15,7 @@ use crate::{ receipt::ReceiptService, storage::{traits::BlockStorage, Storage}, transaction::SignedTx, - trie::TrieDBStore, + trie::{TrieDBStore, GENESIS_STATE_ROOT}, txqueue::TransactionQueueMap, weiamount::WeiAmount, Result, @@ -342,7 +342,7 @@ impl EVMCoreService { /// pub unsafe fn create_queue(&self) -> Result { let (target_block, initial_state_root) = match self.storage.get_latest_block()? { - None => U256::zero(), // Genesis queue + None => (U256::zero(), GENESIS_STATE_ROOT), // Genesis queue Some(block) => (block.header.number + 1, block.header.state_root), }; let queue_id = self.tx_queues.create(target_block, initial_state_root); diff --git a/lib/ain-evm/src/evm.rs b/lib/ain-evm/src/evm.rs index 58d11768df..535ab35526 100644 --- a/lib/ain-evm/src/evm.rs +++ b/lib/ain-evm/src/evm.rs @@ -134,9 +134,7 @@ impl EVMServices { let state_root = self .storage .get_latest_block()? - .map_or(GENESIS_STATE_ROOT.parse().unwrap(), |block| { - block.header.state_root - }); + .map_or(GENESIS_STATE_ROOT, |block| block.header.state_root); debug!("[construct_block] queue_id: {:?}", queue_id); debug!("[construct_block] beneficiary: {:?}", beneficiary); diff --git a/lib/ain-evm/src/trie.rs b/lib/ain-evm/src/trie.rs index fc2737fdcf..5be5d7cdff 100644 --- a/lib/ain-evm/src/trie.rs +++ b/lib/ain-evm/src/trie.rs @@ -14,8 +14,10 @@ use crate::{ }; pub static TRIE_DB_STORE: &str = "trie_db_store.bin"; -pub static GENESIS_STATE_ROOT: &str = - "0xbc36789e7a1e281436464229828f817d6612f7b477d66591ff96a9e064bcc98a"; +pub static GENESIS_STATE_ROOT: H256 = H256([ + 188, 54, 120, 158, 122, 30, 40, 20, 54, 70, 66, 41, 130, 143, 129, 125, 102, 18, 247, 180, 119, + 214, 101, 145, 255, 150, 169, 224, 100, 188, 201, 138, +]); #[derive(Serialize, Deserialize)] pub struct TrieDBStore { @@ -57,7 +59,7 @@ impl TrieDBStore { storage: &Arc, json_file: PathBuf, ) -> Result<(H256, GenesisData)> { - let state_root: H256 = GENESIS_STATE_ROOT.parse().unwrap(); + let state_root: H256 = GENESIS_STATE_ROOT; let mut backend = EVMBackend::from_root( state_root,