Repository navigation
Conversation
…ork-block The sensor only accepted peers whose fork ID hash equalled --fork-id and advertised that hash with no next fork. After a hard fork, upgraded nodes reject that ID, so a sensor restarted after the fork only reached nodes that never upgraded. --next-fork-block advertises the fork's block as the fork ID's next field, which EIP-2124 nodes accept on both sides of the fork, and --next-fork-id accepts peers on the post-fork hash too. --fork-id is now checked to be 4 bytes instead of panicking. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Replace --next-fork-id and --next-fork-block with --fork-blocks and --fork-times. With --genesis-hash the sensor computes every fork ID in the schedule as a node does, advertises the one for its current head with the next scheduled fork, and accepts peers on any of them. It moves to a new fork ID at a fork on its own, and no hash is entered by hand. An explicitly set --fork-id must be in the schedule, so a wrong genesis hash or fork list fails at startup, and a peer on the sensor's fork ID that expects a different next fork is logged. A rejected peer's error lists the accepted fork IDs, and only the schedule is passed through the handshake. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
p2p sensoronly accepted peers whose fork ID hash equalled--fork-id, and advertised that hash withNext: 0. A hard fork changes the fork ID at its activation block, and under EIP-2124 an upgraded node then rejects a peer that still advertises the old hash with no next fork. Connections opened before the fork survive it, because the fork ID is only checked in the handshake. But once a sensor restarts after a fork, it can only reach nodes that never upgraded, which are stuck on the block before the fork and announce no new blocks.This happened on Amoy after the Salvador fork at block 54483500: a sensor restarted on the pre-fork ID received no block announcements until its configuration was changed.
--fork-blocksand--fork-timestake every fork since genesis that changes the fork ID, including scheduled ones;--fork-timescovers forks activated by timestamp. With--genesis-hash, the sensor computes each fork ID the way a node does from its chain config: it sorts the forks, drops duplicates and drops forks at block 0. No hash is entered by hand.--fork-idmust be one of the schedule's fork IDs, so a wrong genesis hash or fork list fails at startup.--fork-idis checked to be 4 bytes. A wrong length used to panic on the array conversion.--fork-idwith no next fork and accepts only that hash.dbfe071c.go-ethereum'sforkid.NewFilterisn't used for validation because it needs aparams.ChainConfig, which can't describe the Bor-specific forks. It would also reject the not-upgraded peers that the sensor deliberately keeps.Testing
p2p/forkid_test.go:22d523b2→a19b27aeat 98803800, and8b7e4175→dbfe071cat 54483500.--fork-idalone, the sensor knows exactly that one hash.forkid.NewIDWithChain.forkid.NewFilteraccepts the sensor's advertised ID from a node on either side of the fork, with the sensor's head on either side. A post-fork node rejects the pre-fork hash withNext: 0, which was the old behaviour.cmd/p2p/sensor/forks_test.go: covers--fork-idalone, a short fork ID, a schedule with and without an explicit--fork-id, a wrong fork block caught by the--fork-idcheck, and a malformed genesis hash.go test ./p2p/... ./cmd/p2p/...passes, andgolangci-lintreports 0 issues.make gen-docregenerateddoc/polycli_p2p_sensor.md.dbfe071c. It accepted 16 upgraded peers ondbfe071cand 10 on8b7e4175.🤖 Generated with Claude Code