fix(frost): a broadcast that queued nothing records nothing
`broadcast` now says whether it queued anything, and `publishOwn` records the local copy only when it did. The copy is what stops `advance` from publishing that message again, so writing one for a message that never went out is a message the group waits on forever -- the exact opposite of the trade the queue-then-record order exists to make. The comment on `publishOwn` had that trade written down in one direction only. Reachable only through the id-collision guard added with the resend, which refuses after four tries rather than overwriting a sent row. Four consecutive seconds of the same message is not something a person with a button can do, but "unreachable" and "safe when reached" are different claims. Also brings the docs up to what was built: the resend note is in the index, the skipped-keys note points at it as the recovery for the failure it describes -- a new message is encrypted at a generation the receiver has not passed, which is the whole mechanism -- and the plan records the two things landing it turned up, plus `ask_again` being reused from the catalogue rather than duplicated. 1279 tests, no failures. m3Audit: all budgets met. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
1 parent
e0f20b2b63
commit
2edd05f3ca
4 files changed
+61
-6
No files matched your search
@@ -2312,6 +2312,10 @@ object FrostSigningManager {
|
||||
* has no local copy of. A crash between the two therefore costs a duplicate
|
||||
* broadcast — which every receiver folds away — rather than a message the
|
||||
* group waits on forever.
|
||||
*
|
||||
* Which cuts both ways, so a [broadcast] that queued nothing records
|
||||
* nothing: the local copy is the thing that stops the next pass from trying
|
||||
* again.
|
||||
*/
|
||||
private suspend fun publishOwn(
|
||||
database: CurareDatabase,
|
||||
@@ -2320,7 +2324,11 @@ object FrostSigningManager {
|
||||
kind: Kind,
|
||||
content: String
|
||||
) {
|
||||
broadcast(database, localChatRoom, session, kind, content)
|
||||
// Nothing is recorded if nothing was queued. The local copy is what stops
|
||||
// [advance] from publishing this again, so writing one for a message that
|
||||
// did not go out would be a message the group waits on forever -- the
|
||||
// opposite of the trade this order is for.
|
||||
if (!broadcast(database, localChatRoom, session, kind, content)) return
|
||||
|
||||
val known = ownMessage(database, session, kind) != null
|
||||
|
||||
@@ -2369,7 +2377,7 @@ object FrostSigningManager {
|
||||
signerIds: List<Int>? = null,
|
||||
silentMembers: List<HexKey>? = null,
|
||||
recipients: Set<HexKey>? = null
|
||||
) {
|
||||
): Boolean {
|
||||
val sessionTags = FrostSigningEvents.assembleTags(
|
||||
sessionId = session.id,
|
||||
dkgSessionId = if (includeKey) session.dkgSessionId else null,
|
||||
@@ -2432,7 +2440,7 @@ object FrostSigningManager {
|
||||
"Session ${session.id}: kind $kind already queued at every second tried; " +
|
||||
"not publishing it again"
|
||||
)
|
||||
return
|
||||
return false
|
||||
}
|
||||
|
||||
if (isMarmotRoom) {
|
||||
@@ -2460,6 +2468,8 @@ object FrostSigningManager {
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
/** Whether this id is already an outbound row on the room's transport. */
|
||||
|
||||
@@ -10,6 +10,7 @@ silent, or a decision that looked arbitrary and was not.
|
||||
| [shared-key-derivation.md](./shared-key-derivation.md) | deriving further keys from the group's threshold key with FROST tweaks — why not BIP32, why no chain code, and the one rule that must not be broken |
|
||||
| [subgroups.md](./subgroups.md) | a group making another group — the four ceremonies, what the parent's signature actually covers, and why the child's key is fresh rather than derived |
|
||||
| [frost-batch-signing.md](./frost-batch-signing.md) | signing several events in one ceremony — why one nonce can never cover two messages, and the phased schema, wire and UI work that follows from it |
|
||||
| [frost-session-resend.md](./frost-session-resend.md) | asking the members who never got a signing proposal to look again — why a proposer can repeat only what it wrote, why a member's availability signal needs no repeating, and the one half that has to come from the silent member's own device |
|
||||
| [marmot-membership.md](./marmot-membership.md) | how members join an MLS group, and the epoch race that makes a missing member look like a successful invite |
|
||||
| [member-chronicle.md](./member-chronicle.md) | handing a member added after the work was done the group's signed record — why the events are not on the wire at all, and why the room's id is enough to verify them |
|
||||
| [marmot-direct-messages.md](./marmot-direct-messages.md) | a one-to-one message inside a group as a stock NIP-59 gift wrap — what its MIP-03 carve-out costs, why the sender cannot read their own, and the one query that would broadcast it |
|
||||
@@ -27,6 +28,8 @@ silent, or a decision that looked arbitrary and was not.
|
||||
Start with the ceremony if you are new to this area; the Marmot notes all assume it.
|
||||
Read the skipped-keys note before debugging any "the other device never got it"
|
||||
report — it is silent, and it looks like every other kind of delivery failure. The
|
||||
resend note is the recovery for it on a signing session, and says which delivery
|
||||
failures a resend repairs and which heal on their own. The
|
||||
sync note stands alone, and the dead-code inventory reads as a follow-up to it. The
|
||||
batch-signing note is a phased plan that has been built: read it after the
|
||||
derivation note, whose one rule is the same one it is built around. The member
|
||||
|
||||
@@ -316,6 +316,10 @@ bounds how often that can happen.
|
||||
|
||||
## Phase 4 — schema 24 → 25: `resentAt`
|
||||
|
||||
*Landed with Phase 2 rather than after it: `resend` needs the column for its
|
||||
cooldown, and writing it twice to keep the phases apart would have been
|
||||
ceremony.*
|
||||
|
||||
A nullable `Instant?` on `FrostSigningSession`, written by `resend`:
|
||||
|
||||
```kotlin
|
||||
@@ -438,8 +442,13 @@ if (state.canResend) {
|
||||
Per `CLAUDE.md`, and each of these is enforced by `./gradlew :composeApp:m3Audit`:
|
||||
|
||||
- strings in `composeApp/src/commonMain/composeResources/values/strings.xml`, in
|
||||
**sentence case**: `ask_again`, `these_members_have_not_answered`,
|
||||
`asked_again`, `asked_again_recently`. Counts interpolate as `%1$d`.
|
||||
**sentence case**: `asked_again`, `one_member_has_not_answered`,
|
||||
`members_have_not_answered`, `asked_again_recently`,
|
||||
`everyone_has_answered_this_session`. The count interpolates as `%1$s`, which
|
||||
is what the catalogue's other counted strings use. `ask_again` was already
|
||||
there for re-querying a list's relays and means exactly this, so it is reused
|
||||
rather than duplicated — two keys with one label is how a translator comes to
|
||||
pick two different words for one idea.
|
||||
- spacing from `MaterialTheme.spacing`; no `.dp` literal in a spacing position.
|
||||
- the icon is beside its label, so `contentDescription = Decorative` — decided, not
|
||||
`null`.
|
||||
@@ -523,6 +532,25 @@ a resent proposal with no silent tag is a resend whose second half silently does
|
||||
nothing. Phases 4 through 7 can land after, and Phase 8's tests should land with the
|
||||
phase they test rather than at the end.
|
||||
|
||||
### What landing it turned up
|
||||
|
||||
Two things worth recording, both of them in `broadcast` and neither of them about
|
||||
resend as such.
|
||||
|
||||
**The id collision was real, and the guard needed a second half.** `broadcast`
|
||||
now steps past a taken id rather than upserting over it, and returns whether it
|
||||
queued anything. That return is load-bearing: `publishOwn` writes the local copy
|
||||
that stops [advance] from publishing a message again, so a `broadcast` that
|
||||
queued nothing must record nothing, or the group waits forever on a message that
|
||||
never went out. The comment on `publishOwn` had the trade written down in one
|
||||
direction only.
|
||||
|
||||
**Narrowing is a `recipientTags` change, not a `broadcast` branch.** On NIP-17 a
|
||||
resend names the quiet members and the signers; on Marmot the parameter is
|
||||
ignored, because a group event is encrypted to the group and names nobody. One
|
||||
optional argument covers both, which is the shape `broadcast` already had for
|
||||
the transports.
|
||||
|
||||
## What this does not do
|
||||
|
||||
- **It does not retry automatically.** See the appendix.
|
||||
|
||||
@@ -85,7 +85,14 @@ back afterwards. So the sequence is
|
||||
4. the exception is swallowed, the event yields no `ApplicationMessage`
|
||||
|
||||
Step 3 is terminal. The key is derived from a ratchet that has moved past it and
|
||||
cannot be recovered, and nothing asks the sender to resend.
|
||||
cannot be recovered.
|
||||
|
||||
Nothing *asked* the sender to resend, either, which is a second gap and a
|
||||
narrower one. A FROST signing session now has a resend: the proposer repeats what
|
||||
it wrote, and the repeat names the members it has heard nothing from so their own
|
||||
devices repeat what they wrote. See
|
||||
[frost-session-resend.md](./frost-session-resend.md). It is a recovery driven by
|
||||
somebody noticing, not a fix — the fix is below, and it is in quartz.
|
||||
|
||||
Verified against the published artifact rather than a checkout:
|
||||
`quartz-1.14.0-sources.jar`, `commonMain/com/vitorpamplona/quartz/marmot/mls/schedule/SecretTree.kt`.
|
||||
@@ -195,6 +202,13 @@ It is not the fix, and it is worth being precise about what it leaves broken:
|
||||
- **Nothing helps a long reorder.** A message the relay holds back until after a
|
||||
restart or an outbound send is gone.
|
||||
|
||||
A message lost this way is gone for good, but it is not necessarily
|
||||
unrecoverable: a *new* message carrying the same payload is encrypted at a
|
||||
generation the receiver has not passed, so it decrypts normally. That is the
|
||||
whole mechanism behind
|
||||
[frost-session-resend.md](./frost-session-resend.md), and the same move would
|
||||
work for any other flow in the table above that someone can be asked to repeat.
|
||||
|
||||
The staleness check is what keeps the cache from being *worse* than no cache: a
|
||||
group that has been overtaken by another writer is never carried on with, so the
|
||||
fallback is always the old behaviour rather than a diverged ratchet.
|
||||
Reference in new issue
Block a user