Repository navigation
fix(dpp): hold arrays to the maximum schema depth in validate_max_depth v2 - #5881
Conversation
…th v2 Generation 2 of the schema depth and cycle check raised the reached depth for an array but compared only maps with the maximum, so a schema whose deepest levels are arrays alone, such as a nested `const` or `enum` value, passed the check past the maximum depth. The array branch now refuses one level past the maximum with the same DataContractMaxDepthExceedError as the map branch, carrying the size measured so far for the registration helper to bill. Both branches build that result through one helper. Generation 2 is selected only by protocol version 15, which is unreleased and not active on testnet or mainnet, so it is fixed in place; generations 0 and 1 are unchanged. The v15 note and the CONTRACT_VERSIONS_V7 comment now state that a schema whose array nesting alone exceeds the maximum depth is refused at registration and update. Tests: an array-only `const` tail exactly at the maximum depth is accepted with its depth and size; one level over is refused with the depth error and the size measured before it, while protocol version 14 (generation 1) still accepts it. Test would have caught this in CI: ✖ before fix (should_refuse_an_array_only_tail_past_the_depth_limit_from_protocol_version_15 failed: no errors at the latest version), ✔ after. Addresses the thepastaclaw suggestion on #5871. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
No actionable comments were generated in the recent review. Walkthrough
Merge Risk:
|
|
Waiting for bot review — thepastaclaw not yet. Wait for the missing reviews, or a writer can post |
|
🔍 Review in progress — actively reviewing now (commit 6e18118) · triage: low |
…roposal-contract-1db678 Brings in v5.1-dev at 8b4ca80: the pin of the bytes protocol version 15 stores contracts in (#5880) and the array depth fix of validate_max_depth 2 (#5881). The merge is clean. The stored contract fixture is regenerated for the one contract this branch changes: the decision proposals contract, which gains `multipleChoiceProposal` and `choice` at protocol version 15 (unreleased). No other line of `stored.jsonl` changes. Co-Authored-By: Claude Fable 5.2 <[email protected]>
…ecision-proposal-description-reference Brings in v5.1-dev at 8b4ca80 (the pin of the bytes protocol version 15 stores contracts in, #5880, and the array depth fix of validate_max_depth 2, #5881) and the multiple choice proposals branch's README and protocol guide wording on when a choice leaves state and how its fund grows. The stored contract fixture is regenerated for the one contract this branch changes: the decision proposals contract, whose `multipleChoiceProposal` names its description through a reference here. No other line of `stored.jsonl` changes. Co-Authored-By: Claude Fable 5.2 <[email protected]>
Issue being fixed or feature implemented
Follow-up to #5871, from the thepastaclaw suggestion on it (comment).
validate_max_depth2, the schema depth and cycle check that #5871 added and that only protocol version 15 selects, raised the reached depth for an array but compared only maps with the maximum. A schema whose deepest levels are all arrays, such as a nestedconstorenumvalue, could therefore go past the maximum depth and still pass, as long as no deeper map triggered the map branch's check.What was done?
validate_max_depth_v2now refuses one level past the maximum with the sameDataContractMaxDepthExceedErroras the map branch. Like the map branch, the result carries the size measured so far, which the registration helper reads on the rejection path to bill the schema. Both branches build that result through one helper,max_depth_exceeded.validate_max_depth2 and theCONTRACT_VERSIONS_V7comment now say that a schema whose array nesting alone exceeds the maximum depth is refused at registration and update.Generation 2 exists only in protocol version 15. That version is unreleased and not active on testnet or mainnet (both run protocol version 14), so it is fixed in place. No shipped generation changes.
How Has This Been Tested?
New tests in
validate_max_depth/v2, built on a document type schema whoseconstholds arrays nested around a scalar:should_accept_an_array_only_tail_reaching_exactly_the_depth_limit: arrays alone reach exactly the maximum depth; the schema is accepted and its exact depth and size are checked.should_refuse_an_array_only_tail_past_the_depth_limit_from_protocol_version_15: arrays alone reach one level past the maximum. Protocol version 14 (generation 1) still accepts it and reports a depth past the maximum. The latest version refuses it withDataContractMaxDepthExceedErrorand the size measured before that level.Red to green: before the fix, the over-limit test failed because the latest-version result had no errors. It passes after the fix.
Also run locally on the rebased branch:
cargo test -p dpp --all-features --lib --tests: 6105 passed, plus all integration tests, including the contract corpus loading at protocol versions 13, 14 and latest.cargo clippy -p dpp -p platform-version --all-features --all-targets -- -D warnings: clean.cargo fmt --all -- --check: clean.Breaking Changes
None for any released or active protocol version. At unreleased protocol version 15, a contract whose schema has array nesting alone past the maximum depth is now refused at registration and update.
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 ·
6e18118/skip-botsproceeds without the ones not yet reported/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.Summary by CodeRabbit
$refpointers consistently with JSON Pointer rules, rejecting pointers whose interpretation differs under those rules.