feat(platform)!: in, value membership in propertyConstraints rules (PV14) - #5038
Conversation
…s (PV14)
A propertyConstraints condition may now be `{ "present": path }` or
`{ "absent": path }`: whether the document holds the property, the one
way to tell a property left out from one set to 0. A presence test may
name a property of any type, an object included, but not a transient
one; it counts as one node and never faults.
Extended in place in meta-schema v3 and parse_property_constraints 0:
every declaration valid before parses and evaluates as it did.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…V14)
A propertyConstraints condition may now be
`{ "in": [expression, [value, ...]] }`: the integer expression takes one
of two or more distinct integer literals. It says what an anyOf of
equals says in one node per value instead of three, so a set of up to 30
values fits the 32-node limit where the anyOf fit 10.
Extended in place in meta-schema v3 and parse_property_constraints 0:
every declaration valid before parses and evaluates as it did.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Warning Review limit reachedNext included review available in 18 minutes. View limit detailsLimit details: You’ve used the included review currently available. You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Review configuration: ⚙️ Run configurationConfiguration used: Repository: dashpay/platform/.coderabbit.yaml Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (11)
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 |
|
📖 Book Preview built successfully. Download the preview from the workflow artifacts. Updated at 2026-09-27T07:59:18.648Z |
|
🕓 Queued for automated review — 4th in line, estimated start in ~25 min (commit a3c5d73)
|
#5037 squash-merged into v4.2-dev as e8c4d1b, whose tree is identical to c8ccb09, the #5037 commit this branch is built on; every conflict resolved to this branch's side, which is that commit plus this PR's own changes. The merged tree equals 8c94d74's. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
#5038 squash-merged into v4.2-dev as b48edfe, whose tree is identical to 8c94d74, the #5038 commit this branch is built on; every conflict resolved to this branch's side, which is that commit plus this PR's own changes. The merged tree equals 19a7cd3's. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Basic explanation
What this does: A
propertyConstraintsrule can now check that a number is one of a list of allowed values:{ "in": ["fee", [0, 10, 25, 50]] }.Value: This was already possible as an
anyOfofequalcomparisons, but that costs 3 nodes per value plus 1. The limit of 32 nodes per rule therefore capped a set at 10 values.incosts one node per value plus 2, so a set can hold up to 30 values, and the rule reads as what it means.Risks: Low. This changes consensus validation, but only in protocol version 14, which is not on mainnet. It only widens what is accepted: every rule that registered before still registers and evaluates the same way.
Issue being fixed or feature implemented
A fixed set of allowed values is a common rule (fee tiers, lot sizes, integer enums), and the only way to write it hit the node limit at 10 values.
What was done?
Grammar
{ "in": [expression, [value, value, ...]] }is a new condition, next to the comparisons, and it nests underanyOf,allOfandnot:ifAbsentor arithmetic.1and1.0count as alike.Before, both of these were refused on registration (the meta-schema didn't know
in). Now:With
tieredFee, a fee of 25 is accepted and a fee of 20 is refused with 10422tieredFeeNotMet.Node cost, before and after, for the same 30-value set:
{ "anyOf": [{ "equal": ["kind", 1] }, { "equal": ["kind", 2] }, ...] } // 91 nodes: refused { "in": ["kind", [1, 2, ...]] } // 32 nodes: registersCode
property_constraints/mod.rs:PropertyConstraint::In { operand, values: BTreeSet<i128> }. It is parsed by the newin_values, which refuses duplicate values on every parse, since a set insertion finds them. Twoins listing the same values in another order are the same condition forrepeated_condition. Node count is 1 + the operand's nodes + one per value.inon thepropertyConstraintdef (prefixItemsof an expression and an integer array withminItems2 anduniqueItems), plus description updates.SystemLimits,DocumentTypeV2andPROPERTY_CONSTRAINTSdocs.How Has This Been Tested?
property_constraints/tests.rs:repeated_conditionmatch.try_from_schema/v3/property_constraints_tests.rs:inregisters, and its operand must read integer properties;batch/tests/document/property_constraints.rs: theofferfixture gainstieredFee, andshould_judge_an_in_against_its_listed_valuesruns real creates (one refused with 10422, one accepted).cargo test -p dpp --lib(4854 passed),cargo test -p drive-abci --lib property_constraints(11 passed),cargo clippy -p dpp --all-features --all-targets -- -D warnings,cargo clippy -p drive-abci --all-targets -- -D warnings.Breaking Changes
Consensus, protocol version 14 only: contracts may now register rules using
in, which earlier 4.2 builds refuse. Meta-schema v3,parse_property_constraints0 andvalidate_property_constraints0 were introduced in protocol version 14, which is not released on mainnet, so they are extended in place. Every declaration valid before parses and evaluates identically.Rust API:
PropertyConstraintgains theInvariant.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 ·
a3c5d73/skip-botsproceeds without the ones not yet reported/self-reviewedonce the bots are donejs-wasm-sdk(packages/js-evo-sdk/README.md) — shumkovdpp— you own itrs-drive-abci— you own itWhen every box is checked the
PR Hygienecheck passes and this can merge.