From 5b9b3dbe5f97e92858fdbe733d526687c654a4e0 Mon Sep 17 00:00:00 2001 From: Quantum Explorer Date: Wed, 17 Jul 2024 13:01:23 +0700 Subject: [PATCH 1/2] feat(platform)!: max field size and some clean up of versioning --- .../methods/validate_document/v0/mod.rs | 22 ++- .../src/errors/consensus/basic/basic_error.rs | 17 +- .../document_field_max_size_exceeded_error.rs | 51 +++++ .../errors/consensus/basic/document/mod.rs | 2 + packages/rs-dpp/src/errors/consensus/codes.rs | 1 + packages/rs-dpp/src/fee/epoch/mod.rs | 1 - packages/rs-dpp/src/identity/mod.rs | 1 - packages/rs-dpp/src/identity/versions.rs | 33 ---- .../v0/v0_methods.rs | 4 +- .../validate_basic_structure/v0/mod.rs | 6 +- .../identity_create_transition/v0/mod.rs | 2 - .../src/abci/handler/process_proposal.rs | 1 - .../decode_raw_state_transitions/v0/mod.rs | 10 +- .../data_contract_update/mod.rs | 2 - .../state_transitions/documents_batch/mod.rs | 128 ++++++++++++- .../identity_credit_withdrawal/mod.rs | 3 +- .../state_transitions/masternode_vote/mod.rs | 1 - .../dashpay-contract-no-max-length.json | 120 ++++++++++++ packages/rs-drive/src/drive/constants.rs | 8 - .../v0/mod.rs | 7 +- .../fetch/fetch_by_public_key_hashes/mod.rs | 6 +- .../src/drive/identity/key/fetch/mod.rs | 4 - packages/rs-platform-value/src/lib.rs | 174 ++++++++++++++++++ .../src/version/dpp_versions.rs | 2 - .../src/version/drive_versions.rs | 6 - .../rs-platform-version/src/version/limits.rs | 7 + .../src/version/mocks/v2_test.rs | 23 +-- .../src/version/mocks/v3_test.rs | 23 +-- .../rs-platform-version/src/version/mod.rs | 1 + .../src/version/protocol_version.rs | 9 +- .../rs-platform-version/src/version/v1.rs | 23 +-- .../src/errors/consensus/consensus_error.rs | 5 +- 32 files changed, 551 insertions(+), 152 deletions(-) create mode 100644 packages/rs-dpp/src/errors/consensus/basic/document/document_field_max_size_exceeded_error.rs delete mode 100644 packages/rs-dpp/src/identity/versions.rs create mode 100644 packages/rs-drive-abci/tests/supporting_files/contract/dashpay/dashpay-contract-no-max-length.json create mode 100644 packages/rs-platform-version/src/version/limits.rs diff --git a/packages/rs-dpp/src/data_contract/methods/validate_document/v0/mod.rs b/packages/rs-dpp/src/data_contract/methods/validate_document/v0/mod.rs index 423f5375696..e7d10410226 100644 --- a/packages/rs-dpp/src/data_contract/methods/validate_document/v0/mod.rs +++ b/packages/rs-dpp/src/data_contract/methods/validate_document/v0/mod.rs @@ -2,7 +2,9 @@ use crate::data_contract::accessors::v0::DataContractV0Getters; use crate::data_contract::document_type::accessors::DocumentTypeV0Getters; use crate::data_contract::document_type::{DocumentType, DocumentTypeRef}; -use crate::consensus::basic::document::{InvalidDocumentTypeError, MissingDocumentTypeError}; +use crate::consensus::basic::document::{ + DocumentFieldMaxSizeExceededError, InvalidDocumentTypeError, MissingDocumentTypeError, +}; use crate::consensus::basic::BasicError; use crate::consensus::ConsensusError; use crate::data_contract::schema::DataContractSchemaMethodsV0; @@ -48,6 +50,24 @@ impl DataContract { DocumentTypeRef::V0(v0) => v0.json_schema_validator.deref(), }; + if let Some((key, size)) = + value.has_data_larger_than(platform_version.system_limits.max_field_value_size) + { + let field = match key { + Some(Value::Text(field)) => field, + _ => "".to_string(), + }; + return Ok(SimpleConsensusValidationResult::new_with_error( + ConsensusError::BasicError(BasicError::DocumentFieldMaxSizeExceededError( + DocumentFieldMaxSizeExceededError::new( + field, + size as u64, + platform_version.system_limits.max_field_value_size as u64, + ), + )), + )); + } + let json_value = match value.try_into_validating_json() { Ok(json_value) => json_value, Err(e) => { diff --git a/packages/rs-dpp/src/errors/consensus/basic/basic_error.rs b/packages/rs-dpp/src/errors/consensus/basic/basic_error.rs index 4a8a29951d8..002db4bd104 100644 --- a/packages/rs-dpp/src/errors/consensus/basic/basic_error.rs +++ b/packages/rs-dpp/src/errors/consensus/basic/basic_error.rs @@ -24,13 +24,13 @@ use crate::consensus::basic::decode::{ }; use crate::consensus::basic::document::{ DataContractNotPresentError, DocumentCreationNotAllowedError, - DocumentTransitionsAreAbsentError, DuplicateDocumentTransitionsWithIdsError, - DuplicateDocumentTransitionsWithIndicesError, InconsistentCompoundIndexDataError, - InvalidDocumentTransitionActionError, InvalidDocumentTransitionIdError, - InvalidDocumentTypeError, MaxDocumentsTransitionsExceededError, - MissingDataContractIdBasicError, MissingDocumentTransitionActionError, - MissingDocumentTransitionTypeError, MissingDocumentTypeError, - MissingPositionsInDocumentTypePropertiesError, NonceOutOfBoundsError, + DocumentFieldMaxSizeExceededError, DocumentTransitionsAreAbsentError, + DuplicateDocumentTransitionsWithIdsError, DuplicateDocumentTransitionsWithIndicesError, + InconsistentCompoundIndexDataError, InvalidDocumentTransitionActionError, + InvalidDocumentTransitionIdError, InvalidDocumentTypeError, + MaxDocumentsTransitionsExceededError, MissingDataContractIdBasicError, + MissingDocumentTransitionActionError, MissingDocumentTransitionTypeError, + MissingDocumentTypeError, MissingPositionsInDocumentTypePropertiesError, NonceOutOfBoundsError, }; use crate::consensus::basic::identity::{ DataContractBoundsNotPresentError, DisablingKeyIdAlsoBeingAddedInSameTransitionError, @@ -364,6 +364,9 @@ pub enum BasicError { #[error(transparent)] MissingStateTransitionTypeError(MissingStateTransitionTypeError), + #[error(transparent)] + DocumentFieldMaxSizeExceededError(DocumentFieldMaxSizeExceededError), + #[error(transparent)] StateTransitionMaxSizeExceededError(StateTransitionMaxSizeExceededError), diff --git a/packages/rs-dpp/src/errors/consensus/basic/document/document_field_max_size_exceeded_error.rs b/packages/rs-dpp/src/errors/consensus/basic/document/document_field_max_size_exceeded_error.rs new file mode 100644 index 00000000000..358d7fd3987 --- /dev/null +++ b/packages/rs-dpp/src/errors/consensus/basic/document/document_field_max_size_exceeded_error.rs @@ -0,0 +1,51 @@ +use crate::consensus::basic::BasicError; +use crate::consensus::ConsensusError; +use crate::errors::ProtocolError; +use bincode::{Decode, Encode}; +use platform_serialization_derive::{PlatformDeserialize, PlatformSerialize}; +use thiserror::Error; + +#[derive( + Error, Debug, Clone, PartialEq, Eq, Encode, Decode, PlatformSerialize, PlatformDeserialize, +)] +#[error( + "Document field {field} size {actual_size_bytes} is more than system maximum {max_size_bytes}" +)] +#[platform_serialize(unversioned)] +pub struct DocumentFieldMaxSizeExceededError { + /* + + DO NOT CHANGE ORDER OF FIELDS WITHOUT INTRODUCING OF NEW VERSION + + */ + field: String, + actual_size_bytes: u64, + max_size_bytes: u64, +} + +impl DocumentFieldMaxSizeExceededError { + pub fn new(field: String, actual_size_bytes: u64, max_size_bytes: u64) -> Self { + Self { + field, + actual_size_bytes, + max_size_bytes, + } + } + + pub fn field(&self) -> &str { + self.field.as_str() + } + + pub fn actual_size_bytes(&self) -> u64 { + self.actual_size_bytes + } + pub fn max_size_bytes(&self) -> u64 { + self.max_size_bytes + } +} + +impl From for ConsensusError { + fn from(err: DocumentFieldMaxSizeExceededError) -> Self { + Self::BasicError(BasicError::DocumentFieldMaxSizeExceededError(err)) + } +} diff --git a/packages/rs-dpp/src/errors/consensus/basic/document/mod.rs b/packages/rs-dpp/src/errors/consensus/basic/document/mod.rs index 9c011e12b59..2297cea2092 100644 --- a/packages/rs-dpp/src/errors/consensus/basic/document/mod.rs +++ b/packages/rs-dpp/src/errors/consensus/basic/document/mod.rs @@ -1,5 +1,6 @@ mod data_contract_not_present_error; mod document_creation_not_allowed_error; +mod document_field_max_size_exceeded_error; mod document_transitions_are_absent_error; mod duplicate_document_transitions_with_ids_error; mod duplicate_document_transitions_with_indices_error; @@ -17,6 +18,7 @@ mod missing_positions_in_document_type_properties_error; pub use data_contract_not_present_error::*; pub use document_creation_not_allowed_error::*; +pub use document_field_max_size_exceeded_error::*; pub use document_transitions_are_absent_error::*; pub use duplicate_document_transitions_with_ids_error::*; pub use duplicate_document_transitions_with_indices_error::*; diff --git a/packages/rs-dpp/src/errors/consensus/codes.rs b/packages/rs-dpp/src/errors/consensus/codes.rs index 793a366e119..3cc2cc8dfbf 100644 --- a/packages/rs-dpp/src/errors/consensus/codes.rs +++ b/packages/rs-dpp/src/errors/consensus/codes.rs @@ -116,6 +116,7 @@ impl ErrorWithCode for BasicError { Self::NonceOutOfBoundsError(_) => 10414, Self::InvalidDocumentTypeNameError(_) => 10415, Self::DocumentCreationNotAllowedError(_) => 10416, + Self::DocumentFieldMaxSizeExceededError(_) => 10417, // Identity Errors: 10500-10599 Self::DuplicatedIdentityPublicKeyBasicError(_) => 10500, diff --git a/packages/rs-dpp/src/fee/epoch/mod.rs b/packages/rs-dpp/src/fee/epoch/mod.rs index f438823506e..0d76c2ed178 100644 --- a/packages/rs-dpp/src/fee/epoch/mod.rs +++ b/packages/rs-dpp/src/fee/epoch/mod.rs @@ -42,7 +42,6 @@ use crate::block::epoch::EpochIndex; use crate::fee::{Credits, SignedCredits}; /// Genesis epoch index -//todo move to dpp pub const GENESIS_EPOCH_INDEX: EpochIndex = 0; /// Eras of fees charged for perpetual storage diff --git a/packages/rs-dpp/src/identity/mod.rs b/packages/rs-dpp/src/identity/mod.rs index 34ad4c34960..f592c045d93 100644 --- a/packages/rs-dpp/src/identity/mod.rs +++ b/packages/rs-dpp/src/identity/mod.rs @@ -29,7 +29,6 @@ pub mod methods; #[cfg(feature = "random-identities")] pub mod random; pub mod v0; -pub mod versions; pub use fields::*; diff --git a/packages/rs-dpp/src/identity/versions.rs b/packages/rs-dpp/src/identity/versions.rs deleted file mode 100644 index ed0b36c2287..00000000000 --- a/packages/rs-dpp/src/identity/versions.rs +++ /dev/null @@ -1,33 +0,0 @@ -use crate::identity::Identity; -use crate::version::{FeatureVersion, PlatformVersion, LATEST_PLATFORM_VERSION}; - -/// Versions -impl Identity { - /// Returns the default FeatureVersion for a given platform version. - /// - /// # Arguments - /// - /// * `platform_version` - A reference to the PlatformVersion object - pub fn default_version_on(platform_version: &PlatformVersion) -> FeatureVersion { - platform_version.identity.default_current_version - } - - /// Returns the default FeatureVersion for the latest platform version. - pub fn default_version() -> FeatureVersion { - LATEST_PLATFORM_VERSION.identity.default_current_version - } - - /// Returns the latest FeatureVersion supported by a given platform version. - /// - /// # Arguments - /// - /// * `platform_version` - A reference to the PlatformVersion object - pub fn latest_version_on(platform_version: &PlatformVersion) -> FeatureVersion { - platform_version.identity.max_version - } - - /// Returns the latest FeatureVersion supported by the latest platform version. - pub fn latest_version() -> FeatureVersion { - LATEST_PLATFORM_VERSION.identity.max_version - } -} diff --git a/packages/rs-dpp/src/state_transition/state_transitions/contract/data_contract_update_transition/v0/v0_methods.rs b/packages/rs-dpp/src/state_transition/state_transitions/contract/data_contract_update_transition/v0/v0_methods.rs index 732b684b7ac..73c0a492613 100644 --- a/packages/rs-dpp/src/state_transition/state_transitions/contract/data_contract_update_transition/v0/v0_methods.rs +++ b/packages/rs-dpp/src/state_transition/state_transitions/contract/data_contract_update_transition/v0/v0_methods.rs @@ -32,8 +32,8 @@ impl DataContractUpdateTransitionMethodsV0 for DataContractUpdateTransitionV0 { signature_public_key_id: key_id, signature: Default::default(), }); - //todo remove close - let mut state_transition: StateTransition = transition.clone().into(); + + let mut state_transition: StateTransition = transition.into(); let value = state_transition.signable_bytes()?; let public_key = identity diff --git a/packages/rs-dpp/src/state_transition/state_transitions/document/documents_batch_transition/validation/validate_basic_structure/v0/mod.rs b/packages/rs-dpp/src/state_transition/state_transitions/document/documents_batch_transition/validation/validate_basic_structure/v0/mod.rs index 84ccb224aa5..1bc2dd8b510 100644 --- a/packages/rs-dpp/src/state_transition/state_transitions/document/documents_batch_transition/validation/validate_basic_structure/v0/mod.rs +++ b/packages/rs-dpp/src/state_transition/state_transitions/document/documents_batch_transition/validation/validate_basic_structure/v0/mod.rs @@ -36,15 +36,13 @@ impl DocumentsBatchTransition { if transitions_len > u16::MAX as usize || transitions_len as u16 > platform_version - .dpp - .state_transitions + .system_limits .max_transitions_in_documents_batch { return Ok(SimpleConsensusValidationResult::new_with_error( MaxDocumentsTransitionsExceededError::new( platform_version - .dpp - .state_transitions + .system_limits .max_transitions_in_documents_batch, ) .into(), diff --git a/packages/rs-dpp/src/state_transition/state_transitions/identity/identity_create_transition/v0/mod.rs b/packages/rs-dpp/src/state_transition/state_transitions/identity/identity_create_transition/v0/mod.rs index 36fba74378f..bf6cae62621 100644 --- a/packages/rs-dpp/src/state_transition/state_transitions/identity/identity_create_transition/v0/mod.rs +++ b/packages/rs-dpp/src/state_transition/state_transitions/identity/identity_create_transition/v0/mod.rs @@ -89,8 +89,6 @@ impl TryFrom for IdentityCreateTransitionV0 { } } -//todo: there shouldn't be a default - impl IdentityCreateTransitionV0 { pub fn try_from_identity_v0( identity: &Identity, diff --git a/packages/rs-drive-abci/src/abci/handler/process_proposal.rs b/packages/rs-drive-abci/src/abci/handler/process_proposal.rs index 9e3c6e5e3eb..88d2feea3a5 100644 --- a/packages/rs-drive-abci/src/abci/handler/process_proposal.rs +++ b/packages/rs-drive-abci/src/abci/handler/process_proposal.rs @@ -10,7 +10,6 @@ use crate::execution::types::block_state_info::v0::{ use crate::platform_types::block_execution_outcome; use crate::platform_types::state_transitions_processing_result::StateTransitionExecutionResult; use crate::rpc::core::CoreRPCLike; -use dpp::version::PlatformVersion; use dpp::version::TryIntoPlatformVersioned; use tenderdash_abci::proto::abci as proto; use tenderdash_abci::proto::abci::tx_record::TxAction; diff --git a/packages/rs-drive-abci/src/execution/platform_events/state_transition_processing/decode_raw_state_transitions/v0/mod.rs b/packages/rs-drive-abci/src/execution/platform_events/state_transition_processing/decode_raw_state_transitions/v0/mod.rs index fd4b756f868..a8a03d5f087 100644 --- a/packages/rs-drive-abci/src/execution/platform_events/state_transition_processing/decode_raw_state_transitions/v0/mod.rs +++ b/packages/rs-drive-abci/src/execution/platform_events/state_transition_processing/decode_raw_state_transitions/v0/mod.rs @@ -53,20 +53,14 @@ where .iter() .map(|raw_state_transition| { if raw_state_transition.as_ref().len() as u64 - > platform_version - .dpp - .state_transitions - .max_state_transition_size + > platform_version.system_limits.max_state_transition_size { // The state transition is too big let consensus_error = ConsensusError::BasicError( BasicError::StateTransitionMaxSizeExceededError( StateTransitionMaxSizeExceededError::new( raw_state_transition.as_ref().len() as u64, - platform_version - .dpp - .state_transitions - .max_state_transition_size, + platform_version.system_limits.max_state_transition_size, ), ), ); diff --git a/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/data_contract_update/mod.rs b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/data_contract_update/mod.rs index a30f47c6528..149184f1a95 100644 --- a/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/data_contract_update/mod.rs +++ b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/data_contract_update/mod.rs @@ -573,8 +573,6 @@ mod tests { .build_with_mock_rpc() .set_initial_state_structure(); - let platform_state = platform.state.load(); - let (identity, signer, key) = setup_identity(&mut platform, 958, dash_to_credits!(0.1)); let card_game_path = "tests/supporting_files/contract/crypto-card-game/crypto-card-game-direct-purchase-creation-restricted-to-owner.json"; diff --git a/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/documents_batch/mod.rs b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/documents_batch/mod.rs index 9373c0b56e5..978fa0c4984 100644 --- a/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/documents_batch/mod.rs +++ b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/documents_batch/mod.rs @@ -274,6 +274,12 @@ mod tests { use dapi_grpc::platform::v0::get_contested_resource_vote_state_response::{get_contested_resource_vote_state_response_v0, GetContestedResourceVoteStateResponseV0}; use super::*; use assert_matches::assert_matches; + use rand::distributions::Standard; + use dpp::consensus::basic::document::DocumentFieldMaxSizeExceededError; + use dpp::consensus::ConsensusError; + use dpp::consensus::basic::BasicError; + use dpp::fee::fee_result::refunds::FeeRefunds; + use dpp::fee::fee_result::FeeResult; use dpp::data_contract::accessors::v0::DataContractV0Setters; use dpp::data_contract::document_type::restricted_creation::CreationRestrictionMode; use dpp::document::Document; @@ -285,8 +291,10 @@ mod tests { use drive::drive::votes::resolved::vote_polls::contested_document_resource_vote_poll::ContestedDocumentResourceVotePollWithContractInfoAllowBorrowed; use drive::query::vote_poll_vote_state_query::ContestedDocumentVotePollDriveQueryResultType::DocumentsAndVoteTally; use drive::query::vote_poll_vote_state_query::ResolvedContestedDocumentVotePollDriveQuery; + use drive::util::test_helpers::setup_contract; use crate::execution::validation::state_transition::state_transitions::tests::{add_contender_to_dpns_name_contest, create_dpns_name_contest, create_dpns_name_contest_give_key_info, fast_forward_to_block, perform_votes_multi}; use crate::platform_types::platform_state::v0::PlatformStateV0Methods; + use crate::platform_types::state_transitions_processing_result::StateTransitionExecutionResult::PaidConsensusError; #[test] fn test_document_creation() { @@ -325,12 +333,6 @@ mod tests { document.set("avatarUrl", "http://test.com/bob.jpg".into()); - let mut altered_document = document.clone(); - - altered_document.increment_revision().unwrap(); - altered_document.set("displayName", "Samuel".into()); - altered_document.set("avatarUrl", "http://test.com/cat.jpg".into()); - let documents_batch_create_transition = DocumentsBatchTransition::new_document_creation_transition_from_document( document, @@ -377,6 +379,118 @@ mod tests { .expect("expected to commit transaction"); } + #[test] + fn test_document_creation_with_very_big_field() { + let platform_version = PlatformVersion::latest(); + let mut platform = TestPlatformBuilder::new() + .build_with_mock_rpc() + .set_genesis_state(); + + let mut rng = StdRng::seed_from_u64(433); + + let platform_state = platform.state.load(); + + let (identity, signer, key) = setup_identity(&mut platform, 958, dash_to_credits!(0.1)); + + let dashpay_contract_no_max_length = setup_contract( + &platform.drive, + "tests/supporting_files/contract/dashpay/dashpay-contract-no-max-length.json", + None, + None, + ); + + let dashpay_contract = dashpay_contract_no_max_length.clone(); + + let profile = dashpay_contract + .document_type_for_name("profile") + .expect("expected a profile document type"); + + assert!(profile.documents_mutable()); + + let entropy = Bytes32::random_with_rng(&mut rng); + + let mut document = profile + .random_document_with_identifier_and_entropy( + &mut rng, + identity.id(), + entropy, + DocumentFieldFillType::FillIfNotRequired, + DocumentFieldFillSize::AnyDocumentFillSize, + platform_version, + ) + .expect("expected a random document"); + + let max_field_size = platform_version.system_limits.max_field_value_size; + let avatar_size = max_field_size + 1000; + + document.set( + "avatar", + Value::Bytes( + rng.sample_iter(Standard) + .take(avatar_size as usize) + .collect(), + ), + ); + + let documents_batch_create_transition = + DocumentsBatchTransition::new_document_creation_transition_from_document( + document, + profile, + entropy.0, + &key, + 2, + 0, + &signer, + platform_version, + None, + None, + None, + ) + .expect("expect to create documents batch transition"); + + let documents_batch_create_serialized_transition = documents_batch_create_transition + .serialize_to_bytes() + .expect("expected documents batch serialized state transition"); + + let transaction = platform.drive.grove.start_transaction(); + + let processing_result = platform + .platform + .process_raw_state_transitions( + &vec![documents_batch_create_serialized_transition.clone()], + &platform_state, + &BlockInfo::default(), + &transaction, + platform_version, + ) + .expect("expected to process state transition"); + assert_eq!( + processing_result.execution_results().first().unwrap(), + &PaidConsensusError( + ConsensusError::BasicError(BasicError::DocumentFieldMaxSizeExceededError( + DocumentFieldMaxSizeExceededError::new( + "avatar".to_string(), + avatar_size as u64, + max_field_size as u64 + ) + )), + FeeResult { + storage_fee: 11556000, + processing_fee: 1253700, + fee_refunds: FeeRefunds::default(), + removed_bytes_from_system: 0 + } + ) + ); + + platform + .drive + .grove + .commit_transaction(transaction) + .unwrap() + .expect("expected to commit transaction"); + } + #[test] fn test_document_creation_on_contested_unique_index() { let platform_version = PlatformVersion::latest(); @@ -1069,8 +1183,6 @@ mod tests { .build_with_mock_rpc() .set_initial_state_structure(); - let platform_state = platform.state.load(); - let (identity, signer, key) = setup_identity(&mut platform, 958, dash_to_credits!(0.1)); let (another_identity, another_identity_signer, another_identity_key) = diff --git a/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/identity_credit_withdrawal/mod.rs b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/identity_credit_withdrawal/mod.rs index c3021ff8b73..8239908332f 100644 --- a/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/identity_credit_withdrawal/mod.rs +++ b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/identity_credit_withdrawal/mod.rs @@ -120,8 +120,7 @@ impl StateTransitionStateValidationV0 for IdentityCreditWithdrawalTransition { mod tests { use crate::config::{PlatformConfig, PlatformTestConfig}; use crate::execution::validation::state_transition::tests::{ - fast_forward_to_block, setup_identity, - setup_identity_with_withdrawal_key_and_system_credits, + fast_forward_to_block, setup_identity_with_withdrawal_key_and_system_credits, }; use crate::platform_types::state_transitions_processing_result::StateTransitionExecutionResult; use crate::test::helpers::setup::TestPlatformBuilder; diff --git a/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/masternode_vote/mod.rs b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/masternode_vote/mod.rs index fe7bcb7e72c..6383ac871bc 100644 --- a/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/masternode_vote/mod.rs +++ b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/masternode_vote/mod.rs @@ -7,7 +7,6 @@ mod transform_into_action; use dpp::block::block_info::BlockInfo; use dpp::state_transition::masternode_vote_transition::MasternodeVoteTransition; use dpp::validation::ConsensusValidationResult; -use dpp::version::PlatformVersion; use drive::state_transition_action::StateTransitionAction; use drive::grovedb::TransactionArg; diff --git a/packages/rs-drive-abci/tests/supporting_files/contract/dashpay/dashpay-contract-no-max-length.json b/packages/rs-drive-abci/tests/supporting_files/contract/dashpay/dashpay-contract-no-max-length.json new file mode 100644 index 00000000000..5939d4221d8 --- /dev/null +++ b/packages/rs-drive-abci/tests/supporting_files/contract/dashpay/dashpay-contract-no-max-length.json @@ -0,0 +1,120 @@ +{ + "$format_version": "0", + "id": "8MjTnX7JUbGfYYswyuCtHU7ZqcYU9s1fUaNiqD9s5tEw", + "ownerId": "2QjL594djCH2NyDsn45vd6yQjEDHupMKo7CEGVTHtQxU", + "version": 1, + "documentSchemas": { + "profile": { + "type": "object", + "indices": [], + "properties": { + "avatar": { + "type": "array", + "byteArray": true, + "position": 0 + }, + "publicMessage": { + "type": "string", + "maxLength": 140, + "position": 1 + }, + "displayName": { + "type": "string", + "maxLength": 25, + "position": 2 + } + }, + "required": [ + "$createdAt", + "$updatedAt" + ], + "additionalProperties": false + }, + "contactInfo": { + "type": "object", + "indices": [], + "properties": { + "encToUserId": { + "type": "array", + "byteArray": true, + "minItems": 32, + "maxItems": 32, + "position": 0 + }, + "rootEncryptionKeyIndex": { + "type": "integer", + "position": 1 + }, + "derivationEncryptionKeyIndex": { + "type": "integer", + "position": 2 + }, + "privateData": { + "type": "array", + "byteArray": true, + "minItems": 48, + "maxItems": 2048, + "position": 3, + "description": "This is the encrypted values of aliasName + note + displayHidden encoded as an array in cbor" + } + }, + "required": [ + "$createdAt", + "$updatedAt", + "encToUserId", + "privateData", + "rootEncryptionKeyIndex", + "derivationEncryptionKeyIndex" + ], + "additionalProperties": false + }, + "contactRequest": { + "type": "object", + "indices": [], + "properties": { + "toUserId": { + "type": "array", + "byteArray": true, + "minItems": 32, + "maxItems": 32, + "position": 0 + }, + "encryptedPublicKey": { + "type": "array", + "byteArray": true, + "minItems": 96, + "maxItems": 96, + "position": 1 + }, + "senderKeyIndex": { + "type": "integer", + "position": 2 + }, + "recipientKeyIndex": { + "type": "integer", + "position": 3 + }, + "accountReference": { + "type": "integer", + "position": 4 + }, + "encryptedAccountLabel": { + "type": "array", + "byteArray": true, + "minItems": 48, + "maxItems": 80, + "position": 5 + } + }, + "required": [ + "$createdAt", + "toUserId", + "encryptedPublicKey", + "senderKeyIndex", + "recipientKeyIndex", + "accountReference" + ], + "additionalProperties": false + } + } +} diff --git a/packages/rs-drive/src/drive/constants.rs b/packages/rs-drive/src/drive/constants.rs index 9359e7d0f64..41644ad7ddd 100644 --- a/packages/rs-drive/src/drive/constants.rs +++ b/packages/rs-drive/src/drive/constants.rs @@ -28,14 +28,6 @@ pub const MAX_INDEX_SIZE: usize = 255; /// Storage flags size pub const STORAGE_FLAGS_SIZE: u32 = 2; -//todo move some of these to versioning - -/// Serialized contract max size -pub const CONTRACT_MAX_SERIALIZED_SIZE: u16 = 16384; -// TODO: Insert correct value here -/// Max element size -pub const MAX_ELEMENT_SIZE: u32 = 5000; - /// Default required bytes to hold a user balance /// TODO We probably don't need it anymore since we always pay for 9 bytes pub const AVERAGE_BALANCE_SIZE: u32 = 6; diff --git a/packages/rs-drive/src/drive/contract/apply/apply_contract_with_serialization/v0/mod.rs b/packages/rs-drive/src/drive/contract/apply/apply_contract_with_serialization/v0/mod.rs index 09f8939cff2..e3566f5fb86 100644 --- a/packages/rs-drive/src/drive/contract/apply/apply_contract_with_serialization/v0/mod.rs +++ b/packages/rs-drive/src/drive/contract/apply/apply_contract_with_serialization/v0/mod.rs @@ -1,4 +1,3 @@ -use crate::drive::constants::CONTRACT_MAX_SERIALIZED_SIZE; use crate::drive::contract::paths::{contract_keeping_history_root_path, contract_root_path}; use crate::drive::Drive; @@ -103,7 +102,11 @@ impl Drive { in_tree_using_sums: false, // we can ignore flags as this is just an approximation // and it's doubtful that contracts will always be inserted at max size - query_target: QueryTargetValue(CONTRACT_MAX_SERIALIZED_SIZE as u32), + query_target: QueryTargetValue( + platform_version + .system_limits + .estimated_contract_max_serialized_size as u32, + ), } }; diff --git a/packages/rs-drive/src/drive/identity/fetch/fetch_by_public_key_hashes/mod.rs b/packages/rs-drive/src/drive/identity/fetch/fetch_by_public_key_hashes/mod.rs index af8c5601dfb..9a928d7b272 100644 --- a/packages/rs-drive/src/drive/identity/fetch/fetch_by_public_key_hashes/mod.rs +++ b/packages/rs-drive/src/drive/identity/fetch/fetch_by_public_key_hashes/mod.rs @@ -17,18 +17,16 @@ mod tests { use dpp::identity::identity_public_key::accessors::v0::IdentityPublicKeyGettersV0; use dpp::identity::identity_public_key::methods::hash::IdentityPublicKeyHashMethodsV0; use dpp::identity::Identity; - use dpp::version::drive_versions::DriveVersion; use dpp::version::PlatformVersion; #[test] fn test_fetch_all_keys_on_identity() { let drive = setup_drive(None); - let drive_version = DriveVersion::latest(); + let platform_version = PlatformVersion::latest(); + let drive_version = &platform_version.drive; let transaction = drive.grove.start_transaction(); - let platform_version = PlatformVersion::first(); - drive .create_initial_state_structure(Some(&transaction), platform_version) .expect("expected to create root tree successfully"); diff --git a/packages/rs-drive/src/drive/identity/key/fetch/mod.rs b/packages/rs-drive/src/drive/identity/key/fetch/mod.rs index 8e86c6a2ee8..4567278c784 100644 --- a/packages/rs-drive/src/drive/identity/key/fetch/mod.rs +++ b/packages/rs-drive/src/drive/identity/key/fetch/mod.rs @@ -999,7 +999,6 @@ mod tests { use dpp::block::block_info::BlockInfo; use dpp::identity::accessors::IdentityGettersV0; use dpp::identity::Identity; - use dpp::version::drive_versions::DriveVersion; use super::*; @@ -1042,7 +1041,6 @@ mod tests { #[test] fn test_fetch_single_identity_key() { let drive = setup_drive(None); - let _drive_version = DriveVersion::latest(); let transaction = drive.grove.start_transaction(); @@ -1083,7 +1081,6 @@ mod tests { #[test] fn test_fetch_multiple_identity_key() { let drive = setup_drive(None); - let _drive_version = DriveVersion::latest(); let transaction = drive.grove.start_transaction(); @@ -1124,7 +1121,6 @@ mod tests { #[test] fn test_fetch_unknown_identity_key_returns_not_found() { let drive = setup_drive(None); - let _drive_version = DriveVersion::latest(); let transaction = drive.grove.start_transaction(); diff --git a/packages/rs-platform-value/src/lib.rs b/packages/rs-platform-value/src/lib.rs index 6d76594be72..ea3530a3f40 100644 --- a/packages/rs-platform-value/src/lib.rs +++ b/packages/rs-platform-value/src/lib.rs @@ -1264,6 +1264,180 @@ impl Value { _other => Err(Error::StructureError("value is not a map".to_string())), } } + + /// can determine if there is any very big data in a value + pub fn has_data_larger_than(&self, size: u32) -> Option<(Option, u32)> { + match self { + Value::U128(_) => { + if size < 16 { + Some((None, 16)) + } else { + None + } + } + Value::I128(_) => { + if size < 16 { + Some((None, 16)) + } else { + None + } + } + Value::U64(_) => { + if size < 8 { + Some((None, 8)) + } else { + None + } + } + Value::I64(_) => { + if size < 8 { + Some((None, 8)) + } else { + None + } + } + Value::U32(_) => { + if size < 4 { + Some((None, 4)) + } else { + None + } + } + Value::I32(_) => { + if size < 4 { + Some((None, 4)) + } else { + None + } + } + Value::U16(_) => { + if size < 2 { + Some((None, 2)) + } else { + None + } + } + Value::I16(_) => { + if size < 2 { + Some((None, 2)) + } else { + None + } + } + Value::U8(_) => { + if size < 1 { + Some((None, 1)) + } else { + None + } + } + Value::I8(_) => { + if size < 1 { + Some((None, 1)) + } else { + None + } + } + Value::Bytes(bytes) => { + if (size as usize) < bytes.len() { + Some((None, bytes.len() as u32)) + } else { + None + } + } + Value::Bytes20(_) => { + if size < 20 { + Some((None, 20)) + } else { + None + } + } + Value::Bytes32(_) => { + if size < 32 { + Some((None, 32)) + } else { + None + } + } + Value::Bytes36(_) => { + if size < 36 { + Some((None, 36)) + } else { + None + } + } + Value::EnumU8(_) => { + if size < 1 { + Some((None, 1)) + } else { + None + } + } + Value::EnumString(strings) => { + let max_len = strings.iter().map(|string| string.as_bytes().len()).max(); + if let Some(max) = max_len { + if max > size as usize { + Some((None, max as u32)) + } else { + None + } + } else { + None + } + } + Value::Identifier(_) => { + if size < 32 { + Some((None, 32)) + } else { + None + } + } + Value::Float(_) => { + if size < 8 { + Some((None, 8)) + } else { + None + } + } + Value::Text(string) => { + if string.as_bytes().len() > size as usize { + Some((None, string.as_bytes().len() as u32)) + } else { + None + } + } + Value::Bool(_) => { + if size < 1 { + Some((None, 1)) + } else { + None + } + } + Value::Null => { + if size < 1 { + Some((None, 1)) + } else { + None + } + } + Value::Array(values) => { + for value in values { + if let Some(result) = value.has_data_larger_than(size) { + return Some((Some(value.clone()), result.1)); + } + } + None + } + Value::Map(map) => { + for (key, value) in map { + if let Some(result) = value.has_data_larger_than(size) { + return Some((Some(key.clone()), result.1)); + } + } + None + } + } + } } macro_rules! implfrom { diff --git a/packages/rs-platform-version/src/version/dpp_versions.rs b/packages/rs-platform-version/src/version/dpp_versions.rs index 3c936327e41..98254686ef4 100644 --- a/packages/rs-platform-version/src/version/dpp_versions.rs +++ b/packages/rs-platform-version/src/version/dpp_versions.rs @@ -18,8 +18,6 @@ pub struct DPPVersion { #[derive(Clone, Debug, Default)] pub struct StateTransitionVersions { - pub max_state_transition_size: u64, - pub max_transitions_in_documents_batch: u16, pub documents: DocumentTransitionVersions, pub identities: IdentityTransitionVersions, } diff --git a/packages/rs-platform-version/src/version/drive_versions.rs b/packages/rs-platform-version/src/version/drive_versions.rs index 64099e47954..fd3027a0d38 100644 --- a/packages/rs-platform-version/src/version/drive_versions.rs +++ b/packages/rs-platform-version/src/version/drive_versions.rs @@ -9,12 +9,6 @@ pub struct DriveVersion { pub grove_version: GroveVersion, } -impl DriveVersion { - pub fn latest() -> DriveVersion { - DriveVersion::default() - } -} - #[derive(Clone, Debug, Default)] pub struct DriveMethodVersions { pub initialization: DriveInitializationMethodVersions, diff --git a/packages/rs-platform-version/src/version/limits.rs b/packages/rs-platform-version/src/version/limits.rs new file mode 100644 index 00000000000..7035d6ae7c1 --- /dev/null +++ b/packages/rs-platform-version/src/version/limits.rs @@ -0,0 +1,7 @@ +#[derive(Clone, Debug, Default)] +pub struct SystemLimits { + pub estimated_contract_max_serialized_size: u16, + pub max_field_value_size: u32, + pub max_state_transition_size: u64, + pub max_transitions_in_documents_batch: u16, +} diff --git a/packages/rs-platform-version/src/version/mocks/v2_test.rs b/packages/rs-platform-version/src/version/mocks/v2_test.rs index 229e262c72e..de6aa2f7ede 100644 --- a/packages/rs-platform-version/src/version/mocks/v2_test.rs +++ b/packages/rs-platform-version/src/version/mocks/v2_test.rs @@ -76,20 +76,16 @@ use crate::version::drive_versions::{ DriveVoteSetupMethodVersions, DriveVoteStorageFormMethodVersions, }; use crate::version::fee::v1::FEE_VERSION1; +use crate::version::limits::SystemLimits; use crate::version::mocks::TEST_PROTOCOL_VERSION_SHIFT_BYTES; use crate::version::protocol_version::{FeatureVersionBounds, PlatformVersion}; -use crate::version::{AbciStructureVersion, PlatformArchitectureVersion}; +use crate::version::PlatformArchitectureVersion; use grovedb_version::version::v1::GROVE_V1; pub const TEST_PROTOCOL_VERSION_2: u32 = (1 << TEST_PROTOCOL_VERSION_SHIFT_BYTES) + 2; pub const TEST_PLATFORM_V2: PlatformVersion = PlatformVersion { protocol_version: TEST_PROTOCOL_VERSION_2, - identity: FeatureVersionBounds { - min_version: 0, - max_version: 0, - default_current_version: 0, - }, proofs: FeatureVersionBounds { min_version: 0, max_version: 0, @@ -582,13 +578,6 @@ pub const TEST_PLATFORM_V2: PlatformVersion = PlatformVersion { }, grove_version: GROVE_V1, }, - abci_structure: AbciStructureVersion { - extended_block_info: FeatureVersionBounds { - min_version: 0, - max_version: 0, - default_current_version: 0, - }, - }, platform_architecture: PlatformArchitectureVersion { data_contract_factory_structure_version: 0, document_factory_structure_version: 0, @@ -1120,8 +1109,6 @@ pub const TEST_PLATFORM_V2: PlatformVersion = PlatformVersion { }, }, state_transitions: StateTransitionVersions { - max_state_transition_size: 20000, - max_transitions_in_documents_batch: 1, documents: DocumentTransitionVersions { documents_batch_transition: DocumentsBatchTransitionVersions { validation: DocumentsBatchTransitionValidationVersions { @@ -1242,4 +1229,10 @@ pub const TEST_PLATFORM_V2: PlatformVersion = PlatformVersion { feature_flags: 1, }, fee_version: FEE_VERSION1, + system_limits: SystemLimits { + estimated_contract_max_serialized_size: 16384, + max_field_value_size: 5000, + max_state_transition_size: 20000, + max_transitions_in_documents_batch: 1, + }, }; diff --git a/packages/rs-platform-version/src/version/mocks/v3_test.rs b/packages/rs-platform-version/src/version/mocks/v3_test.rs index 22c1d8ee7b3..aae61b3a10e 100644 --- a/packages/rs-platform-version/src/version/mocks/v3_test.rs +++ b/packages/rs-platform-version/src/version/mocks/v3_test.rs @@ -76,20 +76,16 @@ use crate::version::drive_versions::{ DriveVoteSetupMethodVersions, DriveVoteStorageFormMethodVersions, }; use crate::version::fee::v1::FEE_VERSION1; +use crate::version::limits::SystemLimits; use crate::version::mocks::TEST_PROTOCOL_VERSION_SHIFT_BYTES; use crate::version::protocol_version::{FeatureVersionBounds, PlatformVersion}; -use crate::version::{AbciStructureVersion, PlatformArchitectureVersion}; +use crate::version::PlatformArchitectureVersion; use grovedb_version::version::v1::GROVE_V1; pub const TEST_PROTOCOL_VERSION_3: u32 = (1 << TEST_PROTOCOL_VERSION_SHIFT_BYTES) + 3; pub const TEST_PLATFORM_V3: PlatformVersion = PlatformVersion { protocol_version: TEST_PROTOCOL_VERSION_3, - identity: FeatureVersionBounds { - min_version: 0, - max_version: 0, - default_current_version: 0, - }, proofs: FeatureVersionBounds { min_version: 0, max_version: 0, @@ -582,13 +578,6 @@ pub const TEST_PLATFORM_V3: PlatformVersion = PlatformVersion { }, grove_version: GROVE_V1, }, - abci_structure: AbciStructureVersion { - extended_block_info: FeatureVersionBounds { - min_version: 0, - max_version: 0, - default_current_version: 0, - }, - }, platform_architecture: PlatformArchitectureVersion { data_contract_factory_structure_version: 0, document_factory_structure_version: 0, @@ -1120,8 +1109,6 @@ pub const TEST_PLATFORM_V3: PlatformVersion = PlatformVersion { }, }, state_transitions: StateTransitionVersions { - max_state_transition_size: 20000, - max_transitions_in_documents_batch: 1, documents: DocumentTransitionVersions { documents_batch_transition: DocumentsBatchTransitionVersions { validation: DocumentsBatchTransitionValidationVersions { @@ -1242,4 +1229,10 @@ pub const TEST_PLATFORM_V3: PlatformVersion = PlatformVersion { feature_flags: 1, }, fee_version: FEE_VERSION1, + system_limits: SystemLimits { + estimated_contract_max_serialized_size: 16384, + max_field_value_size: 5000, + max_state_transition_size: 20000, + max_transitions_in_documents_batch: 1, + }, }; diff --git a/packages/rs-platform-version/src/version/mod.rs b/packages/rs-platform-version/src/version/mod.rs index 928d5ea35af..6422228b1d0 100644 --- a/packages/rs-platform-version/src/version/mod.rs +++ b/packages/rs-platform-version/src/version/mod.rs @@ -7,6 +7,7 @@ pub mod dpp_versions; pub mod drive_abci_versions; pub mod drive_versions; pub mod fee; +mod limits; #[cfg(feature = "mock-versions")] pub mod mocks; pub mod patches; diff --git a/packages/rs-platform-version/src/version/protocol_version.rs b/packages/rs-platform-version/src/version/protocol_version.rs index 487b27513ac..dcb62784b23 100644 --- a/packages/rs-platform-version/src/version/protocol_version.rs +++ b/packages/rs-platform-version/src/version/protocol_version.rs @@ -14,14 +14,10 @@ use crate::version::v1::PLATFORM_V1; #[cfg(feature = "mock-versions")] use std::sync::OnceLock; +use crate::version::limits::SystemLimits; use crate::version::ProtocolVersion; pub use versioned_feature_core::*; -#[derive(Clone, Debug, Default)] -pub struct AbciStructureVersion { - pub extended_block_info: FeatureVersionBounds, -} - #[derive(Clone, Debug, Default)] pub struct PlatformArchitectureVersion { pub data_contract_factory_structure_version: FeatureVersion, @@ -31,15 +27,14 @@ pub struct PlatformArchitectureVersion { #[derive(Clone, Debug)] pub struct PlatformVersion { pub protocol_version: ProtocolVersion, - pub identity: FeatureVersionBounds, pub proofs: FeatureVersionBounds, pub dpp: DPPVersion, pub drive: DriveVersion, pub drive_abci: DriveAbciVersion, pub fee_version: FeeVersion, - pub abci_structure: AbciStructureVersion, pub platform_architecture: PlatformArchitectureVersion, pub system_data_contracts: SystemDataContractVersions, + pub system_limits: SystemLimits, } pub const PLATFORM_VERSIONS: &[PlatformVersion] = &[PLATFORM_V1]; diff --git a/packages/rs-platform-version/src/version/v1.rs b/packages/rs-platform-version/src/version/v1.rs index e26c7a567e4..e0e83f15673 100644 --- a/packages/rs-platform-version/src/version/v1.rs +++ b/packages/rs-platform-version/src/version/v1.rs @@ -76,19 +76,15 @@ use crate::version::drive_versions::{ DriveVoteSetupMethodVersions, DriveVoteStorageFormMethodVersions, }; use crate::version::fee::v1::FEE_VERSION1; +use crate::version::limits::SystemLimits; use crate::version::protocol_version::{FeatureVersionBounds, PlatformVersion}; -use crate::version::{AbciStructureVersion, PlatformArchitectureVersion, ProtocolVersion}; +use crate::version::{PlatformArchitectureVersion, ProtocolVersion}; use grovedb_version::version::v1::GROVE_V1; pub const PROTOCOL_VERSION_1: ProtocolVersion = 1; pub const PLATFORM_V1: PlatformVersion = PlatformVersion { protocol_version: 1, - identity: FeatureVersionBounds { - min_version: 0, - max_version: 0, - default_current_version: 0, - }, proofs: FeatureVersionBounds { min_version: 0, max_version: 0, @@ -581,13 +577,6 @@ pub const PLATFORM_V1: PlatformVersion = PlatformVersion { }, grove_version: GROVE_V1, }, - abci_structure: AbciStructureVersion { - extended_block_info: FeatureVersionBounds { - min_version: 0, - max_version: 0, - default_current_version: 0, - }, - }, platform_architecture: PlatformArchitectureVersion { data_contract_factory_structure_version: 0, document_factory_structure_version: 0, @@ -1119,8 +1108,6 @@ pub const PLATFORM_V1: PlatformVersion = PlatformVersion { }, }, state_transitions: StateTransitionVersions { - max_state_transition_size: 20000, - max_transitions_in_documents_batch: 1, documents: DocumentTransitionVersions { documents_batch_transition: DocumentsBatchTransitionVersions { validation: DocumentsBatchTransitionValidationVersions { @@ -1241,4 +1228,10 @@ pub const PLATFORM_V1: PlatformVersion = PlatformVersion { feature_flags: 1, }, fee_version: FEE_VERSION1, + system_limits: SystemLimits { + estimated_contract_max_serialized_size: 16384, + max_field_value_size: 5120, //5 KiB + max_state_transition_size: 20480, //20 KiB + max_transitions_in_documents_batch: 1, + }, }; diff --git a/packages/wasm-dpp/src/errors/consensus/consensus_error.rs b/packages/wasm-dpp/src/errors/consensus/consensus_error.rs index 14e02526dbf..5961523e8a2 100644 --- a/packages/wasm-dpp/src/errors/consensus/consensus_error.rs +++ b/packages/wasm-dpp/src/errors/consensus/consensus_error.rs @@ -62,7 +62,7 @@ use dpp::consensus::state::data_trigger::DataTriggerError::{ }; use wasm_bindgen::{JsError, JsValue}; use dpp::consensus::basic::data_contract::{ContestedUniqueIndexOnMutableDocumentTypeError, InvalidDocumentTypeRequiredSecurityLevelError, UnknownDocumentCreationRestrictionModeError, UnknownSecurityLevelError, UnknownStorageKeyRequirementsError, UnknownTradeModeError, UnknownTransferableTypeError}; -use dpp::consensus::basic::document::{DocumentCreationNotAllowedError, MaxDocumentsTransitionsExceededError, MissingPositionsInDocumentTypePropertiesError}; +use dpp::consensus::basic::document::{DocumentCreationNotAllowedError, DocumentFieldMaxSizeExceededError, MaxDocumentsTransitionsExceededError, MissingPositionsInDocumentTypePropertiesError}; use dpp::consensus::basic::identity::{DataContractBoundsNotPresentError, DisablingKeyIdAlsoBeingAddedInSameTransitionError, InvalidIdentityCreditWithdrawalTransitionAmountError, InvalidIdentityUpdateTransitionDisableKeysError, InvalidIdentityUpdateTransitionEmptyError, TooManyMasterPublicKeyError}; use dpp::consensus::basic::overflow_error::OverflowError; use dpp::consensus::state::data_contract::document_type_update_error::DocumentTypeUpdateError; @@ -539,6 +539,9 @@ fn from_basic_error(basic_error: &BasicError) -> JsValue { BasicError::UnsupportedFeatureError(e) => { generic_consensus_error!(UnsupportedFeatureError, e).into() } + BasicError::DocumentFieldMaxSizeExceededError(e) => { + generic_consensus_error!(DocumentFieldMaxSizeExceededError, e).into() + } } } From 5fc2543a4dc9ac5f29a2dfb73a328ce7c27be550 Mon Sep 17 00:00:00 2001 From: Ivan Shumkov Date: Wed, 17 Jul 2024 13:45:26 +0700 Subject: [PATCH 2/2] ci: increase timeout for Rust test --- .github/workflows/tests-rs-package.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/tests-rs-package.yml b/.github/workflows/tests-rs-package.yml index eab1f04f74a..e666491ebcf 100644 --- a/.github/workflows/tests-rs-package.yml +++ b/.github/workflows/tests-rs-package.yml @@ -169,7 +169,7 @@ jobs: test: name: Tests runs-on: ${{ fromJSON(inputs.test-runner) }} - timeout-minutes: 20 + timeout-minutes: 25 steps: - name: Check out repo uses: actions/checkout@v4