Repository navigation
feat(p2p): [proxy] magic overrides the devnet's wire magic - #29
Open
cafebedouin wants to merge 2 commits into
Open
cafebedouin wants to merge 2 commits into
cafebedouin wants to merge 2 commits into
Conversation
…t"`) A third `Network` variant for isolated multi-node testing: magic [7,7,7,7], protocol v4 from genesis with the sub-blocks parameter, testnet genesis boxes and digest, difficulty pinned at 1 by an unreachable difficulty and voting epoch (1 << 25 blocks), a 20 s block interval, the v2 activation height and re-emission rules of testnet (neither reachable), and the testnet address prefix. The profile is a Scala `networkType = "devnet60"` node with those overrides (the mixed Scala/Rust devnet of arkadianet/ergo, `scripts/devnet-mixed/genesis.conf`, runs the same one), so a Scala node, an arkadianet node and this node share one wire. Mainnet and testnet behaviour is unchanged: every touched match adds a `Devnet` arm and the existing arms keep their values. Tests cover the magic and its TOML name, the chain, voting and re-emission parameters, the launch parameters, and that the devnet genesis boxes reproduce the testnet state digest. The example config, the manpage, the operator guide, the facts contracts (config, journal events, p2p node, p2p routing, mining), the changelog and the wire-format magic table name the new network. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
An optional `magic = [b0, b1, b2, b3]` under `[proxy]`, accepted only when the network is devnet and never a public network's magic (rejected at config load otherwise), so several private networks can run side by side or a devnet can join another private network's magic. `HandshakeConfig` gains a required `magic` field, the magic in force, and the session feature, the peer check (`validate_peer_magic`; `validate_peer` stays as a wrapper) and the frame codec read it. Mainnet and testnet keep their compiled-in magic: the override cannot be set for them. Tests cover acceptance on devnet, the fallback, both rejections, and that the handshake session body carries the configured magic; the crate's integration tests are updated for the new field. Documented in the example config, the manpage, the p2p-node facts contract and the changelog. Co-Authored-By: Claude Fable 5.1 <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.
Prepared with Claude (Anthropic, Claude Fable 5.1) for cafebedouin; the tests and the mixed-implementation run below were executed on this branch head. Stacked on #28 (the devnet-network pull request): this branch carries that commit too, and only its last commit, the magic override, is under review here.
[proxy] magic: let the devnet's wire magic be overriddenObserved: with the devnet network the magic
[7,7,7,7]is compiled in (p2p/src/types.rs), so two private networks on one host, or a devnet that must join a private network with another magic, cannot be configured.Change: an optional
magic = [b0, b1, b2, b3]under[proxy], accepted only when the network isdevnetand never a public network's magic, both rejected at config load (p2p/src/config.rs).HandshakeConfiggains a requiredmagicfield, the magic in force, and the session feature, the peer check (validate_peer_magic;validate_peerstays as a wrapper) and the frame reader and writer read it. Documented in the example config, the manpage, the p2p-node facts contract and the changelog (which names the crate API change).Invariant kept: mainnet and testnet keep their compiled-in magic; the override cannot be set for them, and the magic in force is
network.magic()whenever the key is absent. Falsifier: a public-network config withmagicthat loads, or a devnet config without the key whose session feature or frames carry anything but[7,7,7,7].Recommended: merge after #28.
Executed:
cargo test -p enr-p2p(library, including acceptance, fallback, both rejections and the session-body test, and every enr-p2p integration test binary, updated for the new field); the root crate's one integration test that builds aHandshakeConfig, also updated, compiled with--no-run. Not run: the workspace suite, clippy, other platforms.Evidence:
ERGO-NODE-RUST-FOLLOW: PASS (A=6.0.6 B=0.8.2 followed=yes maxlag=13 SAME@41 SAME@41 topology=ok): this node, built at this commit (sha2564a0ee25f9230d9e1be7b08737b6265c23f9a727a99b3d10996183c61e1627176) withmagic = [102, 111, 114, 107], followed an ergo v6.0.6 node on that magic to the same chain and state root.To reproduce without the bench that ran it
The devnet-network pull request's recipe with two changes: the Scala node runs
scorex.network.magicBytes = [102, 111, 114, 107], and this node's[proxy]hasmagic = [102, 111, 114, 107]. Same checks. By reading, not executed here: with the key removed on either side the two nodes should never connect (the peer check rejects a magic mismatch); withnetwork = "testnet"and the key, this node refuses at config load (executed as a unit test).