Conversation
Match the leanSpec topic format `/leanconsensus/{fork_digest}/{name}/ssz_snappy`
(leanEthereum/leanSpec#622) instead of the custom `/leanconsensus/devnet0/...`.
Introduce a `ForkDigest` newtype displayed as lowercase hex without `0x`
prefix, plus `block_topic` / `aggregation_topic` / `attestation_subnet_topic`
helpers. The digest is plumbed through `SwarmConfig` / `BuiltSwarm` /
`P2PServer` so it becomes configurable once the spec defines real fork
identification. For now every client agrees on the dummy `12345678` value,
exposed as `ForkDigest::DUMMY`.
Closes #292
Greptile SummaryThis PR replaces the hardcoded Confidence Score: 5/5Safe to merge — clean refactor with no logic errors, full test coverage for the new type, and consistent plumbing throughout the stack. All changes are mechanical substitutions of a hardcoded string with a properly typed value. The ForkDigest Display impl is verified by unit tests, all three topic builders are tested end-to-end, and the runtime message parsing (split("/").nth(3)) is unaffected by the change in position 2 of the topic path. No P0 or P1 findings. No files require special attention.
|
| Filename | Overview |
|---|---|
| crates/net/p2p/src/gossipsub/messages.rs | Introduces ForkDigest newtype with Display (lowercase hex, no 0x prefix), DUMMY constant, and three topic builder functions; covered by unit tests for all cases. |
| crates/net/p2p/src/lib.rs | Adds fork_digest field to SwarmConfig, BuiltSwarm, and P2PServer; replaces all inline topic string construction with builder function calls consistently. |
| crates/net/p2p/src/gossipsub/handler.rs | Updates attestation_subnet_topic fallback call to pass &server.fork_digest; topic parsing via split("/").nth(3) is unaffected and correct for the new format. |
| bin/ethlambda/src/main.rs | Adds ForkDigest::DUMMY to SwarmConfig with a clear TODO comment explaining when to replace it with a real computed digest. |
| crates/net/p2p/src/gossipsub/mod.rs | Re-exports updated to expose ForkDigest and topic builder functions instead of the old NETWORK_NAME/BLOCK_TOPIC_KIND/AGGREGATION_TOPIC_KIND constants. |
| CLAUDE.md | Documentation updated to reflect the new topic format with fork_digest and the 12345678 placeholder, matching the implementation. |
Flowchart
%%{init: {'theme': 'neutral'}}%%
flowchart TD
A["main.rs\nForkDigest::DUMMY"] -->|fork_digest field| B["SwarmConfig"]
B -->|build_swarm| C["BuiltSwarm\n+ fork_digest"]
C -->|P2P::spawn| D["P2PServer\n+ fork_digest"]
B -->|block_topic| E["IdentTopic\nblock"]
B -->|aggregation_topic| F["IdentTopic\naggregation"]
B -->|attestation_subnet_topic| G["IdentTopic\nattestation_N"]
E --> C
F --> C
G -->|cached in attestation_topics| C
D -->|fallback publish| H["attestation_subnet_topic\nfork_digest + subnet_id"]
Reviews (1): Last reviewed commit: "Use fork digest in gossipsub topics" | Re-trigger Greptile
Drop the `ForkDigest` newtype, `SwarmConfig` / `BuiltSwarm` / `P2PServer` plumbing, and `pub` re-export. The fork digest is the dummy `12345678` placeholder every Lean client currently agrees on; a `FORK_DIGEST` `&str` constant with a TODO captures that cleanly until the spec defines real fork identification, and leaves the topic builder functions taking only the pieces that actually vary (subnet id).
Summary
/leanconsensus/{fork_digest}/{name}/ssz_snappyinstead of the custom/leanconsensus/devnet0/...we had hard-coded.Closes #292.