Skip to content

Conversation

@QuantumExplorer
Copy link
Member

@QuantumExplorer QuantumExplorer commented Jan 27, 2026

Issue being fixed or feature implemented

Implements V1 versions of DataContractCreateTransition and DataContractUpdateTransition that store contract fields directly rather than embedding the full DataContractInSerializationFormat. This is part of
Protocol Version 12.

Key problems solved:

  • V0 update transitions embed the entire contract even for small changes, wasting bandwidth and storage
  • V1 update transitions now use delta-based updates, only transmitting what changed
  • V1 create transitions store fields directly instead of embedding a serialization format

What was done?

New State Transition Versions

  • DataContractCreateTransitionV1: Stores contract fields directly (owner_id, config, schema_defs, document_schemas, groups, tokens, keywords, description) rather than embedding
    DataContractInSerializationFormat
  • DataContractUpdateTransitionV1: Delta-based updates with fields for:
    • updated_schema_defs / new_schema_defs
    • updated_document_schemas / new_document_schemas
    • new_groups, new_tokens
    • add_keywords / remove_keywords
    • update_description

New Methods

  • DataContractUpdateTransition::from_contract_update(old_contract, new_contract, nonce, platform_version) - Computes delta between old and new contracts for V1 transitions
  • DataContractUpdateTransition::from_data_contract_v0() - Explicit V0 transition creation for backwards compatibility
  • DataContract::apply_update() - Applies V1 delta updates to an existing contract

New Validation

  • basic_structure_v1 validation for V1 update transitions
  • transform_into_action_v1 for processing V1 transitions
  • New consensus errors: DataContractUpdateTransitionConflictingKeywordError, DataContractUpdateTransitionOverlappingFieldsError

Platform Version Updates

  • Added DRIVE_ABCI_VALIDATION_VERSIONS_V8 with transform_into_action: 1
  • Protocol Version 12 now defaults to V1 transitions (default_current_version: 1)

How Has This Been Tested?

  • Unit tests: 26 v0_tests, 10 v1_tests for data contract update validation
  • Integration tests: 5 data_contract_update_check_tx tests including:
    • data_contract_update_check_tx_first_protocol_version (V0)
    • data_contract_update_check_tx_protocol_version_11 (V0, fee: 27002504030)
    • data_contract_update_check_tx_latest_protocol_version (V1, fee: 27002430530)
    • Invalid update tests for both protocol versions
  • Strategy tests: run_chain_insert_one_new_identity_and_a_contract_with_updates
  • DPP tests: Serialization and basic property tests

Breaking Changes

  • DataContractUpdateTransitionAccessorsV0::data_contract() now returns Option<&DataContractInSerializationFormat> instead of &DataContractInSerializationFormat (V1 transitions don't embed the full contract)
  • new_from_data_contract() method now always creates V0 transitions since V1 requires both old and new contracts. Use from_contract_update() for V1 delta-based transitions.
  • Slightly different fee calculations for V1 transitions (27002430530 vs 27002504030 for V0)

Checklist:

  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have added or updated relevant unit/integration/functional/e2e tests
  • I have added "!" to the title and described breaking changes in the corresponding section if my code contains any
  • I have made corresponding changes to the documentation if needed

For repository code-owners and collaborators only

  • I have assigned this pull request to a milestone

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 27, 2026

Important

Review skipped

Too many files!

This PR contains 109 files, which is 9 over the limit of 100.

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

  • 🔍 Trigger a full review

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 and usage tips.

@github-actions github-actions bot added this to the v3.1.0 milestone Jan 27, 2026
@QuantumExplorer QuantumExplorer marked this pull request as ready for review January 28, 2026 21:15
@QuantumExplorer QuantumExplorer changed the title feat: better contract state transitions feat(platform): better contract state transitions Jan 28, 2026
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