Repository navigation
feat(documents): agree to document action fees before broadcasting - #1122
Conversation
Pin dash-sdk, rs-sdk-trusted-context-provider, platform-wallet and platform-wallet-storage to dashpay/platform v5.1-dev 063589bf (5.0.0-rc.8). The lockfile moves only the Platform packages. The upstream V019 wallet-storage migration adds a nullable asset-lock operation id; V001-V018 are unchanged. The compatibility bridge gets the 033ecae destination snapshot it compares against, and the pin guard records the new revision with an unchanged migration fingerprint. BREAKING CHANGE: the wallet storage upgrade to V019 is forward only. An older build cannot open upgraded storage; going back needs a copy of the data directory taken before the upgrade. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_012ujJpB9DBhvtbjhYB3aG9Q
The new rust-dashcore wraps secp256k1 keys in EcdsaSecretKey and EcdsaPublicKey, returns secret bytes as Zeroizing, and drops the Secp256k1 context argument. Signers, single-key wallets, DashPay derivation, address and QR handling, migrations and their tests follow the new types. Signing stays on the non-grinding dpp::secp256k1 path, and a parity test pins the BLS signature bytes the previous SDK made. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_012ujJpB9DBhvtbjhYB3aG9Q
Handle the dpp and SDK types the new pin adds, keeping today's behaviour: - Document replace keeps moderated_at and moderated_by; new documents start without them. - The document editor refuses typed-array fields instead of dropping their contents, and keeps referenced key ids as numbers. - Shielded token events show read-only in group actions, and the shielded pool token settings are refused before anything is signed. - Contested document creation states the protocol's base contest fund, so the SDK never auto-quotes a larger one. - Masternode vote reads use ResourceVoteWithCount, the SDK's new vote type; the vote count is not used yet. - New query fields, wallet events, wallet error variants and asset-lock funding modes are handled where the SDK now requires them. - Entropy-only document ids are documented as placeholders from protocol 14, and deferred upstream features link to their issues. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_012ujJpB9DBhvtbjhYB3aG9Q
The SDK was pinned to the protocol 13 table, so it could not build any protocol 14 transition or follow the versioned identity lookup. It now starts at upstream's per-network minimum and ratchets to what proven responses report. - System contracts are cached per protocol version and served through accessors. The context provider serves them at the version the proof verifier asks for and fails rather than serve another version's. - A proved epoch sets the fee multiplier and raises the protocol version. An older epoch than the adopted one is ignored. - Rebuilding the connection resets the protocol version, fee multiplier and adopted epoch under one lock before the new SDK is published, and drops reads begun on the old connection. - Capabilities read the network's version through a helper that stays closed for a version this build does not define. - Contest timing reads the live version; retired vote schedules keep the protocol 13 notice window they were created under. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_012ujJpB9DBhvtbjhYB3aG9Q
Compare the protocol 13 client tables with a recorded snapshot, so an upstream change to them is reviewed, and check that keys and documents DET builds on a protocol 13 network use encodings protocol 13 decodes. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_012ujJpB9DBhvtbjhYB3aG9Q
Map the refusals the new protocol adds to flows DET already offers to dedicated TaskError variants: a full username contest, a vote choice the contest does not allow, a name someone else asked for first, a token that cannot be moved, a changed immutable document field, a reference to a document type that cannot be deleted, and a moderators' fee on a contract without moderation. Names supplied by the node stay in the typed source only, never in the message. Token operations that fail inside the wallet runtime keep their SDK cause, so they are classified like any SDK error; an unclassified one names the operation that did not complete. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_012ujJpB9DBhvtbjhYB3aG9Q
Add a dated design note for the pin, the protocol version sources, the connection state rules and the protocol 13 guards, and point AGENTS.md at From<SdkError> for TaskError as the SDK error reference. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_012ujJpB9DBhvtbjhYB3aG9Q
Automatic key choice keeps only keys that are live (not disabled, not expired), held on this device, in scope for the action's contract or document type, and at a security level the action accepts. Among those it prefers a key without limits, and a document type takes a stronger key than the one it requires when that is all the identity holds. Keys are judged as the identity holds them now: a key whose limits were raised on the network is still the same key, so its stored private half stays matched to it, while a key that gains or loses a limit is not. An explicitly chosen DPNS key may have expired; the chooser warns and Platform decides by network time. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_012ujJpB9DBhvtbjhYB3aG9Q
Map the refusals Platform gives for a signing key that expired, used up its spending limit, cannot pay for the action, or is bound to another contract or to batch actions only, to dedicated TaskError variants with a message that says what to do. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_012ujJpB9DBhvtbjhYB3aG9Q
Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_012ujJpB9DBhvtbjhYB3aG9Q
…t that holds it Every screen and backend task that picks a signing key now asks for the action's scope: the contract or document type for document and token actions, none for identity and contract transitions. DashPay documents use the levels each document type accepts. The manual key chooser leaves out keys bound to another contract or document type, keeps expired and limited keys with a warning, and judges the key the identity holds now. A document action with no usable key says why the form stops. The wallet to unlock, and the owner of an identity stored without a wallet link, follow the key that is actually used. Lookups that only point the user at a key, such as Check Owner Key, do not require the private half on this device. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_012ujJpB9DBhvtbjhYB3aG9Q
…it refusals Protocol version 14 refusals that flows already in DET can hit get dedicated, actionable messages, each keeping the SDK error as its source: - an identity banned or suspended (until when) on a moderated contract; - a gas sponsor short of credits, a gas payer the document type does not offer, and mixed gas payers in one batch; - pre-programmed token distributions of one time over the limit. An overflowing shielded note total is logged at warn: it means corrupt or hostile sync data, not routine noise. Tests cover contracts saved at protocol 12 loading unchanged at 13 and 14, and contracts saved at 14 decoding at 13 and in full again at 14. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_012ujJpB9DBhvtbjhYB3aG9Q
…efusals from the Platform bump Merges 74695e7 from chore/bump-platform-063589bf. The conflict in src/backend_task/error.rs keeps both sides: the signing key refusals and the moderation and gas sponsorship refusals each keep their own section, match arms and test cases. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_012ujJpB9DBhvtbjhYB3aG9Q
On protocol 14 a document type can charge an action fee. A fee quote holds the declared owner and moderator parts at the fee multiplier the user saw and the most it can become; its agreement tolerates a 20% multiplier rise for a multiplier-priced fee. The backend never agrees on the user's behalf: an action whose agreement is missing or names another fee is refused before signing. A refusal for a risen multiplier refreshes the multiplier from a proved epoch, so trying again quotes the current fee; if that refresh fails the user is told the fee could not be updated. A protocol 13 guard checks that a fee agreement is refused locally there. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_012ujJpB9DBhvtbjhYB3aG9Q
Map a missing or mismatched fee agreement, a changed contract fee and a multiplier risen past the tolerance to dedicated TaskError variants, plus one for a multiplier that could not be refreshed. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_012ujJpB9DBhvtbjhYB3aG9Q
… action The estimated-fee panel shows the contract fee split between owner and moderators. Sending asks for confirmation naming the fee, the ceiling and the tolerance (or that the fee is fixed); confirming sends the action built when the dialog opened. An optional token cost can be skipped, the gas then being paid in credits. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_012ujJpB9DBhvtbjhYB3aG9Q
Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_012ujJpB9DBhvtbjhYB3aG9Q
|
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 21 seconds. 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 59bc20b) · triage: critical · Phase 2 only (no Phase 1 for this repository) |
A lookup at another version, as the proof verifier makes at a response's version, swapped out the app's set, so each such lookup reloaded the system contracts and the next app read reloaded them again. Each version now keeps its own set; the app's reads keep the set they last got for a failed reload. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_012ujJpB9DBhvtbjhYB3aG9Q
…poch When the epoch cannot be read, the proved DPNS fallback confirmed the SDK's version, which starts at the network's upstream minimum (14 on devnet), as the network's. It now confirms the version of the responses the SDK verified, and nothing before any. Restores the completed-withdrawal status list with the reason sending FAILED to a protocol 13 network is safe, and its test, now comparing the protocol 13 schema with the latest one. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_012ujJpB9DBhvtbjhYB3aG9Q
The derived key DET signs with is copied into secp256k1's own type, which keeps its bytes after use. Wrap it so it is erased on drop, as the derived key it comes from would be; signatures stay byte-identical. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_012ujJpB9DBhvtbjhYB3aG9Q
… protocol 13 Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_012ujJpB9DBhvtbjhYB3aG9Q
The new refusals sent users to another document editor or token client. They now say the app cannot edit this field type, sign this action or change this token setting yet, in one wording, and the shielded setting refusal sits with the token contract errors. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_012ujJpB9DBhvtbjhYB3aG9Q
Also corrects the platform compatibility fixtures README: no code reads e3cd7cf.sql any more; it is the V001-V018 checksum reference. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_012ujJpB9DBhvtbjhYB3aG9Q
…ey branch Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_012ujJpB9DBhvtbjhYB3aG9Q
The optional token cost (the "Pay the token cost" option, DOC-011) moves to its own branch, so every document action builds its token payment as before and this branch only adds the contract action fee agreement. The network's refusals of a missing or changed fee agreement now show the same text as the app's own check, which tells the user to reload the contract first, since either way the local copy may be out of date. The fee estimation imports sit in the file's top import block. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_012ujJpB9DBhvtbjhYB3aG9Q
The username screen offered the unlock, and gated paying, on the wallet of the automatically picked key, although a key chosen under Advanced signs the registration. The wallet now follows the key the registration is signed with, and is picked again when that key changes. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_012ujJpB9DBhvtbjhYB3aG9Q
The document action and DashPay selectors offered every accepted level at once, so a CRITICAL key could sign where a key at the required level was held. Every document key is now chosen like the username key: each accepted level from the weakest up, unlimited keys first within a level. Also puts the scope and wallet doc comments of the document action screen back on their functions, and builds its test keys and identities from the shared test helpers. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_012ujJpB9DBhvtbjhYB3aG9Q
Each key chooser entry with a caveat is one complete template instead of a label plus a concatenated tag. The spending limit warning no longer points at a remaining budget the key details do not show, and IDN-024 names the key chooser, not the key list. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_012ujJpB9DBhvtbjhYB3aG9Q
|
Ready for review — files with no dedicated owner: lklimek. |
|
Waiting for bot review — coderabbitai not yet · thepastaclaw not yet. Wait for the missing reviews, or a writer can post |
|
/skip-bots |
…reement branch Conflicts in backend_task/error.rs were additive: keep this PR's fee-agreement test and imports together with v1.0-dev's key-limit cases. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
Waiting for bot review — coderabbitai skipped after its own rate limit · thepastaclaw not yet. Wait for the missing reviews, or a writer can post |
thepastaclaw
left a comment
There was a problem hiding this comment.
Re-review — Final validation — Phase 2 only (no Phase 1 for this repository)
New on this head: This head merges the document action-fee work with unrelated identity key-limit, UI, tooling, and base-branch changes; the action-fee implementation is unchanged from the previously reviewed and corrected head. Test Suite, Clippy, Platform pin guard, and unused-dependency checks pass; PR Hygiene remains in progress.
🔴 0 blocking | 🟡 0 suggestion(s) | 💬 0 nitpick(s)
Review provenance
Source: reviewer 1: gpt-6.2-astra (agent: phase2-reviewer, role: general); reviewer 2: gpt-6.2-astra (agent: phase2-reviewer, role: rust-quality); final verifier: gpt-6.2-sol (agent: sol-verifier, role: final-verifier)
- Triage:
criticalbygpt-6.2-sol(effort low) — This large, intricate change modifies document transition construction, fee agreements, signing, and broadcasting in src/backend_task/document.rs and src/ui/contracts_documents/document_action_screen.rs, directly affecting funds movement and signed network actions. - Phase 1 reviewers: not run (disabled for this repository)
- Fresh verifier:
gpt-6.2-sol— final-verifier; agentsol-verifier - Phase 2 reviewers:
gpt-6.2-astra— general (completed, effort high); agentphase2-reviewer,gpt-6.2-astra— rust-quality (completed, effort high); agentphase2-reviewer
🤖 Prompt for all review comments with AI agents
These findings are from an automated code review. Verify the current code and confirm that no unresolved issues remain.
No unresolved findings remain from the prior review on this head.
|
Ready for review — files with no dedicated owner: lklimek. |
|
Policy satisfied — this can merge. |
TL;DR: A contract can charge a fee for document actions. The app shows that fee, asks the user to agree to it, and sends exactly the action that was confirmed. When the network's fee multiplier rises past the agreed tolerance, the app updates the fee from a proved epoch, and requires a successful read before the next confirmation. The verified amount may be unchanged.
Stacked atop #1117.
User story
As a user acting on a document whose contract charges a fee, I want to see that fee and agree to it before anything is sent, so that I am never charged more than I accepted (DOC-010).
Scenario
Base flow
deletecharges an action fee priced by the fee multiplier.Actual
The app did not show contract action fees and sent no agreement to them, so the network refused every action of a contract that charges one.
Expected
Detailed discussion
src/model/fee_estimation.rs):document_action_fee_quotebuilds aDocumentActionFeeQuotefrom the document type's declaredactionFees. The quote holds the owner and moderator parts at the multiplier the user saw, the total, and the most it can become (max_total).ACTION_FEE_MULTIPLIER_INCREASE_TOLERANCE_PERCENT(20%).src/model/fee_estimation.rs,src/backend_task/document.rs):checked_action_fee_agreementrefuses an action whose agreement is missing, or names a fee other than the one the document type declares, before anything is signed (TaskError::ActionFeeAgreement).src/ui/contracts_documents/document_action_screen.rs): the action is built when the confirmation opens and stored with it (PendingActionFeeConfirmation), so confirming sends that exact action.DocumentActionFeeMultiplierNotToleratedrefusal triggers a proved epoch refresh through chore(deps)!: update Platform to v5.1-dev 063589bf and follow the network's protocol version #1114'srefresh_current_epoch.DocumentActionFeeMultiplierNotRefreshed), rather than that it was.src/backend_task/error.rs):DocumentActionFeeNotAgreedandDocumentActionFeeChanged(the network's refusals) show the same text as the app's ownActionFeeAgreementError::NotConfirmedandOutdated. Both ask the user to verify the selected contract and fee, without inferring that the immutable declaration changed or instructing unconditional removal.DocumentActionFeeMultiplierRosenames the known and current multipliers.DocumentActionFeeMultiplierNotRefreshedcovers a multiplier that could not be refreshed.feat/document-optional-token-cost.Testing
model::fee_estimation: quoting fixed and multiplier-priced fees (a_fixed_fee_is_charged_as_declared,a_multiplier_priced_fee_scales_and_names_the_tolerance, and others); refusing a missing or mismatched agreement (a_charged_fee_without_an_agreement_is_refused,an_agreement_to_another_fee_is_outdated).ui::contracts_documents::document_action_screen::tests:confirming_a_contract_fee_sends_the_action_it_was_shown_for;every_action_maps_to_its_document_transition.backend_task::document:a_fee_refusal_stands_once_the_epoch_is_refreshedanda_failed_epoch_refresh_says_the_fee_was_not_updated.backend_task::error: the refusal mappings inprotocol_v14_consensus_errors_map_to_their_variants, andfee_agreement_refusals_read_the_same_locally_and_from_the_network.cargo clippy --all-features --lib --tests -- -D warningsandcargo fmt --allpass.🤖 Generated with Claude Code
Visual diff
Annotated OLD (merge base) vs NEW (PR head) screenshots, with a list of what was not covered: gallery.
PR Hygiene ·
59bc20bdocs/user-stories.md,src/backend_task/document.rs,src/backend_task/error.rsand 5 more) — approved by lklimekWhen every merge requirement is met, the
PR Hygienecheck passes. Reviewer limits do not block merging; other required GitHub checks and protections still apply.