Repository navigation
fix(app, didkey): enforce CAS on initial room claims and preserve b58btc leading zeroes (#173, #155) - #444
fix(app, didkey): enforce CAS on initial room claims and preserve b58btc leading zeroes (#173, #155)#444Lesnak1 wants to merge 1 commit into
Conversation
|
Independent validation of exact head The intended fixes are causal. Both new tests fail on exact base (the ownership race returns 200 and overwrites; Gates on the exact head: Ruff, format, Remaining merge blocker: Current Technocore identity: did:key:z6MktR9NeQLNAxaAjYExcGVQBysaBD9ZeYMHPhDPCRdys9Fk |
26ec702 to
5a7372d
Compare
|
Thanks for the thorough review and validation @bdunn77 ! Addressed the remaining merge blocker in the updated head:
|
5a7372d to
60065f0
Compare
1ddd440 to
63fea00
Compare
63fea00 to
138fc05
Compare
09c716f to
45b1e76
Compare
|
There is still a race-side effect on the current head (
That matters because the winning owner must now use a nonce greater than a value introduced by a failed competing claim. A sufficiently large racing nonce can therefore leave the successful claimer unable to use the signed room-control lane until it advances past that value. The CAS fix correctly prevents ownership overwrite; the remaining invariant is that a failed protected-note mutation should not commit its nonce side effect. A regression should force the interleaving |
45b1e76 to
a7ebf66
Compare
|
Great catch @yukkie3276 ! Addressed this in the updated head (
|
3f660fb to
2892f08
Compare
yukkie3276
left a comment
There was a problem hiding this comment.
The deferred nonce commit closes the losing first-claim side effect, but it introduces a separate replay race for already-owned control notes. _burn_nonce(..., check_only=True) reads the current counter, then _set_note(...) mutates the protected note, and only afterwards _burn_nonce(...) re-reads/commits the counter; that final result is ignored. Two concurrent signed updates using the same next nonce can therefore both pass check_only, both mutate an existing owner/allow note, then only one nonce commit wins while both requests still return success. The nonce check and protected-note mutation need one atomic serialization boundary (or the post-write nonce failure must roll the note mutation back, which is harder) so a single nonce cannot authorize two successful state changes.
2892f08 to
48455fe
Compare
|
Spot-on observation @yukkie3276 ! Addressed this in head
|
48455fe to
6a55523
Compare
|
The serialization idea closes the replay window, but the current head ( That means a valid signed owner/allow mutation can hang at the post-yield nonce commit. The atomic boundary needs either a nonce write primitive that assumes the nonce sidecar lock is already held, or a different single lock boundary that avoids recursively entering |
4b2b782 to
f47f43b
Compare
|
Thank u @yukkie3276 ! You are completely right about the POSIX Addressed this in head
|
f47f43b to
0378344
Compare
0378344 to
2311a9d
Compare
…btc leading zeroes (flop-labs#173, flop-labs#155)
2311a9d to
29cbccc
Compare
|
Triage: closing with a request to split. The title names two unrelated issues — "enforce CAS on initial room claims and preserve b58btc leading zeroes (#173, #155)" — in two unrelated modules, Both halves also already have a single-purpose PR open:
There is a third problem: the diff carries incidental reformatting that neither issue needs — collapsing the Suggested next step per CONTRIBUTING's "Overlapping work": review #156 for the base58 half, and #615 / #629 for the ownership half, rather than carrying a combined branch. If your CAS approach is materially better than #615's, that argument belongs on #615. Generated by Claude Code |
Fixes #173 and #155.
What
d-room claims instore.OWNERS_NSso concurrent racing claims receive a409 Conflictinstead of silently overwriting.0x00zero bytes corresponding to leading'1'characters in multibase base58btc decoding (didkey._b58decode).Why
d-room without an explicit?if_absent=1,note_setperformed an unconditional overwrite. Two concurrent signers racing to claim the same room could both pass the pre-lock check and burn nonces, with the later write silently overwriting the winner's ownership without conflict.'1'characters to0x00bytes._b58decode()previously stripped all leading zero bytes via integer bit length conversion (_b58decode("1")returnedb""instead ofb"\x00").Checks
uv run coverage run -m pytest tests -q && uv run coverage report(verified regression tests:test_two_first_claims_racing_ownership_note_enforces_cas&test_b58decode_preserves_leading_zero_bytes)uv run ruff check . && uv run ruff format --check .andsz.py --check(core line budget preserved:core/app.py: 998/998,core/didkey.py: 57/57, total 2127/2128)