fix(platform)!: apply the review of contract group key bounds - #4801
Conversation
Registering or refreshing a key bound to a contract group read the group's info twice and billed both reads: once while building the apply info and again in fetch_bound_root_with_fee, which is the read that checks the group exists. Building the apply info needs nothing from the group, so it no longer reads it. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
…iled Transform v2 resolved contract group memberships for every batch signed by a group-bound key, including one whose transform result already carries errors. Such a result never reaches the bounds check, so the read was wasted and its fee never billed. It now runs only for an error-free result. Tests: CheckTx reaches the same verdict as block processing for every membership case, an identity update registers and revokes a group-bound key through the whole pipeline, and every protocol version pairs advanced structure v1 with the transformer that resolves memberships. The contract group fixtures move to test/helpers so query and validation tests share them. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
IdentityPublicKeyInCreation::first_bound_to_a_contract_group replaces three copies of the same match (the protocol version gate, the shielded builder and the shielded proof validator). The ContractGroupMember import is gated on state-transitions like its only users, a test moves back below the comment and test pair it had split, and four new tests are renamed to start with should. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
|
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 (21)
💤 Files with no reviewable changes (1)
Included review availability: Your plan provides up to 1 included review per hour; 0 remain after this review. 📝 WalkthroughWalkthroughThe change centralizes contract-group key detection, defers group reads during apply-info construction, skips membership resolution after validation errors, adds validation coverage, moves contract-group fixtures into shared test helpers, and updates protocol documentation. ChangesContract-group resolution
Priority: ➖ Normal Estimated code review effort: 3 (Moderate) | ~25 minutes Change: Bug fix Sequence Diagram(s)sequenceDiagram
participant BatchTransition
participant Transformer
participant MembershipResolver
participant CheckTx
BatchTransition->>Transformer: transform batch
Transformer->>MembershipResolver: resolve memberships when validation has no errors
MembershipResolver->>MembershipResolver: read each distinct touched contract
BatchTransition->>CheckTx: check transaction
CheckTx-->>BatchTransition: matching validation result
Merge Risk: ⚪ Minimal · up to The contract-group changes do not leave a concrete unresolved merge risk. 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches 💡 1🛠️ Fix failing CI checks 💡
📝 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 |
|
🕓 Queued for automated review — 9th in line, estimated start in ~7 h (commit 137d38b)
|
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## v4.2-dev #4801 +/- ##
============================================
- Coverage 78.11% 77.28% -0.84%
============================================
Files 2916 2916
Lines 419165 422948 +3783
============================================
- Hits 327434 326863 -571
- Misses 91731 96085 +4354
🚀 New features to boost your workflow:
|
Brings in the review of contract group key bounds (#4801), which moved the "key bound to a contract group" predicate into one helper on IdentityPublicKeyInCreation, shared by the protocol version gate, shielded proof validation and the transition builder. The two conflicts were where this branch had extended that inline predicate. Resolved by following the same shape: `first_in_version_1_format` (the gate: a binary from before cannot decode the format, limits or not) and `first_with_limits` (shielded identity creation and its builder) sit next to `first_bound_to_a_contract_group`, and all three call sites use them. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Issue being fixed or feature implemented
Follow-up to #4793 (authentication keys bound to a contract group), which merged before its code review findings were applied. This PR applies them.
What was done?
Behaviour:
new_from_single_keyread the group's info while building the apply info, thenfetch_bound_root_with_feeread it again when the references were written. Building the apply info needs nothing from the group, so only the second read remains; it is the one that checks the group exists.Cleanup:
IdentityPublicKeyInCreation::first_bound_to_a_contract_groupreplaces three copies of the same match (the protocol version gate, the shielded builder, the shielded proof validator).ContractGroupMemberimport incontract_bounds/mod.rsis gated onstate-transitions, like its only users, so a build without that feature no longer warns.register_group,join_group,single_owner_info, ...) move from the privatequery::contract_group_queriestest module totest/helpers/contract_groups.rs; the batch and key bounds validator tests use them instead of their own copies.Not in this PR: the wallet FFI already emits bounds kind 3 while the Kotlin and Swift layers on
v4.2-devonly know kinds 0 to 2. That is what #4800 fixes, so it should merge soon after #4793 did.How Has This Been Tested?
New tests:
20014outside it.41001while the group is missing, success once it exists, the key indexed under the group, and the bounds kept after revocation (which exercises the refresh path).PLATFORM_VERSIONSpairs batch advanced structure v1 with transform v2, the invariant behind theCorruptedCodeExecutionarm of the bounds check.Ran locally: the affected tests of
dpp,drive,drive-abci(321 tests across contract groups, identity create and update, key bounds, shielded proof),platform-wallet-ffiandrs-unified-sdk-jni;cargo clippy -p dpp -p drive -p drive-abci --all-targets -- -D warnings;cargo fmt --all -- --check.Breaking Changes
Registering or refreshing a key bound to a contract group is billed one group read instead of two. This only exists in protocol version 14, which is unreleased, but nodes built before and after this PR disagree on that fee.
Checklist:
🤖 Generated with Claude Code
Summary by CodeRabbit
Documentation
Bug Fixes
Tests