From a39b6e51e70c54a4e4c334909e47d4aff68ebd40 Mon Sep 17 00:00:00 2001 From: buddh0 Date: Thu, 16 Jan 2025 10:38:33 +0800 Subject: [PATCH] upstream: pectra devnet 5 fix --- core/chain_makers.go | 2 +- core/genesis_test.go | 30 +++++++++++++++++++++++------- core/state_prefetcher_test.go | 7 ++++--- go.sum | 2 -- 4 files changed, 28 insertions(+), 13 deletions(-) diff --git a/core/chain_makers.go b/core/chain_makers.go index f8ab80cd2b..b213b3f416 100644 --- a/core/chain_makers.go +++ b/core/chain_makers.go @@ -325,7 +325,7 @@ func (b *BlockGen) collectRequests(readonly bool) (requests [][]byte) { statedb = statedb.Copy() } - if b.cm.config.IsPrague(b.header.Number, b.header.Time) { + if b.cm.config.IsPrague(b.header.Number, b.header.Time) && b.cm.config.Parlia == nil { requests = [][]byte{} // EIP-6110 deposits var blockLogs []*types.Log diff --git a/core/genesis_test.go b/core/genesis_test.go index b48f7e2543..227ed9e094 100644 --- a/core/genesis_test.go +++ b/core/genesis_test.go @@ -79,11 +79,29 @@ func testSetupGenesis(t *testing.T, scheme string) { { name: "mainnet block in DB, genesis == nil", fn: func(db ethdb.Database) (*params.ChainConfig, common.Hash, *params.ConfigCompatError, error) { - DefaultGenesisBlock().MustCommit(db, triedb.NewDatabase(db, newDbConfig(scheme))) + DefaultBSCGenesisBlock().MustCommit(db, triedb.NewDatabase(db, newDbConfig(scheme))) return SetupGenesisBlock(db, triedb.NewDatabase(db, newDbConfig(scheme)), nil) }, - wantHash: params.MainnetGenesisHash, - wantConfig: params.MainnetChainConfig, + wantHash: params.BSCGenesisHash, + wantConfig: params.BSCChainConfig, + }, + { + name: "chapel block in DB, genesis == nil", + fn: func(db ethdb.Database) (*params.ChainConfig, common.Hash, *params.ConfigCompatError, error) { + DefaultChapelGenesisBlock().MustCommit(db, triedb.NewDatabase(db, newDbConfig(scheme))) + return SetupGenesisBlock(db, triedb.NewDatabase(db, newDbConfig(scheme)), nil) + }, + wantHash: params.ChapelGenesisHash, + wantConfig: params.ChapelChainConfig, + }, + { + name: "chapel block in DB, genesis == chapel", + fn: func(db ethdb.Database) (*params.ChainConfig, common.Hash, *params.ConfigCompatError, error) { + DefaultChapelGenesisBlock().MustCommit(db, triedb.NewDatabase(db, newDbConfig(scheme))) + return SetupGenesisBlock(db, triedb.NewDatabase(db, newDbConfig(scheme)), DefaultChapelGenesisBlock()) + }, + wantHash: params.ChapelGenesisHash, + wantConfig: params.ChapelChainConfig, }, { name: "custom block in DB, genesis == nil", @@ -102,9 +120,7 @@ func testSetupGenesis(t *testing.T, scheme string) { customg.Commit(db, tdb) return SetupGenesisBlock(db, tdb, DefaultChapelGenesisBlock()) }, - wantErr: &GenesisMismatchError{Stored: customghash, New: params.ChapelGenesisHash}, - wantHash: params.ChapelGenesisHash, - wantConfig: params.ChapelChainConfig, + wantErr: &GenesisMismatchError{Stored: customghash, New: params.ChapelGenesisHash}, }, { name: "compatible config in DB", @@ -256,7 +272,7 @@ func TestConfigOrDefault(t *testing.T) { t.Errorf("initial config should have PlanckBlock = nil, but instead PlanckBlock = %v", defaultGenesis.Config.PlanckBlock) } gHash := params.BSCGenesisHash - config := defaultGenesis.configOrDefault(gHash) + config := defaultGenesis.chainConfigOrDefault(gHash, nil) if config.ChainID.Cmp(params.BSCChainConfig.ChainID) != 0 { t.Errorf("ChainID of resulting config should be %v, but is %v instead", params.BSCChainConfig.ChainID, config.ChainID) diff --git a/core/state_prefetcher_test.go b/core/state_prefetcher_test.go index 745fb1559b..28e54c48c9 100644 --- a/core/state_prefetcher_test.go +++ b/core/state_prefetcher_test.go @@ -37,8 +37,8 @@ func TestPrefetchLeaking(t *testing.T) { Alloc: GenesisAlloc{address: {Balance: funds}}, BaseFee: big.NewInt(params.InitialBaseFee), } - triedb = triedb.NewDatabase(gendb, nil) - genesis = gspec.MustCommit(gendb, triedb) + triedb1 = triedb.NewDatabase(gendb, nil) + genesis = gspec.MustCommit(gendb, triedb1) signer = types.LatestSigner(gspec.Config) ) blocks, _ := GenerateChain(gspec.Config, genesis, ethash.NewFaker(), gendb, 1, func(i int, block *BlockGen) { @@ -52,7 +52,8 @@ func TestPrefetchLeaking(t *testing.T) { } }) archiveDb := rawdb.NewMemoryDatabase() - gspec.MustCommit(archiveDb, triedb) + triedb2 := triedb.NewDatabase(archiveDb, nil) + gspec.MustCommit(archiveDb, triedb2) archive, _ := NewBlockChain(archiveDb, nil, gspec, nil, ethash.NewFaker(), vm.Config{}, nil, nil) defer archive.Stop() diff --git a/go.sum b/go.sum index 215303887c..bda3de7943 100644 --- a/go.sum +++ b/go.sum @@ -1597,8 +1597,6 @@ golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= golang.org/x/text v0.21.0 h1:zyQAAkrwaneQ066sspRyJaG9VNi/YJ1NfzcGB3hZ/qo= golang.org/x/text v0.21.0/go.mod h1:4IBbMaMmOPCJ8SecivzSH54+73PCFmPWxNTLm+vZkEQ= golang.org/x/time v0.0.0-20180412165947-fbb02b2291d2/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= -golang.org/x/text v0.21.0 h1:zyQAAkrwaneQ066sspRyJaG9VNi/YJ1NfzcGB3hZ/qo= -golang.org/x/text v0.21.0/go.mod h1:4IBbMaMmOPCJ8SecivzSH54+73PCFmPWxNTLm+vZkEQ= golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20191024005414-555d28b269f0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=