@@ -126,6 +126,7 @@ func (ga *GenesisAlloc) deriveHash(cfg *params.ChainConfig, timestamp uint64) (c
126
126
// all the derived states will be discarded to not pollute disk.
127
127
db := state .NewDatabase (rawdb .NewMemoryDatabase ())
128
128
if cfg .IsPrague (big .NewInt (int64 (0 )), timestamp ) {
129
+ db .StartVerkleTransition (common.Hash {}, common.Hash {}, cfg , & timestamp , common.Hash {})
129
130
db .EndVerkleTransition ()
130
131
}
131
132
statedb , err := state .New (types .EmptyRootHash , db , nil )
@@ -146,15 +147,17 @@ func (ga *GenesisAlloc) deriveHash(cfg *params.ChainConfig, timestamp uint64) (c
146
147
// flush is very similar with deriveHash, but the main difference is
147
148
// all the generated states will be persisted into the given database.
148
149
// Also, the genesis state specification will be flushed as well.
149
- func (ga * GenesisAlloc ) flush (db ethdb.Database , triedb * trie.Database , blockhash common.Hash , cfg * params.ChainConfig ) error {
150
- statedb , err := state .New (types .EmptyRootHash , state .NewDatabaseWithNodeDB (db , triedb ), nil )
151
- if err != nil {
152
- return err
150
+ func (ga * GenesisAlloc ) flush (db ethdb.Database , triedb * trie.Database , blockhash common.Hash , cfg * params.ChainConfig , timestamp * uint64 ) error {
151
+ database := state .NewDatabaseWithNodeDB (db , triedb )
152
+ // End the verkle conversion at genesis if the fork block is 0
153
+ if timestamp != nil && cfg .IsPrague (big .NewInt (int64 (0 )), * timestamp ) {
154
+ database .StartVerkleTransition (common.Hash {}, common.Hash {}, cfg , timestamp , common.Hash {})
155
+ database .EndVerkleTransition ()
153
156
}
154
157
155
- // End the verkle conversion at genesis if the fork block is 0
156
- if triedb . IsVerkle () {
157
- statedb . Database (). EndVerkleTransition ()
158
+ statedb , err := state . New ( types . EmptyRootHash , database , nil )
159
+ if err != nil {
160
+ return err
158
161
}
159
162
160
163
for addr , account := range * ga {
@@ -221,7 +224,7 @@ func CommitGenesisState(db ethdb.Database, triedb *trie.Database, blockhash comm
221
224
return errors .New ("not found" )
222
225
}
223
226
}
224
- return alloc .flush (db , triedb , blockhash , config )
227
+ return alloc .flush (db , triedb , blockhash , config , nil )
225
228
}
226
229
227
230
// GenesisAccount is an account in the state of the genesis block.
@@ -536,7 +539,7 @@ func (g *Genesis) Commit(db ethdb.Database, triedb *trie.Database) (*types.Block
536
539
// All the checks has passed, flush the states derived from the genesis
537
540
// specification as well as the specification itself into the provided
538
541
// database.
539
- if err := g .Alloc .flush (db , triedb , block .Hash (), g .Config ); err != nil {
542
+ if err := g .Alloc .flush (db , triedb , block .Hash (), g .Config , & g . Timestamp ); err != nil {
540
543
return nil , err
541
544
}
542
545
rawdb .WriteTd (db , block .Hash (), block .NumberU64 (), block .Difficulty ())
0 commit comments