Repository navigation
Backlog
Description
#6422 adds DocumentTypeDefinition, a typed form of a document type's schema (packages/rs-dpp/src/data_contract/document_type/definition/). Nothing in consensus uses it yet. Its sixth review round had no blocking finding and left these suggestions, which belong to the pull requests that build on it rather than to another round on #6422. This issue tracks them so they are picked up there.
For the pull request that applies registration's rules to a definition
These are places where a definition reads a value registration refuses. #6422 holds a keyword to the type of its value (a name or code is one the keyword has, an id is 32 bytes) and leaves rules about which values go together to registration, so each of these is a rule to apply to the typed form, with a test against registration beside it.
- The second operand of a requirement condition's
contains(thread).TypeCondition::Containstakes aConditionValue, which admits$kind; registration admits$propertyor a{ "const": ... }there (native_schema/references.rs,slot_condition). - A list of reference targets (same thread).
Reference::targettakes anyReferenceTargetin a list; registration admits a list only on a reference that names its target through the referring document, and only ofpermanentDocumentandmoderatedDocument(reference_kind_list). - A contract id written as text (thread).
ContractId::Texttakes any string; registration reads$self.<property>or a Base58 id that decodes to 32 bytes (parse_document_reference_type, throughValue::to_identifier). A typed form could tell the two apart and hold the id to its width, keeping both spellings a schema writes.
For the pull request that carries a definition in a contract format
- A size budget for decoding (thread). The standalone decoders of
DocumentTypeDefinitionandSchemaDefinitionsdecode under the platform bincode configuration, which has no size limit; nesting is bounded, width is not. The format that carries a definition is bounded by the state transition's size, and should state its own budget for a definition decoded on its own. Until then the module documentation should say the standalone decoders impose none. - One form for the carrying format's bytes. Already recorded in the module documentation: the check that a definition's bytes are the ones it encodes to sits on its standalone decoder, so a format that embeds a definition must hold its own bytes to one form at its own boundary.
Small
SortedMapdecoding (thread). Decoding a contract's$defsstages the entries in a vector, moves them into aBTreeMapand clones each name to compare it with the next. It could keep the decoded vector, check the order on borrowed neighbours and look a name up by binary search, with the same bytes.
Related
- The definition and schema depth limits disagree in both directions #6426: one depth boundary for a definition and a schema, to settle before stored contracts are migrated.
- feat(platform)!: delta-based data contract update transition for protocol version 15 #4730: delta contract updates, which will carry definitions for the document types an update adds or replaces.
Metadata
Metadata
Assignees
Labels
No labels
Activity
QuantumExplorer commentedon Dec 1, 2026
One more item for the pull request that makes the last in-place change to the grammar before protocol version 16 ships.
Mark the grammar's declarations
// @append_only. #6422 now says the definition grows by appending: a keyword added later goes at the end of its group and is available from a protocol version, instead of a new generation. A test pins every position (definition/v0/layout.rs), but the declarations (keywords!,names!,codes!,shapes!and the derived enums of the rule language) do not carry the CI marker yet, because "Detect immutable structure changes" would refuse the changes listed above, which alter the type a keyword or a variant holds. Once those are in, each declaration gets the marker, so CI refuses a removed, renamed, reordered or retyped entry whatever the pull request does to the pinned list.Also for the first keyword added after protocol version 16: it has to bring the check of the version it is available from, at the point where the carrying format is decoded, so that a node refuses it below that version as a node built before it does.
QuantumExplorer commentedon Dec 1, 2026
Correction to the item above, after the review of #6422: the marker goes on the pinned list itself,
PINNEDindefinition/v0/layout.rs, as the last step before a protocol version that carries definitions ships.Every line of the list carries its position and the types of what it holds, so against the base branch the CI check then refuses a removed, renamed, reordered or retyped entry, and also a keyword put in the middle, since that renumbers the lines behind it. On the declarations alone the check would miss a pure insertion.
PINNEDis the last item of its file, which is what the check's block extraction needs for a block without braces: keep it last, and confirm the check sees the list in the pull request that adds the marker.QuantumExplorer commentedon Dec 1, 2026
With the step above (marking
PINNEDfor the CI check), from the last review round of #6422 (thread):should_pin_no_type_by_an_aliasindefinition/v0/layout.rsfinds aliases bypub typeat the start of a line. Make it find an alias of any visibility (pub(crate) type,pub(super) type,type) declared in the grammar's files, so a keyword pinned through one cannot change what it holds with its line unchanged. No such alias exists today.