Skip to content

Commit 5ebdb7e

Browse files
authored
Merge pull request #477 from OffchainLabs/arb_genesis_ParseStateScheme
In ParseStateScheme make sure to set genesis block number properly based on arb/eth chain
2 parents cfee082 + 71577f3 commit 5ebdb7e

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

core/rawdb/accessors_trie.go

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -265,10 +265,20 @@ func ReadStateScheme(db ethdb.Database) string {
265265
if id := ReadPersistentStateID(vdb); id != 0 {
266266
return PathScheme
267267
}
268+
genesisBlockNumber := uint64(0)
269+
block0Hash := ReadCanonicalHash(db, 0)
270+
if (block0Hash != common.Hash{}) {
271+
chainConfig := ReadChainConfig(db, block0Hash)
272+
if chainConfig != nil {
273+
if chainConfig.IsArbitrum() {
274+
genesisBlockNumber = chainConfig.ArbitrumChainParams.GenesisBlockNum
275+
}
276+
}
277+
}
268278
// In a hash-based scheme, the genesis state is consistently stored
269279
// on the disk. To assess the scheme of the persistent state, it
270280
// suffices to inspect the scheme of the genesis state.
271-
header := ReadHeader(db, ReadCanonicalHash(db, 0), 0)
281+
header := ReadHeader(db, ReadCanonicalHash(db, genesisBlockNumber), genesisBlockNumber)
272282
if header == nil {
273283
return "" // empty datadir
274284
}

0 commit comments

Comments
 (0)