From b03ad3027eddf52411c10a963d356f738ae970e5 Mon Sep 17 00:00:00 2001 From: Omar Date: Thu, 24 Jul 2025 11:46:14 +0300 Subject: [PATCH] Pre-seed accounts with more ETH. (#73) * Pre-seed accounts with more ETH. This commit fixes and solves some issues around how much ETH we seed an account with in genesis. Currently, any account that the node has keys to sign for will be seeded with u128::MAX WEI in genesis. This also includes the default signer account. * Bump commit hash of polkadot SDK * Change how the cache key is computed * Revert "Change how the cache key is computed" This reverts commit 75afdd9cfdae7282b261f885e96004b9ead9ba5f. * Revert "Bump commit hash of polkadot SDK" This reverts commit 8aaa69780e7078d58409f3904a4ddd85b0c85367. * Add extra comments * Revert "Add extra comments" This reverts commit bd4de2c83d1bb215ab16dfef40c1003316fea367. * Update the initial balance --- crates/node/src/constants.rs | 6 +++--- crates/node/src/geth.rs | 2 ++ crates/node/src/kitchensink.rs | 2 ++ genesis.json | 6 +----- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/crates/node/src/constants.rs b/crates/node/src/constants.rs index 25b5976..5b02dca 100644 --- a/crates/node/src/constants.rs +++ b/crates/node/src/constants.rs @@ -1,5 +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; +/// Note: After changing this number, check that the tests for kitchensink work as we encountered +/// some issues with different values of the initial balance on Kitchensink. +pub const INITIAL_BALANCE: u128 = 10u128.pow(37); diff --git a/crates/node/src/geth.rs b/crates/node/src/geth.rs index f2ab012..d91a8aa 100644 --- a/crates/node/src/geth.rs +++ b/crates/node/src/geth.rs @@ -86,6 +86,8 @@ impl Instance { for signer_address in >::signer_addresses(&self.wallet) { + // Note, the use of the entry API here means that we only modify the entries for any + // account that is not in the `alloc` field of the genesis state. genesis .alloc .entry(signer_address) diff --git a/crates/node/src/kitchensink.rs b/crates/node/src/kitchensink.rs index b6294ca..200f6aa 100644 --- a/crates/node/src/kitchensink.rs +++ b/crates/node/src/kitchensink.rs @@ -131,6 +131,8 @@ impl KitchensinkNode { for signer_address in >::signer_addresses(&self.wallet) { + // Note, the use of the entry API here means that we only modify the entries for any + // account that is not in the `alloc` field of the genesis state. genesis .alloc .entry(signer_address) diff --git a/genesis.json b/genesis.json index 9993430..106353a 100644 --- a/genesis.json +++ b/genesis.json @@ -33,9 +33,5 @@ "mixhash": "0x0000000000000000000000000000000000000000000000000000000000000000", "parentHash": "0x0000000000000000000000000000000000000000000000000000000000000000", "timestamp": "0x00", - "alloc": { - "90F8bf6A479f320ead074411a4B0e7944Ea8c9C1": { - "balance": "10000000000000000000000" - } - } + "alloc": {} } \ No newline at end of file