Repository navigation
test(drive-abci): cover name price updates at the limits of the recorded price - #5966
QuantumExplorer wants to merge 1 commit into
Conversation
…ded price Adds four tests of a price update on a DPNS name, whose type records each price in the document history contract: at the largest price the record holds, after it, at zero, and above it. They pin today's results at protocol versions 13, 14 and the latest, so a later change to them shows up in a test. Co-Authored-By: Claude Fable 5.2 <[email protected]>
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 14 minutes. View limit details
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. |
|
✅ Final review complete — no blockers (commit 5dd953e) · triage: low |
|
Waiting for bot review — thepastaclaw not yet. Wait for the missing reviews, or a writer can post |
thepastaclaw
left a comment
There was a problem hiding this comment.
Final validation — Phase 1 + Phase 2
The change is a focused, deterministic test-only addition covering DPNS price-history boundaries across protocol versions, with no production or consensus implementation changes. Four minor test-quality improvements remain; no blocking defect was found, and the CI snapshot shows no failed code checks, although runner selection and review checks are still pending.
🟡 3 suggestion(s)
Approved: nothing here blocks the merge. The non-blocking findings are optional: fix them forward, in this PR or a follow-up, without waiting for another review round.
Review provenance
Source: reviewer 1: glm-5.3-flash (agent: phase1-reviewer, role: general); reviewer 2: glm-5.3-flash (agent: phase1-reviewer, role: rust-quality); reviewer 3: gpt-6.1-sol (agent: phase2-reviewer, role: general); reviewer 4: gpt-6.1-sol (agent: phase2-reviewer, role: architecture-layering); reviewer 5: gpt-6.1-sol (agent: phase2-reviewer, role: platform-versioning); reviewer 6: gpt-6.1-sol (agent: phase2-reviewer, role: rust-quality); final verifier: gpt-6.1-sol (agent: sol-verifier, role: final-verifier)
- Triage:
lowbygpt-6.1-sol(effort low) — This is a contained Rust test-only addition in one file with no production behavior, consensus, storage, or API changes, and its correctness is straightforward to verify from the test coverage. - Phase 1 reviewers:
glm-5.3-flash— general (completed, effort high); agentphase1-reviewer,glm-5.3-flash— rust-quality (completed, effort high); agentphase1-reviewer - Phase 1 model:
glm-5.3-flash— zai quota: 5h 99% left, weekly 98% left; passed overgemini-3.8-flash-high(antigravity quota lookup failed) - Fresh verifier:
gpt-6.1-sol— final-verifier; agentsol-verifier - Phase 2 reviewers:
gpt-6.1-sol— general (completed, effort medium); agentphase2-reviewer,gpt-6.1-sol— architecture-layering (completed, effort medium); agentphase2-reviewer,gpt-6.1-sol— platform-versioning (completed, effort medium); agentphase2-reviewer,gpt-6.1-sol— rust-quality (completed, effort medium); agentphase2-reviewer
🤖 Prompt for all review comments with AI agents
These findings are from an automated code review (PastaClaw). How to work through them:
- Verify each finding against the code; fix only what is real, as narrowly as the finding.
- If a finding is wrong, decline it on its thread in one or two sentences; the bot answers once and stops.
- To defer one, link a tracking issue on its thread (or reply asking the bot to file one).
- Suggestions don't block the merge, but most are worth fixing in this PR; judge each on its merits.
- Keep the PR's scope; don't grow it to satisfy hardening suggestions.
- Carried items were raised in an earlier round: read the thread first, and don't re-fix what you already fixed, declined or deferred there. Disputed and deferred items are already handled and are not listed.
In `packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/batch/tests/document/dpns.rs`:
- [SUGGESTION] packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/batch/tests/document/dpns.rs:3484-3493: Use the dedicated sum helper for listed_price_sum
`listed_price_sum` is documented and used as a sum accessor, but it calls the average helper and discards the count with `.1`. The module already provides `history_aggregate_price_sum` for this exact query, so using it avoids an unnecessary count aggregation and makes the assertion's intent explicit.
- [SUGGESTION] packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/batch/tests/document/dpns.rs:3433: Do not let saturating_sub hide an unexpected balance increase
The helper uses `saturating_sub` to calculate the charge. If a regression credited the seller instead of charging them, the result would also be zero and the refused-listing assertion would pass. A checked subtraction makes an unexpected balance increase fail immediately instead of masking it.
- [SUGGESTION] packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/batch/tests/document/dpns.rs:3571-3575: Assert the zero-price listing's check_tx result and aggregate effect
The zero-price case is described as both successfully recorded and as adding nothing to the history sum, but it currently asserts only block success and a positive charge. It also ignores the `check_tx` result returned by the helper. Asserting both values would pin the complete behavior claimed by the test and catch a future check_tx/execution divergence.
Out-of-scope follow-up suggestions (1)
These are valid observations, but they are outside this PR's scope and should be handled in separate issues or author/maintainer-requested PRs rather than blocking this review.
- Price-history sums can permanently reject later positive listings — Once the document-history
priceUpdateaggregate reachesi64::MAX, a later positive price update can passcheck_txbut fail during operation conversion as an internal error, without charging the seller or advancing the nonce. Because the history aggregate is retained, the contract remains unable to record later positive prices. The tests correctly document this existing behavior but do not introduce it.- Follow-up: Add a protocol-versioned state-validation guard or equivalent user-facing handling for document price updates that would overflow the history sum, and audit the token-history set-price path for the same condition.
| history_aggregate_price_average( | ||
| platform, | ||
| "priceUpdate", | ||
| vec![ | ||
| history_where_by_contract(dpns_contract.id()), | ||
| history_where_created_between(0, 9_999_999_999_999), | ||
| ], | ||
| platform_version, | ||
| ) | ||
| .1 |
There was a problem hiding this comment.
🟡 Suggestion: Use the dedicated sum helper for listed_price_sum
listed_price_sum is documented and used as a sum accessor, but it calls the average helper and discards the count with .1. The module already provides history_aggregate_price_sum for this exact query, so using it avoids an unnecessary count aggregation and makes the assertion's intent explicit.
| history_aggregate_price_average( | |
| platform, | |
| "priceUpdate", | |
| vec![ | |
| history_where_by_contract(dpns_contract.id()), | |
| history_where_created_between(0, 9_999_999_999_999), | |
| ], | |
| platform_version, | |
| ) | |
| .1 | |
| history_aggregate_price_sum( | |
| platform, | |
| "priceUpdate", | |
| vec![ | |
| history_where_by_contract(dpns_contract.id()), | |
| history_where_created_between(0, 9_999_999_999_999), | |
| ], | |
| platform_version, | |
| ) |
source: glm-5.3-flash (phase1-reviewer: general, rust-quality)
| ListingOutcome { | ||
| check_tx_valid, | ||
| result: processing_result.into_execution_results().remove(0), | ||
| charged: balance_before.saturating_sub(balance(platform)), |
There was a problem hiding this comment.
🟡 Suggestion: Do not let saturating_sub hide an unexpected balance increase
The helper uses saturating_sub to calculate the charge. If a regression credited the seller instead of charging them, the result would also be zero and the refused-listing assertion would pass. A checked subtraction makes an unexpected balance increase fail immediately instead of masking it.
| charged: balance_before.saturating_sub(balance(platform)), | |
| charged: balance_before | |
| .checked_sub(balance(platform)) | |
| .expect("the seller's balance must never grow from a price update"), |
source: glm-5.3-flash (phase1-reviewer: general, rust-quality)
| assert_matches!( | ||
| free.result, | ||
| StateTransitionExecutionResult::SuccessfulExecution { .. } | ||
| ); | ||
| assert!(free.charged > 0); |
There was a problem hiding this comment.
🟡 Suggestion: Assert the zero-price listing's check_tx result and aggregate effect
The zero-price case is described as both successfully recorded and as adding nothing to the history sum, but it currently asserts only block success and a positive charge. It also ignores the check_tx result returned by the helper. Asserting both values would pin the complete behavior claimed by the test and catch a future check_tx/execution divergence.
| assert_matches!( | |
| free.result, | |
| StateTransitionExecutionResult::SuccessfulExecution { .. } | |
| ); | |
| assert!(free.charged > 0); | |
| assert_eq!(free.check_tx_valid, Ok(true)); | |
| assert_matches!( | |
| free.result, | |
| StateTransitionExecutionResult::SuccessfulExecution { .. } | |
| ); | |
| assert!(free.charged > 0); | |
| assert_eq!( | |
| listed_price_sum(&platform, &dpns_contract, platform_version), | |
| i64::MAX, | |
| "the zero listing added nothing to the recorded sum" | |
| ); |
source: glm-5.3-flash (phase1-reviewer: general, rust-quality)
|
Bots are done — your move: post |
|
Superseded by #5987, which carries these tests and extends them. |
Basic explanation
What this does: Adds four tests around setting a sale price on a DPNS name. The
domaintype records every price in the document history system contract, and these tests cover a price update at the largest price that record holds, the next update after it, an update at zero, and a price above that largest value.Value: The results of these cases were not covered by any test. They are now pinned at protocol versions 13, 14 and the latest, so any later change to how a price update is validated or recorded shows up as a test change instead of going unnoticed.
Risks: Low. Test code only, in one file; no consensus, storage or API change. The tests state today's results, so a later change to this behaviour has to update them.
Issue being fixed or feature implemented
Price updates on a document type that keeps pricing history had no test at the ends of the price range.
What was done?
dpns_username_transfer_testsinpackages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/batch/tests/document/dpns.rsthat sign a price update for an identity's name and run it throughcheck_txand a block, returning whatcheck_txsaid, the execution result and what the seller was charged.should_end_a_listing_as_an_internal_error_once_the_listed_price_sum_is_fullfor the latest protocol version, with_protocol_version_14and_protocol_version_13twins.should_end_a_listing_above_the_signed_range_as_an_internal_error.How Has This Been Tested?
cargo test -p drive-abci --lib should_end_a_listing4 passed.
cargo fmt --allleaves the tree unchanged.Breaking Changes
None.
Checklist:
structure.rs, regeneratedgrovedb-structure.json, and checked the structure viewer link posted on this pull requestFor repository code-owners and collaborators only
🤖 Generated with Claude Code
PR Hygiene ·
5dd953e/self-reviewedWhen every merge requirement is met, the
PR Hygienecheck passes. Reviewer limits do not block merging; other required GitHub checks and protections still apply.