diff --git a/cmd/utils/history_test.go b/cmd/utils/history_test.go index 9b7f1797d8..45a9da6265 100644 --- a/cmd/utils/history_test.go +++ b/cmd/utils/history_test.go @@ -163,7 +163,7 @@ func TestHistoryImportAndExport(t *testing.T) { // Now import Era. freezer := t.TempDir() - db2, err := rawdb.NewDatabaseWithFreezer(rawdb.NewMemoryDatabase(), freezer, "", false) + db2, err := rawdb.NewDatabaseWithFreezer(rawdb.NewMemoryDatabase(), freezer, "", false, false, false, false) if err != nil { panic(err) } diff --git a/core/txpool/blobpool/blobpool_test.go b/core/txpool/blobpool/blobpool_test.go index 3328e460df..3e465a9214 100644 --- a/core/txpool/blobpool/blobpool_test.go +++ b/core/txpool/blobpool/blobpool_test.go @@ -1360,7 +1360,9 @@ func benchmarkPoolPending(b *testing.B, datacap uint64) { statedb.AddBalance(addr, uint256.NewInt(1_000_000_000)) pool.add(tx) } - statedb.Commit(0, true) + statedb.Finalise(true) + statedb.AccountsIntermediateRoot() + statedb.Commit(0, nil) defer pool.Close() // Benchmark assembling the pending diff --git a/core/txpool/legacypool/legacypool_test.go b/core/txpool/legacypool/legacypool_test.go index 38cd34f3e7..5f7a625f13 100644 --- a/core/txpool/legacypool/legacypool_test.go +++ b/core/txpool/legacypool/legacypool_test.go @@ -2544,7 +2544,7 @@ func TestTransactionPendingReannouce(t *testing.T) { reannounceInterval = time.Second pool := New(config, blockchain) - pool.Init(new(big.Int).SetUint64(config.PriceLimit), blockchain.CurrentBlock(), makeAddressReserver()) + pool.Init(config.PriceLimit, blockchain.CurrentBlock(), makeAddressReserver()) // Modify ReannounceTime to trigger quicker. pool.config.ReannounceTime = time.Second defer pool.Close() diff --git a/eth/filters/filter_system_test.go b/eth/filters/filter_system_test.go index a8feed0579..c3e465036d 100644 --- a/eth/filters/filter_system_test.go +++ b/eth/filters/filter_system_test.go @@ -34,7 +34,6 @@ import ( "github.com/ethereum/go-ethereum/core/bloombits" "github.com/ethereum/go-ethereum/core/rawdb" "github.com/ethereum/go-ethereum/core/types" - "github.com/ethereum/go-ethereum/crypto" "github.com/ethereum/go-ethereum/ethdb" "github.com/ethereum/go-ethereum/event" "github.com/ethereum/go-ethereum/internal/ethapi" @@ -773,143 +772,6 @@ func TestPendingLogsSubscription(t *testing.T) { } } -func TestLightFilterLogs(t *testing.T) { - t.Parallel() - - var ( - db = rawdb.NewMemoryDatabase() - backend, sys = newTestFilterSystem(t, db, Config{}) - api = NewFilterAPI(sys, true) - signer = types.HomesteadSigner{} - - firstAddr = common.HexToAddress("0x1111111111111111111111111111111111111111") - secondAddr = common.HexToAddress("0x2222222222222222222222222222222222222222") - thirdAddress = common.HexToAddress("0x3333333333333333333333333333333333333333") - notUsedAddress = common.HexToAddress("0x9999999999999999999999999999999999999999") - firstTopic = common.HexToHash("0x1111111111111111111111111111111111111111111111111111111111111111") - secondTopic = common.HexToHash("0x2222222222222222222222222222222222222222222222222222222222222222") - - // posted twice, once as regular logs and once as pending logs. - allLogs = []*types.Log{ - // Block 1 - {Address: firstAddr, Topics: []common.Hash{}, Data: []byte{}, BlockNumber: 2, Index: 0}, - // Block 2 - {Address: firstAddr, Topics: []common.Hash{firstTopic}, Data: []byte{}, BlockNumber: 3, Index: 0}, - {Address: secondAddr, Topics: []common.Hash{firstTopic}, Data: []byte{}, BlockNumber: 3, Index: 1}, - {Address: thirdAddress, Topics: []common.Hash{secondTopic}, Data: []byte{}, BlockNumber: 3, Index: 2}, - // Block 3 - {Address: thirdAddress, Topics: []common.Hash{secondTopic}, Data: []byte{}, BlockNumber: 4, Index: 0}, - } - - testCases = []struct { - crit FilterCriteria - expected []*types.Log - id rpc.ID - }{ - // match all - 0: {FilterCriteria{}, allLogs, ""}, - // match none due to no matching addresses - 1: {FilterCriteria{Addresses: []common.Address{{}, notUsedAddress}, Topics: [][]common.Hash{nil}}, []*types.Log{}, ""}, - // match logs based on addresses, ignore topics - 2: {FilterCriteria{Addresses: []common.Address{firstAddr}}, allLogs[:2], ""}, - // match logs based on addresses and topics - 3: {FilterCriteria{Addresses: []common.Address{thirdAddress}, Topics: [][]common.Hash{{firstTopic, secondTopic}}}, allLogs[3:5], ""}, - // all logs with block num >= 3 - 4: {FilterCriteria{FromBlock: big.NewInt(3), ToBlock: big.NewInt(5)}, allLogs[1:], ""}, - // all logs - 5: {FilterCriteria{FromBlock: big.NewInt(0), ToBlock: big.NewInt(5)}, allLogs, ""}, - // all logs with 1>= block num <=2 and topic secondTopic - 6: {FilterCriteria{FromBlock: big.NewInt(2), ToBlock: big.NewInt(3), Topics: [][]common.Hash{{secondTopic}}}, allLogs[3:4], ""}, - } - - key, _ = crypto.GenerateKey() - addr = crypto.PubkeyToAddress(key.PublicKey) - genesis = &core.Genesis{Config: params.TestChainConfig, - Alloc: types.GenesisAlloc{ - addr: {Balance: big.NewInt(params.Ether)}, - }, - } - receipts = []*types.Receipt{{ - Logs: []*types.Log{allLogs[0]}, - }, { - Logs: []*types.Log{allLogs[1], allLogs[2], allLogs[3]}, - }, { - Logs: []*types.Log{allLogs[4]}, - }} - ) - - _, blocks, _ := core.GenerateChainWithGenesis(genesis, ethash.NewFaker(), 4, func(i int, b *core.BlockGen) { - if i == 0 { - return - } - receipts[i-1].Bloom = types.CreateBloom(types.Receipts{receipts[i-1]}) - b.AddUncheckedReceipt(receipts[i-1]) - tx, _ := types.SignTx(types.NewTx(&types.LegacyTx{Nonce: uint64(i - 1), To: &common.Address{}, Value: big.NewInt(1000), Gas: params.TxGas, GasPrice: b.BaseFee(), Data: nil}), signer, key) - b.AddTx(tx) - }) - for i, block := range blocks { - rawdb.WriteBlock(db, block) - rawdb.WriteCanonicalHash(db, block.Hash(), block.NumberU64()) - rawdb.WriteHeadBlockHash(db, block.Hash()) - if i > 0 { - rawdb.WriteReceipts(db, block.Hash(), block.NumberU64(), []*types.Receipt{receipts[i-1]}) - } - } - // create all filters - for i := range testCases { - id, err := api.NewFilter(testCases[i].crit) - if err != nil { - t.Fatal(err) - } - testCases[i].id = id - } - - // raise events - time.Sleep(1 * time.Second) - for _, block := range blocks { - backend.chainFeed.Send(core.ChainEvent{Block: block, Hash: common.Hash{}, Logs: allLogs}) - } - - for i, tt := range testCases { - var fetched []*types.Log - timeout := time.Now().Add(1 * time.Second) - for { // fetch all expected logs - results, err := api.GetFilterChanges(tt.id) - if err != nil { - t.Fatalf("Unable to fetch logs: %v", err) - } - fetched = append(fetched, results.([]*types.Log)...) - if len(fetched) >= len(tt.expected) { - break - } - // check timeout - if time.Now().After(timeout) { - break - } - - time.Sleep(100 * time.Millisecond) - } - - if len(fetched) != len(tt.expected) { - t.Errorf("invalid number of logs for case %d, want %d log(s), got %d", i, len(tt.expected), len(fetched)) - return - } - - for l := range fetched { - if fetched[l].Removed { - t.Errorf("expected log not to be removed for log %d in case %d", l, i) - } - expected := *tt.expected[l] - blockNum := expected.BlockNumber - 1 - expected.BlockHash = blocks[blockNum].Hash() - expected.TxHash = blocks[blockNum].Transactions()[0].Hash() - if !reflect.DeepEqual(fetched[l], &expected) { - t.Errorf("invalid log on index %d for case %d", l, i) - } - } - } -} - // TestPendingTxFilterDeadlock tests if the event loop hangs when pending // txes arrive at the same time that one of multiple filters is timing out. // Please refer to #22131 for more details. diff --git a/eth/handler_bsc_test.go b/eth/handler_bsc_test.go index 842db2726f..076b08c213 100644 --- a/eth/handler_bsc_test.go +++ b/eth/handler_bsc_test.go @@ -36,7 +36,7 @@ func (h *testBscHandler) Handle(peer *bsc.Peer, packet bsc.Packet) error { } } -func TestSendVotes67(t *testing.T) { testSendVotes(t, eth.ETH67) } +func TestSendVotes68(t *testing.T) { testSendVotes(t, eth.ETH68) } func testSendVotes(t *testing.T, protocol uint) { t.Parallel() @@ -63,10 +63,6 @@ func testSendVotes(t *testing.T, protocol uint) { time.Sleep(250 * time.Millisecond) // Wait until vote events get out of the system (can't use events, vote broadcaster races with peer join) protos := []p2p.Protocol{ - { - Name: "eth", - Version: eth.ETH67, - }, { Name: "eth", Version: eth.ETH68, @@ -77,10 +73,6 @@ func testSendVotes(t *testing.T, protocol uint) { }, } caps := []p2p.Cap{ - { - Name: "eth", - Version: eth.ETH67, - }, { Name: "eth", Version: eth.ETH68, @@ -163,7 +155,7 @@ func testSendVotes(t *testing.T, protocol uint) { } } -func TestRecvVotes67(t *testing.T) { testRecvVotes(t, eth.ETH67) } +func TestRecvVotes68(t *testing.T) { testRecvVotes(t, eth.ETH68) } func testRecvVotes(t *testing.T, protocol uint) { t.Parallel() @@ -173,10 +165,6 @@ func testRecvVotes(t *testing.T, protocol uint) { defer handler.close() protos := []p2p.Protocol{ - { - Name: "eth", - Version: eth.ETH67, - }, { Name: "eth", Version: eth.ETH68, @@ -187,10 +175,6 @@ func testRecvVotes(t *testing.T, protocol uint) { }, } caps := []p2p.Cap{ - { - Name: "eth", - Version: eth.ETH67, - }, { Name: "eth", Version: eth.ETH68, diff --git a/eth/handler_eth_test.go b/eth/handler_eth_test.go index 0a93f8fcb8..534b72b865 100644 --- a/eth/handler_eth_test.go +++ b/eth/handler_eth_test.go @@ -307,7 +307,7 @@ func testRecvTransactions(t *testing.T, protocol uint) { } } -func TestWaitSnapExtensionTimout67(t *testing.T) { testWaitSnapExtensionTimout(t, eth.ETH67) } +func TestWaitSnapExtensionTimout68(t *testing.T) { testWaitSnapExtensionTimout(t, eth.ETH68) } func testWaitSnapExtensionTimout(t *testing.T, protocol uint) { t.Parallel() @@ -344,7 +344,7 @@ func testWaitSnapExtensionTimout(t *testing.T, protocol uint) { } } -func TestWaitBscExtensionTimout67(t *testing.T) { testWaitBscExtensionTimout(t, eth.ETH67) } +func TestWaitBscExtensionTimout68(t *testing.T) { testWaitBscExtensionTimout(t, eth.ETH68) } func testWaitBscExtensionTimout(t *testing.T, protocol uint) { t.Parallel() @@ -553,8 +553,8 @@ func TestTransactionPendingReannounce(t *testing.T) { defer sourcePipe.Close() defer sinkPipe.Close() - sourcePeer := eth.NewPeer(eth.ETH67, p2p.NewPeer(enode.ID{0}, "", nil), sourcePipe, source.txpool) - sinkPeer := eth.NewPeer(eth.ETH67, p2p.NewPeer(enode.ID{0}, "", nil), sinkPipe, sink.txpool) + sourcePeer := eth.NewPeer(eth.ETH68, p2p.NewPeer(enode.ID{0}, "", nil), sourcePipe, source.txpool) + sinkPeer := eth.NewPeer(eth.ETH68, p2p.NewPeer(enode.ID{0}, "", nil), sinkPipe, sink.txpool) defer sourcePeer.Close() defer sinkPeer.Close() @@ -774,8 +774,8 @@ func TestOptionMaxPeersPerIP(t *testing.T) { } uniPort++ - src := eth.NewPeer(eth.ETH67, peer1, p2pSrc, handler.txpool) - sink := eth.NewPeer(eth.ETH67, peer2, p2pSink, handler.txpool) + src := eth.NewPeer(eth.ETH68, peer1, p2pSrc, handler.txpool) + sink := eth.NewPeer(eth.ETH68, peer2, p2pSink, handler.txpool) defer src.Close() defer sink.Close() diff --git a/miner/worker.go b/miner/worker.go index c2348be690..4eb4d4736a 100644 --- a/miner/worker.go +++ b/miner/worker.go @@ -774,7 +774,7 @@ func (w *worker) commitTransactions(env *environment, plainTxs, blobTxs *transac stopPrefetchCh := make(chan struct{}) defer close(stopPrefetchCh) - // prefetch txs from all pending txs + // prefetch plainTxs txs, don't bother to prefetch a few blobTxs txsPrefetch := plainTxs.Copy() tx := txsPrefetch.PeekWithUnwrap() if tx != nil {