Skip to content

feat(platform)!: add contract groups - #4791

Merged
QuantumExplorer merged 10 commits into
v4.2-devfrom
feat/contract-groups
Sep 17, 2026
Merged

QuantumExplorer merged 10 commits into
v4.2-devfrom
feat/contract-groups

Conversation

@QuantumExplorer

@QuantumExplorer QuantumExplorer commented Sep 16, 2026 •

Copy link
Copy Markdown
Member

Issue being fixed or feature implemented

Contract groups: an identity-owned set of contracts, contract document types and contract tokens. A group is registered when creating a data contract, and later contracts created by an owner can add themselves, one of their document types, or one of their tokens to it. This gives a project a provable, on-chain statement that a set of contracts, types and tokens belong together, for anything that later wants to act on the set as a whole (a contract-group key bound, aggregate queries, tooling).

This is the first of several PRs. It lands the consensus core: wire format, storage, validation, proofs. DAPI queries and the SDK surfaces follow separately.

What was done?

Wire (rs-dpp)

  • DataContractCreateTransitionV1 = V0 plus contract_group: Option<ContractGroupRegistration> and contract_group_memberships: Vec<ContractGroupMembership>, both defaulting to empty when decoded from JSON. V0 stays valid and carries neither; active_version_range and the serialization bounds gate V1 to protocol version 14 (max 1, default 1), so a v13 node rejects it whichever contract format it embeds.
  • New module dpp::contract_group: ContractGroupOwner (SingleOwner(id) / OwnerAndAdmins { owner, admins }), ContractGroupMember (Contract / DocumentType(name) / Token(position)), ContractGroupMembership, ContractGroupRegistration (admins, name, description; the owner is the transition signer and is never on the wire), versioned ContractGroupInfo and generate_contract_group_id.
  • The group id is derived, never sent: hash_double("contract_group" || owner_id || identity_nonce). The contract created by the same transition is hash_double(owner_id || identity_nonce), so a client knows both ids up front and they cannot collide.

Storage (rs-drive)

New root tree ContractGroups (key 124, under the Versions node so no existing root node gains a child and asset lock fees do not move):

[124] ContractGroups
├── [0] Groups
│   └── <contract group id>
│       ├── [0] Info            -> Item(bincode ContractGroupInfo { owner, name?, description? })
│       ├── [1] Contracts       -> <contract id> -> Item([])
│       ├── [2] DocumentTypes   -> <contract id || document type name> -> Item([])
│       └── [3] Tokens          -> <contract id || token position, u16 BE> -> Item([])
└── [1] Members
    └── <contract id>
        ├── [0] Groups          -> <contract group id> -> Reference to Groups/<group>/[1]/<contract id>
        ├── [1] DocumentTypes   -> <document type name> -> <contract group id> -> Reference
        └── [2] Tokens          -> <token position> -> <contract group id> -> Reference

The backwards side holds plain one-hop UpstreamRootHeightReferences rather than GroveDB bidirectional references: memberships are append-only and contracts are never deleted, so nothing can dangle, and a bidirectional reference would add a backref slot per forward leaf for cleanup that never happens. Members is keyed by contract first so "is document type D of contract C in group G" is one point lookup, which is what a future ContractBounds::ContractGroup check would need per batch member. Document type and token members of a group sit on one level under a composite key (contract id followed by the name or position) rather than under a subtree per contract, so a page of members is a plain range after the cursor key with no descent that could be empty.

Fresh chains build the three trees in create_initial_state_structure v4; upgrading chains build them in transition_to_version_14. Both call the same insert_contract_groups_structure, which inserts each tree only if it does not exist. Insert, fetch, prove, verify and estimation all sit under drive.methods.contract_group / drive.methods.verify.contract_group.

