diff --git a/crates/node/src/constants.rs b/crates/node/src/constants.rs new file mode 100644 index 0000000..25b5976 --- /dev/null +++ b/crates/node/src/constants.rs @@ -0,0 +1,5 @@ +/// This constant defines how much Wei accounts are pre-seeded with in genesis. +/// +/// We use [`u128::MAX`] here which means that accounts will be given 2^128 - 1 WEI which is +/// (2^128 - 1) / 10^18 ETH. +pub const INITIAL_BALANCE: u128 = u128::MAX; diff --git a/crates/node/src/geth.rs b/crates/node/src/geth.rs index 794650c..0745942 100644 --- a/crates/node/src/geth.rs +++ b/crates/node/src/geth.rs @@ -29,7 +29,7 @@ use revive_dt_config::Arguments; use revive_dt_node_interaction::{BlockingExecutor, EthereumNode}; use tracing::Level; -use crate::{Node, common::FallbackGasFiller}; +use crate::{Node, common::FallbackGasFiller, constants::INITIAL_BALANCE}; static NODE_COUNT: AtomicU32 = AtomicU32::new(0); @@ -84,10 +84,10 @@ impl Instance { for signer_address in >::signer_addresses(&self.wallet) { - genesis.alloc.entry(signer_address).or_insert( - GenesisAccount::default() - .with_balance(10000000000000000000000u128.try_into().unwrap()), - ); + genesis + .alloc + .entry(signer_address) + .or_insert(GenesisAccount::default().with_balance(U256::from(INITIAL_BALANCE))); } let genesis_path = self.base_directory.join(Self::GENESIS_JSON_FILE); serde_json::to_writer(File::create(&genesis_path)?, &genesis)?; diff --git a/crates/node/src/kitchensink.rs b/crates/node/src/kitchensink.rs index 3820f08..b6294ca 100644 --- a/crates/node/src/kitchensink.rs +++ b/crates/node/src/kitchensink.rs @@ -39,7 +39,7 @@ use tracing::Level; use revive_dt_config::Arguments; use revive_dt_node_interaction::{BlockingExecutor, EthereumNode}; -use crate::{Node, common::FallbackGasFiller}; +use crate::{Node, common::FallbackGasFiller, constants::INITIAL_BALANCE}; static NODE_COUNT: AtomicU32 = AtomicU32::new(0); @@ -131,10 +131,10 @@ impl KitchensinkNode { for signer_address in >::signer_addresses(&self.wallet) { - genesis.alloc.entry(signer_address).or_insert( - GenesisAccount::default() - .with_balance(10000000000000000000000u128.try_into().unwrap()), - ); + genesis + .alloc + .entry(signer_address) + .or_insert(GenesisAccount::default().with_balance(U256::from(INITIAL_BALANCE))); } self.extract_balance_from_genesis_file(&genesis)? }; diff --git a/crates/node/src/lib.rs b/crates/node/src/lib.rs index 8084150..1232e97 100644 --- a/crates/node/src/lib.rs +++ b/crates/node/src/lib.rs @@ -4,6 +4,7 @@ use revive_dt_config::Arguments; use revive_dt_node_interaction::EthereumNode; pub mod common; +pub mod constants; pub mod geth; pub mod kitchensink; pub mod pool;