diff --git a/cmd/devp2p/internal/ethtest/suite.go b/cmd/devp2p/internal/ethtest/suite.go index 73df3e73fa..c23360bf82 100644 --- a/cmd/devp2p/internal/ethtest/suite.go +++ b/cmd/devp2p/internal/ethtest/suite.go @@ -21,7 +21,6 @@ import ( "crypto/rand" "errors" "fmt" - "os" "reflect" "sync" "time" @@ -87,7 +86,6 @@ func (s *Suite) EthTests() []utesting.Test { {Name: "LargeTxRequest", Fn: s.TestLargeTxRequest, Slow: true}, {Name: "Transaction", Fn: s.TestTransaction}, {Name: "InvalidTxs", Fn: s.TestInvalidTxs}, - {Name: "InvalidMetadata", Fn: s.TestInvalidMetadata}, {Name: "NewPooledTxs", Fn: s.TestNewPooledTxs}, {Name: "BlobViolations", Fn: s.TestBlobViolations}, {Name: "TestBlobTxWithoutSidecar", Fn: s.TestBlobTxWithoutSidecar}, @@ -886,62 +884,6 @@ the transactions using a GetPooledTransactions request.`) } } -func (s *Suite) TestInvalidMetadata(t *utesting.T) { - t.Log(`This test announces transactions to the node and expects it not to fetch - transaction hash with wrong/unsupported metadata.`) - - // Nudge client out of syncing mode to accept pending txs. - if err := s.engine.sendForkchoiceUpdated(); err != nil { - t.Fatalf("failed to send next block: %v", err) - } - - from, nonce := s.chain.GetSender(1) - inner := &types.DynamicFeeTx{ - ChainID: s.chain.config.ChainID, - Nonce: nonce, - GasTipCap: common.Big1, - GasFeeCap: s.chain.Head().BaseFee(), - Gas: 75000, - } - tx, err := s.chain.SignTx(from, types.NewTx(inner)) - if err != nil { - t.Fatalf("failed to sign tx: err") - } - - conn, err := s.dial() - if err != nil { - t.Fatalf("dial failed: %v", err) - } - defer conn.Close() - if err = conn.peer(s.chain, nil); err != nil { - t.Fatalf("peering failed: %v", err) - } - - ann := eth.NewPooledTransactionHashesPacket{Types: []byte{0x09}, Sizes: []uint32{uint32(tx.Size())}, Hashes: []common.Hash{tx.Hash()}} - err = conn.Write(ethProto, eth.NewPooledTransactionHashesMsg, ann) - if err != nil { - t.Fatalf("failed to write to connection: %v", err) - } - - conn.SetReadDeadline(time.Now().Add(timeout)) - msg, err := conn.ReadEth() - if err != nil && !errors.Is(err, os.ErrDeadlineExceeded) { - t.Fatalf("unexpected err: %v", err) - } - if err == nil { - switch msg := msg.(type) { - case *eth.GetPooledTransactionsPacket: - t.Fatalf("Transaction announcements with invalid metadata should be ignored") - case *eth.NewPooledTransactionHashesPacket: - return - case *eth.TransactionsPacket: - return - default: - t.Fatalf("unexpected %s", pretty.Sdump(msg)) - } - } -} - func makeSidecar(data ...byte) *types.BlobTxSidecar { var ( blobs = make([]kzg4844.Blob, len(data)) diff --git a/eth/fetcher/tx_fetcher_test.go b/eth/fetcher/tx_fetcher_test.go index 637dcd63b8..d6d5a8692e 100644 --- a/eth/fetcher/tx_fetcher_test.go +++ b/eth/fetcher/tx_fetcher_test.go @@ -1908,6 +1908,35 @@ func TestTransactionFetcherDropAlternates(t *testing.T) { }) } +func TestTransactionFetcherWrongMetadata(t *testing.T) { + testTransactionFetcherParallel(t, txFetcherTest{ + init: func() *TxFetcher { + return NewTxFetcher( + func(_ common.Hash, kind byte) error { + switch kind { + case types.LegacyTxType, types.AccessListTxType, types.DynamicFeeTxType, types.BlobTxType, types.SetCodeTxType: + return nil + } + return types.ErrTxTypeNotSupported + }, + func(txs []*types.Transaction) []error { + return make([]error, len(txs)) + }, + func(string, []common.Hash) error { return nil }, + nil, + ) + }, + steps: []interface{}{ + doTxNotify{peer: "A", hashes: []common.Hash{{0x01}, {0x02}}, types: []byte{0xff, types.LegacyTxType}, sizes: []uint32{111, 222}}, + isWaiting(map[string][]announce{ + "A": { + {common.Hash{0x02}, types.LegacyTxType, 222}, + }, + }), + }, + }) +} + func testTransactionFetcherParallel(t *testing.T, tt txFetcherTest) { t.Parallel() testTransactionFetcher(t, tt)