Validation (rs-drive-abci)

  • Basic structure v2 (unpaid): the registrant is the owner, a registration only names admins, at most 16 of them and none of them the owner; name 1 to 64 and description 1 to 256 characters; every member must exist in the created contract; no duplicate membership; no document type or token membership when the whole contract already joins the same group; at most 16 memberships. Codes 10360 to 10367, with 10365 unassigned.
  • State v1 (paid, nonce bumped): the registered group must not already exist and every admin it names must be an existing non-masternode identity; every group joined must exist and have the signer as its owner or one of its admins; a membership the contract already holds, or one the contract's existing whole-contract membership makes redundant, is refused against state as well as within the transition. Codes 41000 to 41003. Each identity and group lookup, and the group id hash, is billed through the execution context.
  • The action gains a V1 carrying the derived group id and the memberships; the high-level converter emits RegisterContractGroup before AddContractGroupMemberships, both after the contract itself, so a contract can join the group its own transition registers.

Limits rename

SystemLimits::max_contract_group_size becomes max_group_member_count. It bounds the members of a change-control Group declared inside a contract, which is a different concept from a contract group, and keeping both names as "contract group" would be a trap. Protocol version 14 is unreleased, so the rename is in place across every table. New limits: max_contract_group_memberships_per_contract (16), max_contract_group_admins (16), max_contract_group_name_length (64), max_contract_group_description_length (256).

Docs

  • docs/protocol/contract-groups.md: the protocol note.
  • The Dash Platform Book gains a full chapter, book/src/data-model/contract-groups.md (Data Model section): the model and id derivation, the types, create transition V1 and its bounds, the unpaid structure and paid state checks with codes, action and operation ordering, the root tree layout and why it uses plain references, cost estimation, tree creation on fresh and upgrading chains, fetch/prove/verify, the version tables and limits touched, fees, what is deliberately not there yet, tests, and rules. The error codes chapter lists the two new ranges. mdbook build is clean.

Tests

  • rs-dpp (3): id derivation is distinct from the contract id and stable; owner resolution for both kinds; stored info round-trips through bincode.
  • rs-drive (6): the root tree exists at genesis on v14 and is absent on v13; registration with present and absent proofs; memberships recorded on both sides for two contracts and three member kinds, each proved and verified; estimation builds the same operations as apply and its fee is never below actual; a second registration of the same id is refused.
  • rs-drive-abci (9): register and join in one transition; an owner adding later contracts by document type and by token, with the proof verified against the committed root; joining a group you do not own is a paid failure with the nonce bumped and nothing written; joining an unknown group; a group with admins accepts the owner and each admin and refuses an outsider; naming an unknown admin, and re-adding a membership the contract already holds, are paid failures; a version 0 create still processes at the latest version; malformed registrations and memberships each produce their own structure error.

Workspace cargo check --tests is clean and clippy -D warnings passes on dpp, drive, drive-abci and platform-version.

CI on the first push failed data_contract::factory::v0::tests::should_create_data_contract_create_transition_from_data_contract, which asserted the factory builds a version 0 transition; the targeted runs above had filtered it out. It now compares against the versioned default_current_version (3d0bec9), and the whole dpp package (4263 tests, --all-features) passes locally.

The state codes were moved from 40218-40220, which sat inside the identity block, to their own range 41000-41002 (40900 belongs to shielded errors). PV14 is unreleased, so nothing shipped with the old numbers.

A local no-fail-fast run of the whole drive and drive-abci packages found what CI's fail-fast would have shown one at a time (cada386): the drive initialization tests count 18 root trees and prove the new tree, and four drive-abci fee tests that write an asset lock outpoint (identity create validation, asset lock reuse after issue, asset lock replay attack, identity top-up validation) each became a run_*_at_protocol_version helper with a _protocol_version_13 twin. The root key was first 68, which sat under SpentAssetLockTransactions and raised every asset lock fee by 1480 credits; it is now 124, under the Versions node, so those fees are unchanged and the twins pin the latest-version fee equal to the version 13 fee. The chain-simulation baseline run_chain_one_identity_in_solitude_latest_protocol_version is likewise back at its version 13 balance.

Review fix: the whole-group query enumerated every member with no limit, and a group can grow without bound across contracts (the 16 cap is per creating transition), so fetching or proving a large group was unbounded work. It is replaced by a separate info proof (fetch_/prove_/verify_contract_group_info) and paged member enumeration (fetch_/prove_/verify_contract_group_members) driven by a ContractGroupMembersQuery that names one kind (Contracts, DocumentTypes, Tokens) and a start_after cursor, with a limit that must lie between 1 and the node's max_query_limit on both the fetch and the proof side. Document type and token members are stored under a flat composite key (contract id followed by the name or position), so every kind pages with a plain range after the cursor key; a subtree per contract would have made a continuation page descend into the cursor's contract, and GroveDB charges an empty descent against the limit, which shortened every continuation page and ended a limit-one walk early. The per-contract memberships query keeps no limit because a contract's memberships are creation-only and capped at 16. A drive test walks every kind with the cursor, proves each page and checks that zero and over-limit page sizes are refused.

Review round 2 (5e0f738) addressed the 15 findings from the high-effort code review: the protocol version gate on V1 in active_version_range, the flat member keys above, the root key move to 124, admin existence checks, per-contract invariants checked against state with idempotent tree creation, the frozen discriminant test extended, an upgrade test for transition_to_version_14, protocol version 13 twins for the root structure tests, a V0 create at the latest version, the V1 fields in wasm-dpp2, serde(default) on the V1 fields with a JSON round trip, the group id hash billed and read from the action, one shared signing tail for V0 and V1, one shared tree creation helper for genesis and upgrade, and the owner dropped from the wire.

Breaking changes

Consensus. A new state transition version, a new root tree and new consensus error codes, all gated to protocol version 14, which is unreleased.

Notes for reviewers

Decisions taken that are worth a second opinion:

  • Group ownership is one owner, optionally with admins. The owner is the registrant and is never sent; a registration only lists admins, identities that may add members alongside the owner, acting alone, not a multisig (changed from a co-owner set on Sam's review). A Group variant pointing at a contract's change-control group, so a token group's roster owns the contract group, was specified and deliberately left out of this PR.
  • Memberships are creation-only. No update path, no leaving. Contract update support would be a later DataContractUpdateTransitionV1.
  • Redundancy is rejected, not tolerated: a document type membership is refused when the whole contract already joins that group, so the tree stays canonical.
  • Empty groups are allowed at registration; the registering contract need not join.
  • An optional Owners index (identity to the groups it owns) was considered and left out, since owners can derive their own group ids from their nonces.

Follow-ups, not in this PR: getContractGroupInfo, a paged getContractGroupMembers and getContractGroupsForContract through DAPI and the SDKs; the legacy wasm-dpp JSON surface for the two new fields (wasm-dpp2 has them); ContractBounds::ContractGroup for identity keys.

🤖 Generated with Claude Code

A contract group is an identity-owned set of contracts, contract document
types and contract tokens. A group is registered by a data contract create
transition; later contracts created by an owner can add themselves, one of
their document types, or one of their tokens to it in their own create
transition.

Wire: DataContractCreateTransition version 1 adds `contractGroup`, an
optional registration carrying the owner (single or multi owner), a name and
a description, and `contractGroupMemberships`. The group id is derived, not
sent: hash_double("contract_group" || owner id || identity nonce), which can
never collide with the contract id the same transition derives. Version 0
stays valid and carries neither; the version bounds gate version 1 to
protocol version 14.

Storage: a new `ContractGroups` root tree (key 68) holds every group under
`Groups` and a backwards index from each member contract under `Members`.
The backwards entries are plain one-hop GroveDB references; memberships are
append-only and contracts are never deleted, so a reference cannot dangle.
Fresh chains build the tree in `create_initial_state_structure` v4, upgrading
chains in `transition_to_version_14`.

Validation: structure checks (owner rules, name and description lengths,
member existence in the created contract, duplicates, redundancy, membership
cap) are unpaid, codes 10360 to 10367. State checks (the registered group
must be new, every group joined must exist and count the signer among its
owners) are paid with a nonce bump, codes 40218 to 40220. Each group lookup
is billed.

`SystemLimits::max_contract_group_size` becomes `max_group_member_count`: it
bounds the members of a change-control `Group` inside a contract, which is a
different thing from a contract group. Protocol version 14 is unreleased, so
the rename is in place across every table.

Co-Authored-By: Claude Opus 5 <[email protected]>
@coderabbitai

coderabbitai Bot commented Sep 16, 2026 •

Copy link
Copy Markdown
Contributor

Important

Review skipped

Too many files!

This PR contains 130 files, which is 30 over the limit of 100.

To get a review, reduce the PR to 100 files or fewer by splitting it into smaller PRs or changing its base branch.

Upgrade to a paid plan to raise the limit.

This review couldn't start because sufficient usage credits or metered capacity aren't available. Add credits or update usage-based reviews in the billing tab, then retry.

⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Advanced

Run ID: f46eadfa-3337-4889-95b3-74a83b11f5a1

📥 Commits

Reviewing files that changed from the base of the PR and between 475df38 and 5e0f738.

📒 Files selected for processing (130)
  • book/src/SUMMARY.md
  • book/src/data-model/contract-groups.md
  • book/src/error-handling/error-codes.md
  • docs/protocol/contract-groups.md
  • packages/rs-dpp/src/contract_group/mod.rs
  • packages/rs-dpp/src/data_contract/factory/v0/mod.rs
  • packages/rs-dpp/src/data_contract/group/v0/mod.rs
  • packages/rs-dpp/src/errors/consensus/basic/basic_error.rs
  • packages/rs-dpp/src/errors/consensus/basic/contract_group/contract_group_member_not_in_contract_error.rs
  • packages/rs-dpp/src/errors/consensus/basic/contract_group/contract_group_memberships_over_limit_error.rs
  • packages/rs-dpp/src/errors/consensus/basic/contract_group/duplicate_contract_group_membership_error.rs
  • packages/rs-dpp/src/errors/consensus/basic/contract_group/invalid_contract_group_admins_error.rs
  • packages/rs-dpp/src/errors/consensus/basic/contract_group/invalid_contract_group_description_length_error.rs
  • packages/rs-dpp/src/errors/consensus/basic/contract_group/invalid_contract_group_name_length_error.rs
  • packages/rs-dpp/src/errors/consensus/basic/contract_group/mod.rs
  • packages/rs-dpp/src/errors/consensus/basic/contract_group/redundant_contract_group_membership_error.rs
  • packages/rs-dpp/src/errors/consensus/basic/mod.rs
  • packages/rs-dpp/src/errors/consensus/codes.rs
  • packages/rs-dpp/src/errors/consensus/state/contract_group/contract_group_admin_not_found_error.rs
  • packages/rs-dpp/src/errors/consensus/state/contract_group/contract_group_already_exists_error.rs
  • packages/rs-dpp/src/errors/consensus/state/contract_group/contract_group_not_found_error.rs
  • packages/rs-dpp/src/errors/consensus/state/contract_group/identity_not_contract_group_owner_or_admin_error.rs
  • packages/rs-dpp/src/errors/consensus/state/contract_group/mod.rs
  • packages/rs-dpp/src/errors/consensus/state/mod.rs
  • packages/rs-dpp/src/errors/consensus/state/state_error.rs
  • packages/rs-dpp/src/lib.rs
  • packages/rs-dpp/src/serialization/json/safe_fields.rs
  • packages/rs-dpp/src/state_transition/mod.rs
  • packages/rs-dpp/src/state_transition/state_transitions/contract/data_contract_create_transition/accessors/mod.rs
  • packages/rs-dpp/src/state_transition/state_transitions/contract/data_contract_create_transition/accessors/v1/mod.rs
  • packages/rs-dpp/src/state_transition/state_transitions/contract/data_contract_create_transition/identity_signed.rs
  • packages/rs-dpp/src/state_transition/state_transitions/contract/data_contract_create_transition/methods/mod.rs
  • packages/rs-dpp/src/state_transition/state_transitions/contract/data_contract_create_transition/methods/v1/mod.rs
  • packages/rs-dpp/src/state_transition/state_transitions/contract/data_contract_create_transition/mod.rs
  • packages/rs-dpp/src/state_transition/state_transitions/contract/data_contract_create_transition/state_transition_like.rs
  • packages/rs-dpp/src/state_transition/state_transitions/contract/data_contract_create_transition/v0/v0_methods.rs
  • packages/rs-dpp/src/state_transition/state_transitions/contract/data_contract_create_transition/v1/identity_signed.rs
  • packages/rs-dpp/src/state_transition/state_transitions/contract/data_contract_create_transition/v1/mod.rs
  • packages/rs-dpp/src/state_transition/state_transitions/contract/data_contract_create_transition/v1/state_transition_like.rs
  • packages/rs-dpp/src/state_transition/state_transitions/contract/data_contract_create_transition/v1/types.rs
  • packages/rs-dpp/src/state_transition/state_transitions/contract/data_contract_create_transition/v1/v1_methods.rs
  • packages/rs-dpp/src/state_transition/state_transitions/contract/data_contract_create_transition/v1/version.rs
  • packages/rs-dpp/src/state_transition/state_transitions/contract/data_contract_create_transition/version.rs
  • packages/rs-drive-abci/src/execution/platform_events/protocol_upgrade/perform_events_on_first_block_of_protocol_change/v0/mod.rs
  • packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/data_contract_create/basic_structure/v2/mod.rs
  • packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/data_contract_create/contract_group_tests.rs
  • packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/data_contract_create/mod.rs
  • packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/data_contract_create/state/v1/mod.rs
  • packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/identity_create/mod.rs
  • packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/identity_top_up/mod.rs
  • packages/rs-drive-abci/tests/strategy_tests/test_cases/identity_and_document_tests.rs
  • packages/rs-drive/src/drive/contract_groups/estimated_costs/for_insert_contract_group/mod.rs
  • packages/rs-drive/src/drive/contract_groups/estimated_costs/for_insert_contract_group/v0/mod.rs
  • packages/rs-drive/src/drive/contract_groups/estimated_costs/for_insert_contract_group_memberships/mod.rs
  • packages/rs-drive/src/drive/contract_groups/estimated_costs/for_insert_contract_group_memberships/v0/mod.rs
  • packages/rs-drive/src/drive/contract_groups/estimated_costs/mod.rs
  • packages/rs-drive/src/drive/contract_groups/fetch/fetch_contract_group_info/mod.rs
  • packages/rs-drive/src/drive/contract_groups/fetch/fetch_contract_group_info/v0/mod.rs
  • packages/rs-drive/src/drive/contract_groups/fetch/fetch_contract_group_members/mod.rs
  • packages/rs-drive/src/drive/contract_groups/fetch/fetch_contract_group_members/v0/mod.rs
  • packages/rs-drive/src/drive/contract_groups/fetch/fetch_contract_group_memberships_for_contract/mod.rs
  • packages/rs-drive/src/drive/contract_groups/fetch/fetch_contract_group_memberships_for_contract/v0/mod.rs
  • packages/rs-drive/src/drive/contract_groups/fetch/mod.rs
  • packages/rs-drive/src/drive/contract_groups/insert/insert_contract_group/mod.rs
  • packages/rs-drive/src/drive/contract_groups/insert/insert_contract_group/v0/mod.rs
  • packages/rs-drive/src/drive/contract_groups/insert/insert_contract_group_memberships/mod.rs
  • packages/rs-drive/src/drive/contract_groups/insert/insert_contract_group_memberships/v0/mod.rs
  • packages/rs-drive/src/drive/contract_groups/insert/mod.rs
  • packages/rs-drive/src/drive/contract_groups/insert_contract_groups_structure.rs
  • packages/rs-drive/src/drive/contract_groups/mod.rs
  • packages/rs-drive/src/drive/contract_groups/paths.rs
  • packages/rs-drive/src/drive/contract_groups/prove/mod.rs
  • packages/rs-drive/src/drive/contract_groups/prove/prove_contract_group_info/mod.rs
  • packages/rs-drive/src/drive/contract_groups/prove/prove_contract_group_info/v0/mod.rs
  • packages/rs-drive/src/drive/contract_groups/prove/prove_contract_group_members/mod.rs
  • packages/rs-drive/src/drive/contract_groups/prove/prove_contract_group_members/v0/mod.rs
  • packages/rs-drive/src/drive/contract_groups/prove/prove_contract_group_memberships_for_contract/mod.rs
  • packages/rs-drive/src/drive/contract_groups/prove/prove_contract_group_memberships_for_contract/v0/mod.rs
  • packages/rs-drive/src/drive/contract_groups/queries.rs
  • packages/rs-drive/src/drive/contract_groups/tests.rs
  • packages/rs-drive/src/drive/contract_groups/types.rs
  • packages/rs-drive/src/drive/group/insert/add_group_action/v0/mod.rs
  • packages/rs-drive/src/drive/initialization/mod.rs
  • packages/rs-drive/src/drive/initialization/v0/mod.rs
  • packages/rs-drive/src/drive/initialization/v4/mod.rs
  • packages/rs-drive/src/drive/mod.rs
  • packages/rs-drive/src/state_transition_action/action_convert_to_operations/contract/data_contract_create_transition.rs
  • packages/rs-drive/src/state_transition_action/contract/data_contract_create/mod.rs
  • packages/rs-drive/src/state_transition_action/contract/data_contract_create/transformer.rs
  • packages/rs-drive/src/state_transition_action/contract/data_contract_create/v1/mod.rs
  • packages/rs-drive/src/state_transition_action/contract/data_contract_create/v1/transformer.rs
  • packages/rs-drive/src/state_transition_action/system/bump_identity_nonce_action/transformer.rs
  • packages/rs-drive/src/state_transition_action/system/bump_identity_nonce_action/v0/transformer.rs
  • packages/rs-drive/src/util/batch/drive_op_batch/contract_group.rs
  • packages/rs-drive/src/util/batch/drive_op_batch/mod.rs
  • packages/rs-drive/src/util/batch/grovedb_op_batch/mod.rs
  • packages/rs-drive/src/util/batch/mod.rs
  • packages/rs-drive/src/verify/contract_groups/mod.rs
  • packages/rs-drive/src/verify/contract_groups/verify_contract_group_info/mod.rs
  • packages/rs-drive/src/verify/contract_groups/verify_contract_group_info/v0/mod.rs
  • packages/rs-drive/src/verify/contract_groups/verify_contract_group_members/mod.rs
  • packages/rs-drive/src/verify/contract_groups/verify_contract_group_members/v0/mod.rs
  • packages/rs-drive/src/verify/contract_groups/verify_contract_group_memberships_for_contract/mod.rs
  • packages/rs-drive/src/verify/contract_groups/verify_contract_group_memberships_for_contract/v0/mod.rs
  • packages/rs-drive/src/verify/mod.rs
  • packages/rs-platform-version/src/version/dpp_versions/dpp_state_transition_serialization_versions/v3.rs
  • packages/rs-platform-version/src/version/drive_versions/drive_contract_group_method_versions/mod.rs
  • packages/rs-platform-version/src/version/drive_versions/drive_contract_group_method_versions/v1.rs
  • packages/rs-platform-version/src/version/drive_versions/drive_state_transition_method_versions/v4.rs
  • packages/rs-platform-version/src/version/drive_versions/drive_verify_method_versions/mod.rs
  • packages/rs-platform-version/src/version/drive_versions/drive_verify_method_versions/v1.rs
  • packages/rs-platform-version/src/version/drive_versions/mod.rs
  • packages/rs-platform-version/src/version/drive_versions/v1.rs
  • packages/rs-platform-version/src/version/drive_versions/v2.rs
  • packages/rs-platform-version/src/version/drive_versions/v3.rs
  • packages/rs-platform-version/src/version/drive_versions/v4.rs
  • packages/rs-platform-version/src/version/drive_versions/v5.rs
  • packages/rs-platform-version/src/version/drive_versions/v6.rs
  • packages/rs-platform-version/src/version/drive_versions/v7.rs
  • packages/rs-platform-version/src/version/drive_versions/v8.rs
  • packages/rs-platform-version/src/version/drive_versions/v9.rs
  • packages/rs-platform-version/src/version/mocks/v2_test.rs
  • packages/rs-platform-version/src/version/system_limits/mod.rs
  • packages/rs-platform-version/src/version/system_limits/v1.rs
  • packages/rs-platform-version/src/version/system_limits/v2.rs
  • packages/rs-platform-version/src/version/system_limits/v3.rs
  • packages/rs-platform-version/src/version/system_limits/v4.rs
  • packages/wasm-dpp/src/errors/consensus/consensus_error.rs
  • packages/wasm-dpp2/src/data_contract/transitions/create.rs
  • packages/wasm-dpp2/src/state_transitions/base/state_transition.rs

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.


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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actions github-actions Bot added this to the v4.2.0 milestone Sep 16, 2026
@thepastaclaw

thepastaclaw commented Sep 16, 2026 •

Copy link
Copy Markdown
Collaborator

🕓 Queued for automated review — 5th in line, estimated start in ~2.7 h (commit 5e0f738)
Estimated review time once started: ~1.1 h (two-phase automated review; median of recent runs).

  • Request priority review — click to move this review to the front of the queue.

QuantumExplorer and others added 2 commits September 17, 2026 04:56
… version

The factory test asserted the transition it builds is version 0. PV14
raised the default contract create transition version to 1, so the
assertion now compares against the versioned default instead of a
literal.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
A Data Model chapter covering what a contract group is, the id
derivation, the wire and stored types, version 1 of the create
transition and its bounds, the unpaid structure and paid state checks
with their codes, the action and operation ordering, the ContractGroups
root tree layout and why it uses plain references, cost estimation,
tree creation on fresh and upgrading chains, fetch, prove and verify,
the version tables and limits touched, fees, what is deliberately not
there yet, the tests, and the rules to follow. The error codes chapter
gains the two new ranges.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
@github-actions

github-actions Bot commented Sep 16, 2026 •

Copy link
Copy Markdown
Contributor

📖 Book Preview built successfully.

Download the preview from the workflow artifacts.
To view locally: download the artifact, unzip, and open index.html.

Updated at 2026-09-17T01:53:10.594Z

QuantumExplorer and others added 5 commits September 17, 2026 05:08
The three contract group state errors were numbered 40218 to 40220,
inside the identity block, while every other family has its own
hundred. They move to 41000 to 41002 (40900 is shielded). Protocol
version 14 is unreleased, so nothing shipped with the old numbers.

The book's error codes chapter gains the shielded row it was missing
along with the new contract group row.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Contact requests and profiles are document types of the one dashpay
contract, not separate contracts. The opening now motivates contract
groups from what actually pushes a project onto several contracts:
frozen indexes, tokens kept apart, and versioned contracts. The JSON
example no longer borrows the dashpay name.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
The new root tree at key 68 lands under the SpentAssetLockTransactions
(72) node of the root Merk. Two drive initialization tests now count
18 root elements and expect the larger proof for that node, plus a
proof for the new tree. Four drive-abci fee tests that write an asset
lock outpoint moved by 1480 credits; each becomes a helper run at the
latest version with the new fee and at protocol version 13 with the
old one, so a leak into the released version would fail the twin.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
…ractGroups root tree

The nightly chain-simulation suite runs run_chain_one_identity_in_solitude
at the latest version; its identity creation writes a spent asset lock
outpoint, so the balance moves by the same 1480 credits as the unit fee
tests. The protocol version 13 twin keeps the old balance and its comment
now explains the difference instead of claiming parity.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
MultiOwner, a set of co-owners any of whom could register or add
members, becomes OwnerAndAdmins { owner, admins }: one owner, who must
be the identity registering the group in both forms, plus one to
sixteen admins who may add members alongside it. Being named as an
admin is not enough to register. InvalidContractGroupOwnersError
becomes InvalidContractGroupAdminsError (10364) and
IdentityNotContractGroupOwnerError becomes
IdentityNotContractGroupOwnerOrAdminError (41002); the limit is
max_contract_group_admins. Docs, book chapter and tests follow.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
@codecov

codecov Bot commented Sep 16, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 82.15022% with 606 lines in your changes missing coverage. Please review.
✅ Project coverage is 78.53%. Comparing base (475df38) to head (5e0f738).
⚠️ Report is 1 commits behind head on v4.2-dev.

Files with missing lines Patch % Lines
...ystem/bump_identity_nonce_action/v0/transformer.rs 15.00% 51 Missing ⚠️
...ransition/state_transitions/identity_create/mod.rs 57.28% 44 Missing ⚠️
...on/contract/data_contract_create/v1/transformer.rs 45.45% 36 Missing ⚠️
...tch_contract_group_memberships_for_contract/mod.rs 50.70% 35 Missing ⚠️
...ract_groups/fetch/fetch_contract_group_info/mod.rs 49.25% 34 Missing ⚠️
...events_on_first_block_of_protocol_change/v0/mod.rs 66.32% 33 Missing ⚠️
packages/rs-dpp/src/state_transition/mod.rs 47.54% 32 Missing ⚠️
...ns/contract/data_contract_create_transition/mod.rs 65.55% 31 Missing ⚠️
packages/rs-dpp/src/contract_group/mod.rs 84.72% 22 Missing ⚠️
...act/data_contract_create_transition/methods/mod.rs 77.64% 19 Missing ⚠️
... and 38 more
Additional details and impacted files
@@             Coverage Diff              @@
##           v4.2-dev    #4791      +/-   ##
============================================
+ Coverage     78.51%   78.53%   +0.02%     
============================================
  Files          2868     2905      +37     
  Lines        411869   416700    +4831     
============================================
+ Hits         323396   327275    +3879     
- Misses        88473    89425     +952     
Components Coverage Δ
dpp 76.89% <74.83%> (-0.13%) ⬇️
drive 79.87% <84.84%> (+0.28%) ⬆️
drive-abci 78.87% <75.75%> (-0.30%) ⬇️
sdk ∅ <ø> (∅)
dapi-client ∅ <ø> (∅)
platform-version ∅ <ø> (∅)
platform-value 86.79% <ø> (+0.18%) ⬆️
platform-wallet ∅ <ø> (∅)
drive-proof-verifier 30.98% <ø> (+0.10%) ⬆️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

The whole-group query enumerated every member with no limit. The 16
membership cap is per creating transition, so a group can grow without
bound across contracts, and fetching or proving a large group was
unbounded work and proof size.

The group's information now has its own single-item proof, and members
are read one kind at a time (contracts, document types, tokens) in
pages: a start-after cursor, key order, and a limit that must lie
between 1 and the node's max_query_limit on both the fetch and the
proof side. For the two-level kinds the cursor's contract gets a
conditional subquery starting after the cursor's entry, so a page can
end mid-contract and the next resumes there. The per-contract
memberships query keeps no limit: memberships are creation-only and
capped at 16 per contract.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Consensus and wire format:
- gate DataContractCreateTransition V1 to protocol version 14 and later in
  active_version_range, independently of the embedded contract format
- drop the redundant owner from ContractGroupRegistration; the registrant is
  the owner, a registration only names admins, and 10365 is unassigned
- validate that every admin identity exists and is not a masternode
  identity (new state error 41003 ContractGroupAdminNotFoundError)
- read the registered group id from the action instead of re-deriving it,
  and bill the double SHA-256 the derivation costs
- check new memberships against the contract's existing memberships, not
  only against the transition, and create per-contract trees only if they
  do not exist yet
- move the ContractGroups root tree from key 68 to key 124 so it hangs
  under the Versions node and leaves asset lock fees unchanged
- default the V1 contract group fields when decoding JSON

Storage:
- store document type and token members of a group under a flat composite
  key (contract id followed by name or position) instead of a subtree per
  contract, so a continuation page is a plain range after the cursor key
  and GroveDB never charges an empty descent against the page limit
- share insert_contract_groups_structure between genesis and the
  protocol version 14 upgrade

Bindings and cleanup:
- share the signing tail between the V0 and V1 create transition methods
- expose the V1 fields in wasm-dpp2 and pick the transition version from
  the platform version

Tests: frozen discriminant test pins 41003; protocol version 13 twins for
the root structure and heights; transition_to_version_14 tree creation;
V0 create at the latest version; V1 JSON round trip and default; unknown
admin and already-held membership paid failures; limit-one paging past a
contract with no entries left.

Co-Authored-By: Claude Fable 5.1 <[email protected]>

@QuantumExplorer QuantumExplorer left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants