diff --git a/packages/rs-drive-abci/src/execution/validation/state_transition/common/validate_identity_public_key_contract_bounds/mod.rs b/packages/rs-drive-abci/src/execution/validation/state_transition/common/validate_identity_public_key_contract_bounds/mod.rs index aabfec69beb..3476f891ed4 100644 --- a/packages/rs-drive-abci/src/execution/validation/state_transition/common/validate_identity_public_key_contract_bounds/mod.rs +++ b/packages/rs-drive-abci/src/execution/validation/state_transition/common/validate_identity_public_key_contract_bounds/mod.rs @@ -8,8 +8,10 @@ use crate::error::Error; use crate::error::execution::ExecutionError; use crate::execution::types::state_transition_execution_context::StateTransitionExecutionContext; use crate::execution::validation::state_transition::common::validate_identity_public_key_contract_bounds::v0::validate_identity_public_keys_contract_bounds_v0; +use crate::execution::validation::state_transition::common::validate_identity_public_key_contract_bounds::v1::validate_identity_public_keys_contract_bounds_v1; pub mod v0; +pub mod v1; pub(crate) fn validate_identity_public_keys_contract_bounds( identity_id: Identifier, @@ -34,9 +36,17 @@ pub(crate) fn validate_identity_public_keys_contract_bounds( execution_context, platform_version, ), + 1 => validate_identity_public_keys_contract_bounds_v1( + identity_id, + identity_public_keys_with_witness, + drive, + transaction, + execution_context, + platform_version, + ), version => Err(Error::Execution(ExecutionError::UnknownVersionMismatch { method: "validate_identity_public_keys_contract_bounds".to_string(), - known_versions: vec![0], + known_versions: vec![0, 1], received: version, })), } diff --git a/packages/rs-drive-abci/src/execution/validation/state_transition/common/validate_identity_public_key_contract_bounds/v1/mod.rs b/packages/rs-drive-abci/src/execution/validation/state_transition/common/validate_identity_public_key_contract_bounds/v1/mod.rs new file mode 100644 index 00000000000..ac68f06a3a1 --- /dev/null +++ b/packages/rs-drive-abci/src/execution/validation/state_transition/common/validate_identity_public_key_contract_bounds/v1/mod.rs @@ -0,0 +1,308 @@ +// v1: Fixes bug where DECRYPTION case was incorrectly calling +// requires_identity_encryption_bounded_key() instead of requires_identity_decryption_bounded_key() +// for SingleContractDocumentType bounds validation. + +use crate::error::Error; +use crate::execution::types::state_transition_execution_context::StateTransitionExecutionContext; +use dpp::consensus::basic::document::{ + DataContractNotPresentError, InvalidDocumentTypeError, +}; +use dpp::consensus::basic::identity::{DataContractBoundsNotPresentError, InvalidKeyPurposeForContractBoundsError}; +use dpp::consensus::basic::BasicError; +use dpp::consensus::ConsensusError; +use dpp::consensus::state::identity::identity_public_key_already_exists_for_unique_contract_bounds_error::IdentityPublicKeyAlreadyExistsForUniqueContractBoundsError; +use dpp::consensus::state::state_error::StateError; +use dpp::data_contract::accessors::v0::DataContractV0Getters; +use dpp::data_contract::config::v0::DataContractConfigGettersV0; +use dpp::data_contract::document_type::accessors::DocumentTypeV0Getters; +use dpp::data_contract::storage_requirements::keys_for_document_type::StorageKeyRequirements; +use dpp::identifier::Identifier; +use dpp::identity::contract_bounds::ContractBounds; +use dpp::identity::identity_public_key::accessors::v0::IdentityPublicKeyGettersV0; +use dpp::identity::Purpose::{DECRYPTION, ENCRYPTION}; +use dpp::state_transition::public_key_in_creation::accessors::IdentityPublicKeyInCreationV0Getters; +use dpp::state_transition::public_key_in_creation::IdentityPublicKeyInCreation; +use dpp::validation::SimpleConsensusValidationResult; +use dpp::version::PlatformVersion; +use drive::drive::Drive; +use drive::drive::identity::key::fetch::{IdentityKeysRequest, KeyKindRequestType, KeyRequestType, OptionalSingleIdentityPublicKeyOutcome}; +use drive::grovedb::TransactionArg; + +pub(super) fn validate_identity_public_keys_contract_bounds_v1( + identity_id: Identifier, + identity_public_keys_with_witness: &[IdentityPublicKeyInCreation], + drive: &Drive, + transaction: TransactionArg, + execution_context: &mut StateTransitionExecutionContext, + platform_version: &PlatformVersion, +) -> Result { + let consensus_validation_results = identity_public_keys_with_witness + .iter() + .map(|identity_public_key| { + validate_identity_public_key_contract_bounds_v1( + identity_id, + identity_public_key, + drive, + transaction, + execution_context, + platform_version, + ) + }) + .collect::, Error>>()?; + Ok(SimpleConsensusValidationResult::merge_many_errors( + consensus_validation_results, + )) +} + +fn validate_identity_public_key_contract_bounds_v1( + identity_id: Identifier, + identity_public_key_in_creation: &IdentityPublicKeyInCreation, + drive: &Drive, + transaction: TransactionArg, + _execution_context: &mut StateTransitionExecutionContext, + platform_version: &PlatformVersion, +) -> Result { + //todo: we should add to the execution context the cost of fetching contracts + let purpose = identity_public_key_in_creation.purpose(); + if let Some(contract_bounds) = identity_public_key_in_creation.contract_bounds() { + match contract_bounds { + ContractBounds::SingleContract { id: contract_id } => { + // we should fetch the contract + let contract = drive.get_contract_with_fetch_info( + contract_id.to_buffer(), + false, + transaction, + platform_version, + )?; + match contract { + None => Ok(SimpleConsensusValidationResult::new_with_error( + ConsensusError::BasicError(BasicError::DataContractNotPresentError( + DataContractNotPresentError::new(*contract_id), + )), + )), + Some(contract) => { + match purpose { + ENCRYPTION => { + let Some(requirements) = contract + .contract + .config() + .requires_identity_encryption_bounded_key() + else { + return Ok(SimpleConsensusValidationResult::new_with_error( + ConsensusError::BasicError( + BasicError::DataContractBoundsNotPresentError( + DataContractBoundsNotPresentError::new( + *contract_id, + ), + ), + ), + )); + }; + + match requirements { + // We should make sure no other key exists for these bounds + StorageKeyRequirements::Unique => { + let key_request = IdentityKeysRequest { + identity_id: identity_id.to_buffer(), + request_type: KeyRequestType::ContractBoundKey( + contract_id.to_buffer(), + purpose, + KeyKindRequestType::CurrentKeyOfKindRequest, + ), + limit: None, + offset: None, + }; + let maybe_conflicting_key = drive.fetch_identity_keys::(key_request, transaction, platform_version)?; + if let Some(conflicting_key) = maybe_conflicting_key { + Ok(SimpleConsensusValidationResult::new_with_error(ConsensusError::StateError(StateError::IdentityPublicKeyAlreadyExistsForUniqueContractBoundsError(IdentityPublicKeyAlreadyExistsForUniqueContractBoundsError::new(identity_id, *contract_id, purpose, identity_public_key_in_creation.id(), conflicting_key.id()))))) + } else { + Ok(SimpleConsensusValidationResult::new()) + } + } + StorageKeyRequirements::Multiple + | StorageKeyRequirements::MultipleReferenceToLatest => { + Ok(SimpleConsensusValidationResult::new()) + } + } + } + DECRYPTION => { + let Some(requirements) = contract + .contract + .config() + .requires_identity_decryption_bounded_key() + else { + return Ok(SimpleConsensusValidationResult::new_with_error( + ConsensusError::BasicError( + BasicError::DataContractBoundsNotPresentError( + DataContractBoundsNotPresentError::new( + *contract_id, + ), + ), + ), + )); + }; + + match requirements { + StorageKeyRequirements::Unique => { + // We should make sure no other key exists for these bounds + let key_request = IdentityKeysRequest { + identity_id: identity_id.to_buffer(), + request_type: KeyRequestType::ContractBoundKey( + contract_id.to_buffer(), + purpose, + KeyKindRequestType::CurrentKeyOfKindRequest, + ), + limit: None, + offset: None, + }; + let maybe_conflicting_key = drive.fetch_identity_keys::(key_request, transaction, platform_version)?; + if let Some(conflicting_key) = maybe_conflicting_key { + Ok(SimpleConsensusValidationResult::new_with_error(ConsensusError::StateError(StateError::IdentityPublicKeyAlreadyExistsForUniqueContractBoundsError(IdentityPublicKeyAlreadyExistsForUniqueContractBoundsError::new(identity_id, *contract_id, purpose, identity_public_key_in_creation.id(), conflicting_key.id()))))) + } else { + Ok(SimpleConsensusValidationResult::new()) + } + } + StorageKeyRequirements::Multiple + | StorageKeyRequirements::MultipleReferenceToLatest => { + Ok(SimpleConsensusValidationResult::new()) + } + } + } + purpose => Ok(SimpleConsensusValidationResult::new_with_error( + ConsensusError::BasicError( + BasicError::InvalidKeyPurposeForContractBoundsError( + InvalidKeyPurposeForContractBoundsError::new( + purpose, + vec![ENCRYPTION, DECRYPTION], + ), + ), + ), + )), + } + } + } + } + ContractBounds::SingleContractDocumentType { + id: contract_id, + document_type_name, + } => { + let contract = drive.get_contract_with_fetch_info( + contract_id.to_buffer(), + false, + transaction, + platform_version, + )?; + match contract { + None => Ok(SimpleConsensusValidationResult::new_with_error( + ConsensusError::BasicError(BasicError::DataContractNotPresentError( + DataContractNotPresentError::new(*contract_id), + )), + )), + Some(contract) => { + let document_type = contract + .contract + .document_type_optional_for_name(document_type_name.as_str()); + match document_type { + None => Ok(SimpleConsensusValidationResult::new_with_error( + ConsensusError::BasicError(BasicError::InvalidDocumentTypeError( + InvalidDocumentTypeError::new( + document_type_name.clone(), + *contract_id, + ), + )), + )), + Some(document_type) => { + match purpose { + ENCRYPTION => { + let Some(requirements) = document_type + .requires_identity_encryption_bounded_key() + else { + return Ok(SimpleConsensusValidationResult::new_with_error( + ConsensusError::BasicError( + BasicError::DataContractBoundsNotPresentError( + DataContractBoundsNotPresentError::new(*contract_id), + ), + ), + )); + }; + + match requirements { + StorageKeyRequirements::Unique => { + // We should make sure no other key exists for these bounds + let key_request = IdentityKeysRequest { + identity_id: identity_id.to_buffer(), + request_type: KeyRequestType::ContractDocumentTypeBoundKey(contract_id.to_buffer(), document_type_name.clone(), purpose, KeyKindRequestType::CurrentKeyOfKindRequest), + limit: None, + offset: None, + }; + let maybe_conflicting_key = drive.fetch_identity_keys::(key_request, transaction, platform_version)?; + if let Some(conflicting_key) = maybe_conflicting_key + { + Ok(SimpleConsensusValidationResult::new_with_error(ConsensusError::StateError(StateError::IdentityPublicKeyAlreadyExistsForUniqueContractBoundsError(IdentityPublicKeyAlreadyExistsForUniqueContractBoundsError::new(identity_id, *contract_id, purpose, identity_public_key_in_creation.id(), conflicting_key.id()))))) + } else { + Ok(SimpleConsensusValidationResult::new()) + } + } + StorageKeyRequirements::Multiple + | StorageKeyRequirements::MultipleReferenceToLatest => { + Ok(SimpleConsensusValidationResult::new()) + } + } + } + DECRYPTION => { + // v1 fix: Use requires_identity_decryption_bounded_key() for DECRYPTION + let Some(requirements) = document_type + .requires_identity_decryption_bounded_key() + else { + return Ok(SimpleConsensusValidationResult::new_with_error( + ConsensusError::BasicError( + BasicError::DataContractBoundsNotPresentError( + DataContractBoundsNotPresentError::new(*contract_id), + ), + ), + )); + }; + + match requirements { + StorageKeyRequirements::Unique => { + let key_request = IdentityKeysRequest { + identity_id: identity_id.to_buffer(), + request_type: KeyRequestType::ContractDocumentTypeBoundKey(contract_id.to_buffer(), document_type_name.clone(), purpose, KeyKindRequestType::CurrentKeyOfKindRequest), + limit: None, + offset: None, + }; + let maybe_conflicting_key = drive.fetch_identity_keys::(key_request, transaction, platform_version)?; + if let Some(conflicting_key) = maybe_conflicting_key + { + Ok(SimpleConsensusValidationResult::new_with_error(ConsensusError::StateError(StateError::IdentityPublicKeyAlreadyExistsForUniqueContractBoundsError(IdentityPublicKeyAlreadyExistsForUniqueContractBoundsError::new(identity_id, *contract_id, purpose, identity_public_key_in_creation.id(), conflicting_key.id()))))) + } else { + Ok(SimpleConsensusValidationResult::new()) + } + } + StorageKeyRequirements::Multiple + | StorageKeyRequirements::MultipleReferenceToLatest => { + Ok(SimpleConsensusValidationResult::new()) + } + } + } + _ => Ok(SimpleConsensusValidationResult::new_with_error( + ConsensusError::BasicError( + BasicError::InvalidKeyPurposeForContractBoundsError( + InvalidKeyPurposeForContractBoundsError::new( + purpose, + vec![ENCRYPTION, DECRYPTION], + ), + ), + ), + )), + } + } + } + } + } + } + } + } else { + Ok(SimpleConsensusValidationResult::new()) + } +} diff --git a/packages/rs-platform-version/src/version/drive_abci_versions/drive_abci_validation_versions/mod.rs b/packages/rs-platform-version/src/version/drive_abci_versions/drive_abci_validation_versions/mod.rs index 23163606246..fc8364f8201 100644 --- a/packages/rs-platform-version/src/version/drive_abci_versions/drive_abci_validation_versions/mod.rs +++ b/packages/rs-platform-version/src/version/drive_abci_versions/drive_abci_validation_versions/mod.rs @@ -5,6 +5,7 @@ pub mod v4; pub mod v5; pub mod v6; pub mod v7; +pub mod v8; use versioned_feature_core::{FeatureVersion, OptionalFeatureVersion}; diff --git a/packages/rs-platform-version/src/version/drive_abci_versions/drive_abci_validation_versions/v8.rs b/packages/rs-platform-version/src/version/drive_abci_versions/drive_abci_validation_versions/v8.rs new file mode 100644 index 00000000000..ae41e0b6dd6 --- /dev/null +++ b/packages/rs-platform-version/src/version/drive_abci_versions/drive_abci_validation_versions/v8.rs @@ -0,0 +1,222 @@ +use crate::version::drive_abci_versions::drive_abci_validation_versions::{ + DriveAbciAssetLockValidationVersions, DriveAbciDocumentsStateTransitionValidationVersions, + DriveAbciStateTransitionCommonValidationVersions, DriveAbciStateTransitionValidationVersion, + DriveAbciStateTransitionValidationVersions, DriveAbciValidationConstants, + DriveAbciValidationDataTriggerAndBindingVersions, DriveAbciValidationDataTriggerVersions, + DriveAbciValidationVersions, PenaltyAmounts, +}; + +// Fix for validate_identity_public_key_contract_bounds where DECRYPTION case was incorrectly +// calling requires_identity_encryption_bounded_key() instead of requires_identity_decryption_bounded_key() +pub const DRIVE_ABCI_VALIDATION_VERSIONS_V8: DriveAbciValidationVersions = + DriveAbciValidationVersions { + state_transitions: DriveAbciStateTransitionValidationVersions { + common_validation_methods: DriveAbciStateTransitionCommonValidationVersions { + asset_locks: DriveAbciAssetLockValidationVersions { + fetch_asset_lock_transaction_output_sync: 0, + verify_asset_lock_is_not_spent_and_has_enough_balance: 0, + }, + validate_identity_public_key_contract_bounds: 1, // Changed from 0 to 1 to fix decryption bounded key bug + validate_identity_public_key_ids_dont_exist_in_state: 0, + validate_identity_public_key_ids_exist_in_state: 0, + validate_state_transition_identity_signed: 0, + validate_unique_identity_public_key_hashes_in_state: 1, + validate_master_key_uniqueness: 0, + validate_non_masternode_identity_exists: 0, + validate_identity_exists: 0, + }, + max_asset_lock_usage_attempts: 16, + identity_create_state_transition: DriveAbciStateTransitionValidationVersion { + basic_structure: Some(0), + advanced_structure: Some(0), + identity_signatures: Some(0), + nonce: None, + state: 0, + transform_into_action: 0, + }, + identity_update_state_transition: DriveAbciStateTransitionValidationVersion { + basic_structure: Some(0), + advanced_structure: Some(0), + identity_signatures: Some(0), + nonce: Some(0), + state: 0, + transform_into_action: 0, + }, + identity_top_up_state_transition: DriveAbciStateTransitionValidationVersion { + basic_structure: Some(0), + advanced_structure: None, + identity_signatures: None, + nonce: None, + state: 0, + transform_into_action: 0, + }, + identity_credit_withdrawal_state_transition: + DriveAbciStateTransitionValidationVersion { + basic_structure: Some(1), + advanced_structure: None, + identity_signatures: None, + nonce: Some(0), + state: 0, + transform_into_action: 0, + }, + identity_credit_withdrawal_state_transition_purpose_matches_requirements: 0, + identity_credit_transfer_state_transition: DriveAbciStateTransitionValidationVersion { + basic_structure: Some(0), + advanced_structure: None, + identity_signatures: None, + nonce: Some(0), + state: 0, + transform_into_action: 0, + }, + identity_credit_transfer_to_addresses_state_transition: + DriveAbciStateTransitionValidationVersion { + basic_structure: Some(0), + advanced_structure: None, + identity_signatures: None, + nonce: Some(0), + state: 0, + transform_into_action: 0, + }, + masternode_vote_state_transition: DriveAbciStateTransitionValidationVersion { + basic_structure: None, + advanced_structure: Some(0), + identity_signatures: None, + nonce: Some(1), + state: 0, + transform_into_action: 0, + }, + masternode_vote_state_transition_balance_pre_check: 0, + contract_create_state_transition: DriveAbciStateTransitionValidationVersion { + basic_structure: Some(0), + advanced_structure: Some(1), + identity_signatures: None, + nonce: Some(0), + state: 0, + transform_into_action: 0, + }, + contract_update_state_transition: DriveAbciStateTransitionValidationVersion { + basic_structure: Some(0), + advanced_structure: None, + identity_signatures: None, + nonce: Some(0), + state: 0, + transform_into_action: 0, + }, + batch_state_transition: DriveAbciDocumentsStateTransitionValidationVersions { + basic_structure: 0, + advanced_structure: 0, + state: 0, + revision: 0, + transform_into_action: 0, + data_triggers: DriveAbciValidationDataTriggerAndBindingVersions { + bindings: 0, + triggers: DriveAbciValidationDataTriggerVersions { + create_contact_request_data_trigger: 0, + create_domain_data_trigger: 0, + create_identity_data_trigger: 0, + create_feature_flag_data_trigger: 0, + create_masternode_reward_shares_data_trigger: 0, + delete_withdrawal_data_trigger: 0, + reject_data_trigger: 0, + }, + }, + is_allowed: 0, + document_create_transition_structure_validation: 0, + document_delete_transition_structure_validation: 0, + document_replace_transition_structure_validation: 0, + document_transfer_transition_structure_validation: 0, + document_purchase_transition_structure_validation: 0, + document_update_price_transition_structure_validation: 0, + document_base_transition_state_validation: 0, + document_create_transition_state_validation: 1, + document_delete_transition_state_validation: 0, + document_replace_transition_state_validation: 0, + document_transfer_transition_state_validation: 0, + document_purchase_transition_state_validation: 0, + document_update_price_transition_state_validation: 0, + token_mint_transition_structure_validation: 0, + token_burn_transition_structure_validation: 0, + token_transfer_transition_structure_validation: 0, + token_mint_transition_state_validation: 0, + token_burn_transition_state_validation: 0, + token_transfer_transition_state_validation: 0, + token_base_transition_structure_validation: 0, + token_base_transition_state_validation: 0, + token_freeze_transition_structure_validation: 0, + token_unfreeze_transition_structure_validation: 0, + token_freeze_transition_state_validation: 0, + token_unfreeze_transition_state_validation: 0, + token_destroy_frozen_funds_transition_structure_validation: 0, + token_destroy_frozen_funds_transition_state_validation: 0, + token_emergency_action_transition_structure_validation: 0, + token_emergency_action_transition_state_validation: 0, + token_config_update_transition_structure_validation: 0, + token_config_update_transition_state_validation: 0, + token_base_transition_group_action_validation: 0, + token_claim_transition_structure_validation: 0, + token_claim_transition_state_validation: 0, + token_direct_purchase_transition_structure_validation: 0, + token_direct_purchase_transition_state_validation: 0, + token_set_price_for_direct_purchase_transition_structure_validation: 0, + token_set_price_for_direct_purchase_transition_state_validation: 0, + }, + identity_create_from_addresses_state_transition: + DriveAbciStateTransitionValidationVersion { + basic_structure: Some(0), + advanced_structure: Some(0), + identity_signatures: Some(0), + nonce: Some(0), + state: 0, + transform_into_action: 0, + }, + identity_top_up_from_addresses_state_transition: + DriveAbciStateTransitionValidationVersion { + basic_structure: Some(0), + advanced_structure: None, + identity_signatures: None, + nonce: Some(0), + state: 0, + transform_into_action: 0, + }, + address_credit_withdrawal: DriveAbciStateTransitionValidationVersion { + basic_structure: Some(0), + advanced_structure: None, + identity_signatures: None, + nonce: Some(0), + state: 0, + transform_into_action: 0, + }, + address_funds_from_asset_lock: DriveAbciStateTransitionValidationVersion { + basic_structure: Some(0), + advanced_structure: Some(0), + identity_signatures: None, + nonce: Some(0), + state: 0, + transform_into_action: 0, + }, + address_funds_transfer: DriveAbciStateTransitionValidationVersion { + basic_structure: Some(0), + advanced_structure: None, + identity_signatures: None, + nonce: Some(0), + state: 0, + transform_into_action: 0, + }, + }, + has_nonce_validation: 1, + has_address_witness_validation: 0, + validate_address_witnesses: 0, + process_state_transition: 0, + state_transition_to_execution_event_for_check_tx: 0, + penalties: PenaltyAmounts { + identity_id_not_correct: 50000000, + unique_key_already_present: 10000000, + validation_of_added_keys_structure_failure: 10000000, + validation_of_added_keys_proof_of_possession_failure: 50000000, + address_funds_insufficient_balance: 10000000, + }, + event_constants: DriveAbciValidationConstants { + maximum_vote_polls_to_process: 2, + maximum_contenders_to_consider: 100, + }, + }; diff --git a/packages/rs-platform-version/src/version/mod.rs b/packages/rs-platform-version/src/version/mod.rs index 7e30d38fbea..38ba95f577b 100644 --- a/packages/rs-platform-version/src/version/mod.rs +++ b/packages/rs-platform-version/src/version/mod.rs @@ -1,6 +1,6 @@ mod protocol_version; -use crate::version::v11::PROTOCOL_VERSION_11; +use crate::version::v12::PROTOCOL_VERSION_12; pub use protocol_version::*; use std::ops::RangeInclusive; @@ -17,6 +17,7 @@ mod system_limits; pub mod v1; pub mod v10; pub mod v11; +pub mod v12; pub mod v2; pub mod v3; pub mod v4; @@ -30,5 +31,5 @@ pub type ProtocolVersion = u32; pub const ALL_VERSIONS: RangeInclusive = 1..=LATEST_VERSION; -pub const LATEST_VERSION: ProtocolVersion = PROTOCOL_VERSION_11; +pub const LATEST_VERSION: ProtocolVersion = PROTOCOL_VERSION_12; pub const INITIAL_PROTOCOL_VERSION: ProtocolVersion = 1; diff --git a/packages/rs-platform-version/src/version/protocol_version.rs b/packages/rs-platform-version/src/version/protocol_version.rs index 366b3158b27..16c5b194b5a 100644 --- a/packages/rs-platform-version/src/version/protocol_version.rs +++ b/packages/rs-platform-version/src/version/protocol_version.rs @@ -27,6 +27,7 @@ use crate::version::v8::PLATFORM_V8; use crate::version::v9::PLATFORM_V9; use crate::version::v11::PLATFORM_V11; +use crate::version::v12::PLATFORM_V12; use crate::version::ProtocolVersion; pub use versioned_feature_core::*; @@ -54,6 +55,7 @@ pub const PLATFORM_VERSIONS: &[PlatformVersion] = &[ PLATFORM_V9, PLATFORM_V10, PLATFORM_V11, + PLATFORM_V12, ]; #[cfg(feature = "mock-versions")] @@ -62,7 +64,7 @@ pub static PLATFORM_TEST_VERSIONS: OnceLock> = OnceLock::ne #[cfg(feature = "mock-versions")] const DEFAULT_PLATFORM_TEST_VERSIONS: &[PlatformVersion] = &[TEST_PLATFORM_V2, TEST_PLATFORM_V3]; -pub const LATEST_PLATFORM_VERSION: &PlatformVersion = &PLATFORM_V11; +pub const LATEST_PLATFORM_VERSION: &PlatformVersion = &PLATFORM_V12; pub const DESIRED_PLATFORM_VERSION: &PlatformVersion = LATEST_PLATFORM_VERSION; diff --git a/packages/rs-platform-version/src/version/v12.rs b/packages/rs-platform-version/src/version/v12.rs new file mode 100644 index 00000000000..2e5382741aa --- /dev/null +++ b/packages/rs-platform-version/src/version/v12.rs @@ -0,0 +1,69 @@ +use crate::version::consensus_versions::ConsensusVersions; +use crate::version::dpp_versions::dpp_asset_lock_versions::v1::DPP_ASSET_LOCK_VERSIONS_V1; +use crate::version::dpp_versions::dpp_contract_versions::v3::CONTRACT_VERSIONS_V3; +use crate::version::dpp_versions::dpp_costs_versions::v1::DPP_COSTS_VERSIONS_V1; +use crate::version::dpp_versions::dpp_document_versions::v3::DOCUMENT_VERSIONS_V3; +use crate::version::dpp_versions::dpp_factory_versions::v1::DPP_FACTORY_VERSIONS_V1; +use crate::version::dpp_versions::dpp_identity_versions::v1::IDENTITY_VERSIONS_V1; +use crate::version::dpp_versions::dpp_method_versions::v2::DPP_METHOD_VERSIONS_V2; +use crate::version::dpp_versions::dpp_state_transition_conversion_versions::v2::STATE_TRANSITION_CONVERSION_VERSIONS_V2; +use crate::version::dpp_versions::dpp_state_transition_method_versions::v1::STATE_TRANSITION_METHOD_VERSIONS_V1; +use crate::version::dpp_versions::dpp_state_transition_serialization_versions::v2::STATE_TRANSITION_SERIALIZATION_VERSIONS_V2; +use crate::version::dpp_versions::dpp_state_transition_versions::v3::STATE_TRANSITION_VERSIONS_V3; +use crate::version::dpp_versions::dpp_token_versions::v1::TOKEN_VERSIONS_V1; +use crate::version::dpp_versions::dpp_validation_versions::v2::DPP_VALIDATION_VERSIONS_V2; +use crate::version::dpp_versions::dpp_voting_versions::v2::VOTING_VERSION_V2; +use crate::version::dpp_versions::DPPVersion; +use crate::version::drive_abci_versions::drive_abci_checkpoint_parameters::v1::DRIVE_ABCI_CHECKPOINT_PARAMETERS_V1; +use crate::version::drive_abci_versions::drive_abci_method_versions::v7::DRIVE_ABCI_METHOD_VERSIONS_V7; +use crate::version::drive_abci_versions::drive_abci_query_versions::v1::DRIVE_ABCI_QUERY_VERSIONS_V1; +use crate::version::drive_abci_versions::drive_abci_structure_versions::v1::DRIVE_ABCI_STRUCTURE_VERSIONS_V1; +use crate::version::drive_abci_versions::drive_abci_validation_versions::v8::DRIVE_ABCI_VALIDATION_VERSIONS_V8; +use crate::version::drive_abci_versions::drive_abci_withdrawal_constants::v2::DRIVE_ABCI_WITHDRAWAL_CONSTANTS_V2; +use crate::version::drive_abci_versions::DriveAbciVersion; +use crate::version::drive_versions::v6::DRIVE_VERSION_V6; +use crate::version::fee::v2::FEE_VERSION2; +use crate::version::protocol_version::PlatformVersion; +use crate::version::system_data_contract_versions::v1::SYSTEM_DATA_CONTRACT_VERSIONS_V1; +use crate::version::system_limits::v1::SYSTEM_LIMITS_V1; +use crate::version::ProtocolVersion; + +pub const PROTOCOL_VERSION_12: ProtocolVersion = 12; + +/// This version fixes validate_identity_public_key_contract_bounds for DECRYPTION case +/// where it was incorrectly calling requires_identity_encryption_bounded_key() +/// instead of requires_identity_decryption_bounded_key() +pub const PLATFORM_V12: PlatformVersion = PlatformVersion { + protocol_version: PROTOCOL_VERSION_12, + drive: DRIVE_VERSION_V6, + drive_abci: DriveAbciVersion { + structs: DRIVE_ABCI_STRUCTURE_VERSIONS_V1, + methods: DRIVE_ABCI_METHOD_VERSIONS_V7, + validation_and_processing: DRIVE_ABCI_VALIDATION_VERSIONS_V8, // Changed to V8 for validate_identity_public_key_contract_bounds fix + withdrawal_constants: DRIVE_ABCI_WITHDRAWAL_CONSTANTS_V2, + query: DRIVE_ABCI_QUERY_VERSIONS_V1, + checkpoints: DRIVE_ABCI_CHECKPOINT_PARAMETERS_V1, + }, + dpp: DPPVersion { + costs: DPP_COSTS_VERSIONS_V1, + validation: DPP_VALIDATION_VERSIONS_V2, + state_transition_serialization_versions: STATE_TRANSITION_SERIALIZATION_VERSIONS_V2, + state_transition_conversion_versions: STATE_TRANSITION_CONVERSION_VERSIONS_V2, + state_transition_method_versions: STATE_TRANSITION_METHOD_VERSIONS_V1, + state_transitions: STATE_TRANSITION_VERSIONS_V3, + contract_versions: CONTRACT_VERSIONS_V3, + document_versions: DOCUMENT_VERSIONS_V3, + identity_versions: IDENTITY_VERSIONS_V1, + voting_versions: VOTING_VERSION_V2, + token_versions: TOKEN_VERSIONS_V1, + asset_lock_versions: DPP_ASSET_LOCK_VERSIONS_V1, + methods: DPP_METHOD_VERSIONS_V2, + factory_versions: DPP_FACTORY_VERSIONS_V1, + }, + system_data_contracts: SYSTEM_DATA_CONTRACT_VERSIONS_V1, + fee_version: FEE_VERSION2, + system_limits: SYSTEM_LIMITS_V1, + consensus: ConsensusVersions { + tenderdash_consensus_version: 1, + }, +};