go-ethereum/cmd/devp2p/internal/ethtest
ozpool 80b58f649a
cmd/devp2p/internal/ethtest: fix header stride in reverse GetHeaders (#35362)
`Chain.GetHeaders` steps by `1 + Skip` in the forward branch but by `1 -
Skip` in the reverse branch. `Skip` is a `uint64`, so the reverse stride
is wrong for every `Skip > 0`:

| Skip | reverse step | result |
| --- | --- | --- |
| 0 | `-= 1` | correct |
| 1 | `-= 0` | block number never moves, the same header is returned
`Amount` times |
| >= 2 | `1 - Skip` underflows | walks *forward* instead of back (`Skip
= 2` on block 100 lands on 101) |

Per the `GetBlockHeadersRequest` definition, `Skip` is "Blocks to skip
between consecutive headers", so the stride is `Skip + 1` in whichever
direction the query runs. Subtracting `1 + Skip` makes the reverse
branch mirror the forward one.

The existing table test covers forward + `Skip: 1` and reverse + `Skip:
0` (which works by accident, since `1 - 0 == 1`). Added the missing
reverse + `Skip: 1` case; it fails on master:

```
--- FAIL: TestChainGetHeaders/3
    Test: TestChainGetHeaders/3
FAIL	github.com/ethereum/go-ethereum/cmd/devp2p/internal/ethtest
```

and passes with the fix (4/4).

No caller sends a reverse request with `Skip > 0` today, so nothing is
broken in the current suite. The helper computes the expected headers
that responses are checked against, though, so the moment a reverse+skip
case is added it would silently assert the wrong headers rather than
fail loudly.
2026-07-17 18:51:45 +02:00
..
testdata eth: implement EIP-7975 (eth/70 - partial block receipt lists) (#33153) 2026-03-30 15:17:37 +02:00
chain.go cmd/devp2p/internal/ethtest: fix header stride in reverse GetHeaders (#35362) 2026-07-17 18:51:45 +02:00
chain_test.go cmd/devp2p/internal/ethtest: fix header stride in reverse GetHeaders (#35362) 2026-07-17 18:51:45 +02:00
conn.go core/txpool/blobpool, eth: implement sparse blobpool (#34047) 2026-07-15 14:41:04 +02:00
engine.go cmd: use package filepath over path for file system operations (#29227) 2024-03-12 10:00:34 +01:00
mkchain.sh cmd/devp2p/internal/ethtest: update to PoS-only test chain (#32850) 2025-10-08 11:14:27 +02:00
protocol.go core, eth/protocols/snap, eth/downloader: snap/2 sync logic (#34626) 2026-06-11 14:45:07 +08:00
snap.go eth: implement EIP-7975 (eth/70 - partial block receipt lists) (#33153) 2026-03-30 15:17:37 +02:00
snap2.go core, eth/protocols/snap, eth/downloader: snap/2 sync logic (#34626) 2026-06-11 14:45:07 +08:00
suite.go core/txpool/blobpool, eth: implement sparse blobpool (#34047) 2026-07-15 14:41:04 +02:00
suite_test.go core, eth/protocols/snap, eth/downloader: snap/2 sync logic (#34626) 2026-06-11 14:45:07 +08:00
transaction.go core/txpool/blobpool, eth: implement sparse blobpool (#34047) 2026-07-15 14:41:04 +02:00