diff --git a/packages/rs-drive-abci/src/execution/platform_events/withdrawals/pool_withdrawals_into_transactions_queue/v0/mod.rs b/packages/rs-drive-abci/src/execution/platform_events/withdrawals/pool_withdrawals_into_transactions_queue/v0/mod.rs index 86ebeb6fbb..01c84035f6 100644 --- a/packages/rs-drive-abci/src/execution/platform_events/withdrawals/pool_withdrawals_into_transactions_queue/v0/mod.rs +++ b/packages/rs-drive-abci/src/execution/platform_events/withdrawals/pool_withdrawals_into_transactions_queue/v0/mod.rs @@ -1,21 +1,10 @@ use dpp::block::block_info::BlockInfo; - -use dpp::data_contract::accessors::v0::DataContractV0Getters; -use dpp::document::DocumentV0Getters; -use dpp::platform_value::btreemap_extensions::BTreeValueMapHelper; use dpp::version::PlatformVersion; use drive::grovedb::TransactionArg; -use dpp::system_data_contracts::withdrawals_contract; -use dpp::system_data_contracts::withdrawals_contract::v1::document_types::withdrawal; - use crate::platform_types::platform_state::v0::PlatformStateV0Methods; use crate::platform_types::platform_state::PlatformState; -use crate::{ - error::{execution::ExecutionError, Error}, - platform_types::platform::Platform, - rpc::core::CoreRPCLike, -}; +use crate::{error::Error, platform_types::platform::Platform, rpc::core::CoreRPCLike}; impl Platform where @@ -53,20 +42,21 @@ where mod tests { use super::*; use dpp::block::epoch::Epoch; - use itertools::Itertools; - + use dpp::data_contract::accessors::v0::DataContractV0Getters; use dpp::data_contracts::SystemDataContract; use dpp::identifier::Identifier; use dpp::identity::core_script::CoreScript; use dpp::tests::fixtures::get_withdrawal_document_fixture; use dpp::withdrawal::Pooling; use drive::util::test_helpers::setup::{setup_document, setup_system_data_contract}; + use itertools::Itertools; use crate::test::helpers::setup::TestPlatformBuilder; use dpp::document::DocumentV0Getters; use dpp::platform_value::btreemap_extensions::BTreeValueMapHelper; use dpp::platform_value::platform_value; - use dpp::system_data_contracts::load_system_data_contract; + use dpp::system_data_contracts::withdrawals_contract::v1::document_types::withdrawal; + use dpp::system_data_contracts::{load_system_data_contract, withdrawals_contract}; use dpp::version::PlatformVersion; use drive::config::DEFAULT_QUERY_LIMIT; diff --git a/packages/rs-drive-abci/src/execution/platform_events/withdrawals/rebroadcast_expired_withdrawal_documents/mod.rs b/packages/rs-drive-abci/src/execution/platform_events/withdrawals/rebroadcast_expired_withdrawal_documents/mod.rs index f4e9daab97..cb01272fdc 100644 --- a/packages/rs-drive-abci/src/execution/platform_events/withdrawals/rebroadcast_expired_withdrawal_documents/mod.rs +++ b/packages/rs-drive-abci/src/execution/platform_events/withdrawals/rebroadcast_expired_withdrawal_documents/mod.rs @@ -24,6 +24,7 @@ where /// /// # Parameters /// - `block_info`: Information about the current block (e.g., timestamp). + /// - `last_committed_platform_state`: The last committed platform state needed to check active validator set. /// - `transaction`: The transaction within which the rebroadcast should be executed. /// - `platform_version`: The version of the platform, used to determine the correct method implementation. /// diff --git a/packages/rs-drive-abci/src/execution/types/execution_operation/mod.rs b/packages/rs-drive-abci/src/execution/types/execution_operation/mod.rs index 4024224e2e..d44b854495 100644 --- a/packages/rs-drive-abci/src/execution/types/execution_operation/mod.rs +++ b/packages/rs-drive-abci/src/execution/types/execution_operation/mod.rs @@ -67,6 +67,7 @@ pub enum ValidationOperation { Protocol(ProtocolValidationOperation), RetrieveIdentity(RetrieveIdentityInfo), RetrievePrefundedSpecializedBalance, + PerformNetworkThresholdSigning, SingleSha256(HashBlockCount), DoubleSha256(HashBlockCount), ValidateKeyStructure(KeyCount), // This is extremely cheap @@ -210,6 +211,19 @@ impl ValidationOperation { "execution processing fee overflow error", ))?; } + ValidationOperation::PerformNetworkThresholdSigning => { + let operation_cost = platform_version + .fee_version + .processing + .perform_network_threshold_signing; + + fee_result.processing_fee = fee_result + .processing_fee + .checked_add(operation_cost) + .ok_or(ExecutionError::Overflow( + "execution processing fee overflow error", + ))?; + } } } Ok(()) diff --git a/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/identity_credit_withdrawal/balance/v0/mod.rs b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/identity_credit_withdrawal/balance/v0/mod.rs index 0c1b879b0f..9dc60ba353 100644 --- a/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/identity_credit_withdrawal/balance/v0/mod.rs +++ b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/identity_credit_withdrawal/balance/v0/mod.rs @@ -5,6 +5,10 @@ use dpp::state_transition::identity_credit_withdrawal_transition::accessors::Ide use dpp::state_transition::identity_credit_withdrawal_transition::IdentityCreditWithdrawalTransition; use crate::error::execution::ExecutionError; +use crate::execution::types::execution_operation::ValidationOperation; +use crate::execution::types::state_transition_execution_context::{ + StateTransitionExecutionContext, StateTransitionExecutionContextMethodsV0, +}; use dpp::validation::SimpleConsensusValidationResult; use dpp::version::PlatformVersion; 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 a1ed43702c..c2eaee7f71 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 @@ -33,7 +33,7 @@ impl StateTransitionActionTransformerV0 for IdentityCreditWithdrawalTransition { platform: &PlatformRef, block_info: &BlockInfo, _validation_mode: ValidationMode, - _execution_context: &mut StateTransitionExecutionContext, + execution_context: &mut StateTransitionExecutionContext, tx: TransactionArg, ) -> Result, Error> { let platform_version = platform.state.current_platform_version()?; @@ -45,7 +45,13 @@ impl StateTransitionActionTransformerV0 for IdentityCreditWithdrawalTransition { .identity_credit_withdrawal_state_transition .transform_into_action { - 0 => self.transform_into_action_v0(platform, block_info, tx, platform_version), + 0 => self.transform_into_action_v0( + platform, + block_info, + execution_context, + tx, + platform_version, + ), version => Err(Error::Execution(ExecutionError::UnknownVersionMismatch { method: "identity credit withdrawal transition: transform_into_action".to_string(), known_versions: vec![0], @@ -94,7 +100,7 @@ impl StateTransitionStateValidationV0 for IdentityCreditWithdrawalTransition { platform: &PlatformRef, _validation_mode: ValidationMode, block_info: &BlockInfo, - _execution_context: &mut StateTransitionExecutionContext, + execution_context: &mut StateTransitionExecutionContext, tx: TransactionArg, ) -> Result, Error> { let platform_version = platform.state.current_platform_version()?; @@ -106,7 +112,13 @@ impl StateTransitionStateValidationV0 for IdentityCreditWithdrawalTransition { .identity_credit_withdrawal_state_transition .state { - 0 => self.validate_state_v0(platform, block_info, tx, platform_version), + 0 => self.validate_state_v0( + platform, + block_info, + execution_context, + tx, + platform_version, + ), version => Err(Error::Execution(ExecutionError::UnknownVersionMismatch { method: "identity credit withdrawal transition: validate_state".to_string(), known_versions: vec![0], diff --git a/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/identity_credit_withdrawal/state/v0/mod.rs b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/identity_credit_withdrawal/state/v0/mod.rs index 87fe5892fe..fefadaa8c7 100644 --- a/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/identity_credit_withdrawal/state/v0/mod.rs +++ b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/identity_credit_withdrawal/state/v0/mod.rs @@ -9,6 +9,10 @@ use dpp::prelude::ConsensusValidationResult; use dpp::state_transition::identity_credit_withdrawal_transition::accessors::IdentityCreditWithdrawalTransitionAccessorsV0; use dpp::state_transition::identity_credit_withdrawal_transition::IdentityCreditWithdrawalTransition; +use crate::execution::types::execution_operation::ValidationOperation; +use crate::execution::types::state_transition_execution_context::{ + StateTransitionExecutionContext, StateTransitionExecutionContextMethodsV0, +}; use dpp::version::PlatformVersion; use drive::grovedb::TransactionArg; use drive::state_transition_action::identity::identity_credit_withdrawal::IdentityCreditWithdrawalTransitionAction; @@ -19,6 +23,7 @@ pub(in crate::execution::validation::state_transition::state_transitions::identi &self, platform: &PlatformRef, block_info: &BlockInfo, + execution_context: &mut StateTransitionExecutionContext, tx: TransactionArg, platform_version: &PlatformVersion, ) -> Result, Error>; @@ -27,6 +32,7 @@ pub(in crate::execution::validation::state_transition::state_transitions::identi &self, platform: &PlatformRef, block_info: &BlockInfo, + execution_context: &mut StateTransitionExecutionContext, tx: TransactionArg, platform_version: &PlatformVersion, ) -> Result, Error>; @@ -39,6 +45,7 @@ impl IdentityCreditWithdrawalStateTransitionStateValidationV0 &self, platform: &PlatformRef, block_info: &BlockInfo, + execution_context: &mut StateTransitionExecutionContext, tx: TransactionArg, platform_version: &PlatformVersion, ) -> Result, Error> { @@ -65,17 +72,24 @@ impl IdentityCreditWithdrawalStateTransitionStateValidationV0 )); } - self.transform_into_action_v0(platform, block_info, tx, platform_version) + self.transform_into_action_v0( + platform, + block_info, + execution_context, + tx, + platform_version, + ) } fn transform_into_action_v0( &self, platform: &PlatformRef, block_info: &BlockInfo, + execution_context: &mut StateTransitionExecutionContext, tx: TransactionArg, platform_version: &PlatformVersion, ) -> Result, Error> { - Ok( + let consensus_validation_result = IdentityCreditWithdrawalTransitionAction::try_from_identity_credit_withdrawal( &platform.drive, tx, @@ -85,7 +99,11 @@ impl IdentityCreditWithdrawalStateTransitionStateValidationV0 ) .map(|consensus_validation_result| { consensus_validation_result.map(|withdrawal| withdrawal.into()) - })?, - ) + })?; + if consensus_validation_result.is_valid() { + // If this is valid then we will apply the action and eventually perform network threshold signing + execution_context.add_operation(ValidationOperation::PerformNetworkThresholdSigning); + } + Ok(consensus_validation_result) } } diff --git a/packages/rs-platform-version/src/version/fee/mod.rs b/packages/rs-platform-version/src/version/fee/mod.rs index c868a3028d..6022a89a1f 100644 --- a/packages/rs-platform-version/src/version/fee/mod.rs +++ b/packages/rs-platform-version/src/version/fee/mod.rs @@ -72,8 +72,9 @@ mod tests { fetch_identity_balance_and_revision_processing_cost: 3, fetch_identity_cost_per_look_up_key_by_id: 4, fetch_single_identity_key_processing_cost: 5, - validate_key_structure: 6, - fetch_prefunded_specialized_balance_processing_cost: 7, + perform_network_threshold_signing: 6, + validate_key_structure: 7, + fetch_prefunded_specialized_balance_processing_cost: 8, }, data_contract: FeeDataContractValidationVersion { document_type_base_fee: 1, @@ -129,8 +130,9 @@ mod tests { fetch_identity_balance_and_revision_processing_cost: 3, fetch_identity_cost_per_look_up_key_by_id: 4, fetch_single_identity_key_processing_cost: 5, - validate_key_structure: 6, - fetch_prefunded_specialized_balance_processing_cost: 7, + perform_network_threshold_signing: 6, + validate_key_structure: 7, + fetch_prefunded_specialized_balance_processing_cost: 8, }, data_contract: FeeDataContractValidationVersion { document_type_base_fee: 1, diff --git a/packages/rs-platform-version/src/version/fee/processing/mod.rs b/packages/rs-platform-version/src/version/fee/processing/mod.rs index 0427cd0916..df88c9c0dc 100644 --- a/packages/rs-platform-version/src/version/fee/processing/mod.rs +++ b/packages/rs-platform-version/src/version/fee/processing/mod.rs @@ -10,6 +10,7 @@ pub struct FeeProcessingVersion { pub fetch_identity_cost_per_look_up_key_by_id: u64, pub fetch_prefunded_specialized_balance_processing_cost: u64, pub fetch_single_identity_key_processing_cost: u64, + pub perform_network_threshold_signing: u64, pub validate_key_structure: u64, } @@ -26,8 +27,9 @@ mod tests { fetch_identity_balance_and_revision_processing_cost: 3, fetch_identity_cost_per_look_up_key_by_id: 4, fetch_single_identity_key_processing_cost: 5, - validate_key_structure: 6, - fetch_prefunded_specialized_balance_processing_cost: 7, + perform_network_threshold_signing: 6, + validate_key_structure: 7, + fetch_prefunded_specialized_balance_processing_cost: 8, }; let version2 = FeeProcessingVersion { @@ -36,8 +38,9 @@ mod tests { fetch_identity_balance_and_revision_processing_cost: 3, fetch_identity_cost_per_look_up_key_by_id: 4, fetch_single_identity_key_processing_cost: 5, - validate_key_structure: 6, - fetch_prefunded_specialized_balance_processing_cost: 7, + perform_network_threshold_signing: 6, + validate_key_structure: 7, + fetch_prefunded_specialized_balance_processing_cost: 8, }; // This assertion will check if all fields are considered in the equality comparison diff --git a/packages/rs-platform-version/src/version/fee/processing/v1.rs b/packages/rs-platform-version/src/version/fee/processing/v1.rs index dbedd153d9..b6ba5ca998 100644 --- a/packages/rs-platform-version/src/version/fee/processing/v1.rs +++ b/packages/rs-platform-version/src/version/fee/processing/v1.rs @@ -7,5 +7,6 @@ pub const FEE_PROCESSING_VERSION1: FeeProcessingVersion = FeeProcessingVersion { fetch_identity_cost_per_look_up_key_by_id: 9000, fetch_prefunded_specialized_balance_processing_cost: 10000, fetch_single_identity_key_processing_cost: 10000, + perform_network_threshold_signing: 100000000, // 1mDash (2.5 cents at 25$/Dash) validate_key_structure: 50, }; diff --git a/packages/rs-platform-version/src/version/fee/state_transition_min_fees/v1.rs b/packages/rs-platform-version/src/version/fee/state_transition_min_fees/v1.rs index 5f759e50fc..5fbfdbbfe6 100644 --- a/packages/rs-platform-version/src/version/fee/state_transition_min_fees/v1.rs +++ b/packages/rs-platform-version/src/version/fee/state_transition_min_fees/v1.rs @@ -2,7 +2,7 @@ use crate::version::fee::state_transition_min_fees::StateTransitionMinFees; pub const STATE_TRANSITION_MIN_FEES_VERSION1: StateTransitionMinFees = StateTransitionMinFees { credit_transfer: 100000, - credit_withdrawal: 100000, + credit_withdrawal: 400000000, //credit withdrawals are more expensive that the rest identity_update: 100000, document_batch_sub_transition: 100000, contract_create: 100000,