feat(p2p): add live UDP gossip socket and did:web document verifier

Open
#7 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
30/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Active
Tech stack
rust

Research direction

Start with MeshGossipState in src/p2p.rs (lines 51-64) to see how peer tree heads are stored, then review the HTTP handler area in src/http_server.rs (lines 120-177) where POST /v1/p2p/gossip and identity checks would be wired. The new module src/udp_gossip.rs would hold the std::net::UdpSocket code. Done means cargo test passes, a loopback test in tests/milestone6_test.rs detects equivocation between two sockets, and conflicting roots for the same tree_size are rejected.

Written by the indexing model from the issue text.

Description

area::node effort::m impact::high priority::high source::user status::review type::feature

Problem

Tracked under Coordinator Meta-Issue alfonsodg/sonaraim#9 (Milestone 7).
src/p2p.rs:1-98 (692a933) implements MeshGossipState in memory, but does not bind a real UDP socket to exchange SignedTreeHead datagrams between peers or validate did:web JSON documents (/.well-known/did.json) before marking enterprise identities as verified_b2b: true.

Affected Files & Locations

  • src/p2p.rs:1-98
  • src/udp_gossip.rs (new, < 170 lines)
  • src/http_server.rs:120-177
  • tests/milestone6_test.rs

Evidence

// src/p2p.rs:51-64
pub struct MeshGossipState {
    local_node_id: String,
    peer_heads: HashMap<String, SignedTreeHead>,
    epoch_roots: HashMap<usize, String>,
}

Impact and Blast Radius

Allows real UDP datagram gossip between sonaraim-node instances on port 9031/udp (NODE_P2P_LISTEN_ADDR) and enforces cryptographic did:web verification on POST /v1/identity.

Historical Context and Anti-Regression

Builds on sonaraim-node commit 692a933. Must keep src/http_server.rs under 300 lines (extracting helpers into src/udp_gossip.rs).

Proposed Solution

  1. Create src/udp_gossip.rs providing UdpGossipNode (bind, send_tree_head, recv_tree_head_nonblocking) over std::net::UdpSocket, plus verify_did_web_document(did, doc_json) validating id and verificationMethod fields.
  2. Wire POST /v1/p2p/gossip and did:web verification in src/http_server.rs.

Acceptance Criteria

  • L1 (Unit TDD): cargo fmt --check && cargo clippy -- -D warnings && cargo test passes with zero warnings.
  • L2 (Integration): Two local UdpGossipNode sockets exchange SignedTreeHead packets over loopback UDP and detect equivocation.
  • L3 (Container / GHCR): Container image publishes to GHCR and runs on sandbox-ud-ord.
  • L4 (E2E Sandbox): POST /v1/p2p/gossip on sandbox-ud-ord ingests peer SignedTreeHead and rejects conflicting roots for the same tree_size (409 Conflict).
Dominant language
Rust
Stars
0
Forks
0
Avg merge
4m
Merged PRs (30d)
1

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from alfonsodg/sonaraim-node

All issues in alfonsodg/sonaraim-node

Similar issues

More Rust issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.