Skip to content

Commit ac74403

Browse files
Add IsArbitrum special case to NewBlockChain
1 parent 503ffe6 commit ac74403

File tree

3 files changed

+20
-9
lines changed

3 files changed

+20
-9
lines changed

accounts/abi/bind/backends/simulated.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ func NewSimulatedBackendWithDatabase(database ethdb.Database, alloc core.Genesis
8383
GasLimit: gasLimit,
8484
Alloc: alloc,
8585
}
86-
blockchain, _ := core.NewBlockChain(database, nil, &genesis, nil, ethash.NewFaker(), vm.Config{}, nil, nil)
86+
blockchain, _ := core.NewBlockChain(database, nil, nil, &genesis, nil, ethash.NewFaker(), vm.Config{}, nil, nil)
8787

8888
backend := &SimulatedBackend{
8989
database: database,

core/blockchain.go

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,7 @@ type trieGcEntry struct {
246246
// NewBlockChain returns a fully initialised block chain using information
247247
// available in the database. It initialises the default Ethereum Validator
248248
// and Processor.
249-
func NewBlockChain(db ethdb.Database, cacheConfig *CacheConfig, genesis *Genesis, overrides *ChainOverrides, engine consensus.Engine, vmConfig vm.Config, shouldPreserve func(header *types.Header) bool, txLookupLimit *uint64) (*BlockChain, error) {
249+
func NewBlockChain(db ethdb.Database, cacheConfig *CacheConfig, chainConfig *params.ChainConfig, genesis *Genesis, overrides *ChainOverrides, engine consensus.Engine, vmConfig vm.Config, shouldPreserve func(header *types.Header) bool, txLookupLimit *uint64) (*BlockChain, error) {
250250
if cacheConfig == nil {
251251
cacheConfig = defaultCacheConfig
252252
}
@@ -257,12 +257,23 @@ func NewBlockChain(db ethdb.Database, cacheConfig *CacheConfig, genesis *Genesis
257257
Journal: cacheConfig.TrieCleanJournal,
258258
Preimages: cacheConfig.Preimages,
259259
})
260-
// Setup the genesis block, commit the provided genesis specification
261-
// to database if the genesis block is not present yet, or load the
262-
// stored one from database.
263-
chainConfig, genesisHash, genesisErr := SetupGenesisBlockWithOverride(db, triedb, genesis, overrides)
264-
if _, ok := genesisErr.(*params.ConfigCompatError); genesisErr != nil && !ok {
265-
return nil, genesisErr
260+
261+
var genesisHash common.Hash
262+
var genesisErr error
263+
264+
if chainConfig.IsArbitrum() {
265+
genesisHash = rawdb.ReadCanonicalHash(db, chainConfig.ArbitrumChainParams.GenesisBlockNum)
266+
if (genesisHash == common.Hash{}) {
267+
return nil, ErrNoGenesis
268+
}
269+
} else {
270+
// Setup the genesis block, commit the provided genesis specification
271+
// to database if the genesis block is not present yet, or load the
272+
// stored one from database.
273+
chainConfig, genesisHash, genesisErr = SetupGenesisBlockWithOverride(db, triedb, genesis, overrides)
274+
if _, ok := genesisErr.(*params.ConfigCompatError); genesisErr != nil && !ok {
275+
return nil, genesisErr
276+
}
266277
}
267278
log.Info("")
268279
log.Info(strings.Repeat("-", 153))

eth/backend.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ func New(stack *node.Node, config *ethconfig.Config) (*Ethereum, error) {
204204
if config.OverrideShanghai != nil {
205205
overrides.OverrideShanghai = config.OverrideShanghai
206206
}
207-
eth.blockchain, err = core.NewBlockChain(chainDb, cacheConfig, config.Genesis, &overrides, eth.engine, vmConfig, eth.shouldPreserve, &config.TxLookupLimit)
207+
eth.blockchain, err = core.NewBlockChain(chainDb, cacheConfig, nil, config.Genesis, &overrides, eth.engine, vmConfig, eth.shouldPreserve, &config.TxLookupLimit)
208208
if err != nil {
209209
return nil, err
210210
}

0 commit comments

Comments
 (0)