Repository navigation
refactor(protocols): run identify and ping on the real core and host - #89
Open
IvanAnishchuk wants to merge 6 commits into
Open
IvanAnishchuk wants to merge 6 commits into
IvanAnishchuk wants to merge 6 commits into
Conversation
…tiate The host builds its upgrade from the public stages of libp2p/negotiate. The secured checkpoint sits between the handshake and the muxer stage, where the core seam puts it. Stream selection is a host shell over the pure negotiate core. This commit deletes the Negotiate.Legacy copy, and the unit 1b host legs now run. Part of etheorem#70.
This was referenced Nov 10, 2026
Root ARCHITECTURE §3.1 says every suite above the transport runs on the test values, and the Noise test value has fixed keys. The host legs used Noise.securityProtocol, whose ephemeral keys come from Rng.system. Each suite host now takes Noise.fixedKeyProtocol, seeded from its identity byte. The host PLAN offered the production value as an option, and now names the test value only. Part of etheorem#70.
The sim checks of the req/resp suite now run between two hosts with Noise and yamux. Tests/HostPair.lean builds the pair. The requester opens its stream through the host's newStream. This commit deletes Protocols.Mock.Muxer and Protocols.Mock.HostStream. An id the peer does not serve now fails the open. Multistream-select answers na, so the stream never opens for that id. Part of etheorem#78.
The req/resp section said the host still upgrades through a mock of libp2p/negotiate, so the suite ran against a mock of the stream call. etheorem#86 puts the host on the real negotiate, and this branch runs the suite between two real hosts, so the sentence goes. Part of etheorem#78.
… test clock Root ARCHITECTURE §3.1 says every suite above the transport runs on the test values. Tests/HostPair.lean built its hosts with Noise.securityProtocol and the system clock. Each host now takes Noise.fixedKeyProtocol, seeded from its identity byte, and both hosts run on one TestClock that Pair.close closes. Part of etheorem#78.
Identify and ping now type over the seam types of libp2p/core, and this commit deletes Protocols.Mock.Core and Protocols.Mock.Host. The push handler checks the pushed key against the peer of its stream's connection and stores the addresses through the host's peerstore. The responder writes the connection's remote address as the observed address, as go reads both from the connection. The identify deadline reset now runs in a TaskSet the call owns and joins. The old reset task had no owner. GossipsubSession serves the identify handler with no bridge. ReqResp/Payload.lean imports Streams.Error, which it had reached only through the core mock. Part of etheorem#55.
IvanAnishchuk
force-pushed
the
seam-identify-ping
branch
from
November 10, 2026 12:59
e45490f to
3234c20
Compare
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
Identify and ping now run on the real
libp2p/coreandlibp2p/host. This PR deletesProtocols.Mock.CoreandProtocols.Mock.Host, solibp2p/protocolscarries no mock. The handlers read theirStreamContext, and push stores through the host's peerstore. Closes #55.This PR stacks on #86 (the host on the real negotiate) and #87 (the req/resp mocks). Until those merge, the diff also shows their commits. Review the last commit,
refactor(protocols): ….What changed
libp2p/protocols:Constants.lean:identifyId,identifyPushId, andpingIdareLibp2p.Core.ProtocolIdvalues. The module no longer imports the mock.Ping.lean:protocolId,mapPingError, andpingHandlertake the core types.mapPingErrormaps a stream error through the onemapStreamErrorofStreamError.lean.Identify.lean:mapIdentifyError, and the three handler values take the core types.pushandpushHandlertake aLibp2p.Host.Host. The handler checks the pushed key againstctx.remotePeer, and stores the listen addresses throughHost.addAddrs.respondHandlerdrops its fixedobservedargument. Each answer carriesctx.remoteAddr, as go-libp2p reads it froms.Conn()(vendor/go-libp2p/p2p/protocol/identify/id.go). One handler serves every peer, so a fixed value was wrong for all but one.TaskSetthe call owns and joins after the race. The oldresetQuietlyspawned a task that nothing joined, which its own doc called "an exception to §4.1 rule 2" (PRINCIPLES 3.2).ReqResp/Payload.leanimportsStreams.Error. It namesStreams.Error, and it had reached that name only throughConstants, thenMock.Core, thenStreams.Mock/Core.leanandMock/Host.leanare deleted. The package ARCHITECTURE drops the mock row and describes the observed address and the push check.cli/:GossipsubSession.leanservesIdentify.respondHandlerdirectly.mapMockErrorandtoCoreHandler, the bridge PR feat(protocols): W6.4, gossipsub v1.1 #59 added for this swap, are deleted.Tests:
Tests/Protocols.leantypes the pipe-pair cases over the core seam with a fixed context. The push cases store into a real host and read back throughHost.addrsOf.Tests/HostPair.lean: identify through the host proves the server's peer id and reads the client's sim address as observed. A push lands in the server's peerstore under the client's proved peer id. A push with another peer's key stores nothing.Test plan
lake build --wfailis green (283 jobs).GossipsubSession.leantypechecks withlake env lean. A coldlake build gossipsub-interopstill fails on theCliglobs, which fix(cli): build gossipsub-interop from a fresh checkout #85 fixes.lake testpasses: 27832 passed, 0 failed, 4 skipped. It passes again withLEAN_NUM_THREADS=1.identify-go.jsonreplays. The observed address follows go-libp2p'sid.go.Risk / trust footprint
None added.
#print axiomsover the identify and ping theorems: the 13 identify theorems depend onpropext,Classical.choice, andQuot.sound. The six ping theorems depend onpropext, and the twosplitPayloadstheorems also onQuot.sound. The deletedMock/Host.leanheld oneopaque(inMemory).Notes for reviewers
Libp2p/Protocols/Identity.lean, the boundary tolibp2p/identity, stays as it is. It is real code, so the validate theorems keep their premises.Protocols/Mock/Core.leanandProtocols/Mock/Host.lean(PR feat(protocols): W5.7, identify and ping #45) can be struck when this merges.pingCoreHandler, its bridge over the old ping handler.LICENSE (LGPL version 3)