From 8562597c6c1370dd073835d4bc9f3733d01e6793 Mon Sep 17 00:00:00 2001 From: marcello33 Date: Tue, 13 Jun 2023 12:50:48 +0200 Subject: [PATCH] dev: chg: regression changes after develop is merged into upstream-merge --- core/blockchain.go | 16 +++++++++++++--- core/state_processor_test.go | 6 +++--- params/config.go | 4 ++-- 3 files changed, 18 insertions(+), 8 deletions(-) diff --git a/core/blockchain.go b/core/blockchain.go index 44b0fdee00..f7d09bbc82 100644 --- a/core/blockchain.go +++ b/core/blockchain.go @@ -472,14 +472,24 @@ func NewBlockChain(db ethdb.Database, cacheConfig *CacheConfig, genesis *Genesis } // NewParallelBlockChain , similar to NewBlockChain, creates a new blockchain object, but with a parallel state processor -// TODO marcello check this func -func NewParallelBlockChain(db ethdb.Database, cacheConfig *CacheConfig, chainConfig *params.ChainConfig, engine consensus.Engine, vmConfig vm.Config, shouldPreserve func(header *types.Header) bool, txLookupLimit *uint64, checker ethereum.ChainValidator) (*BlockChain, error) { - bc, err := NewBlockChain(db, cacheConfig, chainConfig, engine, vmConfig, shouldPreserve, txLookupLimit, checker) +func NewParallelBlockChain(db ethdb.Database, cacheConfig *CacheConfig, genesis *Genesis, overrides *ChainOverrides, engine consensus.Engine, vmConfig vm.Config, shouldPreserve func(header *types.Header) bool, txLookupLimit *uint64, checker ethereum.ChainValidator) (*BlockChain, error) { + bc, err := NewBlockChain(db, cacheConfig, genesis, overrides, engine, vmConfig, shouldPreserve, txLookupLimit, checker) if err != nil { return nil, err } + // Open trie database with provided config + triedb := trie.NewDatabaseWithConfig(db, &trie.Config{ + Cache: cacheConfig.TrieCleanLimit, + Journal: cacheConfig.TrieCleanJournal, + Preimages: cacheConfig.Preimages, + }) + chainConfig, _, genesisErr := SetupGenesisBlockWithOverride(db, triedb, genesis, overrides) + if _, ok := genesisErr.(*params.ConfigCompatError); genesisErr != nil && !ok { + return nil, genesisErr + } + bc.parallelProcessor = NewParallelStateProcessor(chainConfig, bc, engine) return bc, nil diff --git a/core/state_processor_test.go b/core/state_processor_test.go index 0865c32a4b..4f06d39410 100644 --- a/core/state_processor_test.go +++ b/core/state_processor_test.go @@ -248,7 +248,7 @@ func TestStateProcessorErrors(t *testing.T) { }, } blockchain, _ = NewBlockChain(db, nil, gspec, nil, ethash.NewFaker(), vm.Config{}, nil, nil, nil) - parallelBlockchain, _ = NewParallelBlockChain(db, nil, gspec.Config, ethash.NewFaker(), vm.Config{ParallelEnable: true, ParallelSpeculativeProcesses: 8}, nil, nil, nil) + parallelBlockchain, _ = NewParallelBlockChain(db, nil, gspec, nil, ethash.NewFaker(), vm.Config{ParallelEnable: true, ParallelSpeculativeProcesses: 8}, nil, nil, nil) ) defer blockchain.Stop() defer parallelBlockchain.Stop() @@ -292,7 +292,7 @@ func TestStateProcessorErrors(t *testing.T) { }, } blockchain, _ = NewBlockChain(db, nil, gspec, nil, ethash.NewFaker(), vm.Config{}, nil, nil, nil) - parallelBlockchain, _ = NewParallelBlockChain(db, nil, gspec.Config, ethash.NewFaker(), vm.Config{ParallelEnable: true, ParallelSpeculativeProcesses: 8}, nil, nil, nil) + parallelBlockchain, _ = NewParallelBlockChain(db, nil, gspec, nil, ethash.NewFaker(), vm.Config{ParallelEnable: true, ParallelSpeculativeProcesses: 8}, nil, nil, nil) ) defer blockchain.Stop() defer parallelBlockchain.Stop() @@ -356,7 +356,7 @@ func TestStateProcessorErrors(t *testing.T) { } genesis = gspec.MustCommit(db) blockchain, _ = NewBlockChain(db, nil, gspec, nil, beacon.New(ethash.NewFaker()), vm.Config{}, nil, nil, nil) - parallelBlockchain, _ = NewParallelBlockChain(db, nil, gspec.Config, ethash.NewFaker(), vm.Config{ParallelEnable: true, ParallelSpeculativeProcesses: 8}, nil, nil, nil) + parallelBlockchain, _ = NewParallelBlockChain(db, nil, gspec, nil, ethash.NewFaker(), vm.Config{ParallelEnable: true, ParallelSpeculativeProcesses: 8}, nil, nil, nil) tooBigInitCode = [params.MaxInitCodeSize + 1]byte{} smallInitCode = [320]byte{} ) diff --git a/params/config.go b/params/config.go index 6ea1a6c41d..cc7afe5537 100644 --- a/params/config.go +++ b/params/config.go @@ -712,7 +712,7 @@ func (c *BorConfig) IsDelhi(number *big.Int) bool { } func (c *BorConfig) IsIndore(number *big.Int) bool { - return isForked(c.IndoreBlock, number) + return isBlockForked(c.IndoreBlock, number) } func (c *BorConfig) CalculateStateSyncDelay(number uint64) uint64 { @@ -725,7 +725,7 @@ func (c *BorConfig) IsParallelUniverse(number *big.Int) bool { return false } - return isForked(c.ParallelUniverseBlock, number) + return isBlockForked(c.ParallelUniverseBlock, number) } func (c *BorConfig) IsSprintStart(number uint64) bool {