Repository navigation
test(username): pin the DPNS contestability rule; extract the UI hints - #1563
HashEngineering wants to merge 1 commit into
Conversation
|
Warning Review limit reachedNext included review available in 33 minutes. View limit detailsLimit details: You’ve used all 2 included reviews currently available. You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Review configuration: ⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (3)
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (3)
Included review availability: Your plan provides up to 2 included reviews per hour; 1 remains after this review. 📝 WalkthroughWalkthroughThe change centralizes DPNS username contestability checks, updates request validation to use the shared helpers, and adds boundary, field-log, and randomized property tests. ChangesUsername contestability
Priority: ⬇️ Low Estimated code review effort: 2 (Simple) | ~15 minutes Change: Other Merge Risk: ⚪ Minimal · up to The shared contestability hints and request-screen wiring are covered by boundary and equivalence tests, with no current merge-blocking risk identified. 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches 💡 1📝 Generate docstrings 💡
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
MO-973 read `checkUsername('asd10augsh'): contested=false` against
`SdkShieldedUsernameCreation ... 0.25 denomination, contested=true` as two
contestability implementations disagreeing, with the creation path
overcharging. Neither half of that holds:
- `checkUsername`'s `contested` is not contestability. It is
`contenders.map.isNotEmpty()` — a network query for whether the name
already has vote contenders. The same log has contested=false for
'asdsd', 'asda', 'asds', 'asdsg', all short all-letter names that ARE
contestable, and contested=true only for 'asd', the one name with real
contenders (blocked=true, from a live lockVoteTally).
- The DPNS rule is not "short AND no digits". The contract's
contestedIndex regex is ^[a-zA-Z01-]{3,19}$: `0` and `1` are homoglyphs
of `o` and `l`, so they stay in the contest. 'asd10augsh' is
contestable, and 0.25 DASH was the correct denomination.
There is also only ONE predicate. All 21 call sites — the balance gate,
both SDK creation paths, TopUpRepository, CreateIdentityService,
PlatformSyncService, IdentityRepository, RestoreIdentityWorker — call
dashj `Names.isUsernameContestable`. The MO-972 gate log confirms it
end to end: every name it required 0.25 for is [a-z0-1]-only, and
'asd10augda6' produced no gate failure at all, i.e. the `6` dropped the
requirement to 0.03.
No funding bug, so no caller changes. What was genuinely duplicated is
the request screen's two "avoid the contest" checkmarks, which
hand-encoded the rule's complement privately in the ViewModel
(`[2-9]` and a hardcoded 20). Those are label-only — no denomination
derives from them — but they could drift away from what the wallet
spends. Extracted to pure internal functions in UsernameContestability.kt
and pinned in UsernameContestabilityTest against
`Names.isUsernameContestable` itself, so a dashj bump that moves the rule
breaks a test instead of quietly repricing a creation.
Tests pin: short all-letters contestable; a 2-9 digit clears the contest;
0/1 do not; the 3..19 length window and the 20 threshold one past it; the
field-log names; and the hints as an exact decomposition of the rule over
~8k generated names. Verified with teeth — encoding the report's assumed
"any digit" rule fails the equivalence test.
Co-Authored-By: Claude Opus 5 <[email protected]>
e301691 to
6896686
Compare
|
@coderabbitai full review |
|
|
✅ Final review complete — no blockers (commit 6896686) · triage: low · Phase 2 only (queue backlog) |
thepastaclaw
left a comment
There was a problem hiding this comment.
Final validation — Phase 2 only (queue backlog)
The changes correctly extract the request-screen contestability hints without altering funding or username-creation decisions. The new tests directly pin the UI hint decomposition against dashj’s contestability predicate, including the DPNS treatment of digits 0/1 and the 3–19 character contested-name range; no in-scope defects were found.
Review provenance
Source: reviewer 1: gpt-6-astra (agent: phase2-reviewer, role: general); final verifier: gpt-6-astra (agent: astra-verifier, role: final-verifier)
- Triage:
lowbygpt-6-astra(effort low) — The diff is a small, well-contained UI-hint extraction with comprehensive tests and no changes to username contestability, funding, routing, or other critical wallet surfaces. - Phase 1 reviewers: not run (skipped for throughput: 18 PRs queued, above the 10 limit)
- Fresh verifier:
gpt-6-astra— final-verifier; agentastra-verifier - Phase 2 reviewers:
gpt-6-astra— general (completed, effort medium); agentphase2-reviewer
Summary
Investigation of the reported username contestability disagreement (MO-973 / MO-972). The reported bug is not real — no wrong funding denomination, no duplicated predicate. This PR adds the tests that would have answered the question in seconds, and removes the one piece of genuine duplication that could have grown into the reported bug.
The report's two premises are both wrong
1.
checkUsername'scontestedis not contestability. It iscontenders.map.isNotEmpty()— a network query for whether the name already has vote contenders. The MO-973 log proves it:asdsdandasdaare short all-letter names — unambiguously contestable — yet the checker reports false. It reports true only forasd, the one name with real contenders (blocked=true, from a livelockVoteTally). A rule-based predicate could not produce that pattern.2. The DPNS rule is not "short AND no digits." dashj's
Names.isUsernameContestableis the DPNS contract'scontestedIndexregex:0and1are in the alphabet because they are homoglyphs ofoandl— "he11o" vs "hello" — so DPNS keeps them in the contest.asd10augsh's only digits are1and0, so it is contestable and 0.25 DASH was the correct denomination. Digits2-9have no letter lookalike; one of those anywhere clears the contest.There is also only one implementation
All 21 call sites — the balance gate,
SdkShieldedUsernameCreation,SdkTransparentUsernameCreation,TopUpRepository,CreateIdentityService,PlatformSyncService,IdentityRepository,RestoreIdentityWorker— call the same dashj function.The MO-972 gate log confirms the rule working end to end: every name the gate demanded 0.25 for is
[a-z0-1]-only, andasd10augda6produced no gate-failure line at all — the6dropped the requirement to 0.03 against a 0.24999474 balance. That is a positive observation, not just an absence of evidence.So: no wrong denomination, no wrong post-creation routing, and no caller changes in this PR.
What actually changed
The one genuinely duplicated thing was the request screen's two "avoid the contest" checkmarks, which hand-encoded the rule's complement privately in the ViewModel (
Regex("[2-9]")and a hardcoded20).Those are label-only —
usernameNonContestedChars/usernameNonContestedLengthfeed only theRequestUsernameFragmentcheckmark rows, and no denomination derives from them — but nothing stopped them drifting from what the wallet spends.UsernameContestability.kt(new): the two hints as pureinternalfunctions, with the homoglyph rule documented where the next reader will hit it, and an explicit "do not re-implement the rule" note.RequestUserNameViewModel.kt: calls those instead of the private copies. Behaviour-identical.UsernameContestabilityTest.kt(new): pins the hints as an exact decomposition ofNames.isUsernameContestableitself, so a dashj bump that moves the rule breaks a test instead of quietly repricing a creation.Tests
Seven tests pin: a short all-letters name is contestable; a
2-9digit clears the contest;0/1do not; the 3..19 length window and the20threshold one past it; the actual field-log names from both reports; and the hint/rule equivalence over ~8k generated names.One requested assertion was itself the bug's premise — "a name containing digits is not contestable" is false — so the tests pin the real rule instead.
Verified with teeth: substituting the report's assumed
[0-9]rule fails the equivalence test. Restored, then:./gradlew ktlintFormat— no changes./gradlew :wallet:compile_testNet3DebugKotlin— clean./gradlew :wallet:test_testNet3DebugUnitTest— 1914 tests, 0 failuresScope
Separate from the two underlying MO-973 / MO-972 failures (the FFI "Invalid identity data" DPNS rejection and the HONOR auth-gated Keystore refusal), which are handled elsewhere.
🤖 Generated with Claude Code
Summary by CodeRabbit