Repository navigation
feat(peer): add Ed25519 node identity, signed reachability leases, and resumable peer streams - #7137
Conversation
…d resumable peer streams
jackwener
left a comment
There was a problem hiding this comment.
I found one recovery correctness issue that should be fixed before relying on the stream's graceful-close semantics.
Reviewed head: 850494fdf662f75b638ede836405d2911cba8144.
Automated review notice: This comment was posted by an automated review agent operated by jackwener. It is not an independent human review and does not replace one.
| fn is_complete(&self) -> bool { | ||
| self.local_fin_sent | ||
| && self.remote_fin_received | ||
| && self.peer_acked_offset == self.outbound_next_offset |
There was a problem hiding this comment.
[P2][recovery path] Wait for an explicit FIN acknowledgement before completing
peer_acked_offset == outbound_next_offset acknowledges only DATA bytes; it is already true at offset 0 and can also become true before the peer receives FRAME_FIN. Once both sides have sent FIN, this lets the worker exit after merely writing its FIN to the current carrier. If that frame is lost during a carrier switchover, the sender drops its control receiver while the peer still waits for FIN and eventually times out, so graceful close is not actually resumable.
I reproduced this by forwarding both HELLO frames, dropping A's FIN after A's carrier write succeeded, and then replacing B's carrier: A's replace_carrier returned Closed, while B terminated with TimedOut. Please track FIN acknowledgement separately (or add a FIN-ACK), retain FIN in replay state until the peer confirms it, and add this loss boundary as a regression test.
Stack A: P2P Mesh (Stacked PRs)
stack/p2p-mesh-1-accept-remote-streamsrust-previewstack/p2p-mesh-2-peer-identity-and-reachabilitystack/p2p-mesh-1-accept-remote-streamsstack/p2p-mesh-3-mesh-control-and-transitstack/p2p-mesh-2-peer-identity-and-reachabilitystack/p2p-mesh-4-cli-and-pairing-ticketstack/p2p-mesh-3-mesh-control-and-transitIntroduce
platform/peer(maka-peer) providing cryptographic peer identity, signed reachability leases for seamless IP rotation, and resumable byte streams across mid-session carrier switchover.Changes
platform/peer/src/identity.rs:PeerIdnewtype, Ed25519NodeIdentitywith zeroized seed loading (load_or_create/load_or_create_async), canonical Base64 signature validation, and 6-digit SAS derivation.platform/peer/src/reachability.rs:DirectRoute,RelayRoute,PeerReachabilityLeaseV1,SignedPeerReachabilityLeaseV1, andLeaseReceiptStorewith monotonicInstantdeadlines (immune to wall-clock rollback) returning zero-copyUsableLease<'a>.platform/peer/src/resumable.rs:ResumablePeerStream+ResumableStreamControlwith 30s default recovery window, 2 MiB replay buffer, cancel-safeFrameDecoder, split carrier I/O,FRAME_REJECTmismatch abort, and explicitTerminalErrorSloterrors.platform/peer/tests/peer_behaviors.rs: behavioral integration tests includingreal_host_websocket_session_survives_resumable_carrier_switchoverrunning a realHost::serve_remote+Client::connect_websocket+HostLogs::readRPC across carrier switchover.Verification
cargo test --locked -p maka-peer(5/5 pass, plus 50/50 consecutive stress runs)node scripts/asf-license-headers.mjs check(pass)