Skip to content

refactor(protocols): run identify and ping on the real core and host - #89

Open
IvanAnishchuk wants to merge 6 commits into
etheorem:hackathon26from
IvanAnishchuk:seam-identify-ping
Open

IvanAnishchuk wants to merge 6 commits into
etheorem:hackathon26from
IvanAnishchuk:seam-identify-ping

Conversation

@IvanAnishchuk

Copy link
Copy Markdown
Contributor

Summary

Identify and ping now run on the real libp2p/core and libp2p/host. This PR deletes Protocols.Mock.Core and Protocols.Mock.Host, so libp2p/protocols carries no mock. The handlers read their StreamContext, 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, and pingId are Libp2p.Core.ProtocolId values. The module no longer imports the mock.
  • Ping.lean: protocolId, mapPingError, and pingHandler take the core types. mapPingError maps a stream error through the one mapStreamError of StreamError.lean.
  • Identify.lean:
    • The ids, mapIdentifyError, and the three handler values take the core types.
    • push and pushHandler take a Libp2p.Host.Host. The handler checks the pushed key against ctx.remotePeer, and stores the listen addresses through Host.addAddrs.
    • respondHandler drops its fixed observed argument. Each answer carries ctx.remoteAddr, as go-libp2p reads it from s.Conn() (vendor/go-libp2p/p2p/protocol/identify/id.go). One handler serves every peer, so a fixed value was wrong for all but one.
    • The deadline reset runs in a TaskSet the call owns and joins after the race. The old resetQuietly spawned a task that nothing joined, which its own doc called "an exception to §4.1 rule 2" (PRINCIPLES 3.2).
  • ReqResp/Payload.lean imports Streams.Error. It names Streams.Error, and it had reached that name only through Constants, then Mock.Core, then Streams.
  • Mock/Core.lean and Mock/Host.lean are deleted. The package ARCHITECTURE drops the mock row and describes the observed address and the push check.

cli/:

Tests:

  • Tests/Protocols.lean types the pipe-pair cases over the core seam with a fixed context. The push cases store into a real host and read back through Host.addrsOf.
  • New: the responder writes the context's address as observed. A push whose key is not the context's peer stores nothing.
  • New, between two hosts of 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 --wfail is green (283 jobs). GossipsubSession.lean typechecks with lake env lean. A cold lake build gossipsub-interop still fails on the Cli globs, which fix(cli): build gossipsub-interop from a fresh checkout #85 fixes.
  • lake test passes: 27832 passed, 0 failed, 4 skipped. It passes again with LEAN_NUM_THREADS=1.
  • Stress: the test binary passes 8 of 8 runs at 4 workers, each under a 600 s timeout.
  • The import-rule lint is green: 184 modules, 0 violations.
  • A new codec or framing layer comes with its round-trip theorem or property test, and with a test for its length cap. (n/a: no new codec)
  • If this touches wire behavior: the captured vectors still pass, and the description names the spec section the change follows. The identify vector of identify-go.json replays. The observed address follows go-libp2p's id.go.
  • If this touches the go interop path: the interop matrix (PLAN W5.9) is green. (feat(cli): run the interop harness on the real stack #88 re-runs it on this base.)

Risk / trust footprint

None added. #print axioms over the identify and ping theorems: the 13 identify theorems depend on propext, Classical.choice, and Quot.sound. The six ping theorems depend on propext, and the two splitPayloads theorems also on Quot.sound. The deleted Mock/Host.lean held one opaque (inMemory).

Notes for reviewers

LICENSE (LGPL version 3)

  • I have read and accepted LICENSE (LGPL version 3), NOTICE and CLA in the root of this project.

…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.
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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[SEAM] W5.7 identify/ping: the mock connections of #45

1 participant