Skip to content

Commit

Permalink
Cleanup GENESIS_STATE_ROOT
Browse files Browse the repository at this point in the history
  • Loading branch information
Jouzo committed Sep 7, 2023
1 parent fdb52f6 commit fec2262
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
4 changes: 2 additions & 2 deletions lib/ain-evm/src/core.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -342,7 +342,7 @@ impl EVMCoreService {
///
pub unsafe fn create_queue(&self) -> Result<u64> {
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);
Expand Down
4 changes: 1 addition & 3 deletions lib/ain-evm/src/evm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
8 changes: 5 additions & 3 deletions lib/ain-evm/src/trie.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -57,7 +59,7 @@ impl TrieDBStore {
storage: &Arc<Storage>,
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,
Expand Down

0 comments on commit fec2262

Please sign in to comment.