Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
139 commits
Select commit Hold shift + click to select a range
95af53f
feat(protocols): W6.4 gossipsub, the router core and its codecs
Wenbobobo Nov 5, 2026
b72b032
fix(protocols): close the rpc cap bound without naming the mock varint
Wenbobobo Nov 5, 2026
6fc2c18
feat(protocols): W5.7 1a, identify and ping pure core
Wenbobobo Nov 3, 2026
b73ec3c
feat(protocols): W5.7 1b, identify and ping handlers and clients
Wenbobobo Nov 3, 2026
1e76fc6
docs(protocols): describe the code, drop the work-split labels
Wenbobobo Nov 4, 2026
4deee3c
docs(protocols): correct the constants doc and axiom note
Wenbobobo Nov 4, 2026
fe4af46
docs(protocols): qualify the identify validation claim
Wenbobobo Nov 4, 2026
0d78379
fix(protocols): make the host mock atomic, record two deltas
leolara Nov 4, 2026
f40c8e6
fix(protocols): reject a ping echo longer than one payload
Wenbobobo Nov 4, 2026
126e665
feat(negotiate): W5.5 1a, the multistream core and its suite
Wenbobobo Nov 3, 2026
6d9bc83
feat(negotiate): W5.5 1b, the upgrader, the seam mocks, and the upgra…
Wenbobobo Nov 3, 2026
9850843
docs(negotiate): drop Action.error and record the decision
wenbo Nov 3, 2026
83937f9
docs(negotiate): state what propose actually does
wenbo Nov 3, 2026
50209fa
fix(negotiate): cap the send path, start the responder first, free th…
wenbo Nov 3, 2026
d1a8513
style(negotiate): clear the naming and prose debt the review listed
wenbo Nov 3, 2026
9a8d344
refactor(negotiate): drop the unreachable proposal branch
wenbo Nov 3, 2026
7d59469
docs(negotiate): correct the merged-dependency claims and two prose nits
leolara Nov 3, 2026
6378f3e
test(negotiate): run the two-party upgrade over the splitting sim
Wenbobobo Nov 3, 2026
0699717
docs(protocols): state the stored-and-unread window in the score params
leolara Nov 5, 2026
b2fb433
refactor(negotiate): use the real varint and streams packages
Wenbobobo Nov 5, 2026
78aa924
fix(protocols): validate identify addresses with the real multiaddr d…
Wenbobobo Nov 5, 2026
c6e926b
docs(protocols): give the trickle regressions an owner in the plan
Wenbobobo Nov 5, 2026
35196cd
feat(protocols): add the identify push sender
Wenbobobo Nov 5, 2026
190b2de
fix(protocols): tighten the push sender schedule and test the half-close
Wenbobobo Nov 5, 2026
cefa7e2
feat(protocols): add the host seam and the in-memory switch to the mocks
Wenbobobo Nov 5, 2026
ccd0207
feat(protocols): W6.4 unit 3b, the gossipsub loop over the core
Wenbobobo Nov 5, 2026
2451654
test(protocols): W6.4 unit 3b, the loop suite over the in-memory switch
Wenbobobo Nov 5, 2026
49ef702
docs(protocols): name the trickle owner and the loop checks in the un…
Wenbobobo Nov 5, 2026
be3351c
test(protocols): pin the over-cap reset on an open stream and the sen…
Wenbobobo Nov 5, 2026
7e70b57
fix(protocols): cap the inbound buffer and serve one frame per stream
Wenbobobo Nov 5, 2026
bcfae27
fix(protocols): reuse peer streams and observe RPC receipts before th…
Wenbobobo Nov 5, 2026
406d60a
fix(protocols): retry one failed stream write and close departing peers
Wenbobobo Nov 5, 2026
618bcd9
docs(protocols): cite the harness receipt contract before deduplication
Wenbobobo Nov 5, 2026
3d5e842
fix(protocols): expose optional gossip spread with a zero default
Wenbobobo Nov 5, 2026
aaec618
fix(protocols): drive the node through one queue and an alarm task
Wenbobobo Nov 5, 2026
ef0805c
test(protocols): pin the gossipsub RPC bytes against the go encoder
Wenbobobo Nov 5, 2026
b7795ba
fix(protocols): enqueue peer writes and wake writers before stop joins
Wenbobobo Nov 5, 2026
be0e870
fix(protocols): bound gossip and register inbound peers before their …
Wenbobobo Nov 5, 2026
18c9922
test(protocols): regenerate the RPC fixture from its committed generator
Wenbobobo Nov 5, 2026
c31794c
test(protocols): pin alarm deadlines and bounded peer writer behavior
Wenbobobo Nov 5, 2026
779b9f8
docs(protocols): state the writer and alarm regression contracts
Wenbobobo Nov 5, 2026
480b86e
test(protocols): pin consecutive RPC frames and framing failures
Wenbobobo Nov 5, 2026
26127b5
docs(protocols): state the multi-frame handler milestone
Wenbobobo Nov 5, 2026
864e7df
fix(protocols): correct the trickle index contract and the generator …
Wenbobobo Nov 5, 2026
e96e60d
docs(protocols): state why the wire fixture lives under fixtures
Wenbobobo Nov 5, 2026
c72c652
fix(protocols): register subscriptions before posting their events
Wenbobobo Nov 5, 2026
6ac101b
fix(protocols): retain inbound peers and read framed bodies with one …
Wenbobobo Nov 5, 2026
eb40c40
docs(protocols): drop process references from the shipped docstrings
Wenbobobo Nov 5, 2026
0f25e63
docs(protocols): describe the shipped tree in the root docstring
leolara Nov 6, 2026
f2825e8
Merge origin/hackathon26 into w6.4-integrate, resolves Tests/Main.lea…
Wenbobobo Nov 6, 2026
d712257
feat(security): W5.3, Noise XX and the secure transport
IvanAnishchuk Nov 6, 2026
6a68b0d
fix(security): derive Hashable on the mocked Core.Error
IvanAnishchuk Nov 6, 2026
1a330ae
refactor(security): take the keys and the peer id from libp2p/identity
IvanAnishchuk Nov 6, 2026
c4e2b73
Add the pure gossipsub interop core
Wenbobobo Nov 6, 2026
1b2e1d3
feat(host): W5.6, the host with dedup, serving, and shutdown
IvanAnishchuk Nov 5, 2026
16455e2
fix(host): refuse a /p2p-only dial address as noTransport
IvanAnishchuk Nov 5, 2026
29fa46a
docs(host): state the base/bytes name the dial path calls
leolara Nov 6, 2026
adf11df
refactor(host): take the keys and the peer id from libp2p/identity
IvanAnishchuk Nov 6, 2026
569effa
Merge base 02f93ca for the 12-hour identity mock swap
Wenbobobo Nov 6, 2026
e4615f5
Add Shadow host resolution and dry-run plan
Wenbobobo Nov 6, 2026
32df0b0
Pin monotonic virtual interop schedule
Wenbobobo Nov 6, 2026
cd8bf24
Test virtual clock barriers and publish assignments
Wenbobobo Nov 6, 2026
7a64f65
Remove identity mock after #63 merge
Wenbobobo Nov 6, 2026
1d53ad0
Complete identity mock swap after #63
Wenbobobo Nov 6, 2026
57caabc
Wait for matching unsubscribe record
Wenbobobo Nov 6, 2026
5830975
Merge remote-tracking branch 'origin/hackathon26' into seam-55
Wenbobobo Nov 6, 2026
71ffaba
Merge origin/hackathon26 into w5.5-negotiate
Wenbobobo Nov 6, 2026
a9dc369
feat(host): hand each served stream the context of its connection
IvanAnishchuk Nov 6, 2026
d02d134
docs(mux): freeze adapter and test-value contracts
Mouzayan Nov 4, 2026
4c34303
feat(mux): add protocol constants
Mouzayan Nov 4, 2026
f4f93f7
docs(mux): define the private test-session protocol
Mouzayan Nov 5, 2026
ef20766
feat(mux): add private test framing
Mouzayan Nov 5, 2026
9eb3bf7
feat(mux): add the temporary core seam
Mouzayan Nov 5, 2026
55c3dfe
feat(mux): add pure test-session state
Mouzayan Nov 5, 2026
cda78fb
feat(mux): add the test session shell
Mouzayan Nov 5, 2026
61efa19
feat(mux): expose the test muxer
Mouzayan Nov 5, 2026
fa077a9
test(mux): synchronize reader terminal events
Mouzayan Nov 5, 2026
703557b
test(mux): cover the public session lifecycle
Mouzayan Nov 5, 2026
bc1bf95
test(mux): cover public reader-fault propagation
Mouzayan Nov 5, 2026
9bf06b3
test(mux): cover public malformed-frame handling
Mouzayan Nov 5, 2026
73678ba
test(mux): cover unknown inbound stream ids
Mouzayan Nov 5, 2026
377d431
test(mux): cover inbox-credit overflow
Mouzayan Nov 5, 2026
c3ed4ff
test(mux): cover the live accept backlog
Mouzayan Nov 5, 2026
430e5e7
test(mux): cover the public peer-reset lifecycle
Mouzayan Nov 5, 2026
031c403
test(mux): cover the public half-close lifecycle
Mouzayan Nov 5, 2026
306927d
test(mux): cover the public local-reset lifecycle
Mouzayan Nov 5, 2026
ea079ce
test(mux): parse test addresses with the real Multiaddr
leolara Nov 6, 2026
a34c80e
Fix four compile errors in gossipsub tests
Wenbobobo Nov 6, 2026
d1eb82e
docs(security): record the units done in the package plan
leolara Nov 6, 2026
8d6d7dd
test(yamux): wait for the data frame before teardown
Wenbobobo Nov 6, 2026
4e0461a
docs(protocols): drop the streams mock axiom from the frame-step note
leolara Nov 6, 2026
76e5136
chore(protocols): drop the dead Multiaddr mock
leolara Nov 6, 2026
2f424b3
refactor(negotiate): take the peer id from libp2p/identity
Wenbobobo Nov 6, 2026
43a34ef
refactor(protocols): take keys and peer ids from libp2p/identity
Wenbobobo Nov 6, 2026
dbd0b13
Merge branch 'w6.4-adapter' into w6.4-adapter-live
Wenbobobo Nov 7, 2026
14efcad
test(protocols): run the interop adapter suite
Wenbobobo Nov 7, 2026
adc45a0
Merge commit 'd9c0afc' into w6.4-full
Wenbobobo Nov 7, 2026
8f19552
Merge commit 'd1eb82e' into w6.4-full
Wenbobobo Nov 7, 2026
d241601
Merge commit 'ea079ce' into w6.4-full
Wenbobobo Nov 7, 2026
3b235ee
Merge commit '2f424b3' into w6.4-full
Wenbobobo Nov 7, 2026
da730ee
Merge commit 'a9dc369' into w6.4-full
Wenbobobo Nov 7, 2026
f9d4751
Merge commit '43a34ef' into w6.4-full
Wenbobobo Nov 7, 2026
90ab75e
fix(negotiate): read handshake bytes through secure connection
Wenbobobo Nov 7, 2026
6cf466a
fix(security): use the merged core seam
Wenbobobo Nov 7, 2026
4b9360d
fix(security): remove the core mock
Wenbobobo Nov 7, 2026
11179b0
fix(negotiate): use the merged core seam
Wenbobobo Nov 7, 2026
c49a2b3
fix(negotiate): remove the core mock
Wenbobobo Nov 7, 2026
6ef2bb9
fix(mux): use the merged core seam
Wenbobobo Nov 7, 2026
622b477
fix(mux): remove the core mocks
Wenbobobo Nov 7, 2026
e0f83ec
fix(host): use the merged core seam
Wenbobobo Nov 7, 2026
a8754bf
fix(host): remove the core mock
Wenbobobo Nov 7, 2026
549b85a
fix(protocols): use core handler context
Wenbobobo Nov 7, 2026
99e0d79
feat(negotiate): negotiate protocols on streams
Wenbobobo Nov 7, 2026
26e908d
fix(host): connect the negotiation checkpoint
Wenbobobo Nov 7, 2026
b85932d
fix(host): remove the negotiate mock
Wenbobobo Nov 7, 2026
714e95c
fix(protocols): use core identify handler types
Wenbobobo Nov 7, 2026
5919010
fix(protocols): store identify addresses in host
Wenbobobo Nov 7, 2026
dfb40a1
fix(protocols): remove dependency mocks
Wenbobobo Nov 7, 2026
c6867ce
fix(tests): name the core switch types
Wenbobobo Nov 7, 2026
4f8a714
fix(negotiate): correct upgrade documentation
Wenbobobo Nov 7, 2026
6cdf239
fix(negotiate): join secure upgrade tasks
Wenbobobo Nov 7, 2026
4ef2d7b
fix(tests): retain split handshake bytes
Wenbobobo Nov 7, 2026
f63f2a8
test(negotiate): cover admission refusal
Wenbobobo Nov 7, 2026
489717a
fix(core): adapt session join results
Wenbobobo Nov 7, 2026
ad58a2c
fix(tests): compare identify address bytes
Wenbobobo Nov 7, 2026
dba4dfc
feat(cli): wire gossipsub socket participant
Wenbobobo Nov 7, 2026
90d1228
fix(cli): preserve monotonic receipt timestamps
Wenbobobo Nov 7, 2026
6f25ea4
test(cli): cover monotonic timestamp formatting
Wenbobobo Nov 7, 2026
7c0f404
fix(cli): retain validation delay settings
Wenbobobo Nov 7, 2026
2860a5f
fix(cli): close owned resources on setup failures
Wenbobobo Nov 7, 2026
e72d591
fix(cli): resolve Shadow peer addresses
Wenbobobo Nov 7, 2026
3aca73c
fix(gossipsub): announce subscriptions after joins
Wenbobobo Nov 7, 2026
fb49070
chore(gossipsub): add gated RPC wire tracing
Wenbobobo Nov 7, 2026
9dd17ff
fix(gossipsub): advertise meshsub in identify
Wenbobobo Nov 7, 2026
407878c
Merge commit 'fd70eeb' into w6.4-final
Wenbobobo Nov 7, 2026
d1c1ab3
docs: correct the interop host wiring claims
leolara Nov 9, 2026
7ac636a
Merge remote-tracking branch 'origin/hackathon26' into w6.4-final
Wenbobobo Nov 9, 2026
b3c76b3
chore: drop dead imports, converge two host files with the tip
leolara Nov 9, 2026
b320e07
Merge remote-tracking branch 'origin/hackathon26' into w6.4-pr
leolara Nov 9, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
181 changes: 181 additions & 0 deletions Tests/Gossipsub/Cache.lean
Original file line number Diff line number Diff line change
@@ -0,0 +1,181 @@
import Tests.Support
import Tests.Gossipsub.Identity
import Libp2p.Protocols.Gossipsub.Cache

/-!
# Gossipsub suite: Cache

The checks of `Libp2p.Protocols.Gossipsub.Cache`. Each check is one step
of a fixed transcript: the inputs are literal times and ids, and the
expected result stands beside the call. The suite names the spec
boundaries: exactly `t + ttl`, exactly `until`, exactly the end of a
window, and exactly the capacity of the seen cache.

The windows of the message cache checks are the spec defaults: five
history windows and three gossip windows. The seen cache uses capacity
three and a TTL of one hundred milliseconds, so each boundary is a round
number.
-/

set_option autoImplicit false

namespace Tests.Gossipsub.Cache

open Libp2p.Protocols.Gossipsub
open Libp2p.Protocols.Gossipsub.Cache

/-- The window parameters of the transcript: the spec defaults of five
history windows and three gossip windows. -/
def window5 : WindowParams :=
{ historyLength := 5, historyGossip := 3, valid := by decide }

/-- The seen cache parameters of the transcript: three entries and a TTL
of one hundred milliseconds. -/
def seen3 : SeenParams :=
{ capacity := 3, ttl := 100, valid := by decide }

/-- A message id from one number. -/
def mid (n : Nat) : MessageId := { bytes := [n] }

/-- One topic of the transcript. -/
def topicA : TopicId := { name := "a" }

/-- A second topic of the transcript. -/
def topicB : TopicId := { name := "b" }

/-- A message with a one-byte payload. -/
def msg (t : TopicId) (n : Nat) : Message :=
{ «from» := none, data := some [n], seqno := none, topic := t, signature := none, key := none }

/-- A peer from one number. -/
def peer (n : Nat) : Peer := Identity.peer n

/-- A promise with explicit fields, for the expected lists. -/
def promiseOf (p : Peer) (i : MessageId) (d : Millis) : IwantPromise :=
{ peer := p, id := i, deadline := d }

/-- A backoff entry with explicit fields, for the expected lists. -/
def backoffOf (p : Peer) (t : TopicId) (u : Millis) : BackoffEntry :=
{ peer := p, topic := t, «until» := u }

/-- Run the checks of this module. -/
def run (r : Runner) : IO Unit := do
r.section "gossipsub Cache" "vendor/specs/pubsub"

-- Message cache: one message, then shifts.
let c0 : MessageCache := MessageCache.empty window5
let c1 : MessageCache := c0.put (mid 1) (msg topicA 1)
r.check "mcache put then get returns the message"
(decide (MessageCache.get c1 (mid 1) = some (msg topicA 1)))
r.check "mcache get returns none for an absent id"
(decide (MessageCache.get c1 (mid 2) = none))
r.check "mcache get returns the message after historyLength minus one shifts"
(decide (MessageCache.get (MessageCache.shiftN c1 4) (mid 1) = some (msg topicA 1)))
r.check "mcache get returns none after historyLength shifts"
(decide (MessageCache.get (MessageCache.shiftN c1 5) (mid 1) = none))

-- Message cache: four messages entered one heartbeat apart, so their
-- ages are zero to three.
let g1 : MessageCache := c0.put (mid 1) (msg topicA 1)
let g2 : MessageCache := (MessageCache.shift g1).put (mid 2) (msg topicA 2)
let g3 : MessageCache := (MessageCache.shift g2).put (mid 3) (msg topicA 3)
let g4 : MessageCache := (MessageCache.shift g3).put (mid 4) (msg topicA 4)
r.check "mcache gossipIds lists only ids newer than historyGossip windows"
(decide (MessageCache.gossipIds g4 topicA = [mid 4, mid 3, mid 2]))
let g5 : MessageCache := g4.put (mid 9) (msg topicB 9)
r.check "mcache gossipIds filters by topic"
(decide (MessageCache.gossipIds g5 topicA = [mid 4, mid 3, mid 2] ∧
MessageCache.gossipIds g5 topicB = [mid 9]))
r.check "mcache gossipIds is empty for a message old enough"
(decide (MessageCache.gossipIds (MessageCache.shiftN c1 3) topicA = []))

-- Window parameters: the validity predicate of the spec.
r.check "window params reject gossip zero" (decide (¬ (0 < 0 ∧ 0 ≤ 5)))
r.check "window params reject gossip above length" (decide (¬ (0 < 6 ∧ 6 ≤ 5)))
r.check "window params accept gossip within length" (decide (0 < 3 ∧ 3 ≤ 5))

-- Seen cache: one id at time ten, and the two time boundaries.
let s0 : SeenCache := SeenCache.empty seen3
r.check "seen contains after add at the same time"
(SeenCache.contains (s0.add (mid 1) 10) (mid 1) 10)
r.check "seen contains holds below t plus ttl"
(SeenCache.contains (s0.add (mid 1) 10) (mid 1) 109)
r.check "seen contains fails at exactly t plus ttl"
(!SeenCache.contains (s0.add (mid 1) 10) (mid 1) 110)

-- Seen cache: three adds fill the cache, one more evicts the oldest.
let f1 : SeenCache := s0.add (mid 1) 10
let f2 : SeenCache := f1.add (mid 2) 20
let f3 : SeenCache := f2.add (mid 3) 30
let f4 : SeenCache := f3.add (mid 4) 40
r.check "seen add at capacity evicts the oldest entry"
(!SeenCache.contains f4 (mid 1) 40)
r.check "seen add at capacity keeps the second oldest entry"
(SeenCache.contains f4 (mid 2) 40)
r.check "seen size stays at capacity after an add at capacity"
(decide (f4.entries.length = seen3.capacity))
let f5 : SeenCache := f3.add (mid 1) 35
r.check "seen add refreshes an existing id"
(decide (f5.entries = [
({ id := mid 1, «at» := 35 } : SeenEntry),
{ id := mid 3, «at» := 30 },
{ id := mid 2, «at» := 20 }]))
let f6 : SeenCache := f2.prune 115
r.check "seen prune drops only expired entries"
(decide (f6.entries = [{ id := mid 2, «at» := 20 }]))

-- Backoff table: a period from ten to sixty.
let b1 : BackoffTable := Backoff.add Backoff.empty (peer 1) topicA 50 10
r.check "backoff active below until"
(Backoff.active b1 (peer 1) topicA 59)
r.check "backoff inactive at exactly until"
(!Backoff.active b1 (peer 1) topicA 60)
r.check "backoff inactive for an unknown pair"
(!Backoff.active b1 (peer 2) topicA 30 && !Backoff.active b1 (peer 1) topicB 30)
let b2 : BackoffTable := Backoff.add b1 (peer 1) topicA 50 40
r.check "backoff a second add extends the period"
(Backoff.active b2 (peer 1) topicA 60 && Backoff.active b2 (peer 1) topicA 89 &&
!Backoff.active b2 (peer 1) topicA 90)
let b3 : BackoffTable :=
Backoff.add (Backoff.add Backoff.empty (peer 1) topicA 50 10) (peer 2) topicA 100 10
let b4 : BackoffTable := Backoff.clear b3 70
r.check "backoff clear keeps active entries"
(Backoff.active b4 (peer 2) topicA 70)
r.check "backoff clear drops expired entries"
(decide (b4 = [backoffOf (peer 2) topicA 110]))

-- Promises: one promise, then the same pair again.
let p0 : PromiseTable := PromiseTable.promise [] (peer 1) (mid 7) 300
r.check "promise records the pair and the deadline"
(decide (p0 = [promiseOf (peer 1) (mid 7) 300]))
let p1 : PromiseTable := PromiseTable.promise p0 (peer 1) (mid 7) 400
r.check "promise a second time for the same pair replaces the deadline"
(decide (p1 = [promiseOf (peer 1) (mid 7) 400]))
let p2 : PromiseTable :=
PromiseTable.promise
(PromiseTable.promise (PromiseTable.promise [] (peer 1) (mid 7) 300) (peer 2) (mid 7) 300)
(peer 1) (mid 8) 300
r.check "deliver removes every promise for the id"
(decide (PromiseTable.deliver p2 (mid 7) = [promiseOf (peer 1) (mid 8) 300]))
let p3 : PromiseTable :=
PromiseTable.promise (PromiseTable.promise [] (peer 1) (mid 7) 300) (peer 2) (mid 8) 400
r.check "deliver keeps promises of other ids"
(decide (PromiseTable.deliver p3 (mid 7) = [promiseOf (peer 2) (mid 8) 400]))

-- Broken promises at time five hundred: one expired promise of peer
-- one, and one promise that is not due.
let q0 : PromiseTable :=
PromiseTable.promise (PromiseTable.promise [] (peer 1) (mid 7) 400) (peer 1) (mid 8) 900
r.check "broken lists the peer with the expired count"
(decide (PromiseTable.broken q0 500 = [(peer 1, 1)]))
let q1 : PromiseTable :=
PromiseTable.promise (PromiseTable.promise [] (peer 1) (mid 7) 400) (peer 1) (mid 8) 450
r.check "broken counts two expired promises for one peer"
(decide (PromiseTable.broken q1 500 = [(peer 1, 2)]))
let q2 : PromiseTable := PromiseTable.promise [] (peer 1) (mid 7) 900
r.check "broken omits peers whose deadlines have not passed"
(decide (PromiseTable.broken q2 500 = []))
r.check "broken after deliver shows no count for the delivered id"
(decide (PromiseTable.broken (PromiseTable.deliver q1 (mid 7)) 500 = [(peer 1, 1)]))

end Tests.Gossipsub.Cache
Loading
Loading