Commit 266272c
authored
feat(frost/roast): RFC-21 Phase 2 -- receiver overflow tracking (no-op default) (#3966)
## Summary
RFC-21 Phase 2: introduces the **`EvidenceRecorder`** interface and a
bounded reference implementation in `pkg/frost/roast/attempt`, then
plumbs it through the three FROST/tbtc-signer receive loops so the
previously silent `select { default }` drops become bounded
transition-evidence recording sites.
**No protocol behaviour change.** All three call sites pass
`attempt.NoOpRecorder()` as the recorder, so overflow-path
observability is identical to before. A coordinator-aware caller in
a later RFC-21 phase will inject a real recorder.
## What lands
### New package surface (`pkg/frost/roast/attempt`)
| Surface | Role |
|---|---|
| `EvidenceRecorder` interface | `RecordOverflow(sender)` + `Snapshot()
Evidence`. Phase 2 covers overflow only; later phases extend with reject
/ conflict / silence. |
| `Evidence` snapshot | `Overflows map[group.MemberIndex]uint`. Empty
map when no overflow. |
| `NewBoundedRecorder()` | Thread-safe recorder with default per-sender
quota of 8 (matches `categoryQuota.Overflow` in RFC-21 Layer A). |
| `NewBoundedRecorderWithQuota(q)` | Test seam for non-default quotas. |
| `NoOpRecorder()` | Discards events; returns an empty snapshot. The
Phase 2 default at every call site. |
### New signing-package helper
`pkg/frost/signing/evidence_overflow.go` adds `enqueueOrRecordOverflow[T
senderIndexedMessage](payload, target, recorder) bool`. This is the
shared select-or-record body that replaces the inline `select { default
}` drops. Pulling it out lets the recorder integration be unit-tested in
isolation without spinning up a network channel.
### Plumbing
- `collectNativeFROSTRoundOneMessages`
- `collectNativeFROSTRoundTwoMessages`
- `collectBuildTaggedTBTCSignerRoundContributionMessages`
Each now accepts an `attempt.EvidenceRecorder` parameter and calls
`enqueueOrRecordOverflow` in place of the inline select. All three
callers pass `attempt.NoOpRecorder()`.
## Why the helper refactor
The original inline `select { default }` drops cannot be tested without
a real channel / network. Extracting the body into
`enqueueOrRecordOverflow[T]` makes the integration testable directly,
which is what gives us confidence that overflow drops actually reach the
recorder.
## Test coverage
### Recorder unit tests (7) under
`pkg/frost/roast/attempt/evidence_recorder_test.go`
- `TestNoOpRecorder_IsObservablyInert`
- `TestBoundedRecorder_CountsOverflowsBySender`
- `TestBoundedRecorder_SaturatesAtQuota`
- `TestBoundedRecorder_DefaultQuotaIs8` (asserts the constant matches
the RFC literal)
- `TestBoundedRecorder_SnapshotIsDeepCopy`
- `TestBoundedRecorder_ConcurrentRecordersAreRaceSafe` (8 producers × 16
senders × 200 records)
- `TestNoOpRecorder_DistinctInstancesShareSemantics`
### Helper unit tests (8) under
`pkg/frost/signing/evidence_overflow_test.go`
- `TestEnqueueOrRecordOverflow_EnqueuesWhenChannelHasRoom`
- `TestEnqueueOrRecordOverflow_RecordsOverflowWhenChannelIsFull`
- `TestEnqueueOrRecordOverflow_NoOpRecorderHasNoObservableEffect`
- `TestEnqueueOrRecordOverflow_WorksForRoundTwoMessages`
- `TestEnqueueOrRecordOverflow_WorksForTBTCSignerContributionMessages`
- `TestEnqueueOrRecordOverflow_RepeatedOverflowsSaturateAtQuota`
- `TestEnqueueOrRecordOverflow_ConcurrentCallersAreRaceSafe`
### Verification
| Command | Result |
|---|---|
| `go build ./...` | clean |
| `go build -tags 'frost_native frost_tbtc_signer' ./pkg/frost/...` |
clean |
| `go test -tags 'frost_native frost_tbtc_signer' ./pkg/frost/...` |
pass (5 packages) |
| `go test -race -run
TestEnqueueOrRecordOverflow_ConcurrentCallersAreRaceSafe` | pass |
| `staticcheck -checks '-SA1019' ./pkg/frost/...` | silent |
| `pkg/tbtc` regression subset | pass (91s) |
## Test plan
- [ ] CI green: build/test/lint/scan/vet.
- [ ] Reviewer confirms the NoOp-default approach is acceptable for
Phase 2 (no behaviour change is the explicit goal).
- [ ] Reviewer confirms the bounded recorder's default quota of 8
matches the RFC-21 specification.6 files changed
Lines changed: 472 additions & 12 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
0 commit comments