cmd/devp2p/internal/ethtest: validate received txs, not the sent ones (#35170)
Some checks are pending
/ Linux Build (push) Waiting to run
/ Linux Build (arm) (push) Waiting to run
/ Keeper Build (push) Waiting to run
/ Windows Build (push) Waiting to run
/ Docker Image (push) Waiting to run

sendInvalidTxs's *eth.TransactionsPacket case iterated `txs` — the
locally-sent invalid transactions, every one of which is in `invalids`
by construction — instead of the transactions actually carried by the
received packet. As a result the loop returned "received bad tx" on the
very first TransactionsPacket the peer sent, regardless of its contents,
and never inspected what was really propagated.

Iterate msg.Items() (the decoded contents of the received packet) so the
"node must not propagate invalid txs" conformance check tests the real
condition instead of producing a false negative.

---------

Co-authored-by: Bosul Mun <bsbs8645@snu.ac.kr>
This commit is contained in:
cui 2026-06-16 21:31:02 +08:00 committed by GitHub
parent 6e62cc5aa8
commit cb387c9bc3
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -155,7 +155,11 @@ func (s *Suite) sendInvalidTxs(t *utesting.T, txs []*types.Transaction) error {
switch msg := msg.(type) { switch msg := msg.(type) {
case *eth.TransactionsPacket: case *eth.TransactionsPacket:
for _, tx := range txs { received, err := msg.Items()
if err != nil {
return fmt.Errorf("failed to decode received transactions: %w", err)
}
for _, tx := range received {
if _, ok := invalids[tx.Hash()]; ok { if _, ok := invalids[tx.Hash()]; ok {
return fmt.Errorf("received bad tx: %s", tx.Hash()) return fmt.Errorf("received bad tx: %s", tx.Hash())
} }