From 56f97d756bea611e29c4b5b42031c13d90118414 Mon Sep 17 00:00:00 2001 From: Ivan Shumkov Date: Wed, 13 Mar 2024 10:25:29 +0700 Subject: [PATCH 01/37] feat(drive): consistent versioning based on consensus app version --- packages/dashmate/docker-compose.yml | 1 - .../src/abci/handler/finalize_block.rs | 9 +- .../src/abci/handler/prepare_proposal.rs | 20 ++-- .../src/abci/handler/process_proposal.rs | 110 +++++++++--------- .../engine/finalize_block_proposal/v0/mod.rs | 10 +- .../engine/run_block_proposal/mod.rs | 5 +- .../engine/run_block_proposal/v0/mod.rs | 57 ++++++--- .../block_end/consensus_param_updates/mod.rs | 36 ++++++ .../consensus_param_updates/v0/mod.rs | 31 +++++ .../platform_events/block_end/mod.rs | 1 + .../block_end/update_state_cache/v0/mod.rs | 5 - .../v0/mod.rs | 1 + .../process_block_fees/v0/mod.rs | 1 + .../check_for_desired_protocol_upgrade/mod.rs | 14 +-- .../v0/mod.rs | 39 +++---- .../execution/types/block_state_info/mod.rs | 13 +++ .../types/block_state_info/v0/mod.rs | 17 +++ packages/rs-drive-abci/src/mimic/mod.rs | 39 ++++--- .../block_execution_outcome/v0/mod.rs | 2 + .../tests/strategy_tests/execution.rs | 11 +- .../strategy_tests/upgrade_fork_tests.rs | 1 - .../src/drive/cache/protocol_version.rs | 20 ++-- .../v0/mod.rs | 1 + .../mod.rs | 1 + .../src/version/drive_abci_versions.rs | 1 + .../src/version/mocks/v2_test.rs | 1 + .../src/version/mocks/v3_test.rs | 1 + .../rs-platform-version/src/version/v1.rs | 1 + 28 files changed, 295 insertions(+), 154 deletions(-) create mode 100644 packages/rs-drive-abci/src/execution/platform_events/block_end/consensus_param_updates/mod.rs create mode 100644 packages/rs-drive-abci/src/execution/platform_events/block_end/consensus_param_updates/v0/mod.rs diff --git a/packages/dashmate/docker-compose.yml b/packages/dashmate/docker-compose.yml index 95dc1a46f4c..9ee4f0c0082 100644 --- a/packages/dashmate/docker-compose.yml +++ b/packages/dashmate/docker-compose.yml @@ -201,7 +201,6 @@ services: volumes: core_data: drive_abci_data: - drive_abci_logs: drive_tenderdash: networks: diff --git a/packages/rs-drive-abci/src/abci/handler/finalize_block.rs b/packages/rs-drive-abci/src/abci/handler/finalize_block.rs index f1a5eb2d25c..dee6bf27abb 100644 --- a/packages/rs-drive-abci/src/abci/handler/finalize_block.rs +++ b/packages/rs-drive-abci/src/abci/handler/finalize_block.rs @@ -1,7 +1,10 @@ use crate::abci::app::{BlockExecutionApplication, PlatformApplication, TransactionalApplication}; use crate::error::execution::ExecutionError; use crate::error::Error; +use crate::execution::types::block_execution_context::v0::BlockExecutionContextV0Getters; +use crate::execution::types::block_state_info::v0::BlockStateInfoV0Getters; use crate::rpc::core::CoreRPCLike; +use dpp::version::PlatformVersion; use tenderdash_abci::proto::abci as proto; pub fn finalize_block<'a, A, C>( @@ -32,7 +35,11 @@ where "block execution context must be set in block begin handler for finalize block", )))?; - let platform_version = app.platform().state.load().current_platform_version()?; + // Use current block protocol version + let protocol_version = block_execution_context + .block_state_info() + .protocol_version(); + let platform_version = PlatformVersion::get(protocol_version)?; let block_finalization_outcome = app.platform().finalize_block_proposal( request.try_into()?, diff --git a/packages/rs-drive-abci/src/abci/handler/prepare_proposal.rs b/packages/rs-drive-abci/src/abci/handler/prepare_proposal.rs index ccffb85a981..8b82920bbd1 100644 --- a/packages/rs-drive-abci/src/abci/handler/prepare_proposal.rs +++ b/packages/rs-drive-abci/src/abci/handler/prepare_proposal.rs @@ -113,17 +113,22 @@ where return Err(run_result.errors.remove(0)); } + let block_execution_outcome = run_result.into_data().map_err(Error::Protocol)?; + + let platform_version = PlatformVersion::get(block_execution_outcome.protocol_version) + .expect("must be set in run block proposal from existing protocol version"); + + let consensus_param_updates = app + .platform() + .consensus_param_updates(&block_execution_outcome, platform_version)?; + let block_execution_outcome::v0::BlockExecutionOutcome { app_hash, state_transitions_result, validator_set_update, - protocol_version, mut block_execution_context, - } = run_result.into_data().map_err(Error::Protocol)?; - - // TODO: This is current protocol version and can be read from the state - let platform_version = PlatformVersion::get(protocol_version) - .expect("must be set in run block proposal from existing protocol version"); + .. + } = block_execution_outcome; // We need to let Tenderdash know about the transactions we should remove from execution let valid_tx_count = state_transitions_result.valid_count(); @@ -188,8 +193,7 @@ where signature: chain_lock.signature.to_bytes().to_vec(), }), validator_set_update, - // TODO: implement consensus param updates - consensus_param_updates: None, + consensus_param_updates, }; block_execution_context.set_proposer_results(Some(response.clone())); 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 9a60a8a1e46..79d53cdaef4 100644 --- a/packages/rs-drive-abci/src/abci/handler/process_proposal.rs +++ b/packages/rs-drive-abci/src/abci/handler/process_proposal.rs @@ -196,64 +196,70 @@ where request.round, ); - Ok(response) - } else { - let block_execution_outcome::v0::BlockExecutionOutcome { - app_hash, - state_transitions_result: state_transition_results, - validator_set_update, - protocol_version, - block_execution_context, - } = run_result.into_data().map_err(Error::Protocol)?; + return Ok(response); + } - let platform_version = PlatformVersion::get(protocol_version) - .expect("must be set in run block proposer from existing platform version"); + let block_execution_outcome = run_result.into_data().map_err(Error::Protocol)?; - app.block_execution_context() - .write() - .unwrap() - .replace(block_execution_context); + let platform_version = PlatformVersion::get(block_execution_outcome.protocol_version) + .expect("must be set in run block proposer from existing platform version"); - let invalid_tx_count = state_transition_results.invalid_paid_count(); - let valid_tx_count = state_transition_results.valid_count(); + let consensus_param_updates = app + .platform() + .consensus_param_updates(&block_execution_outcome, platform_version)?; - let tx_results = state_transition_results - .into_execution_results() - .into_iter() - // To prevent spam attacks we add to the block state transitions covered with fees only - .filter(|execution_result| { - matches!( - execution_result, - StateTransitionExecutionResult::SuccessfulExecution(..) - | StateTransitionExecutionResult::PaidConsensusError(..) - ) - }) - .map(|execution_result| execution_result.try_into_platform_versioned(platform_version)) - .collect::>()?; + let block_execution_outcome::v0::BlockExecutionOutcome { + app_hash, + state_transitions_result: state_transition_results, + validator_set_update, + block_execution_context, + .. + } = block_execution_outcome; - let response = proto::ResponseProcessProposal { - app_hash: app_hash.to_vec(), - tx_results, - // TODO: Must be reject if results are different - status: proto::response_process_proposal::ProposalStatus::Accept.into(), - validator_set_update, - // TODO: Implement consensus param updates - consensus_param_updates: None, - }; + app.block_execution_context() + .write() + .unwrap() + .replace(block_execution_context); - let elapsed_time_ms = timer.elapsed().as_millis(); + let invalid_tx_count = state_transition_results.invalid_paid_count(); + let valid_tx_count = state_transition_results.valid_count(); - tracing::info!( - invalid_tx_count, - valid_tx_count, - elapsed_time_ms, - "Processed proposal with {} transactions for height: {}, round: {} in {} ms", - valid_tx_count + invalid_tx_count, - request.height, - request.round, - elapsed_time_ms, - ); + let tx_results = state_transition_results + .into_execution_results() + .into_iter() + // To prevent spam attacks we add to the block state transitions covered with fees only + .filter(|execution_result| { + matches!( + execution_result, + StateTransitionExecutionResult::SuccessfulExecution(..) + | StateTransitionExecutionResult::PaidConsensusError(..) + ) + }) + .map(|execution_result| execution_result.try_into_platform_versioned(platform_version)) + .collect::>()?; - Ok(response) - } + let response = proto::ResponseProcessProposal { + app_hash: app_hash.to_vec(), + tx_results, + // TODO: Must be reject if results are different + status: proto::response_process_proposal::ProposalStatus::Accept.into(), + validator_set_update, + // TODO: Implement consensus param updates + consensus_param_updates, + }; + + let elapsed_time_ms = timer.elapsed().as_millis(); + + tracing::info!( + invalid_tx_count, + valid_tx_count, + elapsed_time_ms, + "Processed proposal with {} transactions for height: {}, round: {} in {} ms", + valid_tx_count + invalid_tx_count, + request.height, + request.round, + elapsed_time_ms, + ); + + Ok(response) } diff --git a/packages/rs-drive-abci/src/execution/engine/finalize_block_proposal/v0/mod.rs b/packages/rs-drive-abci/src/execution/engine/finalize_block_proposal/v0/mod.rs index b7a8522b926..0e3ba9b1c59 100644 --- a/packages/rs-drive-abci/src/execution/engine/finalize_block_proposal/v0/mod.rs +++ b/packages/rs-drive-abci/src/execution/engine/finalize_block_proposal/v0/mod.rs @@ -64,7 +64,7 @@ where request_finalize_block: FinalizeBlockCleanedRequest, mut block_execution_context: BlockExecutionContext, transaction: &Transaction, - _last_committed_platform_version: &PlatformVersion, + platform_version: &PlatformVersion, ) -> Result { let mut validation_result = SimpleValidationResult::::new_with_errors(vec![]); @@ -72,14 +72,6 @@ where let epoch_info = block_execution_context.epoch_info(); let block_platform_state = block_execution_context.block_platform_state(); - // TODO: The block was processed with last committed platform version, it's wrong to call all functions - // here with new version. Except probably state storage version. - // Another problem that block was processed wit last committed version but we storing state with new version. - // It means when we load the state we would expect this block to be processed with the new version. - let current_protocol_version = block_platform_state.current_protocol_version_in_consensus(); - - let platform_version = PlatformVersion::get(current_protocol_version)?; - // Let's decompose the request let FinalizeBlockCleanedRequest { commit: mut commit_info, diff --git a/packages/rs-drive-abci/src/execution/engine/run_block_proposal/mod.rs b/packages/rs-drive-abci/src/execution/engine/run_block_proposal/mod.rs index 7904104c4a9..f56038d5a3f 100644 --- a/packages/rs-drive-abci/src/execution/engine/run_block_proposal/mod.rs +++ b/packages/rs-drive-abci/src/execution/engine/run_block_proposal/mod.rs @@ -5,6 +5,7 @@ use crate::platform_types::platform_state::PlatformState; use crate::platform_types::{block_execution_outcome, block_proposal}; use crate::rpc::core::CoreRPCLike; use dpp::validation::ValidationResult; +use dpp::version::PlatformVersion; use drive::grovedb::Transaction; mod v0; @@ -45,7 +46,9 @@ where transaction: &Transaction, ) -> Result, Error> { - let platform_version = platform_state.current_platform_version()?; + // Get current protocol version from block header + let protocol_version = block_proposal.consensus_versions.app as u32; + let platform_version = PlatformVersion::get(protocol_version)?; let epoch_info = self.gather_epoch_info( &block_proposal, diff --git a/packages/rs-drive-abci/src/execution/engine/run_block_proposal/v0/mod.rs b/packages/rs-drive-abci/src/execution/engine/run_block_proposal/v0/mod.rs index 716a264d16a..df44cc8e3dd 100644 --- a/packages/rs-drive-abci/src/execution/engine/run_block_proposal/v0/mod.rs +++ b/packages/rs-drive-abci/src/execution/engine/run_block_proposal/v0/mod.rs @@ -1,4 +1,5 @@ use dpp::block::epoch::Epoch; +use dpp::util::deserializer::ProtocolVersion; use dpp::validation::ValidationResult; use drive::error::Error::GroveDB; @@ -87,6 +88,35 @@ where // Create a bock state from previous committed state let mut block_platform_state = last_committed_platform_state.clone(); + // Set protocol version for this block + { + let current_block_protocol_version = platform_version.protocol_version; + let previous_block_protocol_version = + last_committed_platform_state.current_protocol_version_in_consensus(); + + // Set current protocol version from the block + block_platform_state + .set_current_protocol_version_in_consensus(current_block_protocol_version); + + // Does this block has different protocol version comparing with the previous? + if previous_block_protocol_version != current_block_protocol_version { + tracing::info!( + epoch_index = epoch_info.current_epoch_index(), + "protocol version changed from {} to {}", + previous_block_protocol_version, + current_block_protocol_version, + ); + + // We need to persist new protocol version + // TODO: Must be a part of epoch trees? + self.drive.store_current_protocol_version( + current_block_protocol_version, + Some(transaction), + &platform_version.drive, + )?; + } + } + // Init block execution context let block_state_info = block_state_info::v0::BlockStateInfoV0::from_block_proposal( &block_proposal, @@ -229,6 +259,7 @@ where })?; // This is a system error // Determine a new protocol version if enough proposers voted + let mut next_block_protocol_version = None; if epoch_info.is_epoch_change_but_not_genesis() { tracing::info!( epoch_index = epoch_info.current_epoch_index(), @@ -239,41 +270,35 @@ where epoch_info.current_epoch_index(), ); + // Set next protocol version as a version for next block if changed if block_platform_state.current_protocol_version_in_consensus() == block_platform_state.next_epoch_protocol_version() { tracing::trace!( epoch_index = epoch_info.current_epoch_index(), - "protocol version remains the same {}", + "protocol version for the next block remains the same {}", block_platform_state.current_protocol_version_in_consensus(), ); } else { - tracing::info!( + next_block_protocol_version = + Some(block_platform_state.next_epoch_protocol_version()); + + tracing::trace!( epoch_index = epoch_info.current_epoch_index(), - "protocol version changed from {} to {}", - block_platform_state.current_protocol_version_in_consensus(), + "set new protocol version for the next block {}", block_platform_state.next_epoch_protocol_version(), ); } - // Set current protocol version to the version from upcoming epoch - block_platform_state.set_current_protocol_version_in_consensus( - block_platform_state.next_epoch_protocol_version(), - ); - // Determine new protocol version based on votes for the next epoch - let maybe_new_protocol_version = self.check_for_desired_protocol_upgrade( + let maybe_new_protocol_version = self.check_for_desired_protocol_upgrade_and_reset( hpmn_list_len, - block_platform_state.current_protocol_version_in_consensus(), transaction, + platform_version, )?; if let Some(new_protocol_version) = maybe_new_protocol_version { block_platform_state.set_next_epoch_protocol_version(new_protocol_version); - } else { - block_platform_state.set_next_epoch_protocol_version( - block_platform_state.current_protocol_version_in_consensus(), - ); } } @@ -379,8 +404,8 @@ where app_hash: root_hash, state_transitions_result, validator_set_update, - // TODO: We already know the version outside sine we have state and platform version what pass here protocol_version: platform_version.protocol_version, + next_block_protocol_version, block_execution_context, }, )) diff --git a/packages/rs-drive-abci/src/execution/platform_events/block_end/consensus_param_updates/mod.rs b/packages/rs-drive-abci/src/execution/platform_events/block_end/consensus_param_updates/mod.rs new file mode 100644 index 00000000000..a4fe0bea266 --- /dev/null +++ b/packages/rs-drive-abci/src/execution/platform_events/block_end/consensus_param_updates/mod.rs @@ -0,0 +1,36 @@ +use crate::error::execution::ExecutionError; +use crate::error::Error; +use crate::platform_types::block_execution_outcome::v0::BlockExecutionOutcome; +use crate::platform_types::platform::Platform; +use crate::rpc::core::CoreRPCLike; +use dpp::version::PlatformVersion; +use tenderdash_abci::proto::types::ConsensusParams; + +mod v0; + +impl Platform +where + C: CoreRPCLike, +{ + /// Creates an instance of [ConsensusParams] if there are any consensus param updates are + /// required based on [BlockExecutionOutcome] + pub fn consensus_param_updates( + &self, + block_execution_outcome: &BlockExecutionOutcome, + platform_version: &PlatformVersion, + ) -> Result, Error> { + match platform_version + .drive_abci + .methods + .block_end + .consensus_param_updates + { + 0 => self.consensus_param_updates_v0(block_execution_outcome, platform_version), + version => Err(Error::Execution(ExecutionError::UnknownVersionMismatch { + method: "consensus_param_updates".to_string(), + known_versions: vec![0], + received: version, + })), + } + } +} diff --git a/packages/rs-drive-abci/src/execution/platform_events/block_end/consensus_param_updates/v0/mod.rs b/packages/rs-drive-abci/src/execution/platform_events/block_end/consensus_param_updates/v0/mod.rs new file mode 100644 index 00000000000..39cac2265f6 --- /dev/null +++ b/packages/rs-drive-abci/src/execution/platform_events/block_end/consensus_param_updates/v0/mod.rs @@ -0,0 +1,31 @@ +use crate::error::Error; +use crate::platform_types::block_execution_outcome::v0::BlockExecutionOutcome; +use crate::platform_types::platform::Platform; +use crate::rpc::core::CoreRPCLike; +use dpp::version::PlatformVersion; +use tenderdash_abci::proto::types::{ConsensusParams, VersionParams}; + +impl Platform +where + C: CoreRPCLike, +{ + // TODO: implement update of other consensus params + + pub(super) fn consensus_param_updates_v0( + &self, + block_execution_outcome: &BlockExecutionOutcome, + _platform_version: &PlatformVersion, + ) -> Result, Error> { + let consensus_param_updates = + block_execution_outcome + .next_block_protocol_version + .map(|version| ConsensusParams { + version: Some(VersionParams { + app_version: version as u64, + }), + ..Default::default() + }); + + Ok(consensus_param_updates) + } +} diff --git a/packages/rs-drive-abci/src/execution/platform_events/block_end/mod.rs b/packages/rs-drive-abci/src/execution/platform_events/block_end/mod.rs index f881cea1dd8..fec91594339 100644 --- a/packages/rs-drive-abci/src/execution/platform_events/block_end/mod.rs +++ b/packages/rs-drive-abci/src/execution/platform_events/block_end/mod.rs @@ -3,5 +3,6 @@ pub(in crate::execution) mod update_state_cache; /// Validator set update pub(in crate::execution) mod validator_set_update; +mod consensus_param_updates; /// Updating the drive cache happens as the final part of block finalization pub(in crate::execution) mod update_drive_cache; diff --git a/packages/rs-drive-abci/src/execution/platform_events/block_end/update_state_cache/v0/mod.rs b/packages/rs-drive-abci/src/execution/platform_events/block_end/update_state_cache/v0/mod.rs index 9390dd369fc..068aa647992 100644 --- a/packages/rs-drive-abci/src/execution/platform_events/block_end/update_state_cache/v0/mod.rs +++ b/packages/rs-drive-abci/src/execution/platform_events/block_end/update_state_cache/v0/mod.rs @@ -54,11 +54,6 @@ where block_platform_state.set_genesis_block_info(None); - //todo: verify this with an update - let version = PlatformVersion::get(platform_version.protocol_version)?; - - PlatformVersion::set_current(version); - // Persist block state self.store_platform_state(&block_platform_state, Some(transaction), platform_version)?; diff --git a/packages/rs-drive-abci/src/execution/platform_events/block_fee_processing/add_process_epoch_change_operations/v0/mod.rs b/packages/rs-drive-abci/src/execution/platform_events/block_fee_processing/add_process_epoch_change_operations/v0/mod.rs index 1314bd11165..c9665fbe836 100644 --- a/packages/rs-drive-abci/src/execution/platform_events/block_fee_processing/add_process_epoch_change_operations/v0/mod.rs +++ b/packages/rs-drive-abci/src/execution/platform_events/block_fee_processing/add_process_epoch_change_operations/v0/mod.rs @@ -215,6 +215,7 @@ mod tests { core_chain_locked_height: 1, block_hash: None, app_hash: None, + protocol_version: 1, }; let epoch_info = EpochInfoV0::from_genesis_time_and_block_info( diff --git a/packages/rs-drive-abci/src/execution/platform_events/block_fee_processing/process_block_fees/v0/mod.rs b/packages/rs-drive-abci/src/execution/platform_events/block_fee_processing/process_block_fees/v0/mod.rs index 5659c7affe0..45e778405d9 100644 --- a/packages/rs-drive-abci/src/execution/platform_events/block_fee_processing/process_block_fees/v0/mod.rs +++ b/packages/rs-drive-abci/src/execution/platform_events/block_fee_processing/process_block_fees/v0/mod.rs @@ -257,6 +257,7 @@ mod tests { core_chain_locked_height: 1, block_hash: None, app_hash: None, + protocol_version: 1, }; let epoch_info = EpochInfoV0::from_genesis_time_and_block_info( diff --git a/packages/rs-drive-abci/src/execution/platform_events/protocol_upgrade/check_for_desired_protocol_upgrade/mod.rs b/packages/rs-drive-abci/src/execution/platform_events/protocol_upgrade/check_for_desired_protocol_upgrade/mod.rs index c2d15fa430c..fcc02c772e3 100644 --- a/packages/rs-drive-abci/src/execution/platform_events/protocol_upgrade/check_for_desired_protocol_upgrade/mod.rs +++ b/packages/rs-drive-abci/src/execution/platform_events/protocol_upgrade/check_for_desired_protocol_upgrade/mod.rs @@ -10,13 +10,10 @@ mod v0; impl Platform { /// Checks for a network upgrade and resets activation window. /// This method should only be called when a new epoch starts. - /// It alters the underlying state but does not change the drive cache. /// /// # Arguments /// /// * `total_hpmns` - The total number of high priority masternodes. - /// * `current_protocol_version_in_consensus` - The current protocol version in consensus. - /// * `transaction` - A transaction argument to interact with the underlying storage. /// /// # Returns /// @@ -31,23 +28,22 @@ impl Platform { /// * There is an issue interacting with the underlying storage. /// * An overflow occurs when calculating the required block count. /// * More than one version pass the threshold to upgrade. - pub fn check_for_desired_protocol_upgrade( + pub fn check_for_desired_protocol_upgrade_and_reset( &self, total_hpmns: u32, - current_protocol_version_in_consensus: ProtocolVersion, transaction: &Transaction, + platform_version: &PlatformVersion, ) -> Result, Error> { - let current_platform_version = PlatformVersion::get(current_protocol_version_in_consensus)?; - match current_platform_version + match platform_version .drive_abci .methods .protocol_upgrade .check_for_desired_protocol_upgrade { - 0 => self.check_for_desired_protocol_upgrade_v0( + 0 => self.check_for_desired_protocol_upgrade_and_reset_v0( total_hpmns, - current_protocol_version_in_consensus, transaction, + platform_version, ), version => Err(Error::Execution(ExecutionError::UnknownVersionMismatch { method: "check_for_desired_protocol_upgrade".to_string(), diff --git a/packages/rs-drive-abci/src/execution/platform_events/protocol_upgrade/check_for_desired_protocol_upgrade/v0/mod.rs b/packages/rs-drive-abci/src/execution/platform_events/protocol_upgrade/check_for_desired_protocol_upgrade/v0/mod.rs index 2d7073d9b77..8ad6b3aec5b 100644 --- a/packages/rs-drive-abci/src/execution/platform_events/protocol_upgrade/check_for_desired_protocol_upgrade/v0/mod.rs +++ b/packages/rs-drive-abci/src/execution/platform_events/protocol_upgrade/check_for_desired_protocol_upgrade/v0/mod.rs @@ -13,12 +13,12 @@ const PROTOCOL_VERSION_UPGRADE_PERCENTAGE_NEEDED: u64 = 75; impl Platform { /// checks for a network upgrade and resets activation window /// this should only be called on epoch change - /// this will change backing state, but does not change drive cache - pub(super) fn check_for_desired_protocol_upgrade_v0( + /// this will change backing state and drive cache + pub(super) fn check_for_desired_protocol_upgrade_and_reset_v0( &self, total_hpmns: u32, - current_protocol_version_in_consensus: ProtocolVersion, transaction: &Transaction, + platform_version: &PlatformVersion, ) -> Result, Error> { let required_upgraded_hpns = 1 + (total_hpmns as u64) @@ -30,9 +30,10 @@ impl Platform { // if we are at an epoch change, check to see if over 75% of blocks of previous epoch // were on the future version + // This also clears the cache let mut protocol_versions_counter = self.drive.cache.protocol_versions_counter.write(); - let mut versions_passing_threshold = - protocol_versions_counter.versions_passing_threshold(required_upgraded_hpns); + let mut versions_passing_threshold = protocol_versions_counter + .aggregate_into_versions_passing_threshold(required_upgraded_hpns); drop(protocol_versions_counter); if versions_passing_threshold.len() > 1 { @@ -43,28 +44,20 @@ impl Platform { )); } + // we need to drop all version information + self.drive + .clear_version_information(Some(transaction), &platform_version.drive) + .map_err(Error::Drive)?; + if !versions_passing_threshold.is_empty() { // same as equals 1 - let new_version = versions_passing_threshold.remove(0); - // Persist current and next epoch protocol versions - // we also drop all protocol version votes information - self.drive - .change_to_new_version_and_clear_version_information( - current_protocol_version_in_consensus, - new_version, - Some(transaction), - ) - .map_err(Error::Drive)?; + let next_version = versions_passing_threshold.remove(0); - Ok(Some(new_version)) - } else { - // we need to drop all version information - let current_platform_version = - PlatformVersion::get(current_protocol_version_in_consensus)?; - self.drive - .clear_version_information(Some(transaction), ¤t_platform_version.drive) - .map_err(Error::Drive)?; + // TODO: We stored next version here previously. + // It was never used so we can temporary remove it from here and move it to Epoch trees in upcoming PR + Ok(Some(next_version)) + } else { Ok(None) } } diff --git a/packages/rs-drive-abci/src/execution/types/block_state_info/mod.rs b/packages/rs-drive-abci/src/execution/types/block_state_info/mod.rs index 684bcaaa569..2931f4662cd 100644 --- a/packages/rs-drive-abci/src/execution/types/block_state_info/mod.rs +++ b/packages/rs-drive-abci/src/execution/types/block_state_info/mod.rs @@ -9,6 +9,7 @@ use crate::execution::types::block_state_info::v0::{ use derive_more::From; use dpp::block::block_info::BlockInfo; use dpp::block::epoch::Epoch; +use dpp::util::deserializer::ProtocolVersion; /// The versioned block state info #[derive(Debug, From, Clone, Eq, PartialEq)] @@ -65,6 +66,12 @@ impl BlockStateInfoV0Getters for BlockStateInfo { BlockStateInfo::V0(v0) => v0.app_hash(), } } + + fn protocol_version(&self) -> ProtocolVersion { + match self { + BlockStateInfo::V0(v0) => v0.protocol_version(), + } + } } impl BlockStateInfoV0Setters for BlockStateInfo { @@ -131,6 +138,12 @@ impl BlockStateInfoV0Setters for BlockStateInfo { } } } + + fn set_protocol_version(&mut self, version: ProtocolVersion) { + match self { + BlockStateInfo::V0(v0) => v0.set_protocol_version(version), + } + } } impl BlockStateInfoV0Methods for BlockStateInfo { diff --git a/packages/rs-drive-abci/src/execution/types/block_state_info/v0/mod.rs b/packages/rs-drive-abci/src/execution/types/block_state_info/v0/mod.rs index 8e3b405e651..a8f8250612d 100644 --- a/packages/rs-drive-abci/src/execution/types/block_state_info/v0/mod.rs +++ b/packages/rs-drive-abci/src/execution/types/block_state_info/v0/mod.rs @@ -32,6 +32,7 @@ use crate::error::Error; use crate::platform_types::block_proposal::v0::BlockProposal; use dpp::block::block_info::BlockInfo; use dpp::block::epoch::Epoch; +use dpp::util::deserializer::ProtocolVersion; /// Block info #[derive(Debug, Clone, PartialEq, Eq)] @@ -52,6 +53,8 @@ pub struct BlockStateInfoV0 { pub block_hash: Option<[u8; 32]>, /// Application hash pub app_hash: Option<[u8; 32]>, + /// Current block protocol version + pub protocol_version: ProtocolVersion, } impl BlockStateInfoV0 { @@ -69,6 +72,7 @@ impl BlockStateInfoV0 { core_chain_locked_height: proposal.core_chain_locked_height, block_hash: proposal.block_hash, app_hash: None, + protocol_version: proposal.consensus_versions.app as u32, } } } @@ -201,6 +205,8 @@ pub trait BlockStateInfoV0Getters { /// Gets the application hash. fn app_hash(&self) -> Option<[u8; 32]>; + /// Returns current block protocol version + fn protocol_version(&self) -> ProtocolVersion; } /// A trait for setting the properties of the `BlockStateInfoV0`. @@ -228,6 +234,9 @@ pub trait BlockStateInfoV0Setters { /// Sets the application hash. fn set_app_hash(&mut self, app_hash: Option<[u8; 32]>); + + /// Sets protocol version + fn set_protocol_version(&mut self, version: ProtocolVersion); } impl BlockStateInfoV0Getters for BlockStateInfoV0 { @@ -262,6 +271,10 @@ impl BlockStateInfoV0Getters for BlockStateInfoV0 { fn app_hash(&self) -> Option<[u8; 32]> { self.app_hash } + + fn protocol_version(&self) -> ProtocolVersion { + self.protocol_version + } } impl BlockStateInfoV0Setters for BlockStateInfoV0 { @@ -296,4 +309,8 @@ impl BlockStateInfoV0Setters for BlockStateInfoV0 { fn set_app_hash(&mut self, app_hash: Option<[u8; 32]>) { self.app_hash = app_hash; } + + fn set_protocol_version(&mut self, version: ProtocolVersion) { + self.protocol_version = version; + } } diff --git a/packages/rs-drive-abci/src/mimic/mod.rs b/packages/rs-drive-abci/src/mimic/mod.rs index 53c31e6eee8..02fab12c7bc 100644 --- a/packages/rs-drive-abci/src/mimic/mod.rs +++ b/packages/rs-drive-abci/src/mimic/mod.rs @@ -65,8 +65,8 @@ pub struct MimicExecuteBlockOutcome { pub block_id_hash: [u8; 32], /// Block signature pub signature: [u8; 96], - /// Version of Drive app used to generate this block - pub app_version: u64, + /// Protocol version for next block + pub next_block_protocol_version: Option, } /// Options for execution @@ -88,6 +88,7 @@ impl<'a, C: CoreRPCLike> FullAbciApplication<'a, C> { &self, proposer_pro_tx_hash: [u8; 32], current_quorum: &TestQuorumInfo, + current_version: ProtocolVersion, proposed_version: ProtocolVersion, block_info: BlockInfo, round: u32, @@ -118,8 +119,6 @@ impl<'a, C: CoreRPCLike> FullAbciApplication<'a, C> { .unwrap() }); - const APP_VERSION: u64 = 0; - let mut rng = StdRng::seed_from_u64(block_info.height); let next_validators_hash: [u8; 32] = rng.gen(); // We fake a block hash for the test @@ -154,7 +153,7 @@ impl<'a, C: CoreRPCLike> FullAbciApplication<'a, C> { proposed_app_version: proposed_version as u64, version: Some(Consensus { block: 0, - app: APP_VERSION, + app: current_version as u64, }), quorum_hash: current_quorum.quorum_hash.to_byte_array().to_vec(), }; @@ -232,7 +231,7 @@ impl<'a, C: CoreRPCLike> FullAbciApplication<'a, C> { let state_id = StateId { app_hash: app_hash.clone(), - app_version: APP_VERSION, + app_version: current_version as u64, core_chain_locked_height: core_height, height, time: time.to_milis(), @@ -272,25 +271,28 @@ impl<'a, C: CoreRPCLike> FullAbciApplication<'a, C> { proposed_app_version: proposed_version as u64, version: Some(Consensus { block: 0, - app: APP_VERSION, + app: current_version as u64, }), quorum_hash: current_quorum.quorum_hash.to_byte_array().to_vec(), }; - if !options.independent_process_proposal_verification { + let consensus_param_updates = if !options.independent_process_proposal_verification { //we just check as if we were the proposer //we must call process proposal so the app hash is set - self.process_proposal(request_process_proposal) + let response = self.process_proposal(request_process_proposal) .unwrap_or_else(|e| { panic!( "should skip processing (because we prepared it) block #{} at time #{} : {:?}", block_info.height, block_info.time_ms, e ) }); + + response.consensus_param_updates } else { + // TODO: Shouldn't it be prepare proposal first? //we first call process proposal as the proposer //we must call process proposal so the app hash is set - self.process_proposal(request_process_proposal.clone()) + let response = self.process_proposal(request_process_proposal.clone()) .unwrap_or_else(|e| { panic!( "should skip processing (because we prepared it) block #{} at time #{} : {:?}", @@ -382,7 +384,9 @@ impl<'a, C: CoreRPCLike> FullAbciApplication<'a, C> { "the application hashed are not valid for height {}", block_info.height ); - } + + response.consensus_param_updates + }; let request_extend_vote = RequestExtendVote { hash: block_header_hash.to_vec(), @@ -520,7 +524,7 @@ impl<'a, C: CoreRPCLike> FullAbciApplication<'a, C> { header: Some(Header { version: Some(Consensus { block: 0, //todo - app: APP_VERSION, + app: current_version as u64, }), chain_id: CHAIN_ID.to_string(), height: height as i64, @@ -589,9 +593,18 @@ impl<'a, C: CoreRPCLike> FullAbciApplication<'a, C> { assert_eq!(app_hash, root_hash_after_finalization); } + let next_block_protocol_version = consensus_param_updates + .map(|updates| updates.version) + .map(|version| version.unwrap().app_version) + .map(|version| { + version + .try_into() + .expect("expected a valid protocol version") + }); + Ok(MimicExecuteBlockOutcome { state_transaction_results, - app_version: APP_VERSION, + next_block_protocol_version, withdrawal_transactions, validator_set_update, next_validator_set_hash, diff --git a/packages/rs-drive-abci/src/platform_types/block_execution_outcome/v0/mod.rs b/packages/rs-drive-abci/src/platform_types/block_execution_outcome/v0/mod.rs index e863244a03d..96e52b766fa 100644 --- a/packages/rs-drive-abci/src/platform_types/block_execution_outcome/v0/mod.rs +++ b/packages/rs-drive-abci/src/platform_types/block_execution_outcome/v0/mod.rs @@ -18,6 +18,8 @@ pub struct BlockExecutionOutcome { pub validator_set_update: Option, /// Current block protocol version pub protocol_version: ProtocolVersion, + /// Next block protocol version + pub next_block_protocol_version: Option, /// Block execution context pub block_execution_context: BlockExecutionContext, } diff --git a/packages/rs-drive-abci/tests/strategy_tests/execution.rs b/packages/rs-drive-abci/tests/strategy_tests/execution.rs index af9d6a8adcd..a12a32e1fe1 100644 --- a/packages/rs-drive-abci/tests/strategy_tests/execution.rs +++ b/packages/rs-drive-abci/tests/strategy_tests/execution.rs @@ -837,6 +837,8 @@ pub(crate) fn continue_chain_for_strategy( let mut state_transitions_per_block = BTreeMap::new(); let mut state_transition_results_per_block = BTreeMap::new(); + let mut protocol_version = config.initial_protocol_version; + for block_height in block_start..(block_start + block_count) { let state = platform.state.load(); let epoch_info = EpochInfoV0::calculate( @@ -934,6 +936,7 @@ pub(crate) fn continue_chain_for_strategy( .mimic_execute_block( proposer.pro_tx_hash.into(), current_quorum_with_test_info, + protocol_version, proposed_version, block_info.clone(), round, @@ -963,9 +966,13 @@ pub(crate) fn continue_chain_for_strategy( state_id, block_id_hash: block_hash, signature, - app_version, + next_block_protocol_version, } = block_execution_outcome.unwrap(); + if let Some(version) = next_block_protocol_version { + protocol_version = version; + } + if let Some(validator_set_update) = validator_set_update { validator_set_updates.insert(block_height, validator_set_update); } @@ -1015,7 +1022,7 @@ pub(crate) fn continue_chain_for_strategy( &ProofVerification { quorum_hash: ¤t_quorum_with_test_info.quorum_hash.into(), quorum_type: config.validator_set_quorum_type(), - app_version, + app_version: protocol_version as u64, chain_id: drive_abci::mimic::CHAIN_ID.to_string(), core_chain_locked_height: state_id.core_chain_locked_height, height: state_id.height as i64, diff --git a/packages/rs-drive-abci/tests/strategy_tests/upgrade_fork_tests.rs b/packages/rs-drive-abci/tests/strategy_tests/upgrade_fork_tests.rs index a058ad46ddd..a1ea15e512e 100644 --- a/packages/rs-drive-abci/tests/strategy_tests/upgrade_fork_tests.rs +++ b/packages/rs-drive-abci/tests/strategy_tests/upgrade_fork_tests.rs @@ -52,7 +52,6 @@ mod tests { proposed_protocol_versions_with_weight: vec![(TEST_PROTOCOL_VERSION_2, 1)], upgrade_three_quarters_life: 0.1, }), - proposer_strategy: Default::default(), rotate_quorums: false, failure_testing: None, diff --git a/packages/rs-drive/src/drive/cache/protocol_version.rs b/packages/rs-drive/src/drive/cache/protocol_version.rs index cb1622da398..994eade596a 100644 --- a/packages/rs-drive/src/drive/cache/protocol_version.rs +++ b/packages/rs-drive/src/drive/cache/protocol_version.rs @@ -14,7 +14,6 @@ pub struct ProtocolVersionsCache { pub global_cache: IntMap, block_cache: IntMap, loaded: bool, - needs_wipe: bool, } #[cfg(feature = "full")] @@ -56,13 +55,7 @@ impl ProtocolVersionsCache { /// Merge block cache to global cache pub fn merge_block_cache(&mut self) { - if self.needs_wipe { - self.global_cache.clear(); - self.block_cache.clear(); - self.needs_wipe = false; - } else { - self.global_cache.extend(self.block_cache.drain()); - } + self.global_cache.extend(self.block_cache.drain()); } /// Clear block cache @@ -70,19 +63,20 @@ impl ProtocolVersionsCache { self.block_cache.clear() } - /// Versions passing threshold - pub fn versions_passing_threshold( + /// Collect versions passing threshold + /// and clear both global and block caches + pub fn aggregate_into_versions_passing_threshold( &mut self, - required_upgraded_hpns: u64, + required_upgraded_hpmns: u64, ) -> Vec { - self.needs_wipe = true; let mut cache = self.global_cache.clone(); + self.global_cache.clear(); cache.extend(self.block_cache.drain()); cache .into_iter() .filter_map(|(protocol_version, count)| { - if count >= required_upgraded_hpns { + if count >= required_upgraded_hpmns { Some(protocol_version) } else { None diff --git a/packages/rs-drive/src/drive/protocol_upgrade/change_to_new_version_and_clear_version_information/v0/mod.rs b/packages/rs-drive/src/drive/protocol_upgrade/change_to_new_version_and_clear_version_information/v0/mod.rs index fd37f923f70..b30a6e2db55 100644 --- a/packages/rs-drive/src/drive/protocol_upgrade/change_to_new_version_and_clear_version_information/v0/mod.rs +++ b/packages/rs-drive/src/drive/protocol_upgrade/change_to_new_version_and_clear_version_information/v0/mod.rs @@ -13,6 +13,7 @@ use dpp::ProtocolError; use grovedb::TransactionArg; impl Drive { + /// TODO: Should work with Epoch trees. Will be reworked in upcoming PR /// Clear all version information from the backing store, this is done on epoch change in /// execution logic pub(super) fn change_to_new_version_and_clear_version_information_v0( diff --git a/packages/rs-drive/src/drive/system/protocol_version/set_next_protocol_version_operations/mod.rs b/packages/rs-drive/src/drive/system/protocol_version/set_next_protocol_version_operations/mod.rs index 06dd6e5b040..b2c8cd31a97 100644 --- a/packages/rs-drive/src/drive/system/protocol_version/set_next_protocol_version_operations/mod.rs +++ b/packages/rs-drive/src/drive/system/protocol_version/set_next_protocol_version_operations/mod.rs @@ -25,6 +25,7 @@ impl Drive { /// # Errors /// /// This function will return an error if the version of the Drive is unknown. + // TODO: We should store it for epoch. Will be changed in upcoming PR pub fn set_next_protocol_version_operations( &self, protocol_version: ProtocolVersion, diff --git a/packages/rs-platform-version/src/version/drive_abci_versions.rs b/packages/rs-platform-version/src/version/drive_abci_versions.rs index 902094ddec0..5d01244ed4f 100644 --- a/packages/rs-platform-version/src/version/drive_abci_versions.rs +++ b/packages/rs-platform-version/src/version/drive_abci_versions.rs @@ -249,6 +249,7 @@ pub struct DriveAbciBlockEndMethodVersions { pub update_state_cache: FeatureVersion, pub update_drive_cache: FeatureVersion, pub validator_set_update: FeatureVersion, + pub consensus_param_updates: FeatureVersion, } #[derive(Clone, Debug, Default)] 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 b7103809020..8f593e9254c 100644 --- a/packages/rs-platform-version/src/version/mocks/v2_test.rs +++ b/packages/rs-platform-version/src/version/mocks/v2_test.rs @@ -576,6 +576,7 @@ pub(crate) const TEST_PLATFORM_V2: PlatformVersion = PlatformVersion { update_state_cache: 0, update_drive_cache: 0, validator_set_update: 0, + consensus_param_updates: 0, }, platform_state_storage: DriveAbciPlatformStateStorageMethodVersions { fetch_platform_state: 0, 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 f423c2400fa..45c2bd7efcb 100644 --- a/packages/rs-platform-version/src/version/mocks/v3_test.rs +++ b/packages/rs-platform-version/src/version/mocks/v3_test.rs @@ -576,6 +576,7 @@ pub(crate) const TEST_PLATFORM_V3: PlatformVersion = PlatformVersion { update_state_cache: 0, update_drive_cache: 0, validator_set_update: 0, + consensus_param_updates: 0, }, platform_state_storage: DriveAbciPlatformStateStorageMethodVersions { fetch_platform_state: 0, diff --git a/packages/rs-platform-version/src/version/v1.rs b/packages/rs-platform-version/src/version/v1.rs index 0666b2a9c28..4f57fae5944 100644 --- a/packages/rs-platform-version/src/version/v1.rs +++ b/packages/rs-platform-version/src/version/v1.rs @@ -573,6 +573,7 @@ pub(super) const PLATFORM_V1: PlatformVersion = PlatformVersion { update_state_cache: 0, update_drive_cache: 0, validator_set_update: 0, + consensus_param_updates: 0, }, platform_state_storage: DriveAbciPlatformStateStorageMethodVersions { fetch_platform_state: 0, From b1c77f2627ca9d9252217791af26bf4511983a44 Mon Sep 17 00:00:00 2001 From: Ivan Shumkov Date: Wed, 13 Mar 2024 13:06:37 +0700 Subject: [PATCH 02/37] fix: global cache might be cleaned on failed round --- .../engine/finalize_block_proposal/v0/mod.rs | 4 ++-- .../engine/run_block_proposal/v0/mod.rs | 13 ++++++++----- .../block_end/update_drive_cache/mod.rs | 9 +++++++-- .../block_end/update_drive_cache/v0/mod.rs | 15 ++++++++++++--- .../check_for_desired_protocol_upgrade/mod.rs | 9 ++------- .../v0/mod.rs | 19 ++++--------------- .../src/drive/cache/protocol_version.rs | 16 +++++++++------- 7 files changed, 44 insertions(+), 41 deletions(-) diff --git a/packages/rs-drive-abci/src/execution/engine/finalize_block_proposal/v0/mod.rs b/packages/rs-drive-abci/src/execution/engine/finalize_block_proposal/v0/mod.rs index 0e3ba9b1c59..c96b93b242c 100644 --- a/packages/rs-drive-abci/src/execution/engine/finalize_block_proposal/v0/mod.rs +++ b/packages/rs-drive-abci/src/execution/engine/finalize_block_proposal/v0/mod.rs @@ -237,6 +237,8 @@ where } .into(); + self.update_drive_cache(&block_execution_context, platform_version)?; + let block_platform_state = block_execution_context.block_platform_state_owned(); self.update_state_cache( @@ -246,8 +248,6 @@ where platform_version, )?; - self.update_drive_cache(platform_version)?; - // Gather some metrics crate::metrics::abci_last_block_time(block_header.time.seconds as u64); crate::metrics::abci_last_platform_height(height); diff --git a/packages/rs-drive-abci/src/execution/engine/run_block_proposal/v0/mod.rs b/packages/rs-drive-abci/src/execution/engine/run_block_proposal/v0/mod.rs index df44cc8e3dd..7be6467277c 100644 --- a/packages/rs-drive-abci/src/execution/engine/run_block_proposal/v0/mod.rs +++ b/packages/rs-drive-abci/src/execution/engine/run_block_proposal/v0/mod.rs @@ -291,15 +291,18 @@ where } // Determine new protocol version based on votes for the next epoch - let maybe_new_protocol_version = self.check_for_desired_protocol_upgrade_and_reset( - hpmn_list_len, - transaction, - platform_version, - )?; + let maybe_new_protocol_version = + self.check_for_desired_protocol_upgrade(hpmn_list_len, platform_version)?; if let Some(new_protocol_version) = maybe_new_protocol_version { block_platform_state.set_next_epoch_protocol_version(new_protocol_version); } + + // Since we are starting new epoch we need to drop previously + // proposed versions + self.drive + .clear_version_information(Some(transaction), &platform_version.drive) + .map_err(Error::Drive)?; } // Mark all previously broadcasted and chainlocked withdrawals as complete diff --git a/packages/rs-drive-abci/src/execution/platform_events/block_end/update_drive_cache/mod.rs b/packages/rs-drive-abci/src/execution/platform_events/block_end/update_drive_cache/mod.rs index cc0692e8f3a..0342fe45594 100644 --- a/packages/rs-drive-abci/src/execution/platform_events/block_end/update_drive_cache/mod.rs +++ b/packages/rs-drive-abci/src/execution/platform_events/block_end/update_drive_cache/mod.rs @@ -7,6 +7,7 @@ use crate::platform_types::platform::Platform; use crate::rpc::core::CoreRPCLike; +use crate::execution::types::block_execution_context::BlockExecutionContext; use dpp::version::PlatformVersion; impl Platform @@ -29,7 +30,11 @@ where /// * `Result<(), Error>` - If the state cache and quorums are successfully updated, it returns `Ok(())`. /// If there is a problem with the update, it returns an `Error`. /// - pub fn update_drive_cache(&self, platform_version: &PlatformVersion) -> Result<(), Error> { + pub fn update_drive_cache( + &self, + block_execution_context: &BlockExecutionContext, + platform_version: &PlatformVersion, + ) -> Result<(), Error> { match platform_version .drive_abci .methods @@ -37,7 +42,7 @@ where .update_drive_cache { 0 => { - self.update_drive_cache_v0(); + self.update_drive_cache_v0(block_execution_context); Ok(()) } version => Err(Error::Execution(ExecutionError::UnknownVersionMismatch { diff --git a/packages/rs-drive-abci/src/execution/platform_events/block_end/update_drive_cache/v0/mod.rs b/packages/rs-drive-abci/src/execution/platform_events/block_end/update_drive_cache/v0/mod.rs index 96f8fcea4b4..a75c22d142d 100644 --- a/packages/rs-drive-abci/src/execution/platform_events/block_end/update_drive_cache/v0/mod.rs +++ b/packages/rs-drive-abci/src/execution/platform_events/block_end/update_drive_cache/v0/mod.rs @@ -1,3 +1,6 @@ +use crate::execution::types::block_execution_context::v0::BlockExecutionContextV0Getters; +use crate::execution::types::block_execution_context::BlockExecutionContext; +use crate::platform_types::epoch_info::v0::EpochInfoV0Getters; use crate::platform_types::platform::Platform; use crate::rpc::core::CoreRPCLike; @@ -8,8 +11,8 @@ where /// Updates the drive cache at the end of finalize block. This does a few things like merging /// the data contract cache and the platform versions cache. /// - pub(super) fn update_drive_cache_v0(&self) { - // Update global cache with updated contracts + pub(super) fn update_drive_cache_v0(&self, block_execution_context: &BlockExecutionContext) { + // Update global cache with updated contracts form this block self.drive .cache .data_contracts @@ -17,6 +20,12 @@ where let mut protocol_versions_counter = self.drive.cache.protocol_versions_counter.write(); - protocol_versions_counter.merge_block_cache() + if block_execution_context.epoch_info().is_epoch_change() { + // Clear previously proposed versions since we started a new epoch + protocol_versions_counter.clear(); + } else { + // Update proposed versions with new proposal from the current block + protocol_versions_counter.merge_block_cache() + } } } diff --git a/packages/rs-drive-abci/src/execution/platform_events/protocol_upgrade/check_for_desired_protocol_upgrade/mod.rs b/packages/rs-drive-abci/src/execution/platform_events/protocol_upgrade/check_for_desired_protocol_upgrade/mod.rs index fcc02c772e3..86d518326a4 100644 --- a/packages/rs-drive-abci/src/execution/platform_events/protocol_upgrade/check_for_desired_protocol_upgrade/mod.rs +++ b/packages/rs-drive-abci/src/execution/platform_events/protocol_upgrade/check_for_desired_protocol_upgrade/mod.rs @@ -28,10 +28,9 @@ impl Platform { /// * There is an issue interacting with the underlying storage. /// * An overflow occurs when calculating the required block count. /// * More than one version pass the threshold to upgrade. - pub fn check_for_desired_protocol_upgrade_and_reset( + pub fn check_for_desired_protocol_upgrade( &self, total_hpmns: u32, - transaction: &Transaction, platform_version: &PlatformVersion, ) -> Result, Error> { match platform_version @@ -40,11 +39,7 @@ impl Platform { .protocol_upgrade .check_for_desired_protocol_upgrade { - 0 => self.check_for_desired_protocol_upgrade_and_reset_v0( - total_hpmns, - transaction, - platform_version, - ), + 0 => self.check_for_desired_protocol_upgrade_v0(total_hpmns), version => Err(Error::Execution(ExecutionError::UnknownVersionMismatch { method: "check_for_desired_protocol_upgrade".to_string(), known_versions: vec![0], diff --git a/packages/rs-drive-abci/src/execution/platform_events/protocol_upgrade/check_for_desired_protocol_upgrade/v0/mod.rs b/packages/rs-drive-abci/src/execution/platform_events/protocol_upgrade/check_for_desired_protocol_upgrade/v0/mod.rs index 8ad6b3aec5b..a9d4c77ceb0 100644 --- a/packages/rs-drive-abci/src/execution/platform_events/protocol_upgrade/check_for_desired_protocol_upgrade/v0/mod.rs +++ b/packages/rs-drive-abci/src/execution/platform_events/protocol_upgrade/check_for_desired_protocol_upgrade/v0/mod.rs @@ -1,10 +1,8 @@ use crate::error::execution::ExecutionError; use crate::error::Error; use crate::platform_types::platform::Platform; -use dpp::version::PlatformVersion; use drive::dpp::util::deserializer::ProtocolVersion; -use drive::grovedb::Transaction; /// The percentage needed of HPMNs to upgrade the protocol /// It always needs to be higher than the rounded amount after applying the percentage @@ -13,12 +11,9 @@ const PROTOCOL_VERSION_UPGRADE_PERCENTAGE_NEEDED: u64 = 75; impl Platform { /// checks for a network upgrade and resets activation window /// this should only be called on epoch change - /// this will change backing state and drive cache - pub(super) fn check_for_desired_protocol_upgrade_and_reset_v0( + pub(super) fn check_for_desired_protocol_upgrade_v0( &self, total_hpmns: u32, - transaction: &Transaction, - platform_version: &PlatformVersion, ) -> Result, Error> { let required_upgraded_hpns = 1 + (total_hpmns as u64) @@ -30,10 +25,9 @@ impl Platform { // if we are at an epoch change, check to see if over 75% of blocks of previous epoch // were on the future version - // This also clears the cache - let mut protocol_versions_counter = self.drive.cache.protocol_versions_counter.write(); - let mut versions_passing_threshold = protocol_versions_counter - .aggregate_into_versions_passing_threshold(required_upgraded_hpns); + let protocol_versions_counter = self.drive.cache.protocol_versions_counter.read(); + let mut versions_passing_threshold = + protocol_versions_counter.versions_passing_threshold(required_upgraded_hpns); drop(protocol_versions_counter); if versions_passing_threshold.len() > 1 { @@ -44,11 +38,6 @@ impl Platform { )); } - // we need to drop all version information - self.drive - .clear_version_information(Some(transaction), &platform_version.drive) - .map_err(Error::Drive)?; - if !versions_passing_threshold.is_empty() { // same as equals 1 let next_version = versions_passing_threshold.remove(0); diff --git a/packages/rs-drive/src/drive/cache/protocol_version.rs b/packages/rs-drive/src/drive/cache/protocol_version.rs index 994eade596a..291c942669f 100644 --- a/packages/rs-drive/src/drive/cache/protocol_version.rs +++ b/packages/rs-drive/src/drive/cache/protocol_version.rs @@ -58,21 +58,23 @@ impl ProtocolVersionsCache { self.global_cache.extend(self.block_cache.drain()); } + /// Clears the cache + pub fn clear(&mut self) { + self.loaded = false; + self.global_cache.clear(); + self.block_cache.clear(); + } + /// Clear block cache pub fn clear_block_cache(&mut self) { self.block_cache.clear() } /// Collect versions passing threshold - /// and clear both global and block caches - pub fn aggregate_into_versions_passing_threshold( - &mut self, - required_upgraded_hpmns: u64, - ) -> Vec { + pub fn versions_passing_threshold(&self, required_upgraded_hpmns: u64) -> Vec { let mut cache = self.global_cache.clone(); - self.global_cache.clear(); - cache.extend(self.block_cache.drain()); + cache.extend(self.block_cache.iter()); cache .into_iter() .filter_map(|(protocol_version, count)| { From f7902dbe0aff3e30da15845ebad1fdc2be7c9950 Mon Sep 17 00:00:00 2001 From: Ivan Shumkov Date: Wed, 13 Mar 2024 18:08:41 +0700 Subject: [PATCH 03/37] refactor: reuse version from block platform state --- .../src/abci/handler/finalize_block.rs | 10 +++------- .../src/execution/types/block_state_info/mod.rs | 13 ------------- .../src/execution/types/block_state_info/v0/mod.rs | 13 ------------- 3 files changed, 3 insertions(+), 33 deletions(-) diff --git a/packages/rs-drive-abci/src/abci/handler/finalize_block.rs b/packages/rs-drive-abci/src/abci/handler/finalize_block.rs index dee6bf27abb..e6c1e97600e 100644 --- a/packages/rs-drive-abci/src/abci/handler/finalize_block.rs +++ b/packages/rs-drive-abci/src/abci/handler/finalize_block.rs @@ -2,9 +2,7 @@ use crate::abci::app::{BlockExecutionApplication, PlatformApplication, Transacti use crate::error::execution::ExecutionError; use crate::error::Error; use crate::execution::types::block_execution_context::v0::BlockExecutionContextV0Getters; -use crate::execution::types::block_state_info::v0::BlockStateInfoV0Getters; use crate::rpc::core::CoreRPCLike; -use dpp::version::PlatformVersion; use tenderdash_abci::proto::abci as proto; pub fn finalize_block<'a, A, C>( @@ -35,11 +33,9 @@ where "block execution context must be set in block begin handler for finalize block", )))?; - // Use current block protocol version - let protocol_version = block_execution_context - .block_state_info() - .protocol_version(); - let platform_version = PlatformVersion::get(protocol_version)?; + let platform_version = block_execution_context + .block_platform_state() + .current_platform_version()?; let block_finalization_outcome = app.platform().finalize_block_proposal( request.try_into()?, diff --git a/packages/rs-drive-abci/src/execution/types/block_state_info/mod.rs b/packages/rs-drive-abci/src/execution/types/block_state_info/mod.rs index 2931f4662cd..684bcaaa569 100644 --- a/packages/rs-drive-abci/src/execution/types/block_state_info/mod.rs +++ b/packages/rs-drive-abci/src/execution/types/block_state_info/mod.rs @@ -9,7 +9,6 @@ use crate::execution::types::block_state_info::v0::{ use derive_more::From; use dpp::block::block_info::BlockInfo; use dpp::block::epoch::Epoch; -use dpp::util::deserializer::ProtocolVersion; /// The versioned block state info #[derive(Debug, From, Clone, Eq, PartialEq)] @@ -66,12 +65,6 @@ impl BlockStateInfoV0Getters for BlockStateInfo { BlockStateInfo::V0(v0) => v0.app_hash(), } } - - fn protocol_version(&self) -> ProtocolVersion { - match self { - BlockStateInfo::V0(v0) => v0.protocol_version(), - } - } } impl BlockStateInfoV0Setters for BlockStateInfo { @@ -138,12 +131,6 @@ impl BlockStateInfoV0Setters for BlockStateInfo { } } } - - fn set_protocol_version(&mut self, version: ProtocolVersion) { - match self { - BlockStateInfo::V0(v0) => v0.set_protocol_version(version), - } - } } impl BlockStateInfoV0Methods for BlockStateInfo { diff --git a/packages/rs-drive-abci/src/execution/types/block_state_info/v0/mod.rs b/packages/rs-drive-abci/src/execution/types/block_state_info/v0/mod.rs index a8f8250612d..a5582071881 100644 --- a/packages/rs-drive-abci/src/execution/types/block_state_info/v0/mod.rs +++ b/packages/rs-drive-abci/src/execution/types/block_state_info/v0/mod.rs @@ -205,8 +205,6 @@ pub trait BlockStateInfoV0Getters { /// Gets the application hash. fn app_hash(&self) -> Option<[u8; 32]>; - /// Returns current block protocol version - fn protocol_version(&self) -> ProtocolVersion; } /// A trait for setting the properties of the `BlockStateInfoV0`. @@ -234,9 +232,6 @@ pub trait BlockStateInfoV0Setters { /// Sets the application hash. fn set_app_hash(&mut self, app_hash: Option<[u8; 32]>); - - /// Sets protocol version - fn set_protocol_version(&mut self, version: ProtocolVersion); } impl BlockStateInfoV0Getters for BlockStateInfoV0 { @@ -271,10 +266,6 @@ impl BlockStateInfoV0Getters for BlockStateInfoV0 { fn app_hash(&self) -> Option<[u8; 32]> { self.app_hash } - - fn protocol_version(&self) -> ProtocolVersion { - self.protocol_version - } } impl BlockStateInfoV0Setters for BlockStateInfoV0 { @@ -309,8 +300,4 @@ impl BlockStateInfoV0Setters for BlockStateInfoV0 { fn set_app_hash(&mut self, app_hash: Option<[u8; 32]>) { self.app_hash = app_hash; } - - fn set_protocol_version(&mut self, version: ProtocolVersion) { - self.protocol_version = version; - } } From fc14163f1210013647034dbdd436b4769f4f4613 Mon Sep 17 00:00:00 2001 From: Ivan Shumkov Date: Wed, 13 Mar 2024 18:15:48 +0700 Subject: [PATCH 04/37] refactor: remove unnecessary field --- .../src/execution/types/block_state_info/v0/mod.rs | 3 --- 1 file changed, 3 deletions(-) diff --git a/packages/rs-drive-abci/src/execution/types/block_state_info/v0/mod.rs b/packages/rs-drive-abci/src/execution/types/block_state_info/v0/mod.rs index a5582071881..019e3e3bcf4 100644 --- a/packages/rs-drive-abci/src/execution/types/block_state_info/v0/mod.rs +++ b/packages/rs-drive-abci/src/execution/types/block_state_info/v0/mod.rs @@ -53,8 +53,6 @@ pub struct BlockStateInfoV0 { pub block_hash: Option<[u8; 32]>, /// Application hash pub app_hash: Option<[u8; 32]>, - /// Current block protocol version - pub protocol_version: ProtocolVersion, } impl BlockStateInfoV0 { @@ -72,7 +70,6 @@ impl BlockStateInfoV0 { core_chain_locked_height: proposal.core_chain_locked_height, block_hash: proposal.block_hash, app_hash: None, - protocol_version: proposal.consensus_versions.app as u32, } } } From f759116db4e1e483f132be1e205bc4c7244a47e2 Mon Sep 17 00:00:00 2001 From: Ivan Shumkov Date: Wed, 13 Mar 2024 18:16:46 +0700 Subject: [PATCH 05/37] refactor: remove unused import --- .../rs-drive-abci/src/execution/types/block_state_info/v0/mod.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/packages/rs-drive-abci/src/execution/types/block_state_info/v0/mod.rs b/packages/rs-drive-abci/src/execution/types/block_state_info/v0/mod.rs index 019e3e3bcf4..8e3b405e651 100644 --- a/packages/rs-drive-abci/src/execution/types/block_state_info/v0/mod.rs +++ b/packages/rs-drive-abci/src/execution/types/block_state_info/v0/mod.rs @@ -32,7 +32,6 @@ use crate::error::Error; use crate::platform_types::block_proposal::v0::BlockProposal; use dpp::block::block_info::BlockInfo; use dpp::block::epoch::Epoch; -use dpp::util::deserializer::ProtocolVersion; /// Block info #[derive(Debug, Clone, PartialEq, Eq)] From f611ff65c5e860a88c5b8625bfe1b7db71f63c53 Mon Sep 17 00:00:00 2001 From: Ivan Shumkov Date: Wed, 13 Mar 2024 18:18:54 +0700 Subject: [PATCH 06/37] fix: compilation errors --- .../add_process_epoch_change_operations/v0/mod.rs | 1 - .../block_fee_processing/process_block_fees/v0/mod.rs | 1 - 2 files changed, 2 deletions(-) diff --git a/packages/rs-drive-abci/src/execution/platform_events/block_fee_processing/add_process_epoch_change_operations/v0/mod.rs b/packages/rs-drive-abci/src/execution/platform_events/block_fee_processing/add_process_epoch_change_operations/v0/mod.rs index c9665fbe836..1314bd11165 100644 --- a/packages/rs-drive-abci/src/execution/platform_events/block_fee_processing/add_process_epoch_change_operations/v0/mod.rs +++ b/packages/rs-drive-abci/src/execution/platform_events/block_fee_processing/add_process_epoch_change_operations/v0/mod.rs @@ -215,7 +215,6 @@ mod tests { core_chain_locked_height: 1, block_hash: None, app_hash: None, - protocol_version: 1, }; let epoch_info = EpochInfoV0::from_genesis_time_and_block_info( diff --git a/packages/rs-drive-abci/src/execution/platform_events/block_fee_processing/process_block_fees/v0/mod.rs b/packages/rs-drive-abci/src/execution/platform_events/block_fee_processing/process_block_fees/v0/mod.rs index 45e778405d9..5659c7affe0 100644 --- a/packages/rs-drive-abci/src/execution/platform_events/block_fee_processing/process_block_fees/v0/mod.rs +++ b/packages/rs-drive-abci/src/execution/platform_events/block_fee_processing/process_block_fees/v0/mod.rs @@ -257,7 +257,6 @@ mod tests { core_chain_locked_height: 1, block_hash: None, app_hash: None, - protocol_version: 1, }; let epoch_info = EpochInfoV0::from_genesis_time_and_block_info( From 4f1373f5e5cbd593f8925b8f70d8da30f54d3ad9 Mon Sep 17 00:00:00 2001 From: Ivan Shumkov Date: Thu, 14 Mar 2024 13:31:31 +0700 Subject: [PATCH 07/37] fix: clean first block proposed version --- .../platform_events/block_end/update_drive_cache/v0/mod.rs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/packages/rs-drive-abci/src/execution/platform_events/block_end/update_drive_cache/v0/mod.rs b/packages/rs-drive-abci/src/execution/platform_events/block_end/update_drive_cache/v0/mod.rs index a75c22d142d..f409d077c86 100644 --- a/packages/rs-drive-abci/src/execution/platform_events/block_end/update_drive_cache/v0/mod.rs +++ b/packages/rs-drive-abci/src/execution/platform_events/block_end/update_drive_cache/v0/mod.rs @@ -1,6 +1,6 @@ use crate::execution::types::block_execution_context::v0::BlockExecutionContextV0Getters; use crate::execution::types::block_execution_context::BlockExecutionContext; -use crate::platform_types::epoch_info::v0::EpochInfoV0Getters; +use crate::platform_types::epoch_info::v0::EpochInfoV0Methods; use crate::platform_types::platform::Platform; use crate::rpc::core::CoreRPCLike; @@ -20,7 +20,10 @@ where let mut protocol_versions_counter = self.drive.cache.protocol_versions_counter.write(); - if block_execution_context.epoch_info().is_epoch_change() { + if block_execution_context + .epoch_info() + .is_epoch_change_but_not_genesis() + { // Clear previously proposed versions since we started a new epoch protocol_versions_counter.clear(); } else { From e5f1acc3d90a9c109a4ed589f044ef20d5b1e59b Mon Sep 17 00:00:00 2001 From: Ivan Shumkov Date: Fri, 15 Mar 2024 08:36:45 +0700 Subject: [PATCH 08/37] feat: use version from genesis to run init chain --- packages/rs-drive-abci/src/config.rs | 22 +++++++++---------- .../engine/initialization/init_chain/mod.rs | 21 ++++++++++++++++-- .../rs-drive-abci/src/test/fixture/abci.rs | 2 +- .../tests/strategy_tests/execution.rs | 2 +- packages/rs-drive/src/drive/open/mod.rs | 2 ++ 5 files changed, 33 insertions(+), 16 deletions(-) diff --git a/packages/rs-drive-abci/src/config.rs b/packages/rs-drive-abci/src/config.rs index 29e862e9160..87e060fbb5a 100644 --- a/packages/rs-drive-abci/src/config.rs +++ b/packages/rs-drive-abci/src/config.rs @@ -31,6 +31,7 @@ use std::path::PathBuf; use dpp::util::deserializer::ProtocolVersion; use drive::drive::config::DriveConfig; +use drive::drive::defaults::INITIAL_PROTOCOL_VERSION; use serde::{de::DeserializeOwned, Deserialize, Serialize}; use crate::logging::LogConfigs; @@ -194,10 +195,6 @@ pub struct PlatformConfig { /// Approximately how often are blocks produced pub block_spacing_ms: u64, - /// Initial protocol version - #[serde(default = "PlatformConfig::default_initial_protocol_version")] - pub initial_protocol_version: ProtocolVersion, - /// Path to data storage pub db_path: PathBuf, @@ -237,11 +234,6 @@ impl ExecutionConfig { } impl PlatformConfig { - fn default_initial_protocol_version() -> ProtocolVersion { - //todo: versioning - 1 - } - fn default_tokio_console_address() -> String { String::from("127.0.0.1:6669") } @@ -346,7 +338,6 @@ impl PlatformConfig { tokio_console_enabled: false, tokio_console_address: PlatformConfig::default_tokio_console_address(), tokio_console_retention_secs: PlatformConfig::default_tokio_console_retention_secs(), - initial_protocol_version: 1, prometheus_bind_address: None, grpc_bind_address: "0.0.0.0:26670".to_string(), } @@ -366,7 +357,6 @@ impl PlatformConfig { execution: Default::default(), db_path: PathBuf::from("/var/lib/dash-platform/data"), testing_configs: PlatformTestConfig::default(), - initial_protocol_version: 1, prometheus_bind_address: None, grpc_bind_address: "0.0.0.0:26670".to_string(), tokio_console_enabled: false, @@ -389,7 +379,6 @@ impl PlatformConfig { execution: Default::default(), db_path: PathBuf::from("/var/lib/dash-platform/data"), testing_configs: PlatformTestConfig::default(), - initial_protocol_version: 1, prometheus_bind_address: None, grpc_bind_address: "0.0.0.0:26670".to_string(), tokio_console_enabled: false, @@ -406,6 +395,9 @@ pub struct PlatformTestConfig { pub block_signing: bool, /// Block signature verification pub block_commit_signature_verification: bool, + /// Initial protocol version + #[serde(default = "PlatformTestConfig::default_initial_protocol_version")] + pub initial_protocol_version: ProtocolVersion, } impl PlatformTestConfig { @@ -414,8 +406,13 @@ impl PlatformTestConfig { Self { block_signing: false, block_commit_signature_verification: false, + initial_protocol_version: Self::default_initial_protocol_version(), } } + + fn default_initial_protocol_version() -> ProtocolVersion { + INITIAL_PROTOCOL_VERSION + } } impl Default for PlatformTestConfig { @@ -423,6 +420,7 @@ impl Default for PlatformTestConfig { Self { block_signing: true, block_commit_signature_verification: true, + initial_protocol_version: Self::default_initial_protocol_version(), } } } diff --git a/packages/rs-drive-abci/src/execution/engine/initialization/init_chain/mod.rs b/packages/rs-drive-abci/src/execution/engine/initialization/init_chain/mod.rs index 57ec814c047..17ffc5ca918 100644 --- a/packages/rs-drive-abci/src/execution/engine/initialization/init_chain/mod.rs +++ b/packages/rs-drive-abci/src/execution/engine/initialization/init_chain/mod.rs @@ -5,7 +5,9 @@ use crate::platform_types::platform::Platform; use crate::rpc::core::CoreRPCLike; +use crate::abci::AbciError; use crate::error::execution::ExecutionError; +use dpp::util::deserializer::ProtocolVersion; use dpp::version::PlatformVersion; use drive::grovedb::Transaction; use tenderdash_abci::proto::abci::{RequestInitChain, ResponseInitChain}; @@ -22,8 +24,23 @@ where ) -> Result { // We don't have platform state at this point, so we should // use initial protocol version from genesis - let protocol_version = self.config.initial_protocol_version; - let platform_version = PlatformVersion::get(protocol_version)?; + // TODO: Shall we use request_init_chain_cleaned_params::v0::RequestInitChainCleanedParams::try_from instead of copy + // pasting code form there? + let consensus_params = request + .consensus_params + .as_ref() + .ok_or(AbciError::BadRequest( + "consensus params are required in init chain".to_string(), + ))?; + + let tenderdash_abci::proto::types::VersionParams { app_version } = consensus_params + .version + .as_ref() + .ok_or(AbciError::BadRequest( + "consensus params version is required in init chain".to_string(), + ))?; + + let platform_version = PlatformVersion::get(*app_version as ProtocolVersion)?; match platform_version.drive_abci.methods.engine.init_chain { 0 => self.init_chain_v0(request, transaction, platform_version), diff --git a/packages/rs-drive-abci/src/test/fixture/abci.rs b/packages/rs-drive-abci/src/test/fixture/abci.rs index 0330ac740cc..1e0e2784dae 100644 --- a/packages/rs-drive-abci/src/test/fixture/abci.rs +++ b/packages/rs-drive-abci/src/test/fixture/abci.rs @@ -51,7 +51,7 @@ pub fn static_init_chain_request(config: &PlatformConfig) -> RequestInitChain { chain_id: "strategy_tests".to_string(), consensus_params: Some(ConsensusParams { version: Some(VersionParams { - app_version: config.initial_protocol_version as u64, + app_version: config.testing_configs.initial_protocol_version as u64, }), ..Default::default() }), diff --git a/packages/rs-drive-abci/tests/strategy_tests/execution.rs b/packages/rs-drive-abci/tests/strategy_tests/execution.rs index a12a32e1fe1..2f310489f90 100644 --- a/packages/rs-drive-abci/tests/strategy_tests/execution.rs +++ b/packages/rs-drive-abci/tests/strategy_tests/execution.rs @@ -837,7 +837,7 @@ pub(crate) fn continue_chain_for_strategy( let mut state_transitions_per_block = BTreeMap::new(); let mut state_transition_results_per_block = BTreeMap::new(); - let mut protocol_version = config.initial_protocol_version; + let mut protocol_version = config.testing_configs.initial_protocol_version; for block_height in block_start..(block_start + block_count) { let state = platform.state.load(); diff --git a/packages/rs-drive/src/drive/open/mod.rs b/packages/rs-drive/src/drive/open/mod.rs index 5f3d00f1d26..8dca4f3fc09 100644 --- a/packages/rs-drive/src/drive/open/mod.rs +++ b/packages/rs-drive/src/drive/open/mod.rs @@ -39,6 +39,8 @@ impl Drive { let protocol_version = Drive::fetch_current_protocol_version_with_grovedb(&grove, None)?; + // At this point we don't know the version what we need to process next block or initialize the chain + // so version related data should be updated on init chain or on block execution let platform_version = PlatformVersion::get(protocol_version.unwrap_or(INITIAL_PROTOCOL_VERSION)) .map_err(ProtocolError::PlatformVersionError)?; From 4f155f7f053c46800b5400814a36d833ea329367 Mon Sep 17 00:00:00 2001 From: Ivan Shumkov Date: Fri, 15 Mar 2024 14:11:00 +0700 Subject: [PATCH 09/37] feat: provide protocol version in epoch info query --- .../protos/platform/v0/platform.proto | 101 +++++++++--------- .../proto/org.dash.platform.dapi.v0.rs | 2 + .../src/block/extended_epoch_info/mod.rs | 7 ++ .../src/block/extended_epoch_info/v0/mod.rs | 6 ++ .../engine/run_block_proposal/v0/mod.rs | 3 +- .../mod.rs | 7 +- .../v0/mod.rs | 39 ++++++- .../process_block_fees/mod.rs | 7 +- .../process_block_fees/v0/mod.rs | 36 +++++-- .../create_genesis_state/v0/mod.rs | 4 +- .../src/query/system/epoch_infos/v0/mod.rs | 1 + .../tests/strategy_tests/main.rs | 6 +- .../strategy_tests/upgrade_fork_tests.rs | 33 ++++++ .../epochs/get_epochs_infos/v0/mod.rs | 28 ++++- .../epochs/prove_epochs_infos/v0/mod.rs | 7 +- .../src/drive/initialization/v0/mod.rs | 6 +- .../system/verify_epoch_infos/v0/mod.rs | 29 ++++- .../fee_pools/epochs/epoch_key_constants.rs | 2 + .../fee_pools/epochs/operations_factory.rs | 14 ++- packages/rs-drive/src/fee_pools/mod.rs | 7 ++ 20 files changed, 259 insertions(+), 86 deletions(-) diff --git a/packages/dapi-grpc/protos/platform/v0/platform.proto b/packages/dapi-grpc/protos/platform/v0/platform.proto index f39ef8cc167..6f59ed01f3a 100644 --- a/packages/dapi-grpc/protos/platform/v0/platform.proto +++ b/packages/dapi-grpc/protos/platform/v0/platform.proto @@ -8,31 +8,31 @@ import "google/protobuf/timestamp.proto"; service Platform { rpc broadcastStateTransition(BroadcastStateTransitionRequest) - returns (BroadcastStateTransitionResponse); + returns (BroadcastStateTransitionResponse); rpc getIdentity(GetIdentityRequest) returns (GetIdentityResponse); rpc getIdentities(GetIdentitiesRequest) returns (GetIdentitiesResponse); rpc getIdentityKeys(GetIdentityKeysRequest) returns (GetIdentityKeysResponse); rpc getIdentityNonce(GetIdentityNonceRequest) returns (GetIdentityNonceResponse); rpc getIdentityContractNonce(GetIdentityContractNonceRequest) returns (GetIdentityContractNonceResponse); rpc getIdentityBalance(GetIdentityBalanceRequest) - returns (GetIdentityBalanceResponse); + returns (GetIdentityBalanceResponse); rpc getIdentityBalanceAndRevision(GetIdentityBalanceAndRevisionRequest) - returns (GetIdentityBalanceAndRevisionResponse); + returns (GetIdentityBalanceAndRevisionResponse); rpc getProofs(GetProofsRequest) returns (GetProofsResponse); rpc getDataContract(GetDataContractRequest) returns (GetDataContractResponse); rpc getDataContractHistory(GetDataContractHistoryRequest) - returns (GetDataContractHistoryResponse); + returns (GetDataContractHistoryResponse); rpc getDataContracts(GetDataContractsRequest) - returns (GetDataContractsResponse); + returns (GetDataContractsResponse); rpc getDocuments(GetDocumentsRequest) returns (GetDocumentsResponse); rpc getIdentitiesByPublicKeyHashes(GetIdentitiesByPublicKeyHashesRequest) - returns (GetIdentitiesByPublicKeyHashesResponse); + returns (GetIdentitiesByPublicKeyHashesResponse); rpc getIdentityByPublicKeyHash(GetIdentityByPublicKeyHashRequest) - returns (GetIdentityByPublicKeyHashResponse); + returns (GetIdentityByPublicKeyHashResponse); rpc waitForStateTransitionResult(WaitForStateTransitionResultRequest) - returns (WaitForStateTransitionResultResponse); + returns (WaitForStateTransitionResultResponse); rpc getConsensusParams(GetConsensusParamsRequest) - returns (GetConsensusParamsResponse); + returns (GetConsensusParamsResponse); rpc getProtocolVersionUpgradeState(GetProtocolVersionUpgradeStateRequest) returns (GetProtocolVersionUpgradeStateResponse); rpc getProtocolVersionUpgradeVoteStatus(GetProtocolVersionUpgradeVoteStatusRequest) returns (GetProtocolVersionUpgradeVoteStatusResponse); rpc getEpochsInfo(GetEpochsInfoRequest) returns (GetEpochsInfoResponse); @@ -62,7 +62,7 @@ message StateTransitionBroadcastError { bytes data = 3; } -message BroadcastStateTransitionRequest { bytes state_transition = 1; } +message BroadcastStateTransitionRequest {bytes state_transition = 1;} message BroadcastStateTransitionResponse {} @@ -73,7 +73,7 @@ message GetIdentityRequest { bool prove = 2; } - oneof version { GetIdentityRequestV0 v0 = 1; } + oneof version {GetIdentityRequestV0 v0 = 1;} } message GetIdentityNonceRequest { @@ -83,7 +83,7 @@ message GetIdentityNonceRequest { bool prove = 2; } - oneof version { GetIdentityNonceRequestV0 v0 = 1; } + oneof version {GetIdentityNonceRequestV0 v0 = 1;} } @@ -95,7 +95,7 @@ message GetIdentityContractNonceRequest { bool prove = 3; } - oneof version { GetIdentityContractNonceRequestV0 v0 = 1; } + oneof version {GetIdentityContractNonceRequestV0 v0 = 1;} } message GetIdentityBalanceRequest { @@ -105,7 +105,7 @@ message GetIdentityBalanceRequest { bool prove = 2; } - oneof version { GetIdentityBalanceRequestV0 v0 = 1; } + oneof version {GetIdentityBalanceRequestV0 v0 = 1;} } message GetIdentityBalanceAndRevisionRequest { @@ -115,7 +115,7 @@ message GetIdentityBalanceAndRevisionRequest { bool prove = 2; } - oneof version { GetIdentityBalanceAndRevisionRequestV0 v0 = 1; } + oneof version {GetIdentityBalanceAndRevisionRequestV0 v0 = 1;} } message GetIdentityResponse { @@ -128,7 +128,7 @@ message GetIdentityResponse { ResponseMetadata metadata = 3; } - oneof version { GetIdentityResponseV0 v0 = 1; } + oneof version {GetIdentityResponseV0 v0 = 1;} } message GetIdentitiesRequest { @@ -138,19 +138,19 @@ message GetIdentitiesRequest { bool prove = 2; } - oneof version { GetIdentitiesRequestV0 v0 = 1; } + oneof version {GetIdentitiesRequestV0 v0 = 1;} } message GetIdentitiesResponse { - message IdentityValue { bytes value = 1; } + message IdentityValue {bytes value = 1;} message IdentityEntry { bytes key = 1; IdentityValue value = 2; } - message Identities { repeated IdentityEntry identity_entries = 1; } + message Identities {repeated IdentityEntry identity_entries = 1;} message GetIdentitiesResponseV0 { oneof result { @@ -160,7 +160,7 @@ message GetIdentitiesResponse { ResponseMetadata metadata = 3; } - oneof version { GetIdentitiesResponseV0 v0 = 1; } + oneof version {GetIdentitiesResponseV0 v0 = 1;} } message GetIdentityNonceResponse { @@ -173,7 +173,7 @@ message GetIdentityNonceResponse { ResponseMetadata metadata = 3; } - oneof version { GetIdentityNonceResponseV0 v0 = 1; } + oneof version {GetIdentityNonceResponseV0 v0 = 1;} } message GetIdentityContractNonceResponse { @@ -186,7 +186,7 @@ message GetIdentityContractNonceResponse { ResponseMetadata metadata = 3; } - oneof version { GetIdentityContractNonceResponseV0 v0 = 1; } + oneof version {GetIdentityContractNonceResponseV0 v0 = 1;} } message GetIdentityBalanceResponse { @@ -199,7 +199,7 @@ message GetIdentityBalanceResponse { ResponseMetadata metadata = 3; } - oneof version { GetIdentityBalanceResponseV0 v0 = 1; } + oneof version {GetIdentityBalanceResponseV0 v0 = 1;} } message GetIdentityBalanceAndRevisionResponse { @@ -217,7 +217,7 @@ message GetIdentityBalanceAndRevisionResponse { ResponseMetadata metadata = 3; } - oneof version { GetIdentityBalanceAndRevisionResponseV0 v0 = 1; } + oneof version {GetIdentityBalanceAndRevisionResponseV0 v0 = 1;} } message KeyRequestType { @@ -230,9 +230,9 @@ message KeyRequestType { message AllKeys {} -message SpecificKeys { repeated uint32 key_ids = 1; } +message SpecificKeys {repeated uint32 key_ids = 1;} -message SearchKey { map purpose_map = 1; } +message SearchKey {map purpose_map = 1;} message SecurityLevelMap { enum KeyKindRequestType { @@ -252,13 +252,13 @@ message GetIdentityKeysRequest { bool prove = 5; } - oneof version { GetIdentityKeysRequestV0 v0 = 1; } + oneof version {GetIdentityKeysRequestV0 v0 = 1;} } message GetIdentityKeysResponse { message GetIdentityKeysResponseV0 { - message Keys { repeated bytes keys_bytes = 1; } + message Keys {repeated bytes keys_bytes = 1;} oneof result { Keys keys = 1; @@ -267,7 +267,7 @@ message GetIdentityKeysResponse { ResponseMetadata metadata = 3; } - oneof version { GetIdentityKeysResponseV0 v0 = 1; } + oneof version {GetIdentityKeysResponseV0 v0 = 1;} } message GetProofsRequest { @@ -290,23 +290,23 @@ message GetProofsRequest { Type request_type = 2; } - message ContractRequest { bytes contract_id = 1; } + message ContractRequest {bytes contract_id = 1;} repeated IdentityRequest identities = 1; repeated ContractRequest contracts = 2; repeated DocumentRequest documents = 3; } - oneof version { GetProofsRequestV0 v0 = 1; } + oneof version {GetProofsRequestV0 v0 = 1;} } message GetProofsResponse { message GetProofsResponseV0 { - oneof result { Proof proof = 1; } + oneof result {Proof proof = 1;} ResponseMetadata metadata = 2; } - oneof version { GetProofsResponseV0 v0 = 1; } + oneof version {GetProofsResponseV0 v0 = 1;} } message GetDataContractRequest { @@ -314,7 +314,7 @@ message GetDataContractRequest { bytes id = 1; bool prove = 2; } - oneof version { GetDataContractRequestV0 v0 = 1; } + oneof version {GetDataContractRequestV0 v0 = 1;} } message GetDataContractResponse { @@ -325,7 +325,7 @@ message GetDataContractResponse { } ResponseMetadata metadata = 3; } - oneof version { GetDataContractResponseV0 v0 = 1; } + oneof version {GetDataContractResponseV0 v0 = 1;} } message GetDataContractsRequest { @@ -333,7 +333,7 @@ message GetDataContractsRequest { repeated bytes ids = 1; bool prove = 2; } - oneof version { GetDataContractsRequestV0 v0 = 1; } + oneof version {GetDataContractsRequestV0 v0 = 1;} } message GetDataContractsResponse { @@ -352,7 +352,7 @@ message GetDataContractsResponse { } ResponseMetadata metadata = 3; } - oneof version { GetDataContractsResponseV0 v0 = 1; } + oneof version {GetDataContractsResponseV0 v0 = 1;} } message GetDataContractHistoryRequest { @@ -363,7 +363,7 @@ message GetDataContractHistoryRequest { uint64 start_at_ms = 4; bool prove = 5; } - oneof version { GetDataContractHistoryRequestV0 v0 = 1; } + oneof version {GetDataContractHistoryRequestV0 v0 = 1;} } message GetDataContractHistoryResponse { @@ -384,7 +384,7 @@ message GetDataContractHistoryResponse { ResponseMetadata metadata = 3; } - oneof version { GetDataContractHistoryResponseV0 v0 = 1; } + oneof version {GetDataContractHistoryResponseV0 v0 = 1;} } message GetDocumentsRequest { @@ -400,12 +400,12 @@ message GetDocumentsRequest { } bool prove = 8; } - oneof version { GetDocumentsRequestV0 v0 = 1; } + oneof version {GetDocumentsRequestV0 v0 = 1;} } message GetDocumentsResponse { message GetDocumentsResponseV0 { - message Documents { repeated bytes documents = 1; } + message Documents {repeated bytes documents = 1;} oneof result { Documents documents = 1; @@ -413,7 +413,7 @@ message GetDocumentsResponse { } ResponseMetadata metadata = 3; } - oneof version { GetDocumentsResponseV0 v0 = 1; } + oneof version {GetDocumentsResponseV0 v0 = 1;} } message GetIdentitiesByPublicKeyHashesRequest { @@ -421,7 +421,7 @@ message GetIdentitiesByPublicKeyHashesRequest { repeated bytes public_key_hashes = 1; bool prove = 2; } - oneof version { GetIdentitiesByPublicKeyHashesRequestV0 v0 = 1; } + oneof version {GetIdentitiesByPublicKeyHashesRequestV0 v0 = 1;} } message GetIdentitiesByPublicKeyHashesResponse { @@ -442,7 +442,7 @@ message GetIdentitiesByPublicKeyHashesResponse { ResponseMetadata metadata = 3; } - oneof version { GetIdentitiesByPublicKeyHashesResponseV0 v0 = 1; } + oneof version {GetIdentitiesByPublicKeyHashesResponseV0 v0 = 1;} } message GetIdentityByPublicKeyHashRequest { @@ -450,7 +450,7 @@ message GetIdentityByPublicKeyHashRequest { bytes public_key_hash = 1; bool prove = 2; } - oneof version { GetIdentityByPublicKeyHashRequestV0 v0 = 1; } + oneof version {GetIdentityByPublicKeyHashRequestV0 v0 = 1;} } message GetIdentityByPublicKeyHashResponse { @@ -462,7 +462,7 @@ message GetIdentityByPublicKeyHashResponse { ResponseMetadata metadata = 3; } - oneof version { GetIdentityByPublicKeyHashResponseV0 v0 = 1; } + oneof version {GetIdentityByPublicKeyHashResponseV0 v0 = 1;} } message WaitForStateTransitionResultRequest { @@ -470,7 +470,7 @@ message WaitForStateTransitionResultRequest { bytes state_transition_hash = 1; bool prove = 2; } - oneof version { WaitForStateTransitionResultRequestV0 v0 = 1; } + oneof version {WaitForStateTransitionResultRequestV0 v0 = 1;} } message WaitForStateTransitionResultResponse { @@ -481,7 +481,7 @@ message WaitForStateTransitionResultResponse { } ResponseMetadata metadata = 3; } - oneof version { WaitForStateTransitionResultResponseV0 v0 = 1; } + oneof version {WaitForStateTransitionResultResponseV0 v0 = 1;} } message GetConsensusParamsRequest { @@ -489,7 +489,7 @@ message GetConsensusParamsRequest { int32 height = 1; bool prove = 2; } - oneof version { GetConsensusParamsRequestV0 v0 = 1; } + oneof version {GetConsensusParamsRequestV0 v0 = 1;} } message GetConsensusParamsResponse { @@ -509,7 +509,7 @@ message GetConsensusParamsResponse { ConsensusParamsBlock block = 1; ConsensusParamsEvidence evidence = 2; } - oneof version { GetConsensusParamsResponseV0 v0 = 1; } + oneof version {GetConsensusParamsResponseV0 v0 = 1;} } @@ -606,6 +606,7 @@ message GetEpochsInfoResponse { uint32 first_core_block_height = 3; uint64 start_time = 4; double fee_multiplier = 5; + uint32 protocol_version = 6; } oneof result { diff --git a/packages/dapi-grpc/src/platform/proto/org.dash.platform.dapi.v0.rs b/packages/dapi-grpc/src/platform/proto/org.dash.platform.dapi.v0.rs index 34e7d78313c..0f6446f156b 100644 --- a/packages/dapi-grpc/src/platform/proto/org.dash.platform.dapi.v0.rs +++ b/packages/dapi-grpc/src/platform/proto/org.dash.platform.dapi.v0.rs @@ -2111,6 +2111,8 @@ pub mod get_epochs_info_response { pub start_time: u64, #[prost(double, tag = "5")] pub fee_multiplier: f64, + #[prost(uint32, tag = "6")] + pub protocol_version: u32, } #[derive(::serde::Serialize, ::serde::Deserialize)] #[serde(rename_all = "snake_case")] diff --git a/packages/rs-dpp/src/block/extended_epoch_info/mod.rs b/packages/rs-dpp/src/block/extended_epoch_info/mod.rs index 8562a73bd90..48e9057ea38 100644 --- a/packages/rs-dpp/src/block/extended_epoch_info/mod.rs +++ b/packages/rs-dpp/src/block/extended_epoch_info/mod.rs @@ -3,6 +3,7 @@ pub mod v0; use crate::block::epoch::EpochIndex; use crate::block::extended_epoch_info::v0::{ExtendedEpochInfoV0, ExtendedEpochInfoV0Getters}; use crate::protocol_error::ProtocolError; +use crate::util::deserializer::ProtocolVersion; use bincode::{Decode, Encode}; use derive_more::From; use platform_serialization_derive::{PlatformDeserialize, PlatformSerialize}; @@ -56,4 +57,10 @@ impl ExtendedEpochInfoV0Getters for ExtendedEpochInfo { ExtendedEpochInfo::V0(v0) => v0.fee_multiplier, } } + + fn protocol_version(&self) -> ProtocolVersion { + match self { + ExtendedEpochInfo::V0(v0) => v0.protocol_version, + } + } } diff --git a/packages/rs-dpp/src/block/extended_epoch_info/v0/mod.rs b/packages/rs-dpp/src/block/extended_epoch_info/v0/mod.rs index e99b8e11325..a5e6987b361 100644 --- a/packages/rs-dpp/src/block/extended_epoch_info/v0/mod.rs +++ b/packages/rs-dpp/src/block/extended_epoch_info/v0/mod.rs @@ -1,4 +1,5 @@ use crate::block::epoch::EpochIndex; +use crate::util::deserializer::ProtocolVersion; use bincode::{Decode, Encode}; use serde::{Deserialize, Serialize}; @@ -15,6 +16,8 @@ pub struct ExtendedEpochInfoV0 { pub first_core_block_height: u32, /// Fee multiplier pub fee_multiplier: f64, + /// Protocol version + pub protocol_version: u32, } /// Trait defining getters for `ExtendedEpochInfoV0`. @@ -33,4 +36,7 @@ pub trait ExtendedEpochInfoV0Getters { /// Returns the fee multiplier. fn fee_multiplier(&self) -> f64; + + /// Protocol version + fn protocol_version(&self) -> ProtocolVersion; } diff --git a/packages/rs-drive-abci/src/execution/engine/run_block_proposal/v0/mod.rs b/packages/rs-drive-abci/src/execution/engine/run_block_proposal/v0/mod.rs index 7be6467277c..a6b0065bad1 100644 --- a/packages/rs-drive-abci/src/execution/engine/run_block_proposal/v0/mod.rs +++ b/packages/rs-drive-abci/src/execution/engine/run_block_proposal/v0/mod.rs @@ -366,8 +366,7 @@ where // Process fees let processed_block_fees = self.process_block_fees( - block_execution_context.block_state_info(), - &epoch_info, + &block_execution_context, block_fees_v0.into(), transaction, platform_version, diff --git a/packages/rs-drive-abci/src/execution/platform_events/block_fee_processing/add_process_epoch_change_operations/mod.rs b/packages/rs-drive-abci/src/execution/platform_events/block_fee_processing/add_process_epoch_change_operations/mod.rs index 1d281cb1d1d..97224635665 100644 --- a/packages/rs-drive-abci/src/execution/platform_events/block_fee_processing/add_process_epoch_change_operations/mod.rs +++ b/packages/rs-drive-abci/src/execution/platform_events/block_fee_processing/add_process_epoch_change_operations/mod.rs @@ -12,6 +12,7 @@ use crate::execution::types::block_state_info::BlockStateInfo; use crate::execution::types::storage_fee_distribution_outcome; use crate::error::execution::ExecutionError; +use crate::execution::types::block_execution_context::BlockExecutionContext; use crate::platform_types::epoch_info::EpochInfo; use crate::platform_types::platform::Platform; @@ -41,8 +42,7 @@ impl Platform { /// pub fn add_process_epoch_change_operations( &self, - block_info: &BlockStateInfo, - epoch_info: &EpochInfo, + block_execution_context: &BlockExecutionContext, block_fees: &BlockFees, transaction: &Transaction, batch: &mut Vec, @@ -56,8 +56,7 @@ impl Platform { .add_process_epoch_change_operations { 0 => self.add_process_epoch_change_operations_v0( - block_info, - epoch_info, + block_execution_context, block_fees, transaction, batch, diff --git a/packages/rs-drive-abci/src/execution/platform_events/block_fee_processing/add_process_epoch_change_operations/v0/mod.rs b/packages/rs-drive-abci/src/execution/platform_events/block_fee_processing/add_process_epoch_change_operations/v0/mod.rs index 1314bd11165..d2428967402 100644 --- a/packages/rs-drive-abci/src/execution/platform_events/block_fee_processing/add_process_epoch_change_operations/v0/mod.rs +++ b/packages/rs-drive-abci/src/execution/platform_events/block_fee_processing/add_process_epoch_change_operations/v0/mod.rs @@ -50,9 +50,12 @@ use crate::execution::types::block_state_info::v0::BlockStateInfoV0Getters; use crate::execution::types::block_state_info::BlockStateInfo; use crate::execution::types::storage_fee_distribution_outcome; +use crate::execution::types::block_execution_context::v0::BlockExecutionContextV0Getters; +use crate::execution::types::block_execution_context::BlockExecutionContext; use crate::platform_types::epoch_info::v0::EpochInfoV0Getters; use crate::platform_types::epoch_info::EpochInfo; use crate::platform_types::platform::Platform; +use crate::platform_types::platform_state::v0::PlatformStateV0Methods; use drive::fee_pools::epochs::operations_factory::EpochOperations; /// From the Dash Improvement Proposal: @@ -76,8 +79,7 @@ impl Platform { /// `DistributionLeftoverCredits` will be returned, except if we are at Genesis Epoch. pub(super) fn add_process_epoch_change_operations_v0( &self, - block_info: &BlockStateInfo, - epoch_info: &EpochInfo, + block_execution_context: &BlockExecutionContext, block_fees: &BlockFees, transaction: &Transaction, batch: &mut Vec, @@ -86,6 +88,9 @@ impl Platform { { let mut inner_batch = GroveDbOpBatch::new(); + let epoch_info = block_execution_context.epoch_info(); + let block_info = block_execution_context.block_state_info(); + // init next thousandth empty epochs since last initiated let last_initiated_epoch_index = epoch_info .previous_epoch_index() @@ -110,6 +115,16 @@ impl Platform { &mut inner_batch, ); + // Update next epoch protocol version + let next_epoch = Epoch::new(epoch_info.current_epoch_index() + 1)?; + inner_batch.push( + next_epoch.update_protocol_version_operation( + block_execution_context + .block_platform_state() + .next_epoch_protocol_version(), + ), + ); + // Nothing to distribute on genesis epoch start if current_epoch.index == GENESIS_EPOCH_INDEX { batch.push(DriveOperation::GroveDBOpBatch(inner_batch)); @@ -150,11 +165,14 @@ mod tests { mod helpers { use super::*; + use crate::execution::types::block_execution_context::v0::BlockExecutionContextV0; use crate::execution::types::block_fees::v0::{BlockFeesV0, BlockFeesV0Methods}; use crate::execution::types::block_state_info::v0::BlockStateInfoV0; use crate::platform_types::epoch_info::v0::EpochInfoV0; + use crate::platform_types::platform_state::PlatformState; use dpp::block::block_info::BlockInfo; use dpp::fee::epoch::CreditsPerEpoch; + use drive::drive::defaults::INITIAL_PROTOCOL_VERSION; /// Process and validate an epoch change pub fn process_and_validate_epoch_change( @@ -232,12 +250,25 @@ mod tests { } .into(); + let block_platform_state = PlatformState::default_with_protocol_versions( + INITIAL_PROTOCOL_VERSION, + INITIAL_PROTOCOL_VERSION, + ); + + let block_execution_context = BlockExecutionContextV0 { + block_state_info: block_info.clone().into(), + epoch_info, + hpmn_count: 0, + unsigned_withdrawal_transactions: Default::default(), + block_platform_state, + proposer_results: None, + }; + let mut batch = vec![]; let storage_fee_distribution_outcome = platform .add_process_epoch_change_operations_v0( - &block_info.clone().into(), - &epoch_info, + &block_execution_context.into(), &block_fees, transaction, &mut batch, diff --git a/packages/rs-drive-abci/src/execution/platform_events/block_fee_processing/process_block_fees/mod.rs b/packages/rs-drive-abci/src/execution/platform_events/block_fee_processing/process_block_fees/mod.rs index b82ac36f129..e8cafae10bc 100644 --- a/packages/rs-drive-abci/src/execution/platform_events/block_fee_processing/process_block_fees/mod.rs +++ b/packages/rs-drive-abci/src/execution/platform_events/block_fee_processing/process_block_fees/mod.rs @@ -6,6 +6,7 @@ use drive::grovedb::Transaction; use crate::error::execution::ExecutionError; use crate::error::Error; +use crate::execution::types::block_execution_context::BlockExecutionContext; use crate::execution::types::block_fees::BlockFees; @@ -37,8 +38,7 @@ impl Platform { /// pub fn process_block_fees( &self, - block_info: &BlockStateInfo, - epoch_info: &EpochInfo, + block_execution_context: &BlockExecutionContext, block_fees: BlockFees, transaction: &Transaction, platform_version: &PlatformVersion, @@ -50,8 +50,7 @@ impl Platform { .process_block_fees { 0 => self.process_block_fees_v0( - block_info, - epoch_info, + block_execution_context, block_fees, transaction, platform_version, diff --git a/packages/rs-drive-abci/src/execution/platform_events/block_fee_processing/process_block_fees/v0/mod.rs b/packages/rs-drive-abci/src/execution/platform_events/block_fee_processing/process_block_fees/v0/mod.rs index 5659c7affe0..7a75359ca03 100644 --- a/packages/rs-drive-abci/src/execution/platform_events/block_fee_processing/process_block_fees/v0/mod.rs +++ b/packages/rs-drive-abci/src/execution/platform_events/block_fee_processing/process_block_fees/v0/mod.rs @@ -43,15 +43,15 @@ use drive::grovedb::Transaction; use crate::error::execution::ExecutionError; use crate::error::Error; +use crate::execution::types::block_execution_context::v0::BlockExecutionContextV0Getters; +use crate::execution::types::block_execution_context::BlockExecutionContext; use crate::execution::types::block_fees::v0::BlockFeesV0Getters; use crate::execution::types::block_fees::BlockFees; use crate::execution::types::block_state_info::v0::{ BlockStateInfoV0Getters, BlockStateInfoV0Methods, }; -use crate::execution::types::block_state_info::BlockStateInfo; use crate::execution::types::processed_block_fees_outcome; use crate::platform_types::epoch_info::v0::EpochInfoV0Getters; -use crate::platform_types::epoch_info::EpochInfo; use crate::platform_types::platform::Platform; use drive::fee_pools::epochs::operations_factory::EpochOperations; @@ -75,20 +75,21 @@ impl Platform { /// Returns `ProcessedBlockFeesOutcome`. pub(super) fn process_block_fees_v0( &self, - block_info: &BlockStateInfo, - epoch_info: &EpochInfo, + block_execution_context: &BlockExecutionContext, block_fees: BlockFees, transaction: &Transaction, platform_version: &PlatformVersion, ) -> Result { + let epoch_info = block_execution_context.epoch_info(); + let block_info = block_execution_context.block_state_info(); + let current_epoch = Epoch::new(epoch_info.current_epoch_index())?; let mut batch = vec![]; let storage_fee_distribution_outcome = if epoch_info.is_epoch_change() { self.add_process_epoch_change_operations( - block_info, - epoch_info, + block_execution_context, &block_fees, transaction, &mut batch, @@ -226,10 +227,14 @@ mod tests { mod helpers { use super::*; + use crate::execution::types::block_execution_context::v0::BlockExecutionContextV0; use crate::execution::types::block_fees::v0::BlockFeesV0; use crate::execution::types::block_state_info::v0::BlockStateInfoV0; use crate::platform_types::epoch_info::v0::EpochInfoV0; + use crate::platform_types::epoch_info::EpochInfo; + use crate::platform_types::platform_state::PlatformState; use dpp::fee::epoch::{perpetual_storage_epochs, CreditsPerEpoch, GENESIS_EPOCH_INDEX}; + use drive::drive::defaults::INITIAL_PROTOCOL_VERSION; /// Process and validate block fees pub fn process_and_validate_block_fees( @@ -259,7 +264,7 @@ mod tests { app_hash: None, }; - let epoch_info = EpochInfoV0::from_genesis_time_and_block_info( + let epoch_info: EpochInfo = EpochInfoV0::from_genesis_time_and_block_info( genesis_time_ms, &block_info, platform.config.execution.epoch_time_length_s, @@ -274,10 +279,23 @@ mod tests { } .into(); + let block_platform_state = PlatformState::default_with_protocol_versions( + INITIAL_PROTOCOL_VERSION, + INITIAL_PROTOCOL_VERSION, + ); + + let block_execution_context = BlockExecutionContextV0 { + block_state_info: block_info.clone().into(), + epoch_info: epoch_info.clone(), + hpmn_count: 0, + unsigned_withdrawal_transactions: Default::default(), + block_platform_state, + proposer_results: None, + }; + let storage_fee_distribution_outcome = platform .process_block_fees_v0( - &block_info.clone().into(), - &epoch_info, + &block_execution_context.into(), block_fees.clone(), transaction, platform_version, diff --git a/packages/rs-drive-abci/src/execution/platform_events/initialization/create_genesis_state/v0/mod.rs b/packages/rs-drive-abci/src/execution/platform_events/initialization/create_genesis_state/v0/mod.rs index 130ab04e8cb..83e209a189c 100644 --- a/packages/rs-drive-abci/src/execution/platform_events/initialization/create_genesis_state/v0/mod.rs +++ b/packages/rs-drive-abci/src/execution/platform_events/initialization/create_genesis_state/v0/mod.rs @@ -309,8 +309,8 @@ mod tests { assert_eq!( root_hash, [ - 48, 165, 165, 234, 103, 120, 205, 238, 156, 93, 195, 194, 17, 242, 245, 101, - 176, 129, 137, 59, 185, 249, 76, 104, 217, 226, 66, 115, 67, 226, 235, 180 + 223, 169, 228, 83, 244, 223, 151, 180, 234, 121, 211, 67, 186, 50, 178, 197, + 218, 74, 120, 230, 160, 60, 236, 227, 196, 79, 4, 235, 128, 222, 74, 16 ] ) } diff --git a/packages/rs-drive-abci/src/query/system/epoch_infos/v0/mod.rs b/packages/rs-drive-abci/src/query/system/epoch_infos/v0/mod.rs index 8b9b04d8550..afce1596640 100644 --- a/packages/rs-drive-abci/src/query/system/epoch_infos/v0/mod.rs +++ b/packages/rs-drive-abci/src/query/system/epoch_infos/v0/mod.rs @@ -82,6 +82,7 @@ impl Platform { first_core_block_height: epoch_info.first_core_block_height(), start_time: epoch_info.first_block_time(), fee_multiplier: epoch_info.fee_multiplier(), + protocol_version: epoch_info.protocol_version(), }) .collect(); diff --git a/packages/rs-drive-abci/tests/strategy_tests/main.rs b/packages/rs-drive-abci/tests/strategy_tests/main.rs index 4ebb9dc3fdf..b72eb018e62 100644 --- a/packages/rs-drive-abci/tests/strategy_tests/main.rs +++ b/packages/rs-drive-abci/tests/strategy_tests/main.rs @@ -1150,7 +1150,7 @@ mod tests { .unwrap() .unwrap() ), - "b91e7b8759189050aa92a00dc5fb240689bb0a58e3a2388c80f8d18156d4eb0b".to_string() + "02afcc9932aaa3f6959b0f7eb253c1860964644a90364331faeb9e62003e7381".to_string() ) } @@ -1721,7 +1721,7 @@ mod tests { .unwrap() .unwrap() ), - "8f55b983f206f005897ce067091f144787b21d7c840c47d49fdba5edae3645c5".to_string() + "219a07c68c97f55d1b211fd9f2a7d301bb50fb4a7287c2af38f447229b76a425".to_string() ) } @@ -1842,7 +1842,7 @@ mod tests { .unwrap() .unwrap() ), - "6b5f954928a3f477b9371106f9594046ae3e059bf7eecf60f5f80f59719b8361".to_string() + "cf262a6cc6da0a62f98c3fac218e49b7f65a1560184b28c9d9bdd2368bdd12d5".to_string() ) } diff --git a/packages/rs-drive-abci/tests/strategy_tests/upgrade_fork_tests.rs b/packages/rs-drive-abci/tests/strategy_tests/upgrade_fork_tests.rs index a1ea15e512e..b4dfb2dc78e 100644 --- a/packages/rs-drive-abci/tests/strategy_tests/upgrade_fork_tests.rs +++ b/packages/rs-drive-abci/tests/strategy_tests/upgrade_fork_tests.rs @@ -1,6 +1,7 @@ #[cfg(test)] mod tests { use dpp::block::extended_block_info::v0::ExtendedBlockInfoV0Getters; + use dpp::block::extended_epoch_info::v0::ExtendedEpochInfoV0Getters; use dpp::dashcore::hashes::Hash; use dpp::dashcore::{BlockHash, ChainLock}; use dpp::version::PlatformVersion; @@ -1154,6 +1155,22 @@ mod tests { ), (Some(&2), Some(&68), Some(&3)) ); //some nodes reverted to previous version + + let epochs = platform + .drive + .get_epochs_infos( + 2, + 1, + true, + None, + state + .current_platform_version() + .expect("should have version"), + ) + .expect("should return epochs"); + + assert_eq!(epochs.len(), 1); + assert_eq!(epochs[0].protocol_version(), 1); } let strategy = NetworkStrategy { @@ -1244,6 +1261,22 @@ mod tests { ), (None, Some(&3), Some(&143)) ); + + let epochs = platform + .drive + .get_epochs_infos( + 4, + 1, + true, + None, + state + .current_platform_version() + .expect("should have version"), + ) + .expect("should return epochs"); + + assert_eq!(epochs.len(), 1); + assert_eq!(epochs[0].protocol_version(), TEST_PROTOCOL_VERSION_2); } }) .expect("Failed to create thread with custom stack size"); diff --git a/packages/rs-drive/src/drive/credit_pools/epochs/get_epochs_infos/v0/mod.rs b/packages/rs-drive/src/drive/credit_pools/epochs/get_epochs_infos/v0/mod.rs index 3619900d404..54473011f9b 100644 --- a/packages/rs-drive/src/drive/credit_pools/epochs/get_epochs_infos/v0/mod.rs +++ b/packages/rs-drive/src/drive/credit_pools/epochs/get_epochs_infos/v0/mod.rs @@ -13,7 +13,8 @@ use std::u64; use crate::drive::credit_pools::pools_vec_path; use crate::error::query::QuerySyntaxError; use crate::fee_pools::epochs::epoch_key_constants::{ - KEY_FEE_MULTIPLIER, KEY_START_BLOCK_CORE_HEIGHT, KEY_START_BLOCK_HEIGHT, KEY_START_TIME, + KEY_FEE_MULTIPLIER, KEY_PROTOCOL_VERSION, KEY_START_BLOCK_CORE_HEIGHT, KEY_START_BLOCK_HEIGHT, + KEY_START_TIME, }; use crate::query::QueryItem; use dpp::version::PlatformVersion; @@ -42,6 +43,7 @@ impl Drive { KEY_START_BLOCK_HEIGHT.to_vec(), KEY_START_BLOCK_CORE_HEIGHT.to_vec(), KEY_FEE_MULTIPLIER.to_vec(), + KEY_PROTOCOL_VERSION.to_vec(), ]); let mut query = if ascending { Query::new_single_query_item(QueryItem::RangeFrom( @@ -56,7 +58,8 @@ impl Drive { query.set_subquery(subquery); let path_query = PathQuery::new( pools_vec_path(), - SizedQuery::new(query, Some(count * 4), None), + // The multipler must be equal to requested keys count + SizedQuery::new(query, Some(count * 5), None), ); let results = self @@ -202,6 +205,26 @@ impl Drive { let fee_multiplier = f64::from_be_bytes(fee_multiplier_bytes); + let protocol_version_element = inner_map.get(&KEY_PROTOCOL_VERSION.to_vec())?; + + let Element::Item(encoded_protocol_version, _) = protocol_version_element else { + return Some(Err(Error::Drive(DriveError::UnexpectedElementType( + "start time must be an item", + )))); + }; + + let protocol_version_bytes: [u8; 4] = + match encoded_protocol_version.as_slice().try_into().map_err(|_| { + Error::Drive(DriveError::CorruptedSerialization( + "core block height must be 4 bytes for a u32".to_string(), + )) + }) { + Ok(value) => value, + Err(e) => return Some(Err(e)), + }; + + let protocol_version = u32::from_be_bytes(protocol_version_bytes); + // Construct the ExtendedEpochInfo Some(Ok(ExtendedEpochInfoV0 { index: epoch_index, @@ -209,6 +232,7 @@ impl Drive { first_block_height, first_core_block_height, fee_multiplier, + protocol_version, } .into())) }) diff --git a/packages/rs-drive/src/drive/credit_pools/epochs/prove_epochs_infos/v0/mod.rs b/packages/rs-drive/src/drive/credit_pools/epochs/prove_epochs_infos/v0/mod.rs index 8115361dd2e..71ea656b0d4 100644 --- a/packages/rs-drive/src/drive/credit_pools/epochs/prove_epochs_infos/v0/mod.rs +++ b/packages/rs-drive/src/drive/credit_pools/epochs/prove_epochs_infos/v0/mod.rs @@ -10,7 +10,8 @@ use grovedb::{PathQuery, Query, SizedQuery, TransactionArg}; use crate::drive::credit_pools::pools_vec_path; use crate::error::query::QuerySyntaxError; use crate::fee_pools::epochs::epoch_key_constants::{ - KEY_FEE_MULTIPLIER, KEY_START_BLOCK_CORE_HEIGHT, KEY_START_BLOCK_HEIGHT, KEY_START_TIME, + KEY_FEE_MULTIPLIER, KEY_PROTOCOL_VERSION, KEY_START_BLOCK_CORE_HEIGHT, KEY_START_BLOCK_HEIGHT, + KEY_START_TIME, }; use crate::query::QueryItem; use dpp::version::PlatformVersion; @@ -39,6 +40,7 @@ impl Drive { KEY_START_BLOCK_HEIGHT.to_vec(), KEY_START_BLOCK_CORE_HEIGHT.to_vec(), KEY_FEE_MULTIPLIER.to_vec(), + KEY_PROTOCOL_VERSION.to_vec(), ]); let mut query = if ascending { Query::new_single_query_item(QueryItem::RangeFrom( @@ -53,7 +55,8 @@ impl Drive { query.set_subquery(subquery); let path_query = PathQuery::new( pools_vec_path(), - SizedQuery::new(query, Some(count * 4), None), + // The multipler must be equal to requested keys count + SizedQuery::new(query, Some(count * 5), None), ); self.grove_get_proved_path_query( diff --git a/packages/rs-drive/src/drive/initialization/v0/mod.rs b/packages/rs-drive/src/drive/initialization/v0/mod.rs index b15fd0a345f..34319e837e2 100644 --- a/packages/rs-drive/src/drive/initialization/v0/mod.rs +++ b/packages/rs-drive/src/drive/initialization/v0/mod.rs @@ -177,7 +177,11 @@ impl Drive { ); // In Pools: initialize the pools with epochs - add_create_fee_pool_trees_operations(&mut batch, self.config.epochs_per_era)?; + add_create_fee_pool_trees_operations( + &mut batch, + self.config.epochs_per_era, + platform_version.protocol_version, + )?; // In Withdrawals add_initial_withdrawal_state_structure_operations(&mut batch); diff --git a/packages/rs-drive/src/drive/verify/system/verify_epoch_infos/v0/mod.rs b/packages/rs-drive/src/drive/verify/system/verify_epoch_infos/v0/mod.rs index cea7d679d28..f1c6a843c9e 100644 --- a/packages/rs-drive/src/drive/verify/system/verify_epoch_infos/v0/mod.rs +++ b/packages/rs-drive/src/drive/verify/system/verify_epoch_infos/v0/mod.rs @@ -5,7 +5,8 @@ use crate::error::drive::DriveError; use crate::error::proof::ProofError; use crate::error::Error; use crate::fee_pools::epochs::epoch_key_constants::{ - KEY_FEE_MULTIPLIER, KEY_START_BLOCK_CORE_HEIGHT, KEY_START_BLOCK_HEIGHT, KEY_START_TIME, + KEY_FEE_MULTIPLIER, KEY_PROTOCOL_VERSION, KEY_START_BLOCK_CORE_HEIGHT, KEY_START_BLOCK_HEIGHT, + KEY_START_TIME, }; use crate::query::{Query, QueryItem}; use dpp::block::epoch::{EpochIndex, EPOCH_KEY_OFFSET}; @@ -61,6 +62,7 @@ impl Drive { KEY_START_BLOCK_HEIGHT.to_vec(), KEY_START_BLOCK_CORE_HEIGHT.to_vec(), KEY_FEE_MULTIPLIER.to_vec(), + KEY_PROTOCOL_VERSION.to_vec(), ]); let mut query = if ascending { Query::new_single_query_item(QueryItem::RangeFrom( @@ -75,7 +77,8 @@ impl Drive { query.set_subquery(subquery); let path_query = PathQuery::new( pools_vec_path(), - SizedQuery::new(query, Some(count * 4), None), + // The multipler must be equal to requested keys count + SizedQuery::new(query, Some(count * 5), None), ); let (root_hash, elements) = GroveDb::verify_query(proof, &path_query)?; @@ -212,6 +215,27 @@ impl Drive { let fee_multiplier = f64::from_be_bytes(fee_multiplier_bytes); + let protocol_version_element = inner_map.get(&KEY_PROTOCOL_VERSION.to_vec())?; + + let Some(Element::Item(encoded_protocol_version, _)) = protocol_version_element + else { + return Some(Err(Error::Drive(DriveError::UnexpectedElementType( + "start time must be an item", + )))); + }; + + let protocol_version_bytes: [u8; 4] = + match encoded_protocol_version.as_slice().try_into().map_err(|_| { + Error::Drive(DriveError::CorruptedSerialization( + "core block height must be 4 bytes for a u32".to_string(), + )) + }) { + Ok(value) => value, + Err(e) => return Some(Err(e)), + }; + + let protocol_version = u32::from_be_bytes(protocol_version_bytes); + // Construct the ExtendedEpochInfo Some(Ok(ExtendedEpochInfoV0 { index: epoch_index, @@ -219,6 +243,7 @@ impl Drive { first_block_height, first_core_block_height, fee_multiplier, + protocol_version, } .into())) }) diff --git a/packages/rs-drive/src/fee_pools/epochs/epoch_key_constants.rs b/packages/rs-drive/src/fee_pools/epochs/epoch_key_constants.rs index 208239c1d9d..da7dfab733b 100644 --- a/packages/rs-drive/src/fee_pools/epochs/epoch_key_constants.rs +++ b/packages/rs-drive/src/fee_pools/epochs/epoch_key_constants.rs @@ -4,6 +4,8 @@ pub const KEY_POOL_PROCESSING_FEES: &[u8; 1] = b"p"; pub const KEY_POOL_STORAGE_FEES: &[u8; 1] = b"s"; /// Start time key pub const KEY_START_TIME: &[u8; 1] = b"t"; +/// Epoch's protocol version key +pub const KEY_PROTOCOL_VERSION: &[u8; 1] = b"v"; /// Start block height key pub const KEY_START_BLOCK_HEIGHT: &[u8; 1] = b"h"; /// Start block core chain locked height key diff --git a/packages/rs-drive/src/fee_pools/epochs/operations_factory.rs b/packages/rs-drive/src/fee_pools/epochs/operations_factory.rs index a3b504b4cb9..852bb583380 100644 --- a/packages/rs-drive/src/fee_pools/epochs/operations_factory.rs +++ b/packages/rs-drive/src/fee_pools/epochs/operations_factory.rs @@ -40,12 +40,13 @@ use crate::error::Error; use crate::drive::batch::grovedb_op_batch::GroveDbOpBatchV0Methods; use crate::fee_pools::epochs::epoch_key_constants::{ KEY_FEE_MULTIPLIER, KEY_POOL_PROCESSING_FEES, KEY_POOL_STORAGE_FEES, KEY_PROPOSERS, - KEY_START_BLOCK_CORE_HEIGHT, KEY_START_BLOCK_HEIGHT, KEY_START_TIME, + KEY_PROTOCOL_VERSION, KEY_START_BLOCK_CORE_HEIGHT, KEY_START_BLOCK_HEIGHT, KEY_START_TIME, }; use crate::fee_pools::epochs::paths::EpochProposers; use dpp::balances::credits::Creditable; use dpp::block::epoch::Epoch; use dpp::fee::Credits; +use dpp::util::deserializer::ProtocolVersion; use dpp::version::PlatformVersion; use grovedb::batch::GroveDbOp; use grovedb::{Element, TransactionArg}; @@ -77,6 +78,8 @@ pub trait EpochOperations { ); /// Adds to the groveDB op batch operations signifying that the epoch distribution fees were paid out. fn add_mark_as_paid_operations(&self, batch: &mut GroveDbOpBatch); + /// Update Epoch's protocol version + fn update_protocol_version_operation(&self, protocol_version: ProtocolVersion) -> GroveDbOp; /// Returns a groveDB op which updates the epoch start time. fn update_start_time_operation(&self, time_ms: u64) -> GroveDbOp; /// Returns a groveDB op which updates the epoch start block height. @@ -192,6 +195,15 @@ impl EpochOperations for Epoch { batch.push(self.delete_processing_credits_for_distribution_operation()); } + /// Returns a groveDB op which updates the epoch start time. + fn update_protocol_version_operation(&self, protocol_version: ProtocolVersion) -> GroveDbOp { + GroveDbOp::insert_op( + self.get_path_vec(), + KEY_PROTOCOL_VERSION.to_vec(), + Element::Item(protocol_version.to_be_bytes().to_vec(), None), + ) + } + /// Returns a groveDB op which updates the epoch start time. fn update_start_time_operation(&self, time_ms: u64) -> GroveDbOp { GroveDbOp::insert_op( diff --git a/packages/rs-drive/src/fee_pools/mod.rs b/packages/rs-drive/src/fee_pools/mod.rs index e6e74ccb338..438368c4fbc 100644 --- a/packages/rs-drive/src/fee_pools/mod.rs +++ b/packages/rs-drive/src/fee_pools/mod.rs @@ -49,6 +49,7 @@ use dpp::block::epoch::{Epoch, EpochIndex}; use dpp::fee::epoch::{perpetual_storage_epochs, GENESIS_EPOCH_INDEX}; #[cfg(feature = "full")] use dpp::fee::Credits; +use dpp::util::deserializer::ProtocolVersion; #[cfg(feature = "full")] use grovedb::batch::GroveDbOp; #[cfg(feature = "full")] @@ -67,6 +68,7 @@ pub mod epochs_root_tree_key_constants; pub fn add_create_fee_pool_trees_operations( batch: &mut GroveDbOpBatch, epochs_per_era: u16, + protocol_version: ProtocolVersion, ) -> Result<(), Error> { // Init storage credit pool batch.push(update_storage_fee_distribution_pool_operation(0)?); @@ -84,6 +86,11 @@ pub fn add_create_fee_pool_trees_operations( epoch.add_init_empty_operations(batch)?; } + let genesis_epoch = Epoch::new(GENESIS_EPOCH_INDEX)?; + + // Initial protocol version for genesis epoch + batch.push(genesis_epoch.update_protocol_version_operation(protocol_version)); + Ok(()) } From fb470b56872b46698a2d5bf9c12703a56b3d094f Mon Sep 17 00:00:00 2001 From: Ivan Shumkov Date: Tue, 19 Mar 2024 15:41:39 +0700 Subject: [PATCH 10/37] style: revert formatting --- .../protos/platform/v0/platform.proto | 100 +++++++++--------- 1 file changed, 50 insertions(+), 50 deletions(-) diff --git a/packages/dapi-grpc/protos/platform/v0/platform.proto b/packages/dapi-grpc/protos/platform/v0/platform.proto index 6f59ed01f3a..f364577ad75 100644 --- a/packages/dapi-grpc/protos/platform/v0/platform.proto +++ b/packages/dapi-grpc/protos/platform/v0/platform.proto @@ -8,31 +8,31 @@ import "google/protobuf/timestamp.proto"; service Platform { rpc broadcastStateTransition(BroadcastStateTransitionRequest) - returns (BroadcastStateTransitionResponse); + returns (BroadcastStateTransitionResponse); rpc getIdentity(GetIdentityRequest) returns (GetIdentityResponse); rpc getIdentities(GetIdentitiesRequest) returns (GetIdentitiesResponse); rpc getIdentityKeys(GetIdentityKeysRequest) returns (GetIdentityKeysResponse); rpc getIdentityNonce(GetIdentityNonceRequest) returns (GetIdentityNonceResponse); rpc getIdentityContractNonce(GetIdentityContractNonceRequest) returns (GetIdentityContractNonceResponse); rpc getIdentityBalance(GetIdentityBalanceRequest) - returns (GetIdentityBalanceResponse); + returns (GetIdentityBalanceResponse); rpc getIdentityBalanceAndRevision(GetIdentityBalanceAndRevisionRequest) - returns (GetIdentityBalanceAndRevisionResponse); + returns (GetIdentityBalanceAndRevisionResponse); rpc getProofs(GetProofsRequest) returns (GetProofsResponse); rpc getDataContract(GetDataContractRequest) returns (GetDataContractResponse); rpc getDataContractHistory(GetDataContractHistoryRequest) - returns (GetDataContractHistoryResponse); + returns (GetDataContractHistoryResponse); rpc getDataContracts(GetDataContractsRequest) - returns (GetDataContractsResponse); + returns (GetDataContractsResponse); rpc getDocuments(GetDocumentsRequest) returns (GetDocumentsResponse); rpc getIdentitiesByPublicKeyHashes(GetIdentitiesByPublicKeyHashesRequest) - returns (GetIdentitiesByPublicKeyHashesResponse); + returns (GetIdentitiesByPublicKeyHashesResponse); rpc getIdentityByPublicKeyHash(GetIdentityByPublicKeyHashRequest) - returns (GetIdentityByPublicKeyHashResponse); + returns (GetIdentityByPublicKeyHashResponse); rpc waitForStateTransitionResult(WaitForStateTransitionResultRequest) - returns (WaitForStateTransitionResultResponse); + returns (WaitForStateTransitionResultResponse); rpc getConsensusParams(GetConsensusParamsRequest) - returns (GetConsensusParamsResponse); + returns (GetConsensusParamsResponse); rpc getProtocolVersionUpgradeState(GetProtocolVersionUpgradeStateRequest) returns (GetProtocolVersionUpgradeStateResponse); rpc getProtocolVersionUpgradeVoteStatus(GetProtocolVersionUpgradeVoteStatusRequest) returns (GetProtocolVersionUpgradeVoteStatusResponse); rpc getEpochsInfo(GetEpochsInfoRequest) returns (GetEpochsInfoResponse); @@ -62,7 +62,7 @@ message StateTransitionBroadcastError { bytes data = 3; } -message BroadcastStateTransitionRequest {bytes state_transition = 1;} +message BroadcastStateTransitionRequest { bytes state_transition = 1; } message BroadcastStateTransitionResponse {} @@ -73,7 +73,7 @@ message GetIdentityRequest { bool prove = 2; } - oneof version {GetIdentityRequestV0 v0 = 1;} + oneof version { GetIdentityRequestV0 v0 = 1; } } message GetIdentityNonceRequest { @@ -83,7 +83,7 @@ message GetIdentityNonceRequest { bool prove = 2; } - oneof version {GetIdentityNonceRequestV0 v0 = 1;} + oneof version { GetIdentityNonceRequestV0 v0 = 1; } } @@ -95,7 +95,7 @@ message GetIdentityContractNonceRequest { bool prove = 3; } - oneof version {GetIdentityContractNonceRequestV0 v0 = 1;} + oneof version { GetIdentityContractNonceRequestV0 v0 = 1; } } message GetIdentityBalanceRequest { @@ -105,7 +105,7 @@ message GetIdentityBalanceRequest { bool prove = 2; } - oneof version {GetIdentityBalanceRequestV0 v0 = 1;} + oneof version { GetIdentityBalanceRequestV0 v0 = 1; } } message GetIdentityBalanceAndRevisionRequest { @@ -115,7 +115,7 @@ message GetIdentityBalanceAndRevisionRequest { bool prove = 2; } - oneof version {GetIdentityBalanceAndRevisionRequestV0 v0 = 1;} + oneof version { GetIdentityBalanceAndRevisionRequestV0 v0 = 1; } } message GetIdentityResponse { @@ -128,7 +128,7 @@ message GetIdentityResponse { ResponseMetadata metadata = 3; } - oneof version {GetIdentityResponseV0 v0 = 1;} + oneof version { GetIdentityResponseV0 v0 = 1; } } message GetIdentitiesRequest { @@ -138,19 +138,19 @@ message GetIdentitiesRequest { bool prove = 2; } - oneof version {GetIdentitiesRequestV0 v0 = 1;} + oneof version { GetIdentitiesRequestV0 v0 = 1; } } message GetIdentitiesResponse { - message IdentityValue {bytes value = 1;} + message IdentityValue { bytes value = 1; } message IdentityEntry { bytes key = 1; IdentityValue value = 2; } - message Identities {repeated IdentityEntry identity_entries = 1;} + message Identities { repeated IdentityEntry identity_entries = 1; } message GetIdentitiesResponseV0 { oneof result { @@ -160,7 +160,7 @@ message GetIdentitiesResponse { ResponseMetadata metadata = 3; } - oneof version {GetIdentitiesResponseV0 v0 = 1;} + oneof version { GetIdentitiesResponseV0 v0 = 1; } } message GetIdentityNonceResponse { @@ -173,7 +173,7 @@ message GetIdentityNonceResponse { ResponseMetadata metadata = 3; } - oneof version {GetIdentityNonceResponseV0 v0 = 1;} + oneof version { GetIdentityNonceResponseV0 v0 = 1; } } message GetIdentityContractNonceResponse { @@ -186,7 +186,7 @@ message GetIdentityContractNonceResponse { ResponseMetadata metadata = 3; } - oneof version {GetIdentityContractNonceResponseV0 v0 = 1;} + oneof version { GetIdentityContractNonceResponseV0 v0 = 1; } } message GetIdentityBalanceResponse { @@ -199,7 +199,7 @@ message GetIdentityBalanceResponse { ResponseMetadata metadata = 3; } - oneof version {GetIdentityBalanceResponseV0 v0 = 1;} + oneof version { GetIdentityBalanceResponseV0 v0 = 1; } } message GetIdentityBalanceAndRevisionResponse { @@ -217,7 +217,7 @@ message GetIdentityBalanceAndRevisionResponse { ResponseMetadata metadata = 3; } - oneof version {GetIdentityBalanceAndRevisionResponseV0 v0 = 1;} + oneof version { GetIdentityBalanceAndRevisionResponseV0 v0 = 1; } } message KeyRequestType { @@ -230,9 +230,9 @@ message KeyRequestType { message AllKeys {} -message SpecificKeys {repeated uint32 key_ids = 1;} +message SpecificKeys { repeated uint32 key_ids = 1; } -message SearchKey {map purpose_map = 1;} +message SearchKey { map purpose_map = 1; } message SecurityLevelMap { enum KeyKindRequestType { @@ -252,13 +252,13 @@ message GetIdentityKeysRequest { bool prove = 5; } - oneof version {GetIdentityKeysRequestV0 v0 = 1;} + oneof version { GetIdentityKeysRequestV0 v0 = 1; } } message GetIdentityKeysResponse { message GetIdentityKeysResponseV0 { - message Keys {repeated bytes keys_bytes = 1;} + message Keys { repeated bytes keys_bytes = 1; } oneof result { Keys keys = 1; @@ -267,7 +267,7 @@ message GetIdentityKeysResponse { ResponseMetadata metadata = 3; } - oneof version {GetIdentityKeysResponseV0 v0 = 1;} + oneof version { GetIdentityKeysResponseV0 v0 = 1; } } message GetProofsRequest { @@ -290,23 +290,23 @@ message GetProofsRequest { Type request_type = 2; } - message ContractRequest {bytes contract_id = 1;} + message ContractRequest { bytes contract_id = 1; } repeated IdentityRequest identities = 1; repeated ContractRequest contracts = 2; repeated DocumentRequest documents = 3; } - oneof version {GetProofsRequestV0 v0 = 1;} + oneof version { GetProofsRequestV0 v0 = 1; } } message GetProofsResponse { message GetProofsResponseV0 { - oneof result {Proof proof = 1;} + oneof result { Proof proof = 1; } ResponseMetadata metadata = 2; } - oneof version {GetProofsResponseV0 v0 = 1;} + oneof version { GetProofsResponseV0 v0 = 1; } } message GetDataContractRequest { @@ -314,7 +314,7 @@ message GetDataContractRequest { bytes id = 1; bool prove = 2; } - oneof version {GetDataContractRequestV0 v0 = 1;} + oneof version { GetDataContractRequestV0 v0 = 1; } } message GetDataContractResponse { @@ -325,7 +325,7 @@ message GetDataContractResponse { } ResponseMetadata metadata = 3; } - oneof version {GetDataContractResponseV0 v0 = 1;} + oneof version { GetDataContractResponseV0 v0 = 1; } } message GetDataContractsRequest { @@ -333,7 +333,7 @@ message GetDataContractsRequest { repeated bytes ids = 1; bool prove = 2; } - oneof version {GetDataContractsRequestV0 v0 = 1;} + oneof version { GetDataContractsRequestV0 v0 = 1; } } message GetDataContractsResponse { @@ -352,7 +352,7 @@ message GetDataContractsResponse { } ResponseMetadata metadata = 3; } - oneof version {GetDataContractsResponseV0 v0 = 1;} + oneof version { GetDataContractsResponseV0 v0 = 1; } } message GetDataContractHistoryRequest { @@ -363,7 +363,7 @@ message GetDataContractHistoryRequest { uint64 start_at_ms = 4; bool prove = 5; } - oneof version {GetDataContractHistoryRequestV0 v0 = 1;} + oneof version { GetDataContractHistoryRequestV0 v0 = 1; } } message GetDataContractHistoryResponse { @@ -384,7 +384,7 @@ message GetDataContractHistoryResponse { ResponseMetadata metadata = 3; } - oneof version {GetDataContractHistoryResponseV0 v0 = 1;} + oneof version { GetDataContractHistoryResponseV0 v0 = 1; } } message GetDocumentsRequest { @@ -400,12 +400,12 @@ message GetDocumentsRequest { } bool prove = 8; } - oneof version {GetDocumentsRequestV0 v0 = 1;} + oneof version { GetDocumentsRequestV0 v0 = 1; } } message GetDocumentsResponse { message GetDocumentsResponseV0 { - message Documents {repeated bytes documents = 1;} + message Documents { repeated bytes documents = 1; } oneof result { Documents documents = 1; @@ -413,7 +413,7 @@ message GetDocumentsResponse { } ResponseMetadata metadata = 3; } - oneof version {GetDocumentsResponseV0 v0 = 1;} + oneof version { GetDocumentsResponseV0 v0 = 1; } } message GetIdentitiesByPublicKeyHashesRequest { @@ -421,7 +421,7 @@ message GetIdentitiesByPublicKeyHashesRequest { repeated bytes public_key_hashes = 1; bool prove = 2; } - oneof version {GetIdentitiesByPublicKeyHashesRequestV0 v0 = 1;} + oneof version { GetIdentitiesByPublicKeyHashesRequestV0 v0 = 1; } } message GetIdentitiesByPublicKeyHashesResponse { @@ -442,7 +442,7 @@ message GetIdentitiesByPublicKeyHashesResponse { ResponseMetadata metadata = 3; } - oneof version {GetIdentitiesByPublicKeyHashesResponseV0 v0 = 1;} + oneof version { GetIdentitiesByPublicKeyHashesResponseV0 v0 = 1; } } message GetIdentityByPublicKeyHashRequest { @@ -450,7 +450,7 @@ message GetIdentityByPublicKeyHashRequest { bytes public_key_hash = 1; bool prove = 2; } - oneof version {GetIdentityByPublicKeyHashRequestV0 v0 = 1;} + oneof version { GetIdentityByPublicKeyHashRequestV0 v0 = 1; } } message GetIdentityByPublicKeyHashResponse { @@ -462,7 +462,7 @@ message GetIdentityByPublicKeyHashResponse { ResponseMetadata metadata = 3; } - oneof version {GetIdentityByPublicKeyHashResponseV0 v0 = 1;} + oneof version { GetIdentityByPublicKeyHashResponseV0 v0 = 1; } } message WaitForStateTransitionResultRequest { @@ -470,7 +470,7 @@ message WaitForStateTransitionResultRequest { bytes state_transition_hash = 1; bool prove = 2; } - oneof version {WaitForStateTransitionResultRequestV0 v0 = 1;} + oneof version { WaitForStateTransitionResultRequestV0 v0 = 1; } } message WaitForStateTransitionResultResponse { @@ -481,7 +481,7 @@ message WaitForStateTransitionResultResponse { } ResponseMetadata metadata = 3; } - oneof version {WaitForStateTransitionResultResponseV0 v0 = 1;} + oneof version { WaitForStateTransitionResultResponseV0 v0 = 1; } } message GetConsensusParamsRequest { @@ -489,7 +489,7 @@ message GetConsensusParamsRequest { int32 height = 1; bool prove = 2; } - oneof version {GetConsensusParamsRequestV0 v0 = 1;} + oneof version { GetConsensusParamsRequestV0 v0 = 1; } } message GetConsensusParamsResponse { @@ -509,7 +509,7 @@ message GetConsensusParamsResponse { ConsensusParamsBlock block = 1; ConsensusParamsEvidence evidence = 2; } - oneof version {GetConsensusParamsResponseV0 v0 = 1;} + oneof version { GetConsensusParamsResponseV0 v0 = 1; } } From 69e4dc804950b1b30042d1631e56770585e22ecd Mon Sep 17 00:00:00 2001 From: Ivan Shumkov Date: Tue, 19 Mar 2024 16:03:35 +0700 Subject: [PATCH 11/37] docs: typo in comment --- .../src/drive/credit_pools/epochs/get_epochs_infos/v0/mod.rs | 2 +- .../src/drive/credit_pools/epochs/prove_epochs_infos/v0/mod.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/rs-drive/src/drive/credit_pools/epochs/get_epochs_infos/v0/mod.rs b/packages/rs-drive/src/drive/credit_pools/epochs/get_epochs_infos/v0/mod.rs index 54473011f9b..2d9f33237b3 100644 --- a/packages/rs-drive/src/drive/credit_pools/epochs/get_epochs_infos/v0/mod.rs +++ b/packages/rs-drive/src/drive/credit_pools/epochs/get_epochs_infos/v0/mod.rs @@ -58,7 +58,7 @@ impl Drive { query.set_subquery(subquery); let path_query = PathQuery::new( pools_vec_path(), - // The multipler must be equal to requested keys count + // The multiplier must be equal to requested keys count SizedQuery::new(query, Some(count * 5), None), ); diff --git a/packages/rs-drive/src/drive/credit_pools/epochs/prove_epochs_infos/v0/mod.rs b/packages/rs-drive/src/drive/credit_pools/epochs/prove_epochs_infos/v0/mod.rs index 71ea656b0d4..0417318cb18 100644 --- a/packages/rs-drive/src/drive/credit_pools/epochs/prove_epochs_infos/v0/mod.rs +++ b/packages/rs-drive/src/drive/credit_pools/epochs/prove_epochs_infos/v0/mod.rs @@ -55,7 +55,7 @@ impl Drive { query.set_subquery(subquery); let path_query = PathQuery::new( pools_vec_path(), - // The multipler must be equal to requested keys count + // The multiplier must be equal to requested keys count SizedQuery::new(query, Some(count * 5), None), ); From f19be276fb38bfae9dc7b9fe7b33f697051eca95 Mon Sep 17 00:00:00 2001 From: Ivan Shumkov Date: Tue, 19 Mar 2024 16:05:57 +0700 Subject: [PATCH 12/37] fix: invalid error messages --- .../src/drive/credit_pools/epochs/get_epochs_infos/v0/mod.rs | 4 ++-- .../src/drive/verify/system/verify_epoch_infos/v0/mod.rs | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/rs-drive/src/drive/credit_pools/epochs/get_epochs_infos/v0/mod.rs b/packages/rs-drive/src/drive/credit_pools/epochs/get_epochs_infos/v0/mod.rs index 2d9f33237b3..3fa8a0c9e78 100644 --- a/packages/rs-drive/src/drive/credit_pools/epochs/get_epochs_infos/v0/mod.rs +++ b/packages/rs-drive/src/drive/credit_pools/epochs/get_epochs_infos/v0/mod.rs @@ -209,14 +209,14 @@ impl Drive { let Element::Item(encoded_protocol_version, _) = protocol_version_element else { return Some(Err(Error::Drive(DriveError::UnexpectedElementType( - "start time must be an item", + "protocol version must be an item", )))); }; let protocol_version_bytes: [u8; 4] = match encoded_protocol_version.as_slice().try_into().map_err(|_| { Error::Drive(DriveError::CorruptedSerialization( - "core block height must be 4 bytes for a u32".to_string(), + "protocol version must be 4 bytes for a u32".to_string(), )) }) { Ok(value) => value, diff --git a/packages/rs-drive/src/drive/verify/system/verify_epoch_infos/v0/mod.rs b/packages/rs-drive/src/drive/verify/system/verify_epoch_infos/v0/mod.rs index f1c6a843c9e..71f7a63d6f3 100644 --- a/packages/rs-drive/src/drive/verify/system/verify_epoch_infos/v0/mod.rs +++ b/packages/rs-drive/src/drive/verify/system/verify_epoch_infos/v0/mod.rs @@ -220,14 +220,14 @@ impl Drive { let Some(Element::Item(encoded_protocol_version, _)) = protocol_version_element else { return Some(Err(Error::Drive(DriveError::UnexpectedElementType( - "start time must be an item", + "protocol version must be an item", )))); }; let protocol_version_bytes: [u8; 4] = match encoded_protocol_version.as_slice().try_into().map_err(|_| { Error::Drive(DriveError::CorruptedSerialization( - "core block height must be 4 bytes for a u32".to_string(), + "protocol version must be 4 bytes for a u32".to_string(), )) }) { Ok(value) => value, From bdbe90d0e56eb7c833dff3f7f6a39da451db518a Mon Sep 17 00:00:00 2001 From: Ivan Shumkov Date: Tue, 26 Mar 2024 19:05:10 +0700 Subject: [PATCH 13/37] fix: first block of epoch processed by previous version --- .cargo/config.toml | 1 + .../configs/defaults/getBaseConfigFactory.js | 2 +- .../configs/getConfigFileMigrationsFactory.js | 8 ++ .../src/abci/handler/prepare_proposal.rs | 20 ++- .../src/abci/handler/process_proposal.rs | 110 ++++++++-------- packages/rs-drive-abci/src/config.rs | 20 +-- packages/rs-drive-abci/src/error/execution.rs | 4 + .../engine/initialization/init_chain/mod.rs | 21 +--- .../engine/run_block_proposal/mod.rs | 29 +++-- .../engine/run_block_proposal/v0/mod.rs | 118 ++++++------------ .../block_end/consensus_param_updates/mod.rs | 36 ------ .../consensus_param_updates/v0/mod.rs | 31 ----- .../platform_events/block_end/mod.rs | 1 - .../block_end/update_drive_cache/v0/mod.rs | 2 +- .../epoch/gather_epoch_info/mod.rs | 22 ++-- .../platform_events/protocol_upgrade/mod.rs | 1 + .../upgrade_protocol_version/mod.rs | 52 ++++++++ .../upgrade_protocol_version/v0/mod.rs | 90 +++++++++++++ packages/rs-drive-abci/src/mimic/mod.rs | 43 +++---- .../block_execution_outcome/v0/mod.rs | 2 - .../rs-drive-abci/src/test/fixture/abci.rs | 2 +- .../tests/strategy_tests/execution.rs | 11 +- .../src/version/drive_abci_versions.rs | 2 +- .../src/version/mocks/v2_test.rs | 2 +- .../src/version/mocks/v3_test.rs | 2 +- .../rs-platform-version/src/version/v1.rs | 2 +- 26 files changed, 330 insertions(+), 304 deletions(-) delete mode 100644 packages/rs-drive-abci/src/execution/platform_events/block_end/consensus_param_updates/mod.rs delete mode 100644 packages/rs-drive-abci/src/execution/platform_events/block_end/consensus_param_updates/v0/mod.rs create mode 100644 packages/rs-drive-abci/src/execution/platform_events/protocol_upgrade/upgrade_protocol_version/mod.rs create mode 100644 packages/rs-drive-abci/src/execution/platform_events/protocol_upgrade/upgrade_protocol_version/v0/mod.rs diff --git a/.cargo/config.toml b/.cargo/config.toml index 18bc8e4064b..ad7da957cdc 100644 --- a/.cargo/config.toml +++ b/.cargo/config.toml @@ -11,3 +11,4 @@ linker = "aarch64-linux-gnu-gcc" [build] rustflags = ["--cfg", "tokio_unstable"] +env = { TENDERDASH_COMMITISH = "dcb8ebcc5c52b00cfc5d67c7eb8c15692a34a66e" } diff --git a/packages/dashmate/configs/defaults/getBaseConfigFactory.js b/packages/dashmate/configs/defaults/getBaseConfigFactory.js index 9521b0d715e..264c8a6c5b9 100644 --- a/packages/dashmate/configs/defaults/getBaseConfigFactory.js +++ b/packages/dashmate/configs/defaults/getBaseConfigFactory.js @@ -206,7 +206,7 @@ export default function getBaseConfigFactory(homeDir) { tenderdash: { mode: 'full', docker: { - image: 'dashpay/tenderdash:0.14.0-dev.4', + image: 'dashpay/tenderdash:feat-proposer-app-version', }, p2p: { host: '0.0.0.0', diff --git a/packages/dashmate/configs/getConfigFileMigrationsFactory.js b/packages/dashmate/configs/getConfigFileMigrationsFactory.js index 1a6676ec912..fec6ab4d0fa 100644 --- a/packages/dashmate/configs/getConfigFileMigrationsFactory.js +++ b/packages/dashmate/configs/getConfigFileMigrationsFactory.js @@ -513,6 +513,14 @@ export default function getConfigFileMigrationsFactory(homeDir, defaultConfigs) return configFile; }, + '1.0.0-dev.10': (configFile) => { + Object.entries(configFile.configs) + .forEach(([, options]) => { + options.platform.drive.tenderdash.docker.image = base.get('platform.drive.tenderdash.docker.image'); + }); + + return configFile; + }, }; } diff --git a/packages/rs-drive-abci/src/abci/handler/prepare_proposal.rs b/packages/rs-drive-abci/src/abci/handler/prepare_proposal.rs index 2ce6034e3be..a001b0ec551 100644 --- a/packages/rs-drive-abci/src/abci/handler/prepare_proposal.rs +++ b/packages/rs-drive-abci/src/abci/handler/prepare_proposal.rs @@ -113,22 +113,16 @@ where return Err(run_result.errors.remove(0)); } - let block_execution_outcome = run_result.into_data().map_err(Error::Protocol)?; - - let platform_version = PlatformVersion::get(block_execution_outcome.protocol_version) - .expect("must be set in run block proposal from existing protocol version"); - - let consensus_param_updates = app - .platform() - .consensus_param_updates(&block_execution_outcome, platform_version)?; - let block_execution_outcome::v0::BlockExecutionOutcome { app_hash, state_transitions_result, validator_set_update, + protocol_version, mut block_execution_context, - .. - } = block_execution_outcome; + } = run_result.into_data().map_err(Error::Protocol)?; + + let platform_version = PlatformVersion::get(protocol_version) + .expect("must be set in run block proposal from existing protocol version"); // We need to let Tenderdash know about the transactions we should remove from execution let valid_tx_count = state_transitions_result.valid_count(); @@ -193,7 +187,9 @@ where signature: chain_lock.signature.to_bytes().to_vec(), }), validator_set_update, - consensus_param_updates, + // TODO: implement consensus param updates + consensus_param_updates: None, + app_version: Some(protocol_version as u64), }; block_execution_context.set_proposer_results(Some(response.clone())); 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 79d53cdaef4..9a60a8a1e46 100644 --- a/packages/rs-drive-abci/src/abci/handler/process_proposal.rs +++ b/packages/rs-drive-abci/src/abci/handler/process_proposal.rs @@ -196,70 +196,64 @@ where request.round, ); - return Ok(response); - } - - let block_execution_outcome = run_result.into_data().map_err(Error::Protocol)?; - - let platform_version = PlatformVersion::get(block_execution_outcome.protocol_version) - .expect("must be set in run block proposer from existing platform version"); - - let consensus_param_updates = app - .platform() - .consensus_param_updates(&block_execution_outcome, platform_version)?; + Ok(response) + } else { + let block_execution_outcome::v0::BlockExecutionOutcome { + app_hash, + state_transitions_result: state_transition_results, + validator_set_update, + protocol_version, + block_execution_context, + } = run_result.into_data().map_err(Error::Protocol)?; - let block_execution_outcome::v0::BlockExecutionOutcome { - app_hash, - state_transitions_result: state_transition_results, - validator_set_update, - block_execution_context, - .. - } = block_execution_outcome; + let platform_version = PlatformVersion::get(protocol_version) + .expect("must be set in run block proposer from existing platform version"); - app.block_execution_context() - .write() - .unwrap() - .replace(block_execution_context); + app.block_execution_context() + .write() + .unwrap() + .replace(block_execution_context); - let invalid_tx_count = state_transition_results.invalid_paid_count(); - let valid_tx_count = state_transition_results.valid_count(); + let invalid_tx_count = state_transition_results.invalid_paid_count(); + let valid_tx_count = state_transition_results.valid_count(); - let tx_results = state_transition_results - .into_execution_results() - .into_iter() - // To prevent spam attacks we add to the block state transitions covered with fees only - .filter(|execution_result| { - matches!( - execution_result, - StateTransitionExecutionResult::SuccessfulExecution(..) - | StateTransitionExecutionResult::PaidConsensusError(..) - ) - }) - .map(|execution_result| execution_result.try_into_platform_versioned(platform_version)) - .collect::>()?; + let tx_results = state_transition_results + .into_execution_results() + .into_iter() + // To prevent spam attacks we add to the block state transitions covered with fees only + .filter(|execution_result| { + matches!( + execution_result, + StateTransitionExecutionResult::SuccessfulExecution(..) + | StateTransitionExecutionResult::PaidConsensusError(..) + ) + }) + .map(|execution_result| execution_result.try_into_platform_versioned(platform_version)) + .collect::>()?; - let response = proto::ResponseProcessProposal { - app_hash: app_hash.to_vec(), - tx_results, - // TODO: Must be reject if results are different - status: proto::response_process_proposal::ProposalStatus::Accept.into(), - validator_set_update, - // TODO: Implement consensus param updates - consensus_param_updates, - }; + let response = proto::ResponseProcessProposal { + app_hash: app_hash.to_vec(), + tx_results, + // TODO: Must be reject if results are different + status: proto::response_process_proposal::ProposalStatus::Accept.into(), + validator_set_update, + // TODO: Implement consensus param updates + consensus_param_updates: None, + }; - let elapsed_time_ms = timer.elapsed().as_millis(); + let elapsed_time_ms = timer.elapsed().as_millis(); - tracing::info!( - invalid_tx_count, - valid_tx_count, - elapsed_time_ms, - "Processed proposal with {} transactions for height: {}, round: {} in {} ms", - valid_tx_count + invalid_tx_count, - request.height, - request.round, - elapsed_time_ms, - ); + tracing::info!( + invalid_tx_count, + valid_tx_count, + elapsed_time_ms, + "Processed proposal with {} transactions for height: {}, round: {} in {} ms", + valid_tx_count + invalid_tx_count, + request.height, + request.round, + elapsed_time_ms, + ); - Ok(response) + Ok(response) + } } diff --git a/packages/rs-drive-abci/src/config.rs b/packages/rs-drive-abci/src/config.rs index 87e060fbb5a..209b9809651 100644 --- a/packages/rs-drive-abci/src/config.rs +++ b/packages/rs-drive-abci/src/config.rs @@ -195,6 +195,10 @@ pub struct PlatformConfig { /// Approximately how often are blocks produced pub block_spacing_ms: u64, + /// Initial protocol version + #[serde(default = "PlatformConfig::default_initial_protocol_version")] + pub initial_protocol_version: ProtocolVersion, + /// Path to data storage pub db_path: PathBuf, @@ -234,6 +238,10 @@ impl ExecutionConfig { } impl PlatformConfig { + fn default_initial_protocol_version() -> ProtocolVersion { + INITIAL_PROTOCOL_VERSION + } + fn default_tokio_console_address() -> String { String::from("127.0.0.1:6669") } @@ -338,6 +346,7 @@ impl PlatformConfig { tokio_console_enabled: false, tokio_console_address: PlatformConfig::default_tokio_console_address(), tokio_console_retention_secs: PlatformConfig::default_tokio_console_retention_secs(), + initial_protocol_version: Self::default_initial_protocol_version(), prometheus_bind_address: None, grpc_bind_address: "0.0.0.0:26670".to_string(), } @@ -357,6 +366,7 @@ impl PlatformConfig { execution: Default::default(), db_path: PathBuf::from("/var/lib/dash-platform/data"), testing_configs: PlatformTestConfig::default(), + initial_protocol_version: Self::default_initial_protocol_version(), prometheus_bind_address: None, grpc_bind_address: "0.0.0.0:26670".to_string(), tokio_console_enabled: false, @@ -379,6 +389,7 @@ impl PlatformConfig { execution: Default::default(), db_path: PathBuf::from("/var/lib/dash-platform/data"), testing_configs: PlatformTestConfig::default(), + initial_protocol_version: Self::default_initial_protocol_version(), prometheus_bind_address: None, grpc_bind_address: "0.0.0.0:26670".to_string(), tokio_console_enabled: false, @@ -395,9 +406,6 @@ pub struct PlatformTestConfig { pub block_signing: bool, /// Block signature verification pub block_commit_signature_verification: bool, - /// Initial protocol version - #[serde(default = "PlatformTestConfig::default_initial_protocol_version")] - pub initial_protocol_version: ProtocolVersion, } impl PlatformTestConfig { @@ -406,13 +414,8 @@ impl PlatformTestConfig { Self { block_signing: false, block_commit_signature_verification: false, - initial_protocol_version: Self::default_initial_protocol_version(), } } - - fn default_initial_protocol_version() -> ProtocolVersion { - INITIAL_PROTOCOL_VERSION - } } impl Default for PlatformTestConfig { @@ -420,7 +423,6 @@ impl Default for PlatformTestConfig { Self { block_signing: true, block_commit_signature_verification: true, - initial_protocol_version: Self::default_initial_protocol_version(), } } } diff --git a/packages/rs-drive-abci/src/error/execution.rs b/packages/rs-drive-abci/src/error/execution.rs index 165bbe4f753..3c3b0d3a9eb 100644 --- a/packages/rs-drive-abci/src/error/execution.rs +++ b/packages/rs-drive-abci/src/error/execution.rs @@ -82,6 +82,10 @@ pub enum ExecutionError { #[error("protocol upgrade incoherence error: {0}")] ProtocolUpgradeIncoherence(&'static str), + /// A protocol upgrade should happen only on epoch change + #[error("unexpected protocol upgrade: it should happen only on epoch change")] + UnexpectedProtocolVersionUpgrade, + /// Data is missing from the drive. #[error("drive missing data error: {0}")] DriveMissingData(String), diff --git a/packages/rs-drive-abci/src/execution/engine/initialization/init_chain/mod.rs b/packages/rs-drive-abci/src/execution/engine/initialization/init_chain/mod.rs index 17ffc5ca918..57ec814c047 100644 --- a/packages/rs-drive-abci/src/execution/engine/initialization/init_chain/mod.rs +++ b/packages/rs-drive-abci/src/execution/engine/initialization/init_chain/mod.rs @@ -5,9 +5,7 @@ use crate::platform_types::platform::Platform; use crate::rpc::core::CoreRPCLike; -use crate::abci::AbciError; use crate::error::execution::ExecutionError; -use dpp::util::deserializer::ProtocolVersion; use dpp::version::PlatformVersion; use drive::grovedb::Transaction; use tenderdash_abci::proto::abci::{RequestInitChain, ResponseInitChain}; @@ -24,23 +22,8 @@ where ) -> Result { // We don't have platform state at this point, so we should // use initial protocol version from genesis - // TODO: Shall we use request_init_chain_cleaned_params::v0::RequestInitChainCleanedParams::try_from instead of copy - // pasting code form there? - let consensus_params = request - .consensus_params - .as_ref() - .ok_or(AbciError::BadRequest( - "consensus params are required in init chain".to_string(), - ))?; - - let tenderdash_abci::proto::types::VersionParams { app_version } = consensus_params - .version - .as_ref() - .ok_or(AbciError::BadRequest( - "consensus params version is required in init chain".to_string(), - ))?; - - let platform_version = PlatformVersion::get(*app_version as ProtocolVersion)?; + let protocol_version = self.config.initial_protocol_version; + let platform_version = PlatformVersion::get(protocol_version)?; match platform_version.drive_abci.methods.engine.init_chain { 0 => self.init_chain_v0(request, transaction, platform_version), diff --git a/packages/rs-drive-abci/src/execution/engine/run_block_proposal/mod.rs b/packages/rs-drive-abci/src/execution/engine/run_block_proposal/mod.rs index f56038d5a3f..bb66bea033b 100644 --- a/packages/rs-drive-abci/src/execution/engine/run_block_proposal/mod.rs +++ b/packages/rs-drive-abci/src/execution/engine/run_block_proposal/mod.rs @@ -1,6 +1,8 @@ use crate::error::execution::ExecutionError; use crate::error::Error; +use crate::platform_types::epoch_info::v0::EpochInfoV0Methods; use crate::platform_types::platform::Platform; +use crate::platform_types::platform_state::v0::PlatformStateV0Methods; use crate::platform_types::platform_state::PlatformState; use crate::platform_types::{block_execution_outcome, block_proposal}; use crate::rpc::core::CoreRPCLike; @@ -46,18 +48,31 @@ where transaction: &Transaction, ) -> Result, Error> { - // Get current protocol version from block header - let protocol_version = block_proposal.consensus_versions.app as u32; - let platform_version = PlatformVersion::get(protocol_version)?; + // TODO: We should do it above and validate version from request + // prepare proposal should set this version + // Epoch information is always calculated with the last committed platform version + // even if we are switching to a new version in this block. + let last_committed_platform_version = platform_state.current_platform_version()?; let epoch_info = self.gather_epoch_info( &block_proposal, transaction, platform_state, - platform_version, + last_committed_platform_version, )?; - match platform_version + // Determine a protocol version for this block + let block_platform_version = if epoch_info.is_epoch_change_but_not_genesis() { + // Switch to next proposed platform version if we are on the first block of the new epoch + // This version must be set to the state as current one during block processing + let protocol_version = platform_state.next_epoch_protocol_version(); + PlatformVersion::get(protocol_version)? + } else { + // Stay on the last committed platform version + last_committed_platform_version + }; + + match block_platform_version .drive_abci .methods .engine @@ -66,10 +81,10 @@ where 0 => self.run_block_proposal_v0( block_proposal, known_from_us, - epoch_info.into(), + epoch_info, transaction, platform_state, - platform_version, + block_platform_version, ), version => Err(Error::Execution(ExecutionError::UnknownVersionMismatch { method: "run_block_proposal".to_string(), diff --git a/packages/rs-drive-abci/src/execution/engine/run_block_proposal/v0/mod.rs b/packages/rs-drive-abci/src/execution/engine/run_block_proposal/v0/mod.rs index 9677aab3e2e..2eb8a4e7f00 100644 --- a/packages/rs-drive-abci/src/execution/engine/run_block_proposal/v0/mod.rs +++ b/packages/rs-drive-abci/src/execution/engine/run_block_proposal/v0/mod.rs @@ -1,5 +1,4 @@ use dpp::block::epoch::Epoch; -use dpp::util::deserializer::ProtocolVersion; use dpp::validation::ValidationResult; use drive::error::Error::GroveDB; @@ -69,6 +68,24 @@ where platform_version: &PlatformVersion, ) -> Result, Error> { + // Run block proposal determines version by itself based on the previous + // state and block time. + // It should provide correct version on prepare proposal to block header + // and validate it on process proposal. + // If version set to 0 (default number value) it means we are on prepare proposal, + // so there is no need for validation. + if !known_from_us + && block_proposal.consensus_versions.app != platform_version.protocol_version as u64 + { + return Ok(ValidationResult::new_with_error( + AbciError::BadRequest(format!( + "received a block proposal with protocol version {}, expected: {}", + block_proposal.consensus_versions.app, platform_version.protocol_version + )) + .into(), + )); + } + tracing::trace!( method = "run_block_proposal_v0", ?block_proposal, @@ -78,46 +95,27 @@ where block_proposal.round, ); + if epoch_info.is_epoch_change_but_not_genesis() { + tracing::info!( + epoch_index = epoch_info.current_epoch_index(), + "epoch change occurring from epoch {} to epoch {}", + epoch_info + .previous_epoch_index() + .expect("must be set since we aren't on genesis"), + epoch_info.current_epoch_index(), + ); + } + let last_block_time_ms = last_committed_platform_state.last_committed_block_time_ms(); let last_block_height = last_committed_platform_state.last_committed_known_block_height_or( self.config.abci.genesis_height.saturating_sub(1), ); let last_block_core_height = last_committed_platform_state .last_committed_known_core_height_or(self.config.abci.genesis_core_height); - let hpmn_list_len = last_committed_platform_state.hpmn_list_len() as u32; // Create a bock state from previous committed state let mut block_platform_state = last_committed_platform_state.clone(); - // Set protocol version for this block - { - let current_block_protocol_version = platform_version.protocol_version; - let previous_block_protocol_version = - last_committed_platform_state.current_protocol_version_in_consensus(); - - // Set current protocol version from the block - block_platform_state - .set_current_protocol_version_in_consensus(current_block_protocol_version); - - // Does this block has different protocol version comparing with the previous? - if previous_block_protocol_version != current_block_protocol_version { - tracing::info!( - epoch_index = epoch_info.current_epoch_index(), - "protocol version changed from {} to {}", - previous_block_protocol_version, - current_block_protocol_version, - ); - - // We need to persist new protocol version - // TODO: Must be a part of epoch trees? - self.drive.store_current_protocol_version( - current_block_protocol_version, - Some(transaction), - &platform_version.drive, - )?; - } - } - // Init block execution context let block_state_info = block_state_info::v0::BlockStateInfoV0::from_block_proposal( &block_proposal, @@ -259,52 +257,15 @@ where Error::Execution(ExecutionError::UpdateValidatorProposedAppVersionError(e)) })?; // This is a system error - // Determine a new protocol version if enough proposers voted - let mut next_block_protocol_version = None; - if epoch_info.is_epoch_change_but_not_genesis() { - tracing::info!( - epoch_index = epoch_info.current_epoch_index(), - "epoch change occurring from epoch {} to epoch {}", - epoch_info - .previous_epoch_index() - .expect("must be set since we aren't on genesis"), - epoch_info.current_epoch_index(), - ); - - // Set next protocol version as a version for next block if changed - if block_platform_state.current_protocol_version_in_consensus() - == block_platform_state.next_epoch_protocol_version() - { - tracing::trace!( - epoch_index = epoch_info.current_epoch_index(), - "protocol version for the next block remains the same {}", - block_platform_state.current_protocol_version_in_consensus(), - ); - } else { - next_block_protocol_version = - Some(block_platform_state.next_epoch_protocol_version()); - - tracing::trace!( - epoch_index = epoch_info.current_epoch_index(), - "set new protocol version for the next block {}", - block_platform_state.next_epoch_protocol_version(), - ); - } - - // Determine new protocol version based on votes for the next epoch - let maybe_new_protocol_version = - self.check_for_desired_protocol_upgrade(hpmn_list_len, platform_version)?; - - if let Some(new_protocol_version) = maybe_new_protocol_version { - block_platform_state.set_next_epoch_protocol_version(new_protocol_version); - } - - // Since we are starting new epoch we need to drop previously - // proposed versions - self.drive - .clear_version_information(Some(transaction), &platform_version.drive) - .map_err(Error::Drive)?; - } + // Update block platform state with current and next epoch protocol versions + // if it was proposed + self.upgrade_protocol_version( + &epoch_info, + last_committed_platform_state, + &mut block_platform_state, + transaction, + platform_version, + )?; // Mark all previously broadcasted and chainlocked withdrawals as complete // only when we are on a new core height @@ -355,7 +316,7 @@ where block_execution_context::v0::BlockExecutionContextV0 { block_state_info: block_state_info.into(), epoch_info: epoch_info.clone(), - hpmn_count: hpmn_list_len, + hpmn_count: block_platform_state.hpmn_list_len() as u32, unsigned_withdrawal_transactions: unsigned_withdrawal_transaction_bytes, block_platform_state, proposer_results: None, @@ -409,7 +370,6 @@ where state_transitions_result, validator_set_update, protocol_version: platform_version.protocol_version, - next_block_protocol_version, block_execution_context, }, )) diff --git a/packages/rs-drive-abci/src/execution/platform_events/block_end/consensus_param_updates/mod.rs b/packages/rs-drive-abci/src/execution/platform_events/block_end/consensus_param_updates/mod.rs deleted file mode 100644 index a4fe0bea266..00000000000 --- a/packages/rs-drive-abci/src/execution/platform_events/block_end/consensus_param_updates/mod.rs +++ /dev/null @@ -1,36 +0,0 @@ -use crate::error::execution::ExecutionError; -use crate::error::Error; -use crate::platform_types::block_execution_outcome::v0::BlockExecutionOutcome; -use crate::platform_types::platform::Platform; -use crate::rpc::core::CoreRPCLike; -use dpp::version::PlatformVersion; -use tenderdash_abci::proto::types::ConsensusParams; - -mod v0; - -impl Platform -where - C: CoreRPCLike, -{ - /// Creates an instance of [ConsensusParams] if there are any consensus param updates are - /// required based on [BlockExecutionOutcome] - pub fn consensus_param_updates( - &self, - block_execution_outcome: &BlockExecutionOutcome, - platform_version: &PlatformVersion, - ) -> Result, Error> { - match platform_version - .drive_abci - .methods - .block_end - .consensus_param_updates - { - 0 => self.consensus_param_updates_v0(block_execution_outcome, platform_version), - version => Err(Error::Execution(ExecutionError::UnknownVersionMismatch { - method: "consensus_param_updates".to_string(), - known_versions: vec![0], - received: version, - })), - } - } -} diff --git a/packages/rs-drive-abci/src/execution/platform_events/block_end/consensus_param_updates/v0/mod.rs b/packages/rs-drive-abci/src/execution/platform_events/block_end/consensus_param_updates/v0/mod.rs deleted file mode 100644 index 39cac2265f6..00000000000 --- a/packages/rs-drive-abci/src/execution/platform_events/block_end/consensus_param_updates/v0/mod.rs +++ /dev/null @@ -1,31 +0,0 @@ -use crate::error::Error; -use crate::platform_types::block_execution_outcome::v0::BlockExecutionOutcome; -use crate::platform_types::platform::Platform; -use crate::rpc::core::CoreRPCLike; -use dpp::version::PlatformVersion; -use tenderdash_abci::proto::types::{ConsensusParams, VersionParams}; - -impl Platform -where - C: CoreRPCLike, -{ - // TODO: implement update of other consensus params - - pub(super) fn consensus_param_updates_v0( - &self, - block_execution_outcome: &BlockExecutionOutcome, - _platform_version: &PlatformVersion, - ) -> Result, Error> { - let consensus_param_updates = - block_execution_outcome - .next_block_protocol_version - .map(|version| ConsensusParams { - version: Some(VersionParams { - app_version: version as u64, - }), - ..Default::default() - }); - - Ok(consensus_param_updates) - } -} diff --git a/packages/rs-drive-abci/src/execution/platform_events/block_end/mod.rs b/packages/rs-drive-abci/src/execution/platform_events/block_end/mod.rs index fec91594339..f881cea1dd8 100644 --- a/packages/rs-drive-abci/src/execution/platform_events/block_end/mod.rs +++ b/packages/rs-drive-abci/src/execution/platform_events/block_end/mod.rs @@ -3,6 +3,5 @@ pub(in crate::execution) mod update_state_cache; /// Validator set update pub(in crate::execution) mod validator_set_update; -mod consensus_param_updates; /// Updating the drive cache happens as the final part of block finalization pub(in crate::execution) mod update_drive_cache; diff --git a/packages/rs-drive-abci/src/execution/platform_events/block_end/update_drive_cache/v0/mod.rs b/packages/rs-drive-abci/src/execution/platform_events/block_end/update_drive_cache/v0/mod.rs index d6c4e406730..7c3fe0010cf 100644 --- a/packages/rs-drive-abci/src/execution/platform_events/block_end/update_drive_cache/v0/mod.rs +++ b/packages/rs-drive-abci/src/execution/platform_events/block_end/update_drive_cache/v0/mod.rs @@ -13,7 +13,7 @@ where /// #[inline(always)] pub(super) fn update_drive_cache_v0(&self, block_execution_context: &BlockExecutionContext) { - // Update global cache with updated contracts form this block + // Update global cache with updated contracts self.drive .cache .data_contracts diff --git a/packages/rs-drive-abci/src/execution/platform_events/epoch/gather_epoch_info/mod.rs b/packages/rs-drive-abci/src/execution/platform_events/epoch/gather_epoch_info/mod.rs index 835af9653b9..12aa3233bd7 100644 --- a/packages/rs-drive-abci/src/execution/platform_events/epoch/gather_epoch_info/mod.rs +++ b/packages/rs-drive-abci/src/execution/platform_events/epoch/gather_epoch_info/mod.rs @@ -4,7 +4,7 @@ use crate::error::execution::ExecutionError; use crate::error::Error; use crate::platform_types::block_proposal; -use crate::platform_types::epoch_info::v0::EpochInfoV0; +use crate::platform_types::epoch_info::EpochInfo; use crate::platform_types::platform::Platform; use crate::platform_types::platform_state::PlatformState; use dpp::version::PlatformVersion; @@ -31,14 +31,20 @@ impl Platform { transaction: &Transaction, platform_state: &PlatformState, platform_version: &PlatformVersion, - ) -> Result { + ) -> Result { + // Please be aware epoch information is gathered with previous platform version + // on epoch change (1st block of the epoch), despite we are switching to a new version + // in this block. A new version of this method will be called for the rest of epoch blocks + // and first block of the next epoch. match platform_version.drive_abci.methods.epoch.gather_epoch_info { - 0 => self.gather_epoch_info_v0( - block_proposal, - transaction, - platform_state, - platform_version, - ), + 0 => self + .gather_epoch_info_v0( + block_proposal, + transaction, + platform_state, + platform_version, + ) + .map(|v0| v0.into()), version => Err(Error::Execution(ExecutionError::UnknownVersionMismatch { method: "gather_epoch_info".to_string(), known_versions: vec![0], diff --git a/packages/rs-drive-abci/src/execution/platform_events/protocol_upgrade/mod.rs b/packages/rs-drive-abci/src/execution/platform_events/protocol_upgrade/mod.rs index a69fee99bb2..b2e1e826d4e 100644 --- a/packages/rs-drive-abci/src/execution/platform_events/protocol_upgrade/mod.rs +++ b/packages/rs-drive-abci/src/execution/platform_events/protocol_upgrade/mod.rs @@ -1 +1,2 @@ mod check_for_desired_protocol_upgrade; +mod upgrade_protocol_version; diff --git a/packages/rs-drive-abci/src/execution/platform_events/protocol_upgrade/upgrade_protocol_version/mod.rs b/packages/rs-drive-abci/src/execution/platform_events/protocol_upgrade/upgrade_protocol_version/mod.rs new file mode 100644 index 00000000000..18f40174194 --- /dev/null +++ b/packages/rs-drive-abci/src/execution/platform_events/protocol_upgrade/upgrade_protocol_version/mod.rs @@ -0,0 +1,52 @@ +mod v0; + +use crate::error::execution::ExecutionError; +use crate::error::Error; +use crate::platform_types::epoch_info::EpochInfo; +use crate::platform_types::platform::Platform; +use crate::platform_types::platform_state::PlatformState; +use dpp::version::PlatformVersion; +use drive::grovedb::Transaction; + +impl Platform { + /// Sets current protocol version and next epoch protocol version to block platform state + /// + /// It takes five parameters: + /// * `epoch_info`: Information about the current epoch. + /// * `last_committed_platform_state`: The last committed state of the platform. + /// * `block_platform_state`: The current state of the platform. + /// * `transaction`: The current transaction. + /// * `platform_version`: The current version of the platform. + /// + /// # Errors + /// + /// This function will return an error if the previous block protocol version does not match the current block protocol version not on epoch change + pub fn upgrade_protocol_version( + &self, + epoch_info: &EpochInfo, + last_committed_platform_state: &PlatformState, + block_platform_state: &mut PlatformState, + transaction: &Transaction, + platform_version: &PlatformVersion, + ) -> Result<(), Error> { + match platform_version + .drive_abci + .methods + .protocol_upgrade + .upgrade_protocol_version + { + 0 => self.upgrade_protocol_version_v0( + epoch_info, + last_committed_platform_state, + block_platform_state, + transaction, + platform_version, + ), + version => Err(Error::Execution(ExecutionError::UnknownVersionMismatch { + method: "upgrade_protocol_version".to_string(), + known_versions: vec![0], + received: version, + })), + } + } +} diff --git a/packages/rs-drive-abci/src/execution/platform_events/protocol_upgrade/upgrade_protocol_version/v0/mod.rs b/packages/rs-drive-abci/src/execution/platform_events/protocol_upgrade/upgrade_protocol_version/v0/mod.rs new file mode 100644 index 00000000000..04e534c00c1 --- /dev/null +++ b/packages/rs-drive-abci/src/execution/platform_events/protocol_upgrade/upgrade_protocol_version/v0/mod.rs @@ -0,0 +1,90 @@ +use crate::error::execution::ExecutionError; +use crate::error::Error; +use crate::platform_types::epoch_info::v0::{EpochInfoV0Getters, EpochInfoV0Methods}; +use crate::platform_types::epoch_info::EpochInfo; +use crate::platform_types::platform::Platform; +use crate::platform_types::platform_state::v0::PlatformStateV0Methods; +use crate::platform_types::platform_state::PlatformState; +use dpp::version::PlatformVersion; +use drive::grovedb::Transaction; + +impl Platform { + /// Sets current protocol version and next epoch protocol version to block platform state + /// + /// It takes five parameters: + /// * `epoch_info`: Information about the current epoch. + /// * `last_committed_platform_state`: The last committed state of the platform. + /// * `block_platform_state`: The current state of the platform. + /// * `transaction`: The current transaction. + /// * `platform_version`: The current version of the platform. + /// + /// # Errors + /// + /// This function will return an error if the previous block protocol version does not match the current block protocol version not on epoch change + pub(super) fn upgrade_protocol_version_v0( + &self, + epoch_info: &EpochInfo, + last_committed_platform_state: &PlatformState, + block_platform_state: &mut PlatformState, + transaction: &Transaction, + platform_version: &PlatformVersion, + ) -> Result<(), Error> { + let current_block_protocol_version = platform_version.protocol_version; + let previous_block_protocol_version = + last_committed_platform_state.current_protocol_version_in_consensus(); + + // Set current protocol version + block_platform_state + .set_current_protocol_version_in_consensus(current_block_protocol_version); + + // Protocol version upgrade should happen only on epoch change + if epoch_info.is_epoch_change_but_not_genesis() { + if current_block_protocol_version == previous_block_protocol_version { + tracing::info!( + epoch_index = epoch_info.current_epoch_index(), + "protocol version remains the same {}", + current_block_protocol_version, + ); + } else { + tracing::info!( + epoch_index = epoch_info.current_epoch_index(), + "protocol version changed from {} to {}", + previous_block_protocol_version, + current_block_protocol_version, + ); + + // We need to persist new protocol version + // TODO: Must be a part of epoch trees. The matter of the next PR + self.drive.store_current_protocol_version( + current_block_protocol_version, + Some(transaction), + &platform_version.drive, + )?; + }; + + // Determine a new protocol version for the next epoch if enough proposers voted + // otherwise keep the current one + + let hpmn_list_len = last_committed_platform_state.hpmn_list_len() as u32; + + let next_epoch_protocol_version = + self.check_for_desired_protocol_upgrade(hpmn_list_len, platform_version)?; + + if let Some(protocol_version) = next_epoch_protocol_version { + block_platform_state.set_next_epoch_protocol_version(protocol_version); + } + + // Since we are starting a new epoch we need to drop previously + // proposed versions + self.drive + .clear_version_information(Some(transaction), &platform_version.drive) + .map_err(Error::Drive)?; + } else if previous_block_protocol_version != current_block_protocol_version { + return Err(Error::Execution( + ExecutionError::UnexpectedProtocolVersionUpgrade, + )); + } + + Ok(()) + } +} diff --git a/packages/rs-drive-abci/src/mimic/mod.rs b/packages/rs-drive-abci/src/mimic/mod.rs index 01655e2939a..4d0afcd5a51 100644 --- a/packages/rs-drive-abci/src/mimic/mod.rs +++ b/packages/rs-drive-abci/src/mimic/mod.rs @@ -64,8 +64,8 @@ pub struct MimicExecuteBlockOutcome { pub block_id_hash: [u8; 32], /// Block signature pub signature: [u8; 96], - /// Protocol version for next block - pub next_block_protocol_version: Option, + /// Version of Drive app used to generate this block + pub app_version: u64, } /// Options for execution @@ -87,7 +87,6 @@ impl<'a, C: CoreRPCLike> FullAbciApplication<'a, C> { &self, proposer_pro_tx_hash: [u8; 32], current_quorum: &TestQuorumInfo, - current_version: ProtocolVersion, proposed_version: ProtocolVersion, block_info: BlockInfo, round: u32, @@ -118,6 +117,8 @@ impl<'a, C: CoreRPCLike> FullAbciApplication<'a, C> { .unwrap() }); + const DEFAULT_APP_VERSION: u64 = 0; + let mut rng = StdRng::seed_from_u64(block_info.height); let next_validators_hash: [u8; 32] = rng.gen(); // We fake a block hash for the test @@ -152,7 +153,7 @@ impl<'a, C: CoreRPCLike> FullAbciApplication<'a, C> { proposed_app_version: proposed_version as u64, version: Some(Consensus { block: 0, - app: current_version as u64, + app: DEFAULT_APP_VERSION, // TODO: Prepare proposal should get 0 always }), quorum_hash: current_quorum.quorum_hash.to_byte_array().to_vec(), }; @@ -172,8 +173,12 @@ impl<'a, C: CoreRPCLike> FullAbciApplication<'a, C> { consensus_param_updates: _, core_chain_lock_update, validator_set_update, + app_version, // TODO: Not optional } = response_prepare_proposal; + let current_protocol_version = + app_version.expect("expected app version") as ProtocolVersion; + if let Some(core_chain_lock_update) = core_chain_lock_update.as_ref() { core_height = core_chain_lock_update.core_block_height; } @@ -230,7 +235,7 @@ impl<'a, C: CoreRPCLike> FullAbciApplication<'a, C> { let state_id = StateId { app_hash: app_hash.clone(), - app_version: current_version as u64, + app_version: current_protocol_version as u64, core_chain_locked_height: core_height, height, time: time.to_milis(), @@ -270,28 +275,25 @@ impl<'a, C: CoreRPCLike> FullAbciApplication<'a, C> { proposed_app_version: proposed_version as u64, version: Some(Consensus { block: 0, - app: current_version as u64, + app: current_protocol_version as u64, }), quorum_hash: current_quorum.quorum_hash.to_byte_array().to_vec(), }; - let consensus_param_updates = if !options.independent_process_proposal_verification { + if !options.independent_process_proposal_verification { //we just check as if we were the proposer //we must call process proposal so the app hash is set - let response = self.process_proposal(request_process_proposal) + self.process_proposal(request_process_proposal) .unwrap_or_else(|e| { panic!( "should skip processing (because we prepared it) block #{} at time #{} : {:?}", block_info.height, block_info.time_ms, e ) }); - - response.consensus_param_updates } else { - // TODO: Shouldn't it be prepare proposal first? //we first call process proposal as the proposer //we must call process proposal so the app hash is set - let response = self.process_proposal(request_process_proposal.clone()) + self.process_proposal(request_process_proposal.clone()) .unwrap_or_else(|e| { panic!( "should skip processing (because we prepared it) block #{} at time #{} : {:?}", @@ -383,9 +385,7 @@ impl<'a, C: CoreRPCLike> FullAbciApplication<'a, C> { "the application hashed are not valid for height {}", block_info.height ); - - response.consensus_param_updates - }; + } let request_extend_vote = RequestExtendVote { hash: block_header_hash.to_vec(), @@ -523,7 +523,7 @@ impl<'a, C: CoreRPCLike> FullAbciApplication<'a, C> { header: Some(Header { version: Some(Consensus { block: 0, //todo - app: current_version as u64, + app: current_protocol_version as u64, }), chain_id: CHAIN_ID.to_string(), height: height as i64, @@ -592,18 +592,9 @@ impl<'a, C: CoreRPCLike> FullAbciApplication<'a, C> { assert_eq!(app_hash, root_hash_after_finalization); } - let next_block_protocol_version = consensus_param_updates - .map(|updates| updates.version) - .map(|version| version.unwrap().app_version) - .map(|version| { - version - .try_into() - .expect("expected a valid protocol version") - }); - Ok(MimicExecuteBlockOutcome { state_transaction_results, - next_block_protocol_version, + app_version: current_protocol_version as u64, withdrawal_transactions, validator_set_update, next_validator_set_hash, diff --git a/packages/rs-drive-abci/src/platform_types/block_execution_outcome/v0/mod.rs b/packages/rs-drive-abci/src/platform_types/block_execution_outcome/v0/mod.rs index 96e52b766fa..e863244a03d 100644 --- a/packages/rs-drive-abci/src/platform_types/block_execution_outcome/v0/mod.rs +++ b/packages/rs-drive-abci/src/platform_types/block_execution_outcome/v0/mod.rs @@ -18,8 +18,6 @@ pub struct BlockExecutionOutcome { pub validator_set_update: Option, /// Current block protocol version pub protocol_version: ProtocolVersion, - /// Next block protocol version - pub next_block_protocol_version: Option, /// Block execution context pub block_execution_context: BlockExecutionContext, } diff --git a/packages/rs-drive-abci/src/test/fixture/abci.rs b/packages/rs-drive-abci/src/test/fixture/abci.rs index 1e0e2784dae..0330ac740cc 100644 --- a/packages/rs-drive-abci/src/test/fixture/abci.rs +++ b/packages/rs-drive-abci/src/test/fixture/abci.rs @@ -51,7 +51,7 @@ pub fn static_init_chain_request(config: &PlatformConfig) -> RequestInitChain { chain_id: "strategy_tests".to_string(), consensus_params: Some(ConsensusParams { version: Some(VersionParams { - app_version: config.testing_configs.initial_protocol_version as u64, + app_version: config.initial_protocol_version as u64, }), ..Default::default() }), diff --git a/packages/rs-drive-abci/tests/strategy_tests/execution.rs b/packages/rs-drive-abci/tests/strategy_tests/execution.rs index 7620421b610..66ba2f947e8 100644 --- a/packages/rs-drive-abci/tests/strategy_tests/execution.rs +++ b/packages/rs-drive-abci/tests/strategy_tests/execution.rs @@ -837,8 +837,6 @@ pub(crate) fn continue_chain_for_strategy( let mut state_transitions_per_block = BTreeMap::new(); let mut state_transition_results_per_block = BTreeMap::new(); - let mut protocol_version = config.testing_configs.initial_protocol_version; - for block_height in block_start..(block_start + block_count) { let state = platform.state.load(); let epoch_info = EpochInfoV0::calculate( @@ -935,7 +933,6 @@ pub(crate) fn continue_chain_for_strategy( .mimic_execute_block( proposer.pro_tx_hash.into(), current_quorum_with_test_info, - protocol_version, proposed_version, block_info.clone(), round, @@ -965,13 +962,9 @@ pub(crate) fn continue_chain_for_strategy( state_id, block_id_hash: block_hash, signature, - next_block_protocol_version, + app_version, } = block_execution_outcome.unwrap(); - if let Some(version) = next_block_protocol_version { - protocol_version = version; - } - if let Some(validator_set_update) = validator_set_update { validator_set_updates.insert(block_height, validator_set_update); } @@ -1021,7 +1014,7 @@ pub(crate) fn continue_chain_for_strategy( &ProofVerification { quorum_hash: ¤t_quorum_with_test_info.quorum_hash.into(), quorum_type: config.validator_set_quorum_type(), - app_version: protocol_version as u64, + app_version, chain_id: drive_abci::mimic::CHAIN_ID.to_string(), core_chain_locked_height: state_id.core_chain_locked_height, height: state_id.height as i64, diff --git a/packages/rs-platform-version/src/version/drive_abci_versions.rs b/packages/rs-platform-version/src/version/drive_abci_versions.rs index edcb203e741..f5e7f21f674 100644 --- a/packages/rs-platform-version/src/version/drive_abci_versions.rs +++ b/packages/rs-platform-version/src/version/drive_abci_versions.rs @@ -250,7 +250,6 @@ pub struct DriveAbciBlockEndMethodVersions { pub update_state_cache: FeatureVersion, pub update_drive_cache: FeatureVersion, pub validator_set_update: FeatureVersion, - pub consensus_param_updates: FeatureVersion, } #[derive(Clone, Debug, Default)] @@ -266,6 +265,7 @@ pub struct DriveAbciIdentityCreditWithdrawalMethodVersions { #[derive(Clone, Debug, Default)] pub struct DriveAbciProtocolUpgradeMethodVersions { pub check_for_desired_protocol_upgrade: FeatureVersion, + pub upgrade_protocol_version: FeatureVersion, } #[derive(Clone, Debug, Default)] 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 3cc2274221d..80b4bd4c92a 100644 --- a/packages/rs-platform-version/src/version/mocks/v2_test.rs +++ b/packages/rs-platform-version/src/version/mocks/v2_test.rs @@ -530,6 +530,7 @@ pub(crate) const TEST_PLATFORM_V2: PlatformVersion = PlatformVersion { }, protocol_upgrade: DriveAbciProtocolUpgradeMethodVersions { check_for_desired_protocol_upgrade: 0, + upgrade_protocol_version: 0, }, block_fee_processing: DriveAbciBlockFeeProcessingMethodVersions { add_process_epoch_change_operations: 0, @@ -580,7 +581,6 @@ pub(crate) const TEST_PLATFORM_V2: PlatformVersion = PlatformVersion { update_state_cache: 0, update_drive_cache: 0, validator_set_update: 0, - consensus_param_updates: 0, }, platform_state_storage: DriveAbciPlatformStateStorageMethodVersions { fetch_platform_state: 0, 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 029bdf66071..d16c4ac0c61 100644 --- a/packages/rs-platform-version/src/version/mocks/v3_test.rs +++ b/packages/rs-platform-version/src/version/mocks/v3_test.rs @@ -530,6 +530,7 @@ pub(crate) const TEST_PLATFORM_V3: PlatformVersion = PlatformVersion { }, protocol_upgrade: DriveAbciProtocolUpgradeMethodVersions { check_for_desired_protocol_upgrade: 0, + upgrade_protocol_version: 0, }, block_fee_processing: DriveAbciBlockFeeProcessingMethodVersions { add_process_epoch_change_operations: 0, @@ -580,7 +581,6 @@ pub(crate) const TEST_PLATFORM_V3: PlatformVersion = PlatformVersion { update_state_cache: 0, update_drive_cache: 0, validator_set_update: 0, - consensus_param_updates: 0, }, platform_state_storage: DriveAbciPlatformStateStorageMethodVersions { fetch_platform_state: 0, diff --git a/packages/rs-platform-version/src/version/v1.rs b/packages/rs-platform-version/src/version/v1.rs index 67db5d4c634..a023fb262a7 100644 --- a/packages/rs-platform-version/src/version/v1.rs +++ b/packages/rs-platform-version/src/version/v1.rs @@ -527,6 +527,7 @@ pub(super) const PLATFORM_V1: PlatformVersion = PlatformVersion { }, protocol_upgrade: DriveAbciProtocolUpgradeMethodVersions { check_for_desired_protocol_upgrade: 0, + upgrade_protocol_version: 0, }, block_fee_processing: DriveAbciBlockFeeProcessingMethodVersions { add_process_epoch_change_operations: 0, @@ -577,7 +578,6 @@ pub(super) const PLATFORM_V1: PlatformVersion = PlatformVersion { update_state_cache: 0, update_drive_cache: 0, validator_set_update: 0, - consensus_param_updates: 0, }, platform_state_storage: DriveAbciPlatformStateStorageMethodVersions { fetch_platform_state: 0, From dc9bf0611646f7b1c96250638a51689aff7f081b Mon Sep 17 00:00:00 2001 From: Ivan Shumkov Date: Tue, 26 Mar 2024 19:37:21 +0700 Subject: [PATCH 14/37] chore: update app hash --- .../initialization/create_genesis_state/v0/mod.rs | 4 ++-- packages/rs-drive-abci/tests/strategy_tests/main.rs | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/packages/rs-drive-abci/src/execution/platform_events/initialization/create_genesis_state/v0/mod.rs b/packages/rs-drive-abci/src/execution/platform_events/initialization/create_genesis_state/v0/mod.rs index 61998bac9c7..694a02036df 100644 --- a/packages/rs-drive-abci/src/execution/platform_events/initialization/create_genesis_state/v0/mod.rs +++ b/packages/rs-drive-abci/src/execution/platform_events/initialization/create_genesis_state/v0/mod.rs @@ -314,8 +314,8 @@ mod tests { assert_eq!( root_hash, [ - 234, 164, 235, 118, 224, 151, 97, 37, 216, 180, 69, 227, 187, 186, 178, 82, - 251, 35, 184, 238, 104, 188, 106, 117, 182, 210, 91, 97, 218, 177, 130, 64 + 144, 123, 124, 62, 37, 243, 19, 45, 226, 49, 97, 251, 141, 197, 94, 69, 117, + 126, 182, 44, 148, 143, 41, 113, 245, 86, 229, 207, 100, 56, 17, 177 ] ) } diff --git a/packages/rs-drive-abci/tests/strategy_tests/main.rs b/packages/rs-drive-abci/tests/strategy_tests/main.rs index 973770313a7..9eb44149a09 100644 --- a/packages/rs-drive-abci/tests/strategy_tests/main.rs +++ b/packages/rs-drive-abci/tests/strategy_tests/main.rs @@ -1144,7 +1144,7 @@ mod tests { .unwrap() .unwrap() ), - "8e1e8d1ae51b3fc8a9e4acd0d312c9494943f2b7a5b957cc1379ab246ebd678d".to_string() + "3b384cfa26ba56ccabd9e7fa6b0ae5e00393b4673fe38e604f0fce224541159a".to_string() ) } @@ -1833,7 +1833,7 @@ mod tests { .unwrap() .unwrap() ), - "665ec5018021b0a14a25b7ac6de780edc943a73adb3dc7e2eb623959a08056c3".to_string() + "437d4471e4fd85828b902baad3460b207fb524185803e51d59e4833a17f01732".to_string() ) } @@ -1958,7 +1958,7 @@ mod tests { .unwrap() .unwrap() ), - "3f1cfdfd2e1019e941434cc841282fbc156ee19062569e393a51af621447c7a7".to_string() + "bc8ce6520e097730f247a9d4ce7a927e733d193f833daeec42f7475b4f10983f".to_string() ) } From b08beb5df6fa201660d7f264cc5d78a8937499ad Mon Sep 17 00:00:00 2001 From: Ivan Shumkov Date: Tue, 26 Mar 2024 21:19:27 +0700 Subject: [PATCH 15/37] chore: remove unnecessary functions and move current version to aux --- .../initialization/init_chain/v0/mod.rs | 6 -- .../upgrade_protocol_version/v0/mod.rs | 8 --- .../storage/store_platform_state/v0/mod.rs | 8 ++- .../tests/strategy_tests/main.rs | 8 +-- .../mod.rs | 41 ----------- .../v0/mod.rs | 56 --------------- .../src/drive/protocol_upgrade/mod.rs | 3 - .../src/drive/system/misc_tree_constants.rs | 5 -- packages/rs-drive/src/drive/system/mod.rs | 2 - .../fetch_current_protocol_version.rs | 22 +++--- .../fetch_next_protocol_version/mod.rs | 44 ------------ .../fetch_next_protocol_version/v0/mod.rs | 42 ----------- .../src/drive/system/protocol_version/mod.rs | 5 +- .../mod.rs | 55 -------------- .../v0/mod.rs | 36 ---------- .../store_current_protocol_version.rs | 72 ++++--------------- .../src/version/drive_versions.rs | 8 --- .../src/version/mocks/v2_test.rs | 13 ++-- .../src/version/mocks/v3_test.rs | 13 ++-- .../rs-platform-version/src/version/v1.rs | 13 ++-- 20 files changed, 45 insertions(+), 415 deletions(-) delete mode 100644 packages/rs-drive/src/drive/protocol_upgrade/change_to_new_version_and_clear_version_information/mod.rs delete mode 100644 packages/rs-drive/src/drive/protocol_upgrade/change_to_new_version_and_clear_version_information/v0/mod.rs delete mode 100644 packages/rs-drive/src/drive/system/misc_tree_constants.rs delete mode 100644 packages/rs-drive/src/drive/system/protocol_version/fetch_next_protocol_version/mod.rs delete mode 100644 packages/rs-drive/src/drive/system/protocol_version/fetch_next_protocol_version/v0/mod.rs delete mode 100644 packages/rs-drive/src/drive/system/protocol_version/set_next_protocol_version_operations/mod.rs delete mode 100644 packages/rs-drive/src/drive/system/protocol_version/set_next_protocol_version_operations/v0/mod.rs diff --git a/packages/rs-drive-abci/src/execution/engine/initialization/init_chain/v0/mod.rs b/packages/rs-drive-abci/src/execution/engine/initialization/init_chain/v0/mod.rs index bff63f2aba2..e43a6413631 100644 --- a/packages/rs-drive-abci/src/execution/engine/initialization/init_chain/v0/mod.rs +++ b/packages/rs-drive-abci/src/execution/engine/initialization/init_chain/v0/mod.rs @@ -89,12 +89,6 @@ where initial_platform_state .set_current_protocol_version_in_consensus(request.initial_protocol_version); - self.drive.store_current_protocol_version( - request.initial_protocol_version, - Some(transaction), - &platform_version.drive, - )?; - if tracing::enabled!(tracing::Level::TRACE) { tracing::trace!( platform_state_fingerprint = hex::encode(initial_platform_state.fingerprint()), diff --git a/packages/rs-drive-abci/src/execution/platform_events/protocol_upgrade/upgrade_protocol_version/v0/mod.rs b/packages/rs-drive-abci/src/execution/platform_events/protocol_upgrade/upgrade_protocol_version/v0/mod.rs index 04e534c00c1..1fcf51b75ac 100644 --- a/packages/rs-drive-abci/src/execution/platform_events/protocol_upgrade/upgrade_protocol_version/v0/mod.rs +++ b/packages/rs-drive-abci/src/execution/platform_events/protocol_upgrade/upgrade_protocol_version/v0/mod.rs @@ -52,14 +52,6 @@ impl Platform { previous_block_protocol_version, current_block_protocol_version, ); - - // We need to persist new protocol version - // TODO: Must be a part of epoch trees. The matter of the next PR - self.drive.store_current_protocol_version( - current_block_protocol_version, - Some(transaction), - &platform_version.drive, - )?; }; // Determine a new protocol version for the next epoch if enough proposers voted diff --git a/packages/rs-drive-abci/src/execution/storage/store_platform_state/v0/mod.rs b/packages/rs-drive-abci/src/execution/storage/store_platform_state/v0/mod.rs index b41100eb477..68893fbb0eb 100644 --- a/packages/rs-drive-abci/src/execution/storage/store_platform_state/v0/mod.rs +++ b/packages/rs-drive-abci/src/execution/storage/store_platform_state/v0/mod.rs @@ -14,6 +14,12 @@ impl Platform { ) -> Result<(), Error> { self.drive .store_platform_state_bytes(&state.serialize_to_bytes()?, transaction, platform_version) - .map_err(Error::Drive) + .map_err(Error::Drive)?; + + // We need to persist new protocol version as well be able to read block state + self.drive + .store_current_protocol_version(platform_version.protocol_version, transaction)?; + + Ok(()) } } diff --git a/packages/rs-drive-abci/tests/strategy_tests/main.rs b/packages/rs-drive-abci/tests/strategy_tests/main.rs index 9eb44149a09..05a50fe290f 100644 --- a/packages/rs-drive-abci/tests/strategy_tests/main.rs +++ b/packages/rs-drive-abci/tests/strategy_tests/main.rs @@ -554,7 +554,7 @@ mod tests { .expect("expected to fetch balances") .expect("expected to have an identity to get balance from"); - assert_eq!(balance, 99864800180) + assert_eq!(balance, 99864829780) } #[test] @@ -1144,7 +1144,7 @@ mod tests { .unwrap() .unwrap() ), - "3b384cfa26ba56ccabd9e7fa6b0ae5e00393b4673fe38e604f0fce224541159a".to_string() + "8e16a23bb1e7149d3a68954bed157900398837f279781bb48186f93478c8d922".to_string() ) } @@ -1833,7 +1833,7 @@ mod tests { .unwrap() .unwrap() ), - "437d4471e4fd85828b902baad3460b207fb524185803e51d59e4833a17f01732".to_string() + "2d620f91cb1be7a5dca0123b8d3c804a2efb7440fa81c247322423c86761cd85".to_string() ) } @@ -1958,7 +1958,7 @@ mod tests { .unwrap() .unwrap() ), - "bc8ce6520e097730f247a9d4ce7a927e733d193f833daeec42f7475b4f10983f".to_string() + "f49bcf6fe1022d56ef4bdc372b2f637e8241aafd7b2ea4e10051c0173d974674".to_string() ) } diff --git a/packages/rs-drive/src/drive/protocol_upgrade/change_to_new_version_and_clear_version_information/mod.rs b/packages/rs-drive/src/drive/protocol_upgrade/change_to_new_version_and_clear_version_information/mod.rs deleted file mode 100644 index 41b91c71c73..00000000000 --- a/packages/rs-drive/src/drive/protocol_upgrade/change_to_new_version_and_clear_version_information/mod.rs +++ /dev/null @@ -1,41 +0,0 @@ -use crate::drive::Drive; -use crate::error::drive::DriveError; -use crate::error::Error; -use dpp::util::deserializer::ProtocolVersion; - -use dpp::version::PlatformVersion; -use dpp::ProtocolError; -use grovedb::TransactionArg; - -mod v0; - -impl Drive { - /// Clear all version information from the backing store, this is done on epoch change in - /// execution logic - pub fn change_to_new_version_and_clear_version_information( - &self, - current_version: ProtocolVersion, - next_version: ProtocolVersion, - transaction: TransactionArg, - ) -> Result<(), Error> { - let platform_version = - PlatformVersion::get(current_version).map_err(ProtocolError::PlatformVersionError)?; - match platform_version - .drive - .methods - .protocol_upgrade - .change_to_new_version_and_clear_version_information - { - 0 => self.change_to_new_version_and_clear_version_information_v0( - current_version, - next_version, - transaction, - ), - version => Err(Error::Drive(DriveError::UnknownVersionMismatch { - method: "change_to_new_version_and_clear_version_information".to_string(), - known_versions: vec![0], - received: version, - })), - } - } -} diff --git a/packages/rs-drive/src/drive/protocol_upgrade/change_to_new_version_and_clear_version_information/v0/mod.rs b/packages/rs-drive/src/drive/protocol_upgrade/change_to_new_version_and_clear_version_information/v0/mod.rs deleted file mode 100644 index b30a6e2db55..00000000000 --- a/packages/rs-drive/src/drive/protocol_upgrade/change_to_new_version_and_clear_version_information/v0/mod.rs +++ /dev/null @@ -1,56 +0,0 @@ -use crate::drive::batch::grovedb_op_batch::GroveDbOpBatchV0Methods; -use crate::drive::Drive; - -use crate::error::Error; - -use crate::fee::op::LowLevelDriveOperation; - -use dpp::util::deserializer::ProtocolVersion; - -use dpp::version::PlatformVersion; -use dpp::ProtocolError; - -use grovedb::TransactionArg; - -impl Drive { - /// TODO: Should work with Epoch trees. Will be reworked in upcoming PR - /// Clear all version information from the backing store, this is done on epoch change in - /// execution logic - pub(super) fn change_to_new_version_and_clear_version_information_v0( - &self, - current_version: ProtocolVersion, - next_version: ProtocolVersion, - transaction: TransactionArg, - ) -> Result<(), Error> { - let platform_version = - PlatformVersion::get(current_version).map_err(ProtocolError::PlatformVersionError)?; - let mut batch_operations: Vec = vec![]; - - self.set_current_protocol_version_operations( - current_version, - &mut batch_operations, - &platform_version.drive, - )?; - self.set_next_protocol_version_operations( - next_version, - transaction, - &mut batch_operations, - &platform_version.drive, - )?; - let grove_db_operations = - LowLevelDriveOperation::grovedb_operations_batch(&batch_operations); - if !grove_db_operations.is_empty() { - self.apply_batch_grovedb_operations( - None, - transaction, - grove_db_operations, - &mut vec![], - &platform_version.drive, - )?; - } - - self.clear_version_information(transaction, &platform_version.drive)?; - - Ok(()) - } -} diff --git a/packages/rs-drive/src/drive/protocol_upgrade/mod.rs b/packages/rs-drive/src/drive/protocol_upgrade/mod.rs index 75bc6ed984a..fb72dfa060d 100644 --- a/packages/rs-drive/src/drive/protocol_upgrade/mod.rs +++ b/packages/rs-drive/src/drive/protocol_upgrade/mod.rs @@ -5,8 +5,6 @@ use crate::drive::batch::GroveDbOpBatch; #[cfg(any(feature = "full", feature = "verify"))] use crate::drive::RootTree; -#[cfg(feature = "full")] -mod change_to_new_version_and_clear_version_information; #[cfg(feature = "full")] mod clear_version_information; #[cfg(feature = "full")] @@ -21,7 +19,6 @@ mod fetch_versions_with_counter; mod remove_validators_proposed_app_versions; #[cfg(feature = "full")] mod update_validator_proposed_app_version; - #[cfg(any(feature = "full", feature = "verify"))] /// constant id for various versions counter pub const VERSIONS_COUNTER: [u8; 1] = [0]; diff --git a/packages/rs-drive/src/drive/system/misc_tree_constants.rs b/packages/rs-drive/src/drive/system/misc_tree_constants.rs deleted file mode 100644 index 44a9fa2c23c..00000000000 --- a/packages/rs-drive/src/drive/system/misc_tree_constants.rs +++ /dev/null @@ -1,5 +0,0 @@ -/// Protocol Version Storage key -pub const PROTOCOL_VERSION_STORAGE_KEY: &[u8; 1] = b"v"; - -/// Next Epoch Protocol Version Storage key -pub const NEXT_PROTOCOL_VERSION_STORAGE_KEY: &[u8; 1] = b"n"; diff --git a/packages/rs-drive/src/drive/system/mod.rs b/packages/rs-drive/src/drive/system/mod.rs index 7eaf69a5623..7493702adf7 100644 --- a/packages/rs-drive/src/drive/system/mod.rs +++ b/packages/rs-drive/src/drive/system/mod.rs @@ -2,8 +2,6 @@ mod estimation_costs; /// Genesis time module #[cfg(feature = "full")] pub mod genesis_time; -/// Constants for the misc tree -pub mod misc_tree_constants; /// Protocol version module pub mod protocol_version; diff --git a/packages/rs-drive/src/drive/system/protocol_version/fetch_current_protocol_version.rs b/packages/rs-drive/src/drive/system/protocol_version/fetch_current_protocol_version.rs index fbd2e81b45a..5f971c7cdb2 100644 --- a/packages/rs-drive/src/drive/system/protocol_version/fetch_current_protocol_version.rs +++ b/packages/rs-drive/src/drive/system/protocol_version/fetch_current_protocol_version.rs @@ -2,15 +2,14 @@ use crate::drive::Drive; use crate::error::drive::DriveError; use crate::error::Error; -use crate::drive::system::misc_path; -use crate::drive::system::misc_tree_constants::PROTOCOL_VERSION_STORAGE_KEY; +use crate::drive::system::protocol_version::PROTOCOL_VERSION_AUX_KEY; use dpp::util::deserializer::ProtocolVersion; use grovedb::{GroveDb, TransactionArg}; use integer_encoding::VarInt; /// impl Drive { - /// Gets the current protocol version from the backing store + /// Gets the current protocol version from aux storage /// /// !!!DON'T CHANGE!!!! /// @@ -41,20 +40,15 @@ impl Drive { grove: &GroveDb, transaction: TransactionArg, ) -> Result, Error> { - let misc_path = misc_path(); grove - .get_raw_optional( - (&misc_path).into(), - PROTOCOL_VERSION_STORAGE_KEY, - transaction, - ) + .get_aux(PROTOCOL_VERSION_AUX_KEY, transaction) .unwrap() .map_err(Error::GroveDB) - .map(|maybe_element| { - maybe_element - .map(|e| { - let bytes = e.as_item_bytes()?; - let Some((protocol_version, _)) = ProtocolVersion::decode_var(bytes) else { + .map(|bytes| { + bytes + .map(|bytes| { + let Some((protocol_version, _)) = ProtocolVersion::decode_var(&bytes) + else { return Err(Error::Drive(DriveError::CorruptedSerialization( String::from("protocol version incorrectly serialized"), ))); diff --git a/packages/rs-drive/src/drive/system/protocol_version/fetch_next_protocol_version/mod.rs b/packages/rs-drive/src/drive/system/protocol_version/fetch_next_protocol_version/mod.rs deleted file mode 100644 index 854f35d2594..00000000000 --- a/packages/rs-drive/src/drive/system/protocol_version/fetch_next_protocol_version/mod.rs +++ /dev/null @@ -1,44 +0,0 @@ -mod v0; - -use crate::drive::Drive; -use crate::error::drive::DriveError; -use crate::error::Error; - -use dpp::util::deserializer::ProtocolVersion; -use dpp::version::drive_versions::DriveVersion; -use grovedb::TransactionArg; - -impl Drive { - /// Gets the next protocol version from the backing store - /// - /// # Arguments - /// - /// * `transaction` - A `TransactionArg` object representing the transaction. - /// - /// # Returns - /// - /// * `Result, Error>` - If successful, returns an `Ok(Option)`. If an error occurs during the operation, returns an `Error`. - /// - /// # Errors - /// - /// This function will return an error if the Drive version is unknown. - pub fn fetch_next_protocol_version( - &self, - transaction: TransactionArg, - drive_version: &DriveVersion, - ) -> Result, Error> { - match drive_version - .methods - .platform_system - .protocol_version - .fetch_next_protocol_version - { - 0 => self.fetch_next_protocol_version_v0(transaction), - version => Err(Error::Drive(DriveError::UnknownVersionMismatch { - method: "fetch_next_protocol_version".to_string(), - known_versions: vec![0], - received: version, - })), - } - } -} diff --git a/packages/rs-drive/src/drive/system/protocol_version/fetch_next_protocol_version/v0/mod.rs b/packages/rs-drive/src/drive/system/protocol_version/fetch_next_protocol_version/v0/mod.rs deleted file mode 100644 index dcca2a014f0..00000000000 --- a/packages/rs-drive/src/drive/system/protocol_version/fetch_next_protocol_version/v0/mod.rs +++ /dev/null @@ -1,42 +0,0 @@ -use crate::drive::system::misc_path; -use crate::drive::system::misc_tree_constants::NEXT_PROTOCOL_VERSION_STORAGE_KEY; -use crate::drive::Drive; -use crate::error::drive::DriveError; -use crate::error::Error; - -use dpp::util::deserializer::ProtocolVersion; - -use grovedb::TransactionArg; -use integer_encoding::VarInt; - -impl Drive { - /// Gets the next protocol version from the backing store - #[inline(always)] - pub(super) fn fetch_next_protocol_version_v0( - &self, - transaction: TransactionArg, - ) -> Result, Error> { - let misc_path = misc_path(); - self.grove - .get_raw_optional( - (&misc_path).into(), - NEXT_PROTOCOL_VERSION_STORAGE_KEY, - transaction, - ) - .unwrap() - .map_err(Error::GroveDB) - .map(|maybe_element| { - maybe_element - .map(|e| { - let bytes = e.as_item_bytes()?; - let Some((protocol_version, _)) = ProtocolVersion::decode_var(bytes) else { - return Err(Error::Drive(DriveError::CorruptedSerialization( - String::from("protocol version incorrectly serialized"), - ))); - }; - Ok(protocol_version) - }) - .transpose() - })? - } -} diff --git a/packages/rs-drive/src/drive/system/protocol_version/mod.rs b/packages/rs-drive/src/drive/system/protocol_version/mod.rs index 82b984d14bf..779deab3431 100644 --- a/packages/rs-drive/src/drive/system/protocol_version/mod.rs +++ b/packages/rs-drive/src/drive/system/protocol_version/mod.rs @@ -1,7 +1,6 @@ mod fetch_current_protocol_version; -mod fetch_next_protocol_version; - mod store_current_protocol_version; -mod set_next_protocol_version_operations; +/// Protocol Version Storage key +const PROTOCOL_VERSION_AUX_KEY: &[u8; 16] = b"protocol_version"; diff --git a/packages/rs-drive/src/drive/system/protocol_version/set_next_protocol_version_operations/mod.rs b/packages/rs-drive/src/drive/system/protocol_version/set_next_protocol_version_operations/mod.rs deleted file mode 100644 index b2c8cd31a97..00000000000 --- a/packages/rs-drive/src/drive/system/protocol_version/set_next_protocol_version_operations/mod.rs +++ /dev/null @@ -1,55 +0,0 @@ -mod v0; - -use crate::drive::Drive; -use crate::error::drive::DriveError; -use crate::error::Error; -use crate::fee::op::LowLevelDriveOperation; -use dpp::util::deserializer::ProtocolVersion; -use dpp::version::drive_versions::DriveVersion; -use grovedb::TransactionArg; - -impl Drive { - /// Sets the next protocol version - /// - /// # Arguments - /// - /// * `protocol_version` - A `ProtocolVersion` object representing the next protocol version. - /// * `transaction` - A `TransactionArg` object representing the transaction. - /// * `drive_operations` - A mutable reference to a vector of `LowLevelDriveOperation` objects. - /// * `drive_version` - A `DriveVersion` object representing the version of the Drive. - /// - /// # Returns - /// - /// * `Result<(), Error>` - If successful, returns an `Ok(())`. If an error occurs during the operation, returns an `Error`. - /// - /// # Errors - /// - /// This function will return an error if the version of the Drive is unknown. - // TODO: We should store it for epoch. Will be changed in upcoming PR - pub fn set_next_protocol_version_operations( - &self, - protocol_version: ProtocolVersion, - transaction: TransactionArg, - drive_operations: &mut Vec, - drive_version: &DriveVersion, - ) -> Result<(), Error> { - match drive_version - .methods - .platform_system - .protocol_version - .set_next_protocol_version_operations - { - 0 => self.set_next_protocol_version_operations_v0( - protocol_version, - transaction, - drive_operations, - drive_version, - ), - version => Err(Error::Drive(DriveError::UnknownVersionMismatch { - method: "set_next_protocol_version_operations".to_string(), - known_versions: vec![0], - received: version, - })), - } - } -} diff --git a/packages/rs-drive/src/drive/system/protocol_version/set_next_protocol_version_operations/v0/mod.rs b/packages/rs-drive/src/drive/system/protocol_version/set_next_protocol_version_operations/v0/mod.rs deleted file mode 100644 index 5bcd133eb59..00000000000 --- a/packages/rs-drive/src/drive/system/protocol_version/set_next_protocol_version_operations/v0/mod.rs +++ /dev/null @@ -1,36 +0,0 @@ -use crate::drive::grove_operations::BatchInsertApplyType; -use crate::drive::object_size_info::PathKeyElementInfo; -use crate::drive::system::misc_path; -use crate::drive::system::misc_tree_constants::NEXT_PROTOCOL_VERSION_STORAGE_KEY; -use crate::drive::Drive; -use crate::error::Error; -use crate::fee::op::LowLevelDriveOperation; -use dpp::util::deserializer::ProtocolVersion; -use dpp::version::drive_versions::DriveVersion; -use grovedb::{Element, TransactionArg}; -use integer_encoding::VarInt; - -impl Drive { - /// Sets the next protocol version - #[inline(always)] - pub(super) fn set_next_protocol_version_operations_v0( - &self, - protocol_version: ProtocolVersion, - transaction: TransactionArg, - drive_operations: &mut Vec, - drive_version: &DriveVersion, - ) -> Result<(), Error> { - self.batch_insert_if_changed_value( - PathKeyElementInfo::PathFixedSizeKeyRefElement(( - misc_path(), - NEXT_PROTOCOL_VERSION_STORAGE_KEY, - Element::new_item(protocol_version.encode_var_vec()), - )), - BatchInsertApplyType::StatefulBatchInsert, - transaction, - drive_operations, - drive_version, - )?; - Ok(()) - } -} diff --git a/packages/rs-drive/src/drive/system/protocol_version/store_current_protocol_version.rs b/packages/rs-drive/src/drive/system/protocol_version/store_current_protocol_version.rs index dd4b537a5a4..c63987cd9b0 100644 --- a/packages/rs-drive/src/drive/system/protocol_version/store_current_protocol_version.rs +++ b/packages/rs-drive/src/drive/system/protocol_version/store_current_protocol_version.rs @@ -1,16 +1,12 @@ -use crate::drive::object_size_info::PathKeyElementInfo; -use crate::drive::system::misc_path; -use crate::drive::system::misc_tree_constants::PROTOCOL_VERSION_STORAGE_KEY; +use crate::drive::system::protocol_version::PROTOCOL_VERSION_AUX_KEY; use crate::drive::Drive; use crate::error::Error; -use crate::fee::op::LowLevelDriveOperation; use dpp::util::deserializer::ProtocolVersion; -use dpp::version::drive_versions::DriveVersion; -use grovedb::{Element, TransactionArg}; +use grovedb::TransactionArg; use integer_encoding::VarInt; impl Drive { - /// Store the current protocol version in grovedb storage + /// Store the current protocol version in aux storage /// /// !!!DON'T CHANGE!!!! /// This function should never be changed !!! since it must always be compatible @@ -19,59 +15,15 @@ impl Drive { &self, protocol_version: ProtocolVersion, transaction: TransactionArg, - drive_version: &DriveVersion, ) -> Result<(), Error> { - let mut batch_operations = vec![]; - - self.set_current_protocol_version_operations( - protocol_version, - &mut batch_operations, - drive_version, - )?; - - self.apply_batch_low_level_drive_operations( - None, - transaction, - batch_operations, - &mut vec![], - drive_version, - ) - } - - /// Sets the current protocol version operations to batch - /// - /// !!!DON'T CHANGE!!!! - /// This function should never be changed !!! since it must always be compatible - /// with fetch_current_protocol_version which is should never be changed. - /// - /// # Arguments - /// - /// * `protocol_version` - A `ProtocolVersion` object representing the current protocol version. - /// * `transaction` - A `TransactionArg` object representing the transaction. - /// * `drive_operations` - A mutable reference to a vector of `LowLevelDriveOperation` objects. - /// * `drive_version` - A `DriveVersion` object representing the version of the Drive. - /// - /// # Returns - /// - /// * `Result<(), Error>` - If successful, returns an `Ok(())`. If an error occurs during the operation, returns an `Error`. - /// - /// # Errors - /// - /// This function will return an error if the version of the Drive is unknown. - pub fn set_current_protocol_version_operations( - &self, - protocol_version: ProtocolVersion, - drive_operations: &mut Vec, - drive_version: &DriveVersion, - ) -> Result<(), Error> { - self.batch_insert( - PathKeyElementInfo::PathFixedSizeKeyRefElement(( - misc_path(), - PROTOCOL_VERSION_STORAGE_KEY, - Element::new_item(protocol_version.encode_var_vec()), - )), - drive_operations, - drive_version, - ) + self.grove + .put_aux( + PROTOCOL_VERSION_AUX_KEY, + &protocol_version.encode_var_vec(), + None, + transaction, + ) + .unwrap() + .map_err(Error::GroveDB) } } diff --git a/packages/rs-platform-version/src/version/drive_versions.rs b/packages/rs-platform-version/src/version/drive_versions.rs index e523ebbe606..02a4f97da62 100644 --- a/packages/rs-platform-version/src/version/drive_versions.rs +++ b/packages/rs-platform-version/src/version/drive_versions.rs @@ -203,7 +203,6 @@ pub struct DriveContractCostsMethodVersions { #[derive(Clone, Debug, Default)] pub struct DrivePlatformSystemMethodVersions { - pub protocol_version: DriveSystemProtocolVersionMethodVersions, pub estimation_costs: DriveSystemEstimationCostsMethodVersions, } @@ -224,12 +223,6 @@ pub struct DriveBatchOperationsMethodVersion { pub apply_drive_operations: FeatureVersion, } -#[derive(Clone, Debug, Default)] -pub struct DriveSystemProtocolVersionMethodVersions { - pub fetch_next_protocol_version: FeatureVersion, - pub set_next_protocol_version_operations: FeatureVersion, -} - #[derive(Clone, Debug, Default)] pub struct DriveSystemEstimationCostsMethodVersions { pub for_total_system_credits_update: FeatureVersion, @@ -404,7 +397,6 @@ pub struct DriveCreditPoolStorageFeeDistributionPoolMethodVersions { #[derive(Clone, Debug, Default)] pub struct DriveProtocolUpgradeVersions { pub clear_version_information: FeatureVersion, - pub change_to_new_version_and_clear_version_information: FeatureVersion, pub fetch_versions_with_counter: FeatureVersion, pub fetch_proved_versions_with_counter: FeatureVersion, pub fetch_validator_version_votes: FeatureVersion, 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 80b4bd4c92a..1b02ccc4df3 100644 --- a/packages/rs-platform-version/src/version/mocks/v2_test.rs +++ b/packages/rs-platform-version/src/version/mocks/v2_test.rs @@ -61,10 +61,10 @@ use crate::version::drive_versions::{ DrivePlatformSystemMethodVersions, DriveProtocolUpgradeVersions, DriveProveMethodVersions, DriveStateTransitionMethodVersions, DriveStateTransitionOperationMethodVersions, DriveStructureVersion, DriveSystemEstimationCostsMethodVersions, - DriveSystemProtocolVersionMethodVersions, DriveVerifyContractMethodVersions, - DriveVerifyDocumentMethodVersions, DriveVerifyIdentityMethodVersions, - DriveVerifyMethodVersions, DriveVerifySingleDocumentMethodVersions, - DriveVerifyStateTransitionMethodVersions, DriveVerifySystemMethodVersions, DriveVersion, + DriveVerifyContractMethodVersions, DriveVerifyDocumentMethodVersions, + DriveVerifyIdentityMethodVersions, DriveVerifyMethodVersions, + DriveVerifySingleDocumentMethodVersions, DriveVerifyStateTransitionMethodVersions, + DriveVerifySystemMethodVersions, DriveVersion, }; use crate::version::mocks::TEST_BYTES; use crate::version::protocol_version::{FeatureVersionBounds, PlatformVersion}; @@ -140,7 +140,6 @@ pub(crate) const TEST_PLATFORM_V2: PlatformVersion = PlatformVersion { }, protocol_upgrade: DriveProtocolUpgradeVersions { clear_version_information: 0, - change_to_new_version_and_clear_version_information: 0, fetch_versions_with_counter: 0, fetch_proved_versions_with_counter: 0, fetch_validator_version_votes: 0, @@ -399,10 +398,6 @@ pub(crate) const TEST_PLATFORM_V2: PlatformVersion = PlatformVersion { }, }, platform_system: DrivePlatformSystemMethodVersions { - protocol_version: DriveSystemProtocolVersionMethodVersions { - fetch_next_protocol_version: 0, - set_next_protocol_version_operations: 0, - }, estimation_costs: DriveSystemEstimationCostsMethodVersions { for_total_system_credits_update: 0, }, 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 d16c4ac0c61..7b2fbdc770a 100644 --- a/packages/rs-platform-version/src/version/mocks/v3_test.rs +++ b/packages/rs-platform-version/src/version/mocks/v3_test.rs @@ -61,10 +61,10 @@ use crate::version::drive_versions::{ DrivePlatformSystemMethodVersions, DriveProtocolUpgradeVersions, DriveProveMethodVersions, DriveStateTransitionMethodVersions, DriveStateTransitionOperationMethodVersions, DriveStructureVersion, DriveSystemEstimationCostsMethodVersions, - DriveSystemProtocolVersionMethodVersions, DriveVerifyContractMethodVersions, - DriveVerifyDocumentMethodVersions, DriveVerifyIdentityMethodVersions, - DriveVerifyMethodVersions, DriveVerifySingleDocumentMethodVersions, - DriveVerifyStateTransitionMethodVersions, DriveVerifySystemMethodVersions, DriveVersion, + DriveVerifyContractMethodVersions, DriveVerifyDocumentMethodVersions, + DriveVerifyIdentityMethodVersions, DriveVerifyMethodVersions, + DriveVerifySingleDocumentMethodVersions, DriveVerifyStateTransitionMethodVersions, + DriveVerifySystemMethodVersions, DriveVersion, }; use crate::version::mocks::TEST_BYTES; use crate::version::protocol_version::{FeatureVersionBounds, PlatformVersion}; @@ -140,7 +140,6 @@ pub(crate) const TEST_PLATFORM_V3: PlatformVersion = PlatformVersion { }, protocol_upgrade: DriveProtocolUpgradeVersions { clear_version_information: 0, - change_to_new_version_and_clear_version_information: 0, fetch_versions_with_counter: 0, fetch_proved_versions_with_counter: 0, fetch_validator_version_votes: 0, @@ -407,10 +406,6 @@ pub(crate) const TEST_PLATFORM_V3: PlatformVersion = PlatformVersion { }, }, platform_system: DrivePlatformSystemMethodVersions { - protocol_version: DriveSystemProtocolVersionMethodVersions { - fetch_next_protocol_version: 0, - set_next_protocol_version_operations: 0, - }, estimation_costs: DriveSystemEstimationCostsMethodVersions { for_total_system_credits_update: 0, }, diff --git a/packages/rs-platform-version/src/version/v1.rs b/packages/rs-platform-version/src/version/v1.rs index a023fb262a7..78cca6e8fd3 100644 --- a/packages/rs-platform-version/src/version/v1.rs +++ b/packages/rs-platform-version/src/version/v1.rs @@ -61,10 +61,10 @@ use crate::version::drive_versions::{ DrivePlatformSystemMethodVersions, DriveProtocolUpgradeVersions, DriveProveMethodVersions, DriveStateTransitionMethodVersions, DriveStateTransitionOperationMethodVersions, DriveStructureVersion, DriveSystemEstimationCostsMethodVersions, - DriveSystemProtocolVersionMethodVersions, DriveVerifyContractMethodVersions, - DriveVerifyDocumentMethodVersions, DriveVerifyIdentityMethodVersions, - DriveVerifyMethodVersions, DriveVerifySingleDocumentMethodVersions, - DriveVerifyStateTransitionMethodVersions, DriveVerifySystemMethodVersions, DriveVersion, + DriveVerifyContractMethodVersions, DriveVerifyDocumentMethodVersions, + DriveVerifyIdentityMethodVersions, DriveVerifyMethodVersions, + DriveVerifySingleDocumentMethodVersions, DriveVerifyStateTransitionMethodVersions, + DriveVerifySystemMethodVersions, DriveVersion, }; use crate::version::protocol_version::{FeatureVersionBounds, PlatformVersion}; use crate::version::{AbciStructureVersion, PlatformArchitectureVersion}; @@ -137,7 +137,6 @@ pub(super) const PLATFORM_V1: PlatformVersion = PlatformVersion { }, protocol_upgrade: DriveProtocolUpgradeVersions { clear_version_information: 0, - change_to_new_version_and_clear_version_information: 0, fetch_versions_with_counter: 0, fetch_proved_versions_with_counter: 0, fetch_validator_version_votes: 0, @@ -396,10 +395,6 @@ pub(super) const PLATFORM_V1: PlatformVersion = PlatformVersion { }, }, platform_system: DrivePlatformSystemMethodVersions { - protocol_version: DriveSystemProtocolVersionMethodVersions { - fetch_next_protocol_version: 0, - set_next_protocol_version_operations: 0, - }, estimation_costs: DriveSystemEstimationCostsMethodVersions { for_total_system_credits_update: 0, }, From e58d2ab9a75753fa87eac7ee7a72224ebdb6eb4f Mon Sep 17 00:00:00 2001 From: Ivan Shumkov Date: Wed, 27 Mar 2024 01:56:40 +0700 Subject: [PATCH 16/37] style: unused import --- .../platform_events/block_end/update_state_cache/v0/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/rs-drive-abci/src/execution/platform_events/block_end/update_state_cache/v0/mod.rs b/packages/rs-drive-abci/src/execution/platform_events/block_end/update_state_cache/v0/mod.rs index e67e1ea3790..e9c15fe0e0a 100644 --- a/packages/rs-drive-abci/src/execution/platform_events/block_end/update_state_cache/v0/mod.rs +++ b/packages/rs-drive-abci/src/execution/platform_events/block_end/update_state_cache/v0/mod.rs @@ -4,7 +4,7 @@ use crate::platform_types::platform_state::v0::PlatformStateV0Methods; use crate::platform_types::platform_state::PlatformState; use crate::rpc::core::CoreRPCLike; use dpp::block::extended_block_info::ExtendedBlockInfo; -use dpp::version::{PlatformVersion, PlatformVersionCurrentVersion}; +use dpp::version::PlatformVersion; use drive::grovedb::Transaction; use std::sync::Arc; From 2ac3f8c49ac6e0ca6f9a8731ffd3f8b11d174b32 Mon Sep 17 00:00:00 2001 From: Ivan Shumkov Date: Wed, 27 Mar 2024 10:41:44 +0700 Subject: [PATCH 17/37] chore: use previous block hpmn count --- .../src/execution/engine/run_block_proposal/v0/mod.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/rs-drive-abci/src/execution/engine/run_block_proposal/v0/mod.rs b/packages/rs-drive-abci/src/execution/engine/run_block_proposal/v0/mod.rs index 2eb8a4e7f00..72deb6fb3e3 100644 --- a/packages/rs-drive-abci/src/execution/engine/run_block_proposal/v0/mod.rs +++ b/packages/rs-drive-abci/src/execution/engine/run_block_proposal/v0/mod.rs @@ -316,7 +316,9 @@ where block_execution_context::v0::BlockExecutionContextV0 { block_state_info: block_state_info.into(), epoch_info: epoch_info.clone(), - hpmn_count: block_platform_state.hpmn_list_len() as u32, + // TODO: It doesn't seem correct to use previous block count of hpmns. + // We currently not using this field in the codebase. We probably should just remove it. + hpmn_count: last_committed_platform_state.hpmn_list_len() as u32, unsigned_withdrawal_transactions: unsigned_withdrawal_transaction_bytes, block_platform_state, proposer_results: None, From edff6cbe8a00940397efd491fa950ef1ef204c02 Mon Sep 17 00:00:00 2001 From: Ivan Shumkov Date: Wed, 27 Mar 2024 22:10:07 +0700 Subject: [PATCH 18/37] fix: missing a version proposal on epoch change --- .../engine/finalize_block_proposal/v0/mod.rs | 4 +- .../engine/run_block_proposal/v0/mod.rs | 98 +++++++++++++------ .../block_end/update_drive_cache/mod.rs | 9 +- .../block_end/update_drive_cache/v0/mod.rs | 16 +-- .../upgrade_protocol_version/mod.rs | 4 +- .../upgrade_protocol_version/v0/mod.rs | 69 +++---------- .../tests/strategy_tests/main.rs | 6 +- .../strategy_tests/upgrade_fork_tests.rs | 8 +- .../src/drive/cache/protocol_version.rs | 1 - 9 files changed, 99 insertions(+), 116 deletions(-) diff --git a/packages/rs-drive-abci/src/execution/engine/finalize_block_proposal/v0/mod.rs b/packages/rs-drive-abci/src/execution/engine/finalize_block_proposal/v0/mod.rs index 3eccc5a02da..58e65081d39 100644 --- a/packages/rs-drive-abci/src/execution/engine/finalize_block_proposal/v0/mod.rs +++ b/packages/rs-drive-abci/src/execution/engine/finalize_block_proposal/v0/mod.rs @@ -239,8 +239,6 @@ where } .into(); - self.update_drive_cache(&block_execution_context, platform_version)?; - let block_platform_state = block_execution_context.block_platform_state_owned(); self.update_state_cache( @@ -250,6 +248,8 @@ where platform_version, )?; + self.update_drive_cache(platform_version)?; + // Gather some metrics crate::metrics::abci_last_block_time(block_header.time.seconds as u64); crate::metrics::abci_last_platform_height(height); diff --git a/packages/rs-drive-abci/src/execution/engine/run_block_proposal/v0/mod.rs b/packages/rs-drive-abci/src/execution/engine/run_block_proposal/v0/mod.rs index 72deb6fb3e3..7245b7c2740 100644 --- a/packages/rs-drive-abci/src/execution/engine/run_block_proposal/v0/mod.rs +++ b/packages/rs-drive-abci/src/execution/engine/run_block_proposal/v0/mod.rs @@ -68,6 +68,15 @@ where platform_version: &PlatformVersion, ) -> Result, Error> { + tracing::trace!( + method = "run_block_proposal_v0", + ?block_proposal, + ?epoch_info, + "Running a block proposal for height: {}, round: {}", + block_proposal.height, + block_proposal.round, + ); + // Run block proposal determines version by itself based on the previous // state and block time. // It should provide correct version on prepare proposal to block header @@ -86,26 +95,6 @@ where )); } - tracing::trace!( - method = "run_block_proposal_v0", - ?block_proposal, - ?epoch_info, - "Running a block proposal for height: {}, round: {}", - block_proposal.height, - block_proposal.round, - ); - - if epoch_info.is_epoch_change_but_not_genesis() { - tracing::info!( - epoch_index = epoch_info.current_epoch_index(), - "epoch change occurring from epoch {} to epoch {}", - epoch_info - .previous_epoch_index() - .expect("must be set since we aren't on genesis"), - epoch_info.current_epoch_index(), - ); - } - let last_block_time_ms = last_committed_platform_state.last_committed_block_time_ms(); let last_block_height = last_committed_platform_state.last_committed_known_block_height_or( self.config.abci.genesis_height.saturating_sub(1), @@ -134,6 +123,64 @@ where // Cleanup block cache before we execute a new proposal self.clear_drive_block_cache(platform_version)?; + // Update protocol version for this block + let previous_block_protocol_version = last_committed_platform_state + .current_platform_version()? + .protocol_version; + let current_block_protocol_version = platform_version.protocol_version; + + block_platform_state + .set_current_protocol_version_in_consensus(current_block_protocol_version); + + // Protocol version can be changed only on epoch change + if epoch_info.is_epoch_change_but_not_genesis() { + tracing::info!( + epoch_index = epoch_info.current_epoch_index(), + "epoch change occurring from epoch {} to epoch {}", + epoch_info + .previous_epoch_index() + .expect("must be set since we aren't on genesis"), + epoch_info.current_epoch_index(), + ); + + if current_block_protocol_version == previous_block_protocol_version { + tracing::info!( + epoch_index = epoch_info.current_epoch_index(), + "protocol version remains the same {}", + current_block_protocol_version, + ); + } else { + tracing::info!( + epoch_index = epoch_info.current_epoch_index(), + "protocol version changed from {} to {}", + previous_block_protocol_version, + current_block_protocol_version, + ); + + // TODO: This will be removed in #1778 + self.drive.store_current_protocol_version( + current_block_protocol_version, + Some(transaction), + &platform_version.drive, + )?; + }; + + // Update block platform state with current and next epoch protocol versions + // if it was proposed + // This should happen only on epoch change + self.upgrade_protocol_version( + last_committed_platform_state, + &mut block_platform_state, + transaction, + platform_version, + )?; + } else if current_block_protocol_version != previous_block_protocol_version { + // It might happen only in case of error in the code. + return Err(Error::Execution( + ExecutionError::UnexpectedProtocolVersionUpgrade, + )); + } + // destructure the block proposal let block_proposal::v0::BlockProposal { core_chain_locked_height, @@ -246,6 +293,7 @@ where )?; // Update the validator proposed app version + // It should be called after protocol version upgrade self.drive .update_validator_proposed_app_version( proposer_pro_tx_hash, @@ -257,16 +305,6 @@ where Error::Execution(ExecutionError::UpdateValidatorProposedAppVersionError(e)) })?; // This is a system error - // Update block platform state with current and next epoch protocol versions - // if it was proposed - self.upgrade_protocol_version( - &epoch_info, - last_committed_platform_state, - &mut block_platform_state, - transaction, - platform_version, - )?; - // Mark all previously broadcasted and chainlocked withdrawals as complete // only when we are on a new core height if block_state_info.core_chain_locked_height() != last_block_core_height { diff --git a/packages/rs-drive-abci/src/execution/platform_events/block_end/update_drive_cache/mod.rs b/packages/rs-drive-abci/src/execution/platform_events/block_end/update_drive_cache/mod.rs index 0342fe45594..cc0692e8f3a 100644 --- a/packages/rs-drive-abci/src/execution/platform_events/block_end/update_drive_cache/mod.rs +++ b/packages/rs-drive-abci/src/execution/platform_events/block_end/update_drive_cache/mod.rs @@ -7,7 +7,6 @@ use crate::platform_types::platform::Platform; use crate::rpc::core::CoreRPCLike; -use crate::execution::types::block_execution_context::BlockExecutionContext; use dpp::version::PlatformVersion; impl Platform @@ -30,11 +29,7 @@ where /// * `Result<(), Error>` - If the state cache and quorums are successfully updated, it returns `Ok(())`. /// If there is a problem with the update, it returns an `Error`. /// - pub fn update_drive_cache( - &self, - block_execution_context: &BlockExecutionContext, - platform_version: &PlatformVersion, - ) -> Result<(), Error> { + pub fn update_drive_cache(&self, platform_version: &PlatformVersion) -> Result<(), Error> { match platform_version .drive_abci .methods @@ -42,7 +37,7 @@ where .update_drive_cache { 0 => { - self.update_drive_cache_v0(block_execution_context); + self.update_drive_cache_v0(); Ok(()) } version => Err(Error::Execution(ExecutionError::UnknownVersionMismatch { diff --git a/packages/rs-drive-abci/src/execution/platform_events/block_end/update_drive_cache/v0/mod.rs b/packages/rs-drive-abci/src/execution/platform_events/block_end/update_drive_cache/v0/mod.rs index 7c3fe0010cf..386a335268c 100644 --- a/packages/rs-drive-abci/src/execution/platform_events/block_end/update_drive_cache/v0/mod.rs +++ b/packages/rs-drive-abci/src/execution/platform_events/block_end/update_drive_cache/v0/mod.rs @@ -1,6 +1,3 @@ -use crate::execution::types::block_execution_context::v0::BlockExecutionContextV0Getters; -use crate::execution::types::block_execution_context::BlockExecutionContext; -use crate::platform_types::epoch_info::v0::EpochInfoV0Methods; use crate::platform_types::platform::Platform; use crate::rpc::core::CoreRPCLike; @@ -12,7 +9,7 @@ where /// the data contract cache and the platform versions cache. /// #[inline(always)] - pub(super) fn update_drive_cache_v0(&self, block_execution_context: &BlockExecutionContext) { + pub(super) fn update_drive_cache_v0(&self) { // Update global cache with updated contracts self.drive .cache @@ -21,15 +18,6 @@ where let mut protocol_versions_counter = self.drive.cache.protocol_versions_counter.write(); - if block_execution_context - .epoch_info() - .is_epoch_change_but_not_genesis() - { - // Clear previously proposed versions since we started a new epoch - protocol_versions_counter.clear(); - } else { - // Update proposed versions with new proposal from the current block - protocol_versions_counter.merge_block_cache() - } + protocol_versions_counter.merge_block_cache() } } diff --git a/packages/rs-drive-abci/src/execution/platform_events/protocol_upgrade/upgrade_protocol_version/mod.rs b/packages/rs-drive-abci/src/execution/platform_events/protocol_upgrade/upgrade_protocol_version/mod.rs index 18f40174194..7b8b1dbf152 100644 --- a/packages/rs-drive-abci/src/execution/platform_events/protocol_upgrade/upgrade_protocol_version/mod.rs +++ b/packages/rs-drive-abci/src/execution/platform_events/protocol_upgrade/upgrade_protocol_version/mod.rs @@ -11,6 +11,8 @@ use drive::grovedb::Transaction; impl Platform { /// Sets current protocol version and next epoch protocol version to block platform state /// + /// This function should be called on very top of bock production before we add new proposed version for the next epoch + /// /// It takes five parameters: /// * `epoch_info`: Information about the current epoch. /// * `last_committed_platform_state`: The last committed state of the platform. @@ -23,7 +25,6 @@ impl Platform { /// This function will return an error if the previous block protocol version does not match the current block protocol version not on epoch change pub fn upgrade_protocol_version( &self, - epoch_info: &EpochInfo, last_committed_platform_state: &PlatformState, block_platform_state: &mut PlatformState, transaction: &Transaction, @@ -36,7 +37,6 @@ impl Platform { .upgrade_protocol_version { 0 => self.upgrade_protocol_version_v0( - epoch_info, last_committed_platform_state, block_platform_state, transaction, diff --git a/packages/rs-drive-abci/src/execution/platform_events/protocol_upgrade/upgrade_protocol_version/v0/mod.rs b/packages/rs-drive-abci/src/execution/platform_events/protocol_upgrade/upgrade_protocol_version/v0/mod.rs index 04e534c00c1..f1bbc576622 100644 --- a/packages/rs-drive-abci/src/execution/platform_events/protocol_upgrade/upgrade_protocol_version/v0/mod.rs +++ b/packages/rs-drive-abci/src/execution/platform_events/protocol_upgrade/upgrade_protocol_version/v0/mod.rs @@ -1,7 +1,4 @@ -use crate::error::execution::ExecutionError; use crate::error::Error; -use crate::platform_types::epoch_info::v0::{EpochInfoV0Getters, EpochInfoV0Methods}; -use crate::platform_types::epoch_info::EpochInfo; use crate::platform_types::platform::Platform; use crate::platform_types::platform_state::v0::PlatformStateV0Methods; use crate::platform_types::platform_state::PlatformState; @@ -23,67 +20,33 @@ impl Platform { /// This function will return an error if the previous block protocol version does not match the current block protocol version not on epoch change pub(super) fn upgrade_protocol_version_v0( &self, - epoch_info: &EpochInfo, last_committed_platform_state: &PlatformState, block_platform_state: &mut PlatformState, transaction: &Transaction, platform_version: &PlatformVersion, ) -> Result<(), Error> { - let current_block_protocol_version = platform_version.protocol_version; - let previous_block_protocol_version = - last_committed_platform_state.current_protocol_version_in_consensus(); + // Determine a new protocol version for the next epoch if enough proposers voted + // otherwise keep the current one - // Set current protocol version - block_platform_state - .set_current_protocol_version_in_consensus(current_block_protocol_version); + let hpmn_list_len = last_committed_platform_state.hpmn_list_len() as u32; - // Protocol version upgrade should happen only on epoch change - if epoch_info.is_epoch_change_but_not_genesis() { - if current_block_protocol_version == previous_block_protocol_version { - tracing::info!( - epoch_index = epoch_info.current_epoch_index(), - "protocol version remains the same {}", - current_block_protocol_version, - ); - } else { - tracing::info!( - epoch_index = epoch_info.current_epoch_index(), - "protocol version changed from {} to {}", - previous_block_protocol_version, - current_block_protocol_version, - ); + let next_epoch_protocol_version = + self.check_for_desired_protocol_upgrade(hpmn_list_len, platform_version)?; - // We need to persist new protocol version - // TODO: Must be a part of epoch trees. The matter of the next PR - self.drive.store_current_protocol_version( - current_block_protocol_version, - Some(transaction), - &platform_version.drive, - )?; - }; - - // Determine a new protocol version for the next epoch if enough proposers voted - // otherwise keep the current one - - let hpmn_list_len = last_committed_platform_state.hpmn_list_len() as u32; + if let Some(protocol_version) = next_epoch_protocol_version { + block_platform_state.set_next_epoch_protocol_version(protocol_version); + } - let next_epoch_protocol_version = - self.check_for_desired_protocol_upgrade(hpmn_list_len, platform_version)?; + // Since we are starting a new epoch we need to drop previously + // proposed versions - if let Some(protocol_version) = next_epoch_protocol_version { - block_platform_state.set_next_epoch_protocol_version(protocol_version); - } + let mut protocol_versions_counter = self.drive.cache.protocol_versions_counter.write(); + protocol_versions_counter.clear(); + drop(protocol_versions_counter); - // Since we are starting a new epoch we need to drop previously - // proposed versions - self.drive - .clear_version_information(Some(transaction), &platform_version.drive) - .map_err(Error::Drive)?; - } else if previous_block_protocol_version != current_block_protocol_version { - return Err(Error::Execution( - ExecutionError::UnexpectedProtocolVersionUpgrade, - )); - } + self.drive + .clear_version_information(Some(transaction), &platform_version.drive) + .map_err(Error::Drive)?; Ok(()) } diff --git a/packages/rs-drive-abci/tests/strategy_tests/main.rs b/packages/rs-drive-abci/tests/strategy_tests/main.rs index 973770313a7..e29d299f8df 100644 --- a/packages/rs-drive-abci/tests/strategy_tests/main.rs +++ b/packages/rs-drive-abci/tests/strategy_tests/main.rs @@ -1144,7 +1144,7 @@ mod tests { .unwrap() .unwrap() ), - "8e1e8d1ae51b3fc8a9e4acd0d312c9494943f2b7a5b957cc1379ab246ebd678d".to_string() + "aae3eb47619991d0260a5e168bafe28747c6262628bdf7599649bdacf76bc220".to_string() ) } @@ -1833,7 +1833,7 @@ mod tests { .unwrap() .unwrap() ), - "665ec5018021b0a14a25b7ac6de780edc943a73adb3dc7e2eb623959a08056c3".to_string() + "e8fe6756fe10972fa1f89f84d1e79f71dc20eeae5fbb48dba20cbba53a1663b5".to_string() ) } @@ -1958,7 +1958,7 @@ mod tests { .unwrap() .unwrap() ), - "3f1cfdfd2e1019e941434cc841282fbc156ee19062569e393a51af621447c7a7".to_string() + "909f68b8b480c573e8716ba2165fcaa9082551c0cc6620a1f369df35243788bd".to_string() ) } diff --git a/packages/rs-drive-abci/tests/strategy_tests/upgrade_fork_tests.rs b/packages/rs-drive-abci/tests/strategy_tests/upgrade_fork_tests.rs index 748b8597fea..6511c2dbcca 100644 --- a/packages/rs-drive-abci/tests/strategy_tests/upgrade_fork_tests.rs +++ b/packages/rs-drive-abci/tests/strategy_tests/upgrade_fork_tests.rs @@ -249,7 +249,7 @@ mod tests { ); assert_eq!(state.next_epoch_protocol_version(), TEST_PROTOCOL_VERSION_2); assert_eq!(counter.get(&1), None); //no one has proposed 1 yet - assert_eq!(counter.get(&TEST_PROTOCOL_VERSION_2), Some(&122)); + assert_eq!(counter.get(&TEST_PROTOCOL_VERSION_2), Some(&123)); } }) .expect("Failed to create thread with custom stack size"); @@ -398,7 +398,7 @@ mod tests { ChainExecutionParameters { block_start, core_height_start: 1, - block_count: 2, + block_count: 1, proposers, quorums, current_quorum_hash, @@ -877,7 +877,7 @@ mod tests { assert_eq!(state.next_epoch_protocol_version(), TEST_PROTOCOL_VERSION_2); assert_eq!( (counter.get(&1), counter.get(&TEST_PROTOCOL_VERSION_2)), - (Some(&18), Some(&111)) + (Some(&18), Some(&112)) ); //not all nodes have upgraded } @@ -1010,7 +1010,7 @@ mod tests { let counter = &platform.drive.cache.protocol_versions_counter.read(); assert_eq!( (counter.get(&1), counter.get(&TEST_PROTOCOL_VERSION_2)), - (Some(&23), Some(&2)) + (Some(&24), Some(&2)) ); assert_eq!( state diff --git a/packages/rs-drive/src/drive/cache/protocol_version.rs b/packages/rs-drive/src/drive/cache/protocol_version.rs index 291c942669f..fa7ecbb70bb 100644 --- a/packages/rs-drive/src/drive/cache/protocol_version.rs +++ b/packages/rs-drive/src/drive/cache/protocol_version.rs @@ -60,7 +60,6 @@ impl ProtocolVersionsCache { /// Clears the cache pub fn clear(&mut self) { - self.loaded = false; self.global_cache.clear(); self.block_cache.clear(); } From 1343d991b536d1e2e3c1a200153d5302c845559a Mon Sep 17 00:00:00 2001 From: Ivan Shumkov Date: Wed, 27 Mar 2024 23:16:52 +0700 Subject: [PATCH 19/37] style: unused imports --- .../protocol_upgrade/check_for_desired_protocol_upgrade/mod.rs | 1 - .../protocol_upgrade/upgrade_protocol_version/mod.rs | 1 - 2 files changed, 2 deletions(-) diff --git a/packages/rs-drive-abci/src/execution/platform_events/protocol_upgrade/check_for_desired_protocol_upgrade/mod.rs b/packages/rs-drive-abci/src/execution/platform_events/protocol_upgrade/check_for_desired_protocol_upgrade/mod.rs index 86d518326a4..c6128d16e28 100644 --- a/packages/rs-drive-abci/src/execution/platform_events/protocol_upgrade/check_for_desired_protocol_upgrade/mod.rs +++ b/packages/rs-drive-abci/src/execution/platform_events/protocol_upgrade/check_for_desired_protocol_upgrade/mod.rs @@ -3,7 +3,6 @@ use crate::error::Error; use crate::platform_types::platform::Platform; use dpp::util::deserializer::ProtocolVersion; use dpp::version::PlatformVersion; -use drive::grovedb::Transaction; mod v0; diff --git a/packages/rs-drive-abci/src/execution/platform_events/protocol_upgrade/upgrade_protocol_version/mod.rs b/packages/rs-drive-abci/src/execution/platform_events/protocol_upgrade/upgrade_protocol_version/mod.rs index 7b8b1dbf152..f7cdaa9217e 100644 --- a/packages/rs-drive-abci/src/execution/platform_events/protocol_upgrade/upgrade_protocol_version/mod.rs +++ b/packages/rs-drive-abci/src/execution/platform_events/protocol_upgrade/upgrade_protocol_version/mod.rs @@ -2,7 +2,6 @@ mod v0; use crate::error::execution::ExecutionError; use crate::error::Error; -use crate::platform_types::epoch_info::EpochInfo; use crate::platform_types::platform::Platform; use crate::platform_types::platform_state::PlatformState; use dpp::version::PlatformVersion; From a3d57e6ef5a23acfac2317b6667be3e35effa8c0 Mon Sep 17 00:00:00 2001 From: Ivan Shumkov Date: Thu, 28 Mar 2024 11:33:52 +0700 Subject: [PATCH 20/37] fix: votes are missing for next round and others --- .../engine/finalize_block_proposal/v0/mod.rs | 4 +-- .../engine/run_block_proposal/v0/mod.rs | 7 ----- .../block_end/update_drive_cache/mod.rs | 9 ++++-- .../block_end/update_drive_cache/v0/mod.rs | 16 +++++++++- .../clear_drive_block_cache/v0/mod.rs | 5 +++- .../upgrade_protocol_version/v0/mod.rs | 27 ++++++++++++++--- .../src/drive/cache/protocol_version.rs | 30 +++++++++++++++++-- .../v0/mod.rs | 13 ++++---- .../v0/mod.rs | 18 ++++++----- 9 files changed, 96 insertions(+), 33 deletions(-) diff --git a/packages/rs-drive-abci/src/execution/engine/finalize_block_proposal/v0/mod.rs b/packages/rs-drive-abci/src/execution/engine/finalize_block_proposal/v0/mod.rs index 58e65081d39..3eccc5a02da 100644 --- a/packages/rs-drive-abci/src/execution/engine/finalize_block_proposal/v0/mod.rs +++ b/packages/rs-drive-abci/src/execution/engine/finalize_block_proposal/v0/mod.rs @@ -239,6 +239,8 @@ where } .into(); + self.update_drive_cache(&block_execution_context, platform_version)?; + let block_platform_state = block_execution_context.block_platform_state_owned(); self.update_state_cache( @@ -248,8 +250,6 @@ where platform_version, )?; - self.update_drive_cache(platform_version)?; - // Gather some metrics crate::metrics::abci_last_block_time(block_header.time.seconds as u64); crate::metrics::abci_last_platform_height(height); diff --git a/packages/rs-drive-abci/src/execution/engine/run_block_proposal/v0/mod.rs b/packages/rs-drive-abci/src/execution/engine/run_block_proposal/v0/mod.rs index 7245b7c2740..b7e76493c6c 100644 --- a/packages/rs-drive-abci/src/execution/engine/run_block_proposal/v0/mod.rs +++ b/packages/rs-drive-abci/src/execution/engine/run_block_proposal/v0/mod.rs @@ -156,13 +156,6 @@ where previous_block_protocol_version, current_block_protocol_version, ); - - // TODO: This will be removed in #1778 - self.drive.store_current_protocol_version( - current_block_protocol_version, - Some(transaction), - &platform_version.drive, - )?; }; // Update block platform state with current and next epoch protocol versions diff --git a/packages/rs-drive-abci/src/execution/platform_events/block_end/update_drive_cache/mod.rs b/packages/rs-drive-abci/src/execution/platform_events/block_end/update_drive_cache/mod.rs index cc0692e8f3a..0342fe45594 100644 --- a/packages/rs-drive-abci/src/execution/platform_events/block_end/update_drive_cache/mod.rs +++ b/packages/rs-drive-abci/src/execution/platform_events/block_end/update_drive_cache/mod.rs @@ -7,6 +7,7 @@ use crate::platform_types::platform::Platform; use crate::rpc::core::CoreRPCLike; +use crate::execution::types::block_execution_context::BlockExecutionContext; use dpp::version::PlatformVersion; impl Platform @@ -29,7 +30,11 @@ where /// * `Result<(), Error>` - If the state cache and quorums are successfully updated, it returns `Ok(())`. /// If there is a problem with the update, it returns an `Error`. /// - pub fn update_drive_cache(&self, platform_version: &PlatformVersion) -> Result<(), Error> { + pub fn update_drive_cache( + &self, + block_execution_context: &BlockExecutionContext, + platform_version: &PlatformVersion, + ) -> Result<(), Error> { match platform_version .drive_abci .methods @@ -37,7 +42,7 @@ where .update_drive_cache { 0 => { - self.update_drive_cache_v0(); + self.update_drive_cache_v0(block_execution_context); Ok(()) } version => Err(Error::Execution(ExecutionError::UnknownVersionMismatch { diff --git a/packages/rs-drive-abci/src/execution/platform_events/block_end/update_drive_cache/v0/mod.rs b/packages/rs-drive-abci/src/execution/platform_events/block_end/update_drive_cache/v0/mod.rs index 386a335268c..7d7903c90e5 100644 --- a/packages/rs-drive-abci/src/execution/platform_events/block_end/update_drive_cache/v0/mod.rs +++ b/packages/rs-drive-abci/src/execution/platform_events/block_end/update_drive_cache/v0/mod.rs @@ -1,3 +1,6 @@ +use crate::execution::types::block_execution_context::v0::BlockExecutionContextV0Getters; +use crate::execution::types::block_execution_context::BlockExecutionContext; +use crate::platform_types::epoch_info::v0::EpochInfoV0Methods; use crate::platform_types::platform::Platform; use crate::rpc::core::CoreRPCLike; @@ -9,7 +12,7 @@ where /// the data contract cache and the platform versions cache. /// #[inline(always)] - pub(super) fn update_drive_cache_v0(&self) { + pub(super) fn update_drive_cache_v0(&self, block_execution_context: &BlockExecutionContext) { // Update global cache with updated contracts self.drive .cache @@ -18,6 +21,17 @@ where let mut protocol_versions_counter = self.drive.cache.protocol_versions_counter.write(); + // Clear previously proposed versions since we started a new epoch + // For more information read comments in `upgrade_protocol_version_v0` function + if block_execution_context + .epoch_info() + .is_epoch_change_but_not_genesis() + { + protocol_versions_counter.clear_global_cache(); + protocol_versions_counter.enabled_getter(); + } + + // Update proposed versions with new proposal from the current block protocol_versions_counter.merge_block_cache() } } diff --git a/packages/rs-drive-abci/src/execution/platform_events/block_start/clear_drive_block_cache/v0/mod.rs b/packages/rs-drive-abci/src/execution/platform_events/block_start/clear_drive_block_cache/v0/mod.rs index 3f64aec8b92..2c83689583e 100644 --- a/packages/rs-drive-abci/src/execution/platform_events/block_start/clear_drive_block_cache/v0/mod.rs +++ b/packages/rs-drive-abci/src/execution/platform_events/block_start/clear_drive_block_cache/v0/mod.rs @@ -14,6 +14,9 @@ where let mut protocol_versions_counter = self.drive.cache.protocol_versions_counter.write(); - protocol_versions_counter.clear_block_cache() + protocol_versions_counter.clear_block_cache(); + // Getter is disabled in case of epoch change so we need to enable it back + // For more information read comments in `upgrade_protocol_version_v0` function + protocol_versions_counter.enabled_getter(); } } diff --git a/packages/rs-drive-abci/src/execution/platform_events/protocol_upgrade/upgrade_protocol_version/v0/mod.rs b/packages/rs-drive-abci/src/execution/platform_events/protocol_upgrade/upgrade_protocol_version/v0/mod.rs index f1bbc576622..350a02eca7f 100644 --- a/packages/rs-drive-abci/src/execution/platform_events/protocol_upgrade/upgrade_protocol_version/v0/mod.rs +++ b/packages/rs-drive-abci/src/execution/platform_events/protocol_upgrade/upgrade_protocol_version/v0/mod.rs @@ -25,6 +25,14 @@ impl Platform { transaction: &Transaction, platform_version: &PlatformVersion, ) -> Result<(), Error> { + // Store current protocol version in drive state + // TODO: This will be removed in #1778 + self.drive.store_current_protocol_version( + platform_version.protocol_version, + Some(transaction), + &platform_version.drive, + )?; + // Determine a new protocol version for the next epoch if enough proposers voted // otherwise keep the current one @@ -40,14 +48,25 @@ impl Platform { // Since we are starting a new epoch we need to drop previously // proposed versions - let mut protocol_versions_counter = self.drive.cache.protocol_versions_counter.write(); - protocol_versions_counter.clear(); - drop(protocol_versions_counter); - + // Remove previously proposed versions from Drive state self.drive .clear_version_information(Some(transaction), &platform_version.drive) .map_err(Error::Drive)?; + // We clean voting counter cache only on finalize block because: + // 1. The voting counter global cache uses for querying of voting information in Drive queries + // 2. There might be multiple rounds so on the next round we will lose all previous epoch votes + // + // Instead of clearing cache, the further block processing logic is using `get_if_enabled` + // to get a version counter from the global cache. We disable this getter here to prevent + // reading previous voting information for the new epoch. + // The getter must be enabled back on finalize block in [update_drive_cache] and at the very beginning + // of the block processing in [clear_drive_block_cache]. + + let mut protocol_versions_counter = self.drive.cache.protocol_versions_counter.write(); + protocol_versions_counter.disable_getter(); + drop(protocol_versions_counter); + Ok(()) } } diff --git a/packages/rs-drive/src/drive/cache/protocol_version.rs b/packages/rs-drive/src/drive/cache/protocol_version.rs index fa7ecbb70bb..f87dc8ece2d 100644 --- a/packages/rs-drive/src/drive/cache/protocol_version.rs +++ b/packages/rs-drive/src/drive/cache/protocol_version.rs @@ -14,6 +14,7 @@ pub struct ProtocolVersionsCache { pub global_cache: IntMap, block_cache: IntMap, loaded: bool, + is_getter_disabled: bool, } #[cfg(feature = "full")] @@ -53,15 +54,38 @@ impl ProtocolVersionsCache { } } + /// Disable the getter + /// If disabled, then `get_if_enabled` will return None + pub fn disable_getter(&mut self) { + self.is_getter_disabled = true; + } + + /// Enable the getter + /// If disabled, then [get_if_enabled] will return None + /// This function enable the normal behaviour of the [get] function + pub fn enabled_getter(&mut self) { + self.is_getter_disabled = false; + } + + /// Calls the [get] function if enabled + /// or return `None` if disabled + /// See [disable_getter] and [enabled_getter] + pub fn get_if_enabled(&self, version: &ProtocolVersion) -> Option<&u64> { + if self.is_getter_disabled { + None + } else { + self.get(version) + } + } + /// Merge block cache to global cache pub fn merge_block_cache(&mut self) { self.global_cache.extend(self.block_cache.drain()); } - /// Clears the cache - pub fn clear(&mut self) { + /// Clears the global cache + pub fn clear_global_cache(&mut self) { self.global_cache.clear(); - self.block_cache.clear(); } /// Clear block cache diff --git a/packages/rs-drive/src/drive/protocol_upgrade/remove_validators_proposed_app_versions/v0/mod.rs b/packages/rs-drive/src/drive/protocol_upgrade/remove_validators_proposed_app_versions/v0/mod.rs index 35fc19539e3..2910fdfc920 100644 --- a/packages/rs-drive/src/drive/protocol_upgrade/remove_validators_proposed_app_versions/v0/mod.rs +++ b/packages/rs-drive/src/drive/protocol_upgrade/remove_validators_proposed_app_versions/v0/mod.rs @@ -146,12 +146,13 @@ impl Drive { } for (previous_version, change) in previous_versions_removals { - let previous_count = *version_counter.get(&previous_version).ok_or(Error::Drive( - DriveError::CorruptedCacheState( - "trying to lower the count of a version from cache that is not found" - .to_string(), - ), - ))?; + let previous_count = + *version_counter + .get_if_enabled(&previous_version) + .ok_or(Error::Drive(DriveError::CorruptedCacheState( + "trying to lower the count of a version from cache that is not found" + .to_string(), + )))?; let removed_count = previous_count.checked_sub(change).ok_or(Error::Drive(DriveError::CorruptedDriveState( "trying to lower the count of a version from cache that would result in a negative value" .to_string(), diff --git a/packages/rs-drive/src/drive/protocol_upgrade/update_validator_proposed_app_version/v0/mod.rs b/packages/rs-drive/src/drive/protocol_upgrade/update_validator_proposed_app_version/v0/mod.rs index bd473f6f91f..f3a3a67610a 100644 --- a/packages/rs-drive/src/drive/protocol_upgrade/update_validator_proposed_app_version/v0/mod.rs +++ b/packages/rs-drive/src/drive/protocol_upgrade/update_validator_proposed_app_version/v0/mod.rs @@ -90,12 +90,13 @@ impl Drive { ))) .map(|(value, _)| value)?; //we should remove 1 from the previous version - let previous_count = version_counter.get(&previous_version).ok_or(Error::Drive( - DriveError::CorruptedCacheState( - "trying to lower the count of a version from cache that is not found" - .to_string(), - ), - ))?; + let previous_count = + version_counter + .get_if_enabled(&previous_version) + .ok_or(Error::Drive(DriveError::CorruptedCacheState( + "trying to lower the count of a version from cache that is not found" + .to_string(), + )))?; if previous_count == &0 { return Err(Error::Drive(DriveError::CorruptedCacheState( "trying to lower the count of a version from cache that is already at 0" @@ -115,7 +116,10 @@ impl Drive { )?; } - let mut version_count = version_counter.get(&version).cloned().unwrap_or_default(); + let mut version_count = version_counter + .get_if_enabled(&version) + .cloned() + .unwrap_or_default(); version_count += 1; From 6d994ebdec028edb8b1ac6f400a8f4a8253c101b Mon Sep 17 00:00:00 2001 From: Ivan Shumkov Date: Thu, 28 Mar 2024 11:51:12 +0700 Subject: [PATCH 21/37] chore: update tenderdash to v0.14.0-dev.5 --- .cargo/config.toml | 1 - Cargo.lock | 43 ++++++++++--------- packages/dapi-grpc/Cargo.toml | 2 +- .../configs/defaults/getBaseConfigFactory.js | 2 +- packages/rs-drive-abci/Cargo.toml | 2 +- .../src/abci/handler/finalize_block.rs | 7 +-- .../src/abci/handler/prepare_proposal.rs | 2 +- .../src/abci/handler/process_proposal.rs | 3 ++ packages/rs-drive-abci/src/mimic/mod.rs | 13 +++--- packages/rs-drive-proof-verifier/Cargo.toml | 2 +- 10 files changed, 37 insertions(+), 40 deletions(-) diff --git a/.cargo/config.toml b/.cargo/config.toml index ad7da957cdc..18bc8e4064b 100644 --- a/.cargo/config.toml +++ b/.cargo/config.toml @@ -11,4 +11,3 @@ linker = "aarch64-linux-gnu-gcc" [build] rustflags = ["--cfg", "tokio_unstable"] -env = { TENDERDASH_COMMITISH = "dcb8ebcc5c52b00cfc5d67c7eb8c15692a34a66e" } diff --git a/Cargo.lock b/Cargo.lock index c28a3d3857a..8dacee92c24 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1249,7 +1249,7 @@ dependencies = [ "env_logger 0.9.3", "getrandom", "hex", - "indexmap 2.1.0", + "indexmap 2.2.6", "integer-encoding 4.0.0", "itertools 0.10.5", "json-patch", @@ -1299,7 +1299,7 @@ dependencies = [ "grovedb-path", "grovedb-storage", "hex", - "indexmap 2.1.0", + "indexmap 2.2.6", "integer-encoding 4.0.0", "intmap", "itertools 0.11.0", @@ -1913,7 +1913,7 @@ dependencies = [ "futures-sink", "futures-util", "http", - "indexmap 2.1.0", + "indexmap 2.2.6", "slab", "tokio", "tokio-util", @@ -2069,7 +2069,7 @@ dependencies = [ "httpdate", "itoa", "pin-project-lite", - "socket2 0.4.10", + "socket2 0.5.5", "tokio", "tower-service", "tracing", @@ -2140,9 +2140,9 @@ dependencies = [ [[package]] name = "indexmap" -version = "2.1.0" +version = "2.2.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d530e1a18b1cb4c484e6e34556a0d948706958449fca0cab753d649f2bce3d1f" +checksum = "168fb715dda47215e360912c096649d23d58bf392ac62f73919e831745e40f26" dependencies = [ "equivalent", "hashbrown 0.14.3", @@ -2861,7 +2861,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e1d3afd2628e69da2be385eb6f2fd57c8ac7977ceeff6dc166ff1657b0e386a9" dependencies = [ "fixedbitset", - "indexmap 2.1.0", + "indexmap 2.2.6", ] [[package]] @@ -2939,7 +2939,7 @@ dependencies = [ "bs58 0.4.0", "ciborium", "hex", - "indexmap 2.1.0", + "indexmap 2.2.6", "lazy_static", "platform-serialization", "platform-version", @@ -3205,7 +3205,7 @@ checksum = "c55e02e35260070b6f716a2423c2ff1c3bb1642ddca6f99e1f26d06268a0e2d2" dependencies = [ "bytes", "heck", - "itertools 0.10.5", + "itertools 0.11.0", "log", "multimap", "once_cell", @@ -3239,7 +3239,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "efb6c9a1dd1def8e2124d17e83a20af56f1570d6c2d2bd9e266ccb768df3840e" dependencies = [ "anyhow", - "itertools 0.10.5", + "itertools 0.11.0", "proc-macro2", "quote", "syn 2.0.48", @@ -3897,11 +3897,11 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.111" +version = "1.0.115" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "176e46fa42316f18edd598015a5166857fc835ec732f5215eac6b7bdbf0a84f4" +checksum = "12dc5c46daa8e9fdf4f5e71b6cf9a53f2487da0e86e55808e2d35539666497dd" dependencies = [ - "indexmap 2.1.0", + "indexmap 2.2.6", "itoa", "ryu", "serde", @@ -4275,8 +4275,8 @@ dependencies = [ [[package]] name = "tenderdash-abci" -version = "0.14.0-dev.9" -source = "git+https://github.com/dashpay/rs-tenderdash-abci#af64c65d94ef233053be8616e4c92f571fb5aae0" +version = "0.14.0-dev.11" +source = "git+https://github.com/dashpay/rs-tenderdash-abci#52a0b7cd37d7adcffea7b35eaf9ee10c7a6c8135" dependencies = [ "bytes", "futures", @@ -4284,6 +4284,7 @@ dependencies = [ "lhash", "prost 0.12.3", "semver", + "serde_json", "tenderdash-proto", "thiserror", "tokio", @@ -4296,8 +4297,8 @@ dependencies = [ [[package]] name = "tenderdash-proto" -version = "0.14.0-dev.9" -source = "git+https://github.com/dashpay/rs-tenderdash-abci#af64c65d94ef233053be8616e4c92f571fb5aae0" +version = "0.14.0-dev.11" +source = "git+https://github.com/dashpay/rs-tenderdash-abci#52a0b7cd37d7adcffea7b35eaf9ee10c7a6c8135" dependencies = [ "bytes", "chrono", @@ -4316,8 +4317,8 @@ dependencies = [ [[package]] name = "tenderdash-proto-compiler" -version = "0.14.0-dev.9" -source = "git+https://github.com/dashpay/rs-tenderdash-abci#af64c65d94ef233053be8616e4c92f571fb5aae0" +version = "0.14.0-dev.11" +source = "git+https://github.com/dashpay/rs-tenderdash-abci#52a0b7cd37d7adcffea7b35eaf9ee10c7a6c8135" dependencies = [ "fs_extra", "prost-build 0.12.3", @@ -4561,7 +4562,7 @@ version = "0.19.15" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1b5bb770da30e5cbfde35a2d7b9b8a2c4b8ef89548a7a6aeab5c9a576e3e7421" dependencies = [ - "indexmap 2.1.0", + "indexmap 2.2.6", "toml_datetime", "winnow", ] @@ -4572,7 +4573,7 @@ version = "0.21.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d34d383cd00a163b4a5b85053df514d45bc330f6de7737edfe0a93311d1eaa03" dependencies = [ - "indexmap 2.1.0", + "indexmap 2.2.6", "toml_datetime", "winnow", ] diff --git a/packages/dapi-grpc/Cargo.toml b/packages/dapi-grpc/Cargo.toml index 55cf60954aa..c4525aa878d 100644 --- a/packages/dapi-grpc/Cargo.toml +++ b/packages/dapi-grpc/Cargo.toml @@ -37,7 +37,7 @@ tonic = { version = "0.11", features = [ serde = { version = "1.0.171", optional = true, features = ["derive"] } serde_bytes = { version = "0.11.12", optional = true } serde_json = { version = "1.0", optional = true } -tenderdash-proto = { git = "https://github.com/dashpay/rs-tenderdash-abci", version = "0.14.0-dev.9", features = [ +tenderdash-proto = { git = "https://github.com/dashpay/rs-tenderdash-abci", version = "0.14.0-dev.11", features = [ "grpc", ] } dapi-grpc-macros = { path = "../rs-dapi-grpc-macros" } diff --git a/packages/dashmate/configs/defaults/getBaseConfigFactory.js b/packages/dashmate/configs/defaults/getBaseConfigFactory.js index 264c8a6c5b9..a358496b0e6 100644 --- a/packages/dashmate/configs/defaults/getBaseConfigFactory.js +++ b/packages/dashmate/configs/defaults/getBaseConfigFactory.js @@ -206,7 +206,7 @@ export default function getBaseConfigFactory(homeDir) { tenderdash: { mode: 'full', docker: { - image: 'dashpay/tenderdash:feat-proposer-app-version', + image: 'dashpay/tenderdash:0.14.0-dev.5', }, p2p: { host: '0.0.0.0', diff --git a/packages/rs-drive-abci/Cargo.toml b/packages/rs-drive-abci/Cargo.toml index 484a85c004a..4ade269ccb6 100644 --- a/packages/rs-drive-abci/Cargo.toml +++ b/packages/rs-drive-abci/Cargo.toml @@ -55,7 +55,7 @@ tracing-subscriber = { version = "0.3.16", default-features = false, features = "tracing-log", ], optional = false } atty = { version = "0.2.14", optional = false } -tenderdash-abci = { git = "https://github.com/dashpay/rs-tenderdash-abci", version = "0.14.0-dev.9", features = [ +tenderdash-abci = { git = "https://github.com/dashpay/rs-tenderdash-abci", version = "0.14.0-dev.11", features = [ "grpc", ] } lazy_static = "1.4.0" diff --git a/packages/rs-drive-abci/src/abci/handler/finalize_block.rs b/packages/rs-drive-abci/src/abci/handler/finalize_block.rs index fac416ee8fc..177a97f0c0c 100644 --- a/packages/rs-drive-abci/src/abci/handler/finalize_block.rs +++ b/packages/rs-drive-abci/src/abci/handler/finalize_block.rs @@ -1,8 +1,8 @@ use crate::abci::app::{BlockExecutionApplication, PlatformApplication, TransactionalApplication}; use crate::error::execution::ExecutionError; use crate::error::Error; -use crate::platform_types::cleaned_abci_messages::finalized_block_cleaned_request::v0::FinalizeBlockCleanedRequest; use crate::execution::types::block_execution_context::v0::BlockExecutionContextV0Getters; +use crate::platform_types::cleaned_abci_messages::finalized_block_cleaned_request::v0::FinalizeBlockCleanedRequest; use crate::rpc::core::CoreRPCLike; use std::sync::atomic::Ordering; use tenderdash_abci::proto::abci as proto; @@ -71,8 +71,5 @@ where .committed_block_height_guard .store(block_height, Ordering::Relaxed); - Ok(proto::ResponseFinalizeBlock { - events: vec![], - retain_height: 0, - }) + Ok(proto::ResponseFinalizeBlock { retain_height: 0 }) } diff --git a/packages/rs-drive-abci/src/abci/handler/prepare_proposal.rs b/packages/rs-drive-abci/src/abci/handler/prepare_proposal.rs index a001b0ec551..a8c08f900a5 100644 --- a/packages/rs-drive-abci/src/abci/handler/prepare_proposal.rs +++ b/packages/rs-drive-abci/src/abci/handler/prepare_proposal.rs @@ -189,7 +189,7 @@ where validator_set_update, // TODO: implement consensus param updates consensus_param_updates: None, - app_version: Some(protocol_version as u64), + app_version: protocol_version as u64, }; block_execution_context.set_proposer_results(Some(response.clone())); 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 9a60a8a1e46..bde2cdc9e71 100644 --- a/packages/rs-drive-abci/src/abci/handler/process_proposal.rs +++ b/packages/rs-drive-abci/src/abci/handler/process_proposal.rs @@ -51,6 +51,7 @@ where tx_results: proposal_info.tx_results.clone(), consensus_param_updates: proposal_info.consensus_param_updates.clone(), validator_set_update: proposal_info.validator_set_update.clone(), + events: Vec::new(), }); } @@ -131,6 +132,7 @@ where tx_results, consensus_param_updates, validator_set_update, + events: Vec::new(), }); } else { tracing::warn!( @@ -239,6 +241,7 @@ where validator_set_update, // TODO: Implement consensus param updates consensus_param_updates: None, + events: Vec::new(), }; let elapsed_time_ms = timer.elapsed().as_millis(); diff --git a/packages/rs-drive-abci/src/mimic/mod.rs b/packages/rs-drive-abci/src/mimic/mod.rs index 4d0afcd5a51..d548590106a 100644 --- a/packages/rs-drive-abci/src/mimic/mod.rs +++ b/packages/rs-drive-abci/src/mimic/mod.rs @@ -173,12 +173,9 @@ impl<'a, C: CoreRPCLike> FullAbciApplication<'a, C> { consensus_param_updates: _, core_chain_lock_update, validator_set_update, - app_version, // TODO: Not optional + app_version, } = response_prepare_proposal; - let current_protocol_version = - app_version.expect("expected app version") as ProtocolVersion; - if let Some(core_chain_lock_update) = core_chain_lock_update.as_ref() { core_height = core_chain_lock_update.core_block_height; } @@ -235,7 +232,7 @@ impl<'a, C: CoreRPCLike> FullAbciApplication<'a, C> { let state_id = StateId { app_hash: app_hash.clone(), - app_version: current_protocol_version as u64, + app_version, core_chain_locked_height: core_height, height, time: time.to_milis(), @@ -275,7 +272,7 @@ impl<'a, C: CoreRPCLike> FullAbciApplication<'a, C> { proposed_app_version: proposed_version as u64, version: Some(Consensus { block: 0, - app: current_protocol_version as u64, + app: app_version, }), quorum_hash: current_quorum.quorum_hash.to_byte_array().to_vec(), }; @@ -523,7 +520,7 @@ impl<'a, C: CoreRPCLike> FullAbciApplication<'a, C> { header: Some(Header { version: Some(Consensus { block: 0, //todo - app: current_protocol_version as u64, + app: app_version, }), chain_id: CHAIN_ID.to_string(), height: height as i64, @@ -594,7 +591,7 @@ impl<'a, C: CoreRPCLike> FullAbciApplication<'a, C> { Ok(MimicExecuteBlockOutcome { state_transaction_results, - app_version: current_protocol_version as u64, + app_version, withdrawal_transactions, validator_set_update, next_validator_set_hash, diff --git a/packages/rs-drive-proof-verifier/Cargo.toml b/packages/rs-drive-proof-verifier/Cargo.toml index 62c3deb0b7c..9ab9811b1f8 100644 --- a/packages/rs-drive-proof-verifier/Cargo.toml +++ b/packages/rs-drive-proof-verifier/Cargo.toml @@ -20,7 +20,7 @@ drive = { path = "../rs-drive", default-features = false, features = [ "verify", ] } dpp = { path = "../rs-dpp" } -tenderdash-abci = { git = "https://github.com/dashpay/rs-tenderdash-abci", version = "0.14.0-dev.9", features = [ +tenderdash-abci = { git = "https://github.com/dashpay/rs-tenderdash-abci", version = "0.14.0-dev.11", features = [ "grpc", ] } tracing = { version = "0.1.37" } From c404e2ae4095b29e68bb12f802ea7b79991a05ba Mon Sep 17 00:00:00 2001 From: Ivan Shumkov Date: Thu, 28 Mar 2024 13:17:14 +0700 Subject: [PATCH 22/37] feat: warn user about outdated software --- .../rs-drive-abci/src/abci/handler/info.rs | 6 +- packages/rs-drive-abci/src/config.rs | 11 ++++ .../engine/run_block_proposal/mod.rs | 18 +++++- .../engine/run_block_proposal/v0/mod.rs | 59 ++++++++++++++----- .../v0/mod.rs | 10 ++-- 5 files changed, 81 insertions(+), 23 deletions(-) diff --git a/packages/rs-drive-abci/src/abci/handler/info.rs b/packages/rs-drive-abci/src/abci/handler/info.rs index 5ec0bdf74cb..af8145ae5ca 100644 --- a/packages/rs-drive-abci/src/abci/handler/info.rs +++ b/packages/rs-drive-abci/src/abci/handler/info.rs @@ -26,18 +26,18 @@ where .map(|app_hash| app_hash.to_vec()) .unwrap_or_default(); - let latest_platform_version = PlatformVersion::latest(); + let latest_supported_protocol_version = PlatformVersion::latest().protocol_version; let response = proto::ResponseInfo { data: "".to_string(), - app_version: latest_platform_version.protocol_version as u64, + app_version: latest_supported_protocol_version as u64, last_block_height: platform_state.last_committed_block_height() as i64, version: env!("CARGO_PKG_VERSION").to_string(), last_block_app_hash: state_app_hash.clone(), }; tracing::debug!( - protocol_version = latest_platform_version.protocol_version, + latest_supported_protocol_version, software_version = env!("CARGO_PKG_VERSION"), block_version = request.block_version, p2p_version = request.p2p_version, diff --git a/packages/rs-drive-abci/src/config.rs b/packages/rs-drive-abci/src/config.rs index 209b9809651..e73b14d32ff 100644 --- a/packages/rs-drive-abci/src/config.rs +++ b/packages/rs-drive-abci/src/config.rs @@ -112,6 +112,11 @@ pub struct ExecutionConfig { deserialize_with = "from_str_or_number" )] pub epoch_time_length_s: u64, + + /// The percentage needed of HPMNs to upgrade the protocol + /// It always needs to be higher than the rounded amount after applying the percentage + #[serde(default = "ExecutionConfig::default_protocol_version_upgrade_percentage_needed")] + pub protocol_version_upgrade_percentage_needed: u64, } fn from_str_or_number<'de, D, T>(deserializer: D) -> Result @@ -235,6 +240,10 @@ impl ExecutionConfig { fn default_epoch_time_length_s() -> u64 { 788400 } + + fn default_protocol_version_upgrade_percentage_needed() -> u64 { + 75 + } } impl PlatformConfig { @@ -317,6 +326,8 @@ impl Default for ExecutionConfig { validator_set_rotation_block_count: ExecutionConfig::default_validator_set_rotation_block_count(), epoch_time_length_s: ExecutionConfig::default_epoch_time_length_s(), + protocol_version_upgrade_percentage_needed: + Self::default_protocol_version_upgrade_percentage_needed(), } } } diff --git a/packages/rs-drive-abci/src/execution/engine/run_block_proposal/mod.rs b/packages/rs-drive-abci/src/execution/engine/run_block_proposal/mod.rs index bb66bea033b..1790a23654f 100644 --- a/packages/rs-drive-abci/src/execution/engine/run_block_proposal/mod.rs +++ b/packages/rs-drive-abci/src/execution/engine/run_block_proposal/mod.rs @@ -66,7 +66,23 @@ where // Switch to next proposed platform version if we are on the first block of the new epoch // This version must be set to the state as current one during block processing let protocol_version = platform_state.next_epoch_protocol_version(); - PlatformVersion::get(protocol_version)? + + // If this node is not supported a new protocol version we exit with panic + PlatformVersion::get(protocol_version).map_err(|error| { + format!( + r#"Failed to upgrade the network protocol version {protocol_version}. Please update your software to the latest version. + +{}% of evo masternodes voted to upgrade for the network protocol version from {} to {protocol_version}. + +Your software version: {}, latest supported protocol version: {}."#, + self.config + .execution + .protocol_version_upgrade_percentage_needed, + last_committed_platform_version.protocol_version, + env!("CARGO_PKG_VERSION"), + PlatformVersion::latest().protocol_version + ); + }).unwrap() } else { // Stay on the last committed platform version last_committed_platform_version diff --git a/packages/rs-drive-abci/src/execution/engine/run_block_proposal/v0/mod.rs b/packages/rs-drive-abci/src/execution/engine/run_block_proposal/v0/mod.rs index b7e76493c6c..9b4ad40ef6c 100644 --- a/packages/rs-drive-abci/src/execution/engine/run_block_proposal/v0/mod.rs +++ b/packages/rs-drive-abci/src/execution/engine/run_block_proposal/v0/mod.rs @@ -1,3 +1,4 @@ +use chrono::{TimeZone, Utc}; use dpp::block::epoch::Epoch; use dpp::validation::ValidationResult; @@ -111,6 +112,22 @@ where last_block_time_ms, ); + // destructure the block proposal + let block_proposal::v0::BlockProposal { + core_chain_locked_height, + core_chain_lock_update, + proposed_app_version, + proposer_pro_tx_hash, + validator_set_quorum_hash, + raw_state_transitions, + .. + } = block_proposal; + + let block_info = block_state_info.to_block_info( + Epoch::new(epoch_info.current_epoch_index()) + .expect("current epoch index should be in range"), + ); + // First let's check that this is the follower to a previous block if !block_state_info.next_block_to(last_block_height, last_block_core_height)? { // we are on the wrong height or round @@ -174,21 +191,35 @@ where )); } - // destructure the block proposal - let block_proposal::v0::BlockProposal { - core_chain_locked_height, - core_chain_lock_update, - proposed_app_version, - proposer_pro_tx_hash, - validator_set_quorum_hash, - raw_state_transitions, - .. - } = block_proposal; + // Warn user to update software if the next protocol version is not supported + let latest_supported_protocol_version = PlatformVersion::latest().protocol_version; + let next_epoch_protocol_version = block_platform_state.next_epoch_protocol_version(); + if block_platform_state.next_epoch_protocol_version() > latest_supported_protocol_version { + let genesis_time_ms = self.get_genesis_time( + block_info.height, + block_info.time_ms, + transaction, + platform_version, + )?; - let block_info = block_state_info.to_block_info( - Epoch::new(epoch_info.current_epoch_index()) - .expect("current epoch index should be in range"), - ); + let next_epoch_activation_datetime_ms = genesis_time_ms + + (epoch_info.current_epoch_index() as u64 + * self.config.execution.epoch_time_length_s + * 1000); + + let next_epoch_activation_datetime = Utc + .timestamp_millis_opt(next_epoch_activation_datetime_ms as i64) + .single() + .expect("next_epoch_activation_date must always be in the range"); + + tracing::warn!( + next_epoch_protocol_version, + latest_supported_protocol_version, + "The node doesn't support new protocol version {} that will be activated starting from {}. Please update your software, otherwise the node won't be able to participate in the network.", + next_epoch_protocol_version, + next_epoch_activation_datetime.to_rfc2822(), + ); + } // If there is a core chain lock update, we should start by verifying it if let Some(core_chain_lock_update) = core_chain_lock_update.as_ref() { diff --git a/packages/rs-drive-abci/src/execution/platform_events/protocol_upgrade/check_for_desired_protocol_upgrade/v0/mod.rs b/packages/rs-drive-abci/src/execution/platform_events/protocol_upgrade/check_for_desired_protocol_upgrade/v0/mod.rs index a9d4c77ceb0..e7ff73bd226 100644 --- a/packages/rs-drive-abci/src/execution/platform_events/protocol_upgrade/check_for_desired_protocol_upgrade/v0/mod.rs +++ b/packages/rs-drive-abci/src/execution/platform_events/protocol_upgrade/check_for_desired_protocol_upgrade/v0/mod.rs @@ -4,10 +4,6 @@ use crate::platform_types::platform::Platform; use drive::dpp::util::deserializer::ProtocolVersion; -/// The percentage needed of HPMNs to upgrade the protocol -/// It always needs to be higher than the rounded amount after applying the percentage -const PROTOCOL_VERSION_UPGRADE_PERCENTAGE_NEEDED: u64 = 75; - impl Platform { /// checks for a network upgrade and resets activation window /// this should only be called on epoch change @@ -17,7 +13,11 @@ impl Platform { ) -> Result, Error> { let required_upgraded_hpns = 1 + (total_hpmns as u64) - .checked_mul(PROTOCOL_VERSION_UPGRADE_PERCENTAGE_NEEDED) + .checked_mul( + self.config + .execution + .protocol_version_upgrade_percentage_needed, + ) .and_then(|product| product.checked_div(100)) .ok_or(Error::Execution(ExecutionError::Overflow( "overflow for required block count", From 2f357a677a8bfff6afe82877a2a638dd042a5f52 Mon Sep 17 00:00:00 2001 From: Ivan Shumkov Date: Thu, 28 Mar 2024 13:40:44 +0700 Subject: [PATCH 23/37] fix: process block with the previous version of EpochInfo --- .../engine/run_block_proposal/mod.rs | 34 +++++++++++++------ 1 file changed, 24 insertions(+), 10 deletions(-) diff --git a/packages/rs-drive-abci/src/execution/engine/run_block_proposal/mod.rs b/packages/rs-drive-abci/src/execution/engine/run_block_proposal/mod.rs index 1790a23654f..5d349934e88 100644 --- a/packages/rs-drive-abci/src/execution/engine/run_block_proposal/mod.rs +++ b/packages/rs-drive-abci/src/execution/engine/run_block_proposal/mod.rs @@ -48,13 +48,13 @@ where transaction: &Transaction, ) -> Result, Error> { - // TODO: We should do it above and validate version from request - // prepare proposal should set this version // Epoch information is always calculated with the last committed platform version // even if we are switching to a new version in this block. let last_committed_platform_version = platform_state.current_platform_version()?; - let epoch_info = self.gather_epoch_info( + // This EpochInfo is based on the last committed platform version + // it must be replaced with new version + let mut epoch_info = self.gather_epoch_info( &block_proposal, transaction, platform_state, @@ -65,14 +65,14 @@ where let block_platform_version = if epoch_info.is_epoch_change_but_not_genesis() { // Switch to next proposed platform version if we are on the first block of the new epoch // This version must be set to the state as current one during block processing - let protocol_version = platform_state.next_epoch_protocol_version(); + let next_protocol_version = platform_state.next_epoch_protocol_version(); - // If this node is not supported a new protocol version we exit with panic - PlatformVersion::get(protocol_version).map_err(|error| { - format!( - r#"Failed to upgrade the network protocol version {protocol_version}. Please update your software to the latest version. + // We should panic if this node is not supported a new protocol version + let Ok(next_platform_version) = PlatformVersion::get(next_protocol_version) else { + panic!( + r#"Failed to upgrade the network protocol version {next_protocol_version}. Please update your software to the latest version. -{}% of evo masternodes voted to upgrade for the network protocol version from {} to {protocol_version}. +{}% of evo masternodes voted to upgrade for the network protocol version from {} to {next_protocol_version}. Your software version: {}, latest supported protocol version: {}."#, self.config @@ -82,7 +82,21 @@ Your software version: {}, latest supported protocol version: {}."#, env!("CARGO_PKG_VERSION"), PlatformVersion::latest().protocol_version ); - }).unwrap() + }; + + // Replace EpochInfo created to the new protocol version if needed + if platform_state.current_protocol_version_in_consensus() != next_protocol_version { + // TODO: We are calculating epoch info once again which is not great + // but it happens only once on protocol version upgrade (once a month?) + epoch_info = self.gather_epoch_info( + &block_proposal, + transaction, + platform_state, + next_platform_version, + )?; + } + + next_platform_version } else { // Stay on the last committed platform version last_committed_platform_version From 2d35fe63f6fc802a175e876d25e4ec684fdca8df Mon Sep 17 00:00:00 2001 From: Ivan Shumkov Date: Thu, 28 Mar 2024 13:42:00 +0700 Subject: [PATCH 24/37] refactor: rename variable --- .../src/execution/engine/run_block_proposal/mod.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/rs-drive-abci/src/execution/engine/run_block_proposal/mod.rs b/packages/rs-drive-abci/src/execution/engine/run_block_proposal/mod.rs index 5d349934e88..f387522872a 100644 --- a/packages/rs-drive-abci/src/execution/engine/run_block_proposal/mod.rs +++ b/packages/rs-drive-abci/src/execution/engine/run_block_proposal/mod.rs @@ -62,7 +62,7 @@ where )?; // Determine a protocol version for this block - let block_platform_version = if epoch_info.is_epoch_change_but_not_genesis() { + let platform_version = if epoch_info.is_epoch_change_but_not_genesis() { // Switch to next proposed platform version if we are on the first block of the new epoch // This version must be set to the state as current one during block processing let next_protocol_version = platform_state.next_epoch_protocol_version(); @@ -102,7 +102,7 @@ Your software version: {}, latest supported protocol version: {}."#, last_committed_platform_version }; - match block_platform_version + match platform_version .drive_abci .methods .engine @@ -114,7 +114,7 @@ Your software version: {}, latest supported protocol version: {}."#, epoch_info, transaction, platform_state, - block_platform_version, + platform_version, ), version => Err(Error::Execution(ExecutionError::UnknownVersionMismatch { method: "run_block_proposal".to_string(), From f78465ab00a28178fb4069dae80d907afcfbcb15 Mon Sep 17 00:00:00 2001 From: Ivan Shumkov Date: Thu, 28 Mar 2024 13:52:00 +0700 Subject: [PATCH 25/37] refactor: move code blocks to reduce changes --- .../engine/run_block_proposal/v0/mod.rs | 24 +++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/packages/rs-drive-abci/src/execution/engine/run_block_proposal/v0/mod.rs b/packages/rs-drive-abci/src/execution/engine/run_block_proposal/v0/mod.rs index 9b4ad40ef6c..f27bae3eb8f 100644 --- a/packages/rs-drive-abci/src/execution/engine/run_block_proposal/v0/mod.rs +++ b/packages/rs-drive-abci/src/execution/engine/run_block_proposal/v0/mod.rs @@ -112,6 +112,18 @@ where last_block_time_ms, ); + // First let's check that this is the follower to a previous block + if !block_state_info.next_block_to(last_block_height, last_block_core_height)? { + // we are on the wrong height or round + return Ok(ValidationResult::new_with_error(AbciError::WrongBlockReceived(format!( + "received a block proposal for height: {} core height: {}, current height: {} core height: {}", + block_state_info.height, block_state_info.core_chain_locked_height, last_block_height, last_block_core_height + )).into())); + } + + // Cleanup block cache before we execute a new proposal + self.clear_drive_block_cache(platform_version)?; + // destructure the block proposal let block_proposal::v0::BlockProposal { core_chain_locked_height, @@ -128,18 +140,6 @@ where .expect("current epoch index should be in range"), ); - // First let's check that this is the follower to a previous block - if !block_state_info.next_block_to(last_block_height, last_block_core_height)? { - // we are on the wrong height or round - return Ok(ValidationResult::new_with_error(AbciError::WrongBlockReceived(format!( - "received a block proposal for height: {} core height: {}, current height: {} core height: {}", - block_state_info.height, block_state_info.core_chain_locked_height, last_block_height, last_block_core_height - )).into())); - } - - // Cleanup block cache before we execute a new proposal - self.clear_drive_block_cache(platform_version)?; - // Update protocol version for this block let previous_block_protocol_version = last_committed_platform_state .current_platform_version()? From 6e3dcf2a3330b53940a7a6c6c67866d981be0bc5 Mon Sep 17 00:00:00 2001 From: Ivan Shumkov Date: Thu, 28 Mar 2024 14:01:01 +0700 Subject: [PATCH 26/37] refactor: rename methods for better readability --- .../block_end/update_drive_cache/v0/mod.rs | 2 +- .../block_start/clear_drive_block_cache/v0/mod.rs | 2 +- .../upgrade_protocol_version/v0/mod.rs | 2 +- .../rs-drive/src/drive/cache/protocol_version.rs | 14 +++++++------- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/packages/rs-drive-abci/src/execution/platform_events/block_end/update_drive_cache/v0/mod.rs b/packages/rs-drive-abci/src/execution/platform_events/block_end/update_drive_cache/v0/mod.rs index 7d7903c90e5..b061efe29d1 100644 --- a/packages/rs-drive-abci/src/execution/platform_events/block_end/update_drive_cache/v0/mod.rs +++ b/packages/rs-drive-abci/src/execution/platform_events/block_end/update_drive_cache/v0/mod.rs @@ -28,7 +28,7 @@ where .is_epoch_change_but_not_genesis() { protocol_versions_counter.clear_global_cache(); - protocol_versions_counter.enabled_getter(); + protocol_versions_counter.enabled_counter_getter(); } // Update proposed versions with new proposal from the current block diff --git a/packages/rs-drive-abci/src/execution/platform_events/block_start/clear_drive_block_cache/v0/mod.rs b/packages/rs-drive-abci/src/execution/platform_events/block_start/clear_drive_block_cache/v0/mod.rs index 2c83689583e..9045719fcde 100644 --- a/packages/rs-drive-abci/src/execution/platform_events/block_start/clear_drive_block_cache/v0/mod.rs +++ b/packages/rs-drive-abci/src/execution/platform_events/block_start/clear_drive_block_cache/v0/mod.rs @@ -17,6 +17,6 @@ where protocol_versions_counter.clear_block_cache(); // Getter is disabled in case of epoch change so we need to enable it back // For more information read comments in `upgrade_protocol_version_v0` function - protocol_versions_counter.enabled_getter(); + protocol_versions_counter.enabled_counter_getter(); } } diff --git a/packages/rs-drive-abci/src/execution/platform_events/protocol_upgrade/upgrade_protocol_version/v0/mod.rs b/packages/rs-drive-abci/src/execution/platform_events/protocol_upgrade/upgrade_protocol_version/v0/mod.rs index 350a02eca7f..27c4fc26242 100644 --- a/packages/rs-drive-abci/src/execution/platform_events/protocol_upgrade/upgrade_protocol_version/v0/mod.rs +++ b/packages/rs-drive-abci/src/execution/platform_events/protocol_upgrade/upgrade_protocol_version/v0/mod.rs @@ -64,7 +64,7 @@ impl Platform { // of the block processing in [clear_drive_block_cache]. let mut protocol_versions_counter = self.drive.cache.protocol_versions_counter.write(); - protocol_versions_counter.disable_getter(); + protocol_versions_counter.disable_counter_getter(); drop(protocol_versions_counter); Ok(()) diff --git a/packages/rs-drive/src/drive/cache/protocol_version.rs b/packages/rs-drive/src/drive/cache/protocol_version.rs index f87dc8ece2d..5188ba530f2 100644 --- a/packages/rs-drive/src/drive/cache/protocol_version.rs +++ b/packages/rs-drive/src/drive/cache/protocol_version.rs @@ -14,7 +14,7 @@ pub struct ProtocolVersionsCache { pub global_cache: IntMap, block_cache: IntMap, loaded: bool, - is_getter_disabled: bool, + is_counter_getter_disabled: bool, } #[cfg(feature = "full")] @@ -56,22 +56,22 @@ impl ProtocolVersionsCache { /// Disable the getter /// If disabled, then `get_if_enabled` will return None - pub fn disable_getter(&mut self) { - self.is_getter_disabled = true; + pub fn disable_counter_getter(&mut self) { + self.is_counter_getter_disabled = true; } /// Enable the getter /// If disabled, then [get_if_enabled] will return None /// This function enable the normal behaviour of the [get] function - pub fn enabled_getter(&mut self) { - self.is_getter_disabled = false; + pub fn enabled_counter_getter(&mut self) { + self.is_counter_getter_disabled = false; } /// Calls the [get] function if enabled /// or return `None` if disabled - /// See [disable_getter] and [enabled_getter] + /// See [disable_counter_getter] and [enabled_counter_getter] pub fn get_if_enabled(&self, version: &ProtocolVersion) -> Option<&u64> { - if self.is_getter_disabled { + if self.is_counter_getter_disabled { None } else { self.get(version) From db25ef75bfdfcd3484d3cd8b5059a2c1b1d3a6fe Mon Sep 17 00:00:00 2001 From: Ivan Shumkov Date: Thu, 28 Mar 2024 14:43:12 +0700 Subject: [PATCH 27/37] test: update root hash asserts --- packages/rs-drive-abci/tests/strategy_tests/main.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/rs-drive-abci/tests/strategy_tests/main.rs b/packages/rs-drive-abci/tests/strategy_tests/main.rs index 05a50fe290f..e753cf3cc1a 100644 --- a/packages/rs-drive-abci/tests/strategy_tests/main.rs +++ b/packages/rs-drive-abci/tests/strategy_tests/main.rs @@ -1144,7 +1144,7 @@ mod tests { .unwrap() .unwrap() ), - "8e16a23bb1e7149d3a68954bed157900398837f279781bb48186f93478c8d922".to_string() + "cac443b056272dbaea24692701b49e3679ec0385d68c5810d84d2b0e537f5e4d".to_string() ) } @@ -1833,7 +1833,7 @@ mod tests { .unwrap() .unwrap() ), - "2d620f91cb1be7a5dca0123b8d3c804a2efb7440fa81c247322423c86761cd85".to_string() + "b964833c32c75719fe07f145aa20cc22e11279b5b34eae6381b7944c5b4f4623".to_string() ) } @@ -1958,7 +1958,7 @@ mod tests { .unwrap() .unwrap() ), - "f49bcf6fe1022d56ef4bdc372b2f637e8241aafd7b2ea4e10051c0173d974674".to_string() + "01fe378cc38613821a09e18a16008a6f9f2c9a2a32f87b001ce35777a284bf01".to_string() ) } From 627ba606ea8fa75f28c4082ad8cc531bb1e975aa Mon Sep 17 00:00:00 2001 From: Ivan Shumkov Date: Fri, 29 Mar 2024 00:26:33 +0700 Subject: [PATCH 28/37] chore: fix comments --- packages/rs-drive-abci/src/error/execution.rs | 4 -- .../engine/run_block_proposal/mod.rs | 20 ++---- .../engine/run_block_proposal/v0/mod.rs | 15 +++-- .../block_end/update_drive_cache/v0/mod.rs | 2 +- .../clear_drive_block_cache/v0/mod.rs | 2 +- .../epoch/gather_epoch_info/mod.rs | 7 ++- .../upgrade_protocol_version/v0/mod.rs | 2 +- .../src/platform_types/epoch_info/mod.rs | 11 ++++ .../system/version_upgrade_state/v0/mod.rs | 2 + .../version_upgrade_vote_status/v0/mod.rs | 2 + .../tests/strategy_tests/main.rs | 2 +- .../strategy_tests/upgrade_fork_tests.rs | 63 ++++++++++++------- .../src/drive/cache/protocol_version.rs | 41 ++++++------ .../v0/mod.rs | 20 +++--- .../v0/mod.rs | 21 +++++-- packages/rs-drive/src/error/cache.rs | 7 +++ packages/rs-drive/src/error/mod.rs | 6 ++ 17 files changed, 138 insertions(+), 89 deletions(-) create mode 100644 packages/rs-drive/src/error/cache.rs diff --git a/packages/rs-drive-abci/src/error/execution.rs b/packages/rs-drive-abci/src/error/execution.rs index 3c3b0d3a9eb..165bbe4f753 100644 --- a/packages/rs-drive-abci/src/error/execution.rs +++ b/packages/rs-drive-abci/src/error/execution.rs @@ -82,10 +82,6 @@ pub enum ExecutionError { #[error("protocol upgrade incoherence error: {0}")] ProtocolUpgradeIncoherence(&'static str), - /// A protocol upgrade should happen only on epoch change - #[error("unexpected protocol upgrade: it should happen only on epoch change")] - UnexpectedProtocolVersionUpgrade, - /// Data is missing from the drive. #[error("drive missing data error: {0}")] DriveMissingData(String), diff --git a/packages/rs-drive-abci/src/execution/engine/run_block_proposal/mod.rs b/packages/rs-drive-abci/src/execution/engine/run_block_proposal/mod.rs index f387522872a..501d86f4825 100644 --- a/packages/rs-drive-abci/src/execution/engine/run_block_proposal/mod.rs +++ b/packages/rs-drive-abci/src/execution/engine/run_block_proposal/mod.rs @@ -52,8 +52,8 @@ where // even if we are switching to a new version in this block. let last_committed_platform_version = platform_state.current_platform_version()?; - // This EpochInfo is based on the last committed platform version - // it must be replaced with new version + // !!!! This EpochInfo is based on the last committed platform version + // !!!! and will be used for the first block of the epoch. let mut epoch_info = self.gather_epoch_info( &block_proposal, transaction, @@ -70,7 +70,9 @@ where // We should panic if this node is not supported a new protocol version let Ok(next_platform_version) = PlatformVersion::get(next_protocol_version) else { panic!( - r#"Failed to upgrade the network protocol version {next_protocol_version}. Please update your software to the latest version. + r#"Failed to upgrade the network protocol version {next_protocol_version}. + +Please update your software to the latest version: https://docs.dash.org/platform-protocol-upgrade {}% of evo masternodes voted to upgrade for the network protocol version from {} to {next_protocol_version}. @@ -84,18 +86,6 @@ Your software version: {}, latest supported protocol version: {}."#, ); }; - // Replace EpochInfo created to the new protocol version if needed - if platform_state.current_protocol_version_in_consensus() != next_protocol_version { - // TODO: We are calculating epoch info once again which is not great - // but it happens only once on protocol version upgrade (once a month?) - epoch_info = self.gather_epoch_info( - &block_proposal, - transaction, - platform_state, - next_platform_version, - )?; - } - next_platform_version } else { // Stay on the last committed platform version diff --git a/packages/rs-drive-abci/src/execution/engine/run_block_proposal/v0/mod.rs b/packages/rs-drive-abci/src/execution/engine/run_block_proposal/v0/mod.rs index f27bae3eb8f..308b83d457f 100644 --- a/packages/rs-drive-abci/src/execution/engine/run_block_proposal/v0/mod.rs +++ b/packages/rs-drive-abci/src/execution/engine/run_block_proposal/v0/mod.rs @@ -146,9 +146,6 @@ where .protocol_version; let current_block_protocol_version = platform_version.protocol_version; - block_platform_state - .set_current_protocol_version_in_consensus(current_block_protocol_version); - // Protocol version can be changed only on epoch change if epoch_info.is_epoch_change_but_not_genesis() { tracing::info!( @@ -173,6 +170,9 @@ where previous_block_protocol_version, current_block_protocol_version, ); + + block_platform_state + .set_current_protocol_version_in_consensus(current_block_protocol_version); }; // Update block platform state with current and next epoch protocol versions @@ -185,10 +185,9 @@ where platform_version, )?; } else if current_block_protocol_version != previous_block_protocol_version { - // It might happen only in case of error in the code. - return Err(Error::Execution( - ExecutionError::UnexpectedProtocolVersionUpgrade, - )); + return Err(Error::Execution(ExecutionError::CorruptedCodeExecution( + "unexpected protocol upgrade: it should happen only on epoch change", + ))); } // Warn user to update software if the next protocol version is not supported @@ -215,7 +214,7 @@ where tracing::warn!( next_epoch_protocol_version, latest_supported_protocol_version, - "The node doesn't support new protocol version {} that will be activated starting from {}. Please update your software, otherwise the node won't be able to participate in the network.", + "The node doesn't support new protocol version {} that will be activated starting from {}. Please update your software, otherwise the node won't be able to participate in the network. https://docs.dash.org/platform-protocol-upgrade", next_epoch_protocol_version, next_epoch_activation_datetime.to_rfc2822(), ); diff --git a/packages/rs-drive-abci/src/execution/platform_events/block_end/update_drive_cache/v0/mod.rs b/packages/rs-drive-abci/src/execution/platform_events/block_end/update_drive_cache/v0/mod.rs index b061efe29d1..35852a05d92 100644 --- a/packages/rs-drive-abci/src/execution/platform_events/block_end/update_drive_cache/v0/mod.rs +++ b/packages/rs-drive-abci/src/execution/platform_events/block_end/update_drive_cache/v0/mod.rs @@ -28,7 +28,7 @@ where .is_epoch_change_but_not_genesis() { protocol_versions_counter.clear_global_cache(); - protocol_versions_counter.enabled_counter_getter(); + protocol_versions_counter.unblock_global_cache(); } // Update proposed versions with new proposal from the current block diff --git a/packages/rs-drive-abci/src/execution/platform_events/block_start/clear_drive_block_cache/v0/mod.rs b/packages/rs-drive-abci/src/execution/platform_events/block_start/clear_drive_block_cache/v0/mod.rs index 9045719fcde..ecf723fa2ad 100644 --- a/packages/rs-drive-abci/src/execution/platform_events/block_start/clear_drive_block_cache/v0/mod.rs +++ b/packages/rs-drive-abci/src/execution/platform_events/block_start/clear_drive_block_cache/v0/mod.rs @@ -17,6 +17,6 @@ where protocol_versions_counter.clear_block_cache(); // Getter is disabled in case of epoch change so we need to enable it back // For more information read comments in `upgrade_protocol_version_v0` function - protocol_versions_counter.enabled_counter_getter(); + protocol_versions_counter.unblock_global_cache(); } } diff --git a/packages/rs-drive-abci/src/execution/platform_events/epoch/gather_epoch_info/mod.rs b/packages/rs-drive-abci/src/execution/platform_events/epoch/gather_epoch_info/mod.rs index 12aa3233bd7..57aff29475a 100644 --- a/packages/rs-drive-abci/src/execution/platform_events/epoch/gather_epoch_info/mod.rs +++ b/packages/rs-drive-abci/src/execution/platform_events/epoch/gather_epoch_info/mod.rs @@ -32,10 +32,15 @@ impl Platform { platform_state: &PlatformState, platform_version: &PlatformVersion, ) -> Result { + // !! BE AWARE BEFORE YOU MODIFY THIS CODE !!! // Please be aware epoch information is gathered with previous platform version // on epoch change (1st block of the epoch), despite we are switching to a new version - // in this block. A new version of this method will be called for the rest of epoch blocks + // in this block. Thus, the previous version of EpochInfo might also be used for the first block. + // A new version of this method will be called for the rest of epoch blocks // and first block of the next epoch. + // This means that if we ever want to update EpochInfo, we will need to do so on a release + // where the new fields of epoch info are not being used. Then make another version once + // that one is activated. match platform_version.drive_abci.methods.epoch.gather_epoch_info { 0 => self .gather_epoch_info_v0( diff --git a/packages/rs-drive-abci/src/execution/platform_events/protocol_upgrade/upgrade_protocol_version/v0/mod.rs b/packages/rs-drive-abci/src/execution/platform_events/protocol_upgrade/upgrade_protocol_version/v0/mod.rs index 27c4fc26242..5d775e2751d 100644 --- a/packages/rs-drive-abci/src/execution/platform_events/protocol_upgrade/upgrade_protocol_version/v0/mod.rs +++ b/packages/rs-drive-abci/src/execution/platform_events/protocol_upgrade/upgrade_protocol_version/v0/mod.rs @@ -64,7 +64,7 @@ impl Platform { // of the block processing in [clear_drive_block_cache]. let mut protocol_versions_counter = self.drive.cache.protocol_versions_counter.write(); - protocol_versions_counter.disable_counter_getter(); + protocol_versions_counter.block_global_cache(); drop(protocol_versions_counter); Ok(()) diff --git a/packages/rs-drive-abci/src/platform_types/epoch_info/mod.rs b/packages/rs-drive-abci/src/platform_types/epoch_info/mod.rs index 78dac32a8c1..3fb8512a78b 100644 --- a/packages/rs-drive-abci/src/platform_types/epoch_info/mod.rs +++ b/packages/rs-drive-abci/src/platform_types/epoch_info/mod.rs @@ -15,6 +15,17 @@ use serde::{Deserialize, Serialize}; pub mod v0; /// Info pertinent to the current epoch. +/// +/// BE AWARE BEFORE YOU MODIFY THIS CODE +/// +/// Please be aware epoch information is gathered with previous platform version +/// on epoch change (1st block of the epoch), despite we are switching to a new version +/// in this block. Thus, the previous version of EpochInfo might also be used for the first block. +/// A new version of EpochInfo will be used for the rest of epoch blocks +/// and first block of the next epoch. +/// This means that if we ever want to update EpochInfo, we will need to do so on a release +/// where the new fields of epoch info are not being used. Then make another version once +/// that one is activated. #[derive(Clone, Serialize, Deserialize, Debug, From, Eq, PartialEq)] #[serde(rename_all = "camelCase")] pub enum EpochInfo { diff --git a/packages/rs-drive-abci/src/query/system/version_upgrade_state/v0/mod.rs b/packages/rs-drive-abci/src/query/system/version_upgrade_state/v0/mod.rs index 6736a589a30..e840dd2dffb 100644 --- a/packages/rs-drive-abci/src/query/system/version_upgrade_state/v0/mod.rs +++ b/packages/rs-drive-abci/src/query/system/version_upgrade_state/v0/mod.rs @@ -133,6 +133,7 @@ mod tests { let mut version_count = version_counter .get(&version.protocol_version) + .expect("expected to get version count") .cloned() .unwrap_or_default(); @@ -255,6 +256,7 @@ mod tests { let mut version_count = version_counter .get(&version.protocol_version) + .expect("expected to get version count") .cloned() .unwrap_or_default(); diff --git a/packages/rs-drive-abci/src/query/system/version_upgrade_vote_status/v0/mod.rs b/packages/rs-drive-abci/src/query/system/version_upgrade_vote_status/v0/mod.rs index 52dd78ef9eb..ea550ccf7ca 100644 --- a/packages/rs-drive-abci/src/query/system/version_upgrade_vote_status/v0/mod.rs +++ b/packages/rs-drive-abci/src/query/system/version_upgrade_vote_status/v0/mod.rs @@ -175,6 +175,7 @@ mod tests { let mut version_count = version_counter .get(&version.protocol_version) + .expect("expected to get version count") .cloned() .unwrap_or_default(); @@ -311,6 +312,7 @@ mod tests { let mut version_count = version_counter .get(&version.protocol_version) + .expect("expected to get version count") .cloned() .unwrap_or_default(); diff --git a/packages/rs-drive-abci/tests/strategy_tests/main.rs b/packages/rs-drive-abci/tests/strategy_tests/main.rs index e29d299f8df..6e16bc0f3cb 100644 --- a/packages/rs-drive-abci/tests/strategy_tests/main.rs +++ b/packages/rs-drive-abci/tests/strategy_tests/main.rs @@ -792,7 +792,7 @@ mod tests { .index, 0 ); - assert!(counter.get(&1).unwrap() > &240); + assert!(counter.get(&1).unwrap().unwrap() > &240); } #[test] diff --git a/packages/rs-drive-abci/tests/strategy_tests/upgrade_fork_tests.rs b/packages/rs-drive-abci/tests/strategy_tests/upgrade_fork_tests.rs index 6511c2dbcca..3e8aa09860b 100644 --- a/packages/rs-drive-abci/tests/strategy_tests/upgrade_fork_tests.rs +++ b/packages/rs-drive-abci/tests/strategy_tests/upgrade_fork_tests.rs @@ -129,7 +129,10 @@ mod tests { ); assert_eq!(state.current_protocol_version_in_consensus(), 1); assert_eq!( - (counter.get(&1), counter.get(&TEST_PROTOCOL_VERSION_2)), + ( + counter.get(&1).unwrap(), + counter.get(&TEST_PROTOCOL_VERSION_2).unwrap() + ), (Some(&17), Some(&414)) ); //most nodes were hit (63 were not) @@ -194,8 +197,8 @@ mod tests { ); assert_eq!(state.current_protocol_version_in_consensus(), 1); assert_eq!(state.next_epoch_protocol_version(), TEST_PROTOCOL_VERSION_2); - assert_eq!(counter.get(&1), None); //no one has proposed 1 yet - assert_eq!(counter.get(&TEST_PROTOCOL_VERSION_2), Some(&154)); + assert_eq!(counter.get(&1).unwrap(), None); //no one has proposed 1 yet + assert_eq!(counter.get(&TEST_PROTOCOL_VERSION_2).unwrap(), Some(&154)); } // we locked in @@ -248,8 +251,8 @@ mod tests { TEST_PROTOCOL_VERSION_2 ); assert_eq!(state.next_epoch_protocol_version(), TEST_PROTOCOL_VERSION_2); - assert_eq!(counter.get(&1), None); //no one has proposed 1 yet - assert_eq!(counter.get(&TEST_PROTOCOL_VERSION_2), Some(&123)); + assert_eq!(counter.get(&1).unwrap(), None); //no one has proposed 1 yet + assert_eq!(counter.get(&TEST_PROTOCOL_VERSION_2).unwrap(), Some(&123)); } }) .expect("Failed to create thread with custom stack size"); @@ -368,7 +371,10 @@ mod tests { assert_eq!(state.current_protocol_version_in_consensus(), 1); assert_eq!(state.next_epoch_protocol_version(), 1); assert_eq!( - (counter.get(&1), counter.get(&TEST_PROTOCOL_VERSION_2)), + ( + counter.get(&1).unwrap(), + counter.get(&TEST_PROTOCOL_VERSION_2).unwrap() + ), (Some(&6), Some(&44)) ); //most nodes were hit (63 were not) @@ -428,8 +434,8 @@ mod tests { ); assert_eq!(state.current_protocol_version_in_consensus(), 1); assert_eq!(state.next_epoch_protocol_version(), TEST_PROTOCOL_VERSION_2); - assert_eq!(counter.get(&1), None); //no one has proposed 1 yet - assert_eq!(counter.get(&TEST_PROTOCOL_VERSION_2), Some(&1)); + assert_eq!(counter.get(&1).unwrap(), None); //no one has proposed 1 yet + assert_eq!(counter.get(&TEST_PROTOCOL_VERSION_2).unwrap(), Some(&1)); } // we locked in @@ -479,8 +485,8 @@ mod tests { TEST_PROTOCOL_VERSION_2 ); assert_eq!(state.next_epoch_protocol_version(), TEST_PROTOCOL_VERSION_2); - assert_eq!(counter.get(&1), None); //no one has proposed 1 yet - assert_eq!(counter.get(&TEST_PROTOCOL_VERSION_2), Some(&1)); + assert_eq!(counter.get(&1).unwrap(), None); //no one has proposed 1 yet + assert_eq!(counter.get(&TEST_PROTOCOL_VERSION_2).unwrap(), Some(&1)); } }) .expect("Failed to create thread with custom stack size"); @@ -594,7 +600,10 @@ mod tests { assert_eq!(state.next_epoch_protocol_version(), 1); let counter = &platform.drive.cache.protocol_versions_counter.read(); assert_eq!( - (counter.get(&1), counter.get(&TEST_PROTOCOL_VERSION_2)), + ( + counter.get(&1).unwrap(), + counter.get(&TEST_PROTOCOL_VERSION_2).unwrap() + ), (Some(&35), Some(&64)) ); } @@ -656,7 +665,10 @@ mod tests { assert_eq!(state.next_epoch_protocol_version(), TEST_PROTOCOL_VERSION_2); // the counter is for the current voting during that window assert_eq!( - (counter.get(&1), counter.get(&TEST_PROTOCOL_VERSION_2)), + ( + counter.get(&1).unwrap(), + counter.get(&TEST_PROTOCOL_VERSION_2).unwrap() + ), (Some(&8), Some(&79)) ); } @@ -876,7 +888,10 @@ mod tests { assert_eq!(state.current_protocol_version_in_consensus(), 1); assert_eq!(state.next_epoch_protocol_version(), TEST_PROTOCOL_VERSION_2); assert_eq!( - (counter.get(&1), counter.get(&TEST_PROTOCOL_VERSION_2)), + ( + counter.get(&1).unwrap(), + counter.get(&TEST_PROTOCOL_VERSION_2).unwrap() + ), (Some(&18), Some(&112)) ); //not all nodes have upgraded @@ -957,7 +972,10 @@ mod tests { { let counter = &platform.drive.cache.protocol_versions_counter.read(); assert_eq!( - (counter.get(&1), counter.get(&TEST_PROTOCOL_VERSION_2)), + ( + counter.get(&1).unwrap(), + counter.get(&TEST_PROTOCOL_VERSION_2).unwrap() + ), (Some(&172), Some(&24)) ); //a lot nodes reverted to previous version, however this won't impact things @@ -1009,7 +1027,10 @@ mod tests { { let counter = &platform.drive.cache.protocol_versions_counter.read(); assert_eq!( - (counter.get(&1), counter.get(&TEST_PROTOCOL_VERSION_2)), + ( + counter.get(&1).unwrap(), + counter.get(&TEST_PROTOCOL_VERSION_2).unwrap() + ), (Some(&24), Some(&2)) ); assert_eq!( @@ -1135,9 +1156,9 @@ mod tests { assert_eq!(state.next_epoch_protocol_version(), TEST_PROTOCOL_VERSION_2); assert_eq!( ( - counter.get(&1), - counter.get(&TEST_PROTOCOL_VERSION_2), - counter.get(&TEST_PROTOCOL_VERSION_3) + counter.get(&1).unwrap(), + counter.get(&TEST_PROTOCOL_VERSION_2).unwrap(), + counter.get(&TEST_PROTOCOL_VERSION_3).unwrap() ), (Some(&2), Some(&68), Some(&3)) ); //some nodes reverted to previous version @@ -1223,9 +1244,9 @@ mod tests { assert_eq!(state.next_epoch_protocol_version(), TEST_PROTOCOL_VERSION_3); assert_eq!( ( - counter.get(&1), - counter.get(&TEST_PROTOCOL_VERSION_2), - counter.get(&TEST_PROTOCOL_VERSION_3) + counter.get(&1).unwrap(), + counter.get(&TEST_PROTOCOL_VERSION_2).unwrap(), + counter.get(&TEST_PROTOCOL_VERSION_3).unwrap() ), (None, Some(&3), Some(&143)) ); diff --git a/packages/rs-drive/src/drive/cache/protocol_version.rs b/packages/rs-drive/src/drive/cache/protocol_version.rs index 5188ba530f2..5ca50cc68d5 100644 --- a/packages/rs-drive/src/drive/cache/protocol_version.rs +++ b/packages/rs-drive/src/drive/cache/protocol_version.rs @@ -1,4 +1,5 @@ use crate::drive::Drive; +use crate::error::cache::CacheError; use crate::error::Error; use dpp::util::deserializer::ProtocolVersion; use grovedb::TransactionArg; @@ -14,7 +15,7 @@ pub struct ProtocolVersionsCache { pub global_cache: IntMap, block_cache: IntMap, loaded: bool, - is_counter_getter_disabled: bool, + is_global_cache_blocked: bool, } #[cfg(feature = "full")] @@ -46,36 +47,30 @@ impl ProtocolVersionsCache { /// Tries to get a version from block cache if present /// if block cache doesn't have the version set /// then it tries get the version from global cache - pub fn get(&self, version: &ProtocolVersion) -> Option<&u64> { - if let Some(count) = self.block_cache.get(version) { + pub fn get(&self, version: &ProtocolVersion) -> Result, Error> { + if self.is_global_cache_blocked { + return Err(Error::Cache(CacheError::GlobalCacheIsBlocked)); + } + + let counter = if let Some(count) = self.block_cache.get(version) { Some(count) } else { self.global_cache.get(version) - } - } + }; - /// Disable the getter - /// If disabled, then `get_if_enabled` will return None - pub fn disable_counter_getter(&mut self) { - self.is_counter_getter_disabled = true; + Ok(counter) } - /// Enable the getter - /// If disabled, then [get_if_enabled] will return None - /// This function enable the normal behaviour of the [get] function - pub fn enabled_counter_getter(&mut self) { - self.is_counter_getter_disabled = false; + /// Disable the global cache to do not allow get counters + /// If global cache is blocked then [get] will return an error + pub fn block_global_cache(&mut self) { + self.is_global_cache_blocked = true; } - /// Calls the [get] function if enabled - /// or return `None` if disabled - /// See [disable_counter_getter] and [enabled_counter_getter] - pub fn get_if_enabled(&self, version: &ProtocolVersion) -> Option<&u64> { - if self.is_counter_getter_disabled { - None - } else { - self.get(version) - } + /// Unblock the global cache + /// This function enables the normal behaviour of [get] function + pub fn unblock_global_cache(&mut self) { + self.is_global_cache_blocked = false; } /// Merge block cache to global cache diff --git a/packages/rs-drive/src/drive/protocol_upgrade/remove_validators_proposed_app_versions/v0/mod.rs b/packages/rs-drive/src/drive/protocol_upgrade/remove_validators_proposed_app_versions/v0/mod.rs index 2910fdfc920..1814f605d11 100644 --- a/packages/rs-drive/src/drive/protocol_upgrade/remove_validators_proposed_app_versions/v0/mod.rs +++ b/packages/rs-drive/src/drive/protocol_upgrade/remove_validators_proposed_app_versions/v0/mod.rs @@ -107,7 +107,7 @@ impl Drive { where I: IntoIterator, { - let version_counter = &mut self.cache.protocol_versions_counter.write(); + let mut version_counter = self.cache.protocol_versions_counter.write(); version_counter.load_if_needed(self, transaction, drive_version)?; @@ -146,13 +146,17 @@ impl Drive { } for (previous_version, change) in previous_versions_removals { - let previous_count = - *version_counter - .get_if_enabled(&previous_version) - .ok_or(Error::Drive(DriveError::CorruptedCacheState( - "trying to lower the count of a version from cache that is not found" - .to_string(), - )))?; + let previous_count = version_counter + .get(&previous_version) + .map_err(|error| { + DriveError::CorruptedCacheState(format!( + "{error}. we should never face with blocked global cache when we get previous count because version counter trees must be empty at this point" + )) + })? + .ok_or(Error::Drive(DriveError::CorruptedCacheState( + "trying to lower the count of a version from cache that is not found" + .to_string(), + )))?; let removed_count = previous_count.checked_sub(change).ok_or(Error::Drive(DriveError::CorruptedDriveState( "trying to lower the count of a version from cache that would result in a negative value" .to_string(), diff --git a/packages/rs-drive/src/drive/protocol_upgrade/update_validator_proposed_app_version/v0/mod.rs b/packages/rs-drive/src/drive/protocol_upgrade/update_validator_proposed_app_version/v0/mod.rs index f3a3a67610a..07b3cab2da6 100644 --- a/packages/rs-drive/src/drive/protocol_upgrade/update_validator_proposed_app_version/v0/mod.rs +++ b/packages/rs-drive/src/drive/protocol_upgrade/update_validator_proposed_app_version/v0/mod.rs @@ -12,6 +12,7 @@ use crate::fee::op::LowLevelDriveOperation; use dpp::util::deserializer::ProtocolVersion; use dpp::version::drive_versions::DriveVersion; +use crate::error::cache::CacheError; use grovedb::{Element, TransactionArg}; use integer_encoding::VarInt; @@ -92,7 +93,15 @@ impl Drive { //we should remove 1 from the previous version let previous_count = version_counter - .get_if_enabled(&previous_version) + .get(&previous_version) + .map_err(|error| { + match error { + Error::Cache(CacheError::GlobalCacheIsBlocked) => Error::Drive(DriveError::CorruptedCacheState( + "global cache is blocked. we should never get into it when we get previous count because version counter trees must be empty at this point".to_string(), + )), + _ => error + } + })? .ok_or(Error::Drive(DriveError::CorruptedCacheState( "trying to lower the count of a version from cache that is not found" .to_string(), @@ -116,10 +125,12 @@ impl Drive { )?; } - let mut version_count = version_counter - .get_if_enabled(&version) - .cloned() - .unwrap_or_default(); + let mut version_count = match version_counter.get(&version) { + Ok(count) => count.copied().unwrap_or_default(), + // if global cache is blocked then it means we are starting from scratch + Err(Error::Cache(CacheError::GlobalCacheIsBlocked)) => 0, + Err(other_error) => return Err(other_error), + }; version_count += 1; diff --git a/packages/rs-drive/src/error/cache.rs b/packages/rs-drive/src/error/cache.rs new file mode 100644 index 00000000000..d4aed54d05f --- /dev/null +++ b/packages/rs-drive/src/error/cache.rs @@ -0,0 +1,7 @@ +/// Cache errors +#[derive(Debug, thiserror::Error)] +pub enum CacheError { + /// Overflow error + #[error("global cache is blocked for block execution")] + GlobalCacheIsBlocked, +} diff --git a/packages/rs-drive/src/error/mod.rs b/packages/rs-drive/src/error/mod.rs index 5dc1f759eb5..456e759d0cb 100644 --- a/packages/rs-drive/src/error/mod.rs +++ b/packages/rs-drive/src/error/mod.rs @@ -1,4 +1,5 @@ use self::drive::DriveError; +use crate::error::cache::CacheError; use crate::error::contract::DataContractError; use crate::error::proof::ProofError; use crate::error::storage_flags::StorageFlagsError; @@ -10,6 +11,8 @@ use fee::FeeError; use identity::IdentityError; use query::QuerySyntaxError; +/// Cache errors +pub mod cache; ///DataContract errors pub mod contract; /// Document module @@ -63,6 +66,9 @@ pub enum Error { ///DataContract error #[error("contract: {0}")] DataContract(#[from] DataContractError), + ///Cache error + #[error("contract: {0}")] + Cache(#[from] CacheError), } impl From for Error { From 49565907111949ebb06749111cbc9d9bb5d133a0 Mon Sep 17 00:00:00 2001 From: Ivan Shumkov Date: Mon, 1 Apr 2024 20:23:15 +0700 Subject: [PATCH 29/37] test: propose a new protocol version on epoch change --- .../strategy_tests/upgrade_fork_tests.rs | 20 ++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/packages/rs-drive-abci/tests/strategy_tests/upgrade_fork_tests.rs b/packages/rs-drive-abci/tests/strategy_tests/upgrade_fork_tests.rs index 3e8aa09860b..13093ff74d3 100644 --- a/packages/rs-drive-abci/tests/strategy_tests/upgrade_fork_tests.rs +++ b/packages/rs-drive-abci/tests/strategy_tests/upgrade_fork_tests.rs @@ -368,6 +368,7 @@ mod tests { .index, 0 ); + assert_eq!(state.last_committed_block_epoch().index, 0); assert_eq!(state.current_protocol_version_in_consensus(), 1); assert_eq!(state.next_epoch_protocol_version(), 1); assert_eq!( @@ -380,6 +381,16 @@ mod tests { //most nodes were hit (63 were not) } + // Propose a new version for next epoch + + let mut next_epoch_strategy = strategy.clone(); + + next_epoch_strategy.upgrading_info = Some(UpgradingInfo { + current_protocol_version: 1, + proposed_protocol_versions_with_weight: vec![(TEST_PROTOCOL_VERSION_3, 1)], + upgrade_three_quarters_life: 0.0, + }); + let platform = abci_app.platform; let block_start = state @@ -408,13 +419,13 @@ mod tests { proposers, quorums, current_quorum_hash, - current_proposer_versions: Some(current_proposer_versions.clone()), + current_proposer_versions: None, current_identity_nonce_counter: identity_nonce_counter, current_identity_contract_nonce_counter: identity_contract_nonce_counter, start_time_ms: 1681094380000, current_time_ms: end_time_ms, }, - strategy.clone(), + next_epoch_strategy, config.clone(), StrategyRandomness::SeedEntropy(7), ); @@ -432,10 +443,12 @@ mod tests { .index, 1 ); + assert_eq!(state.last_committed_block_epoch().index, 1); assert_eq!(state.current_protocol_version_in_consensus(), 1); assert_eq!(state.next_epoch_protocol_version(), TEST_PROTOCOL_VERSION_2); assert_eq!(counter.get(&1).unwrap(), None); //no one has proposed 1 yet - assert_eq!(counter.get(&TEST_PROTOCOL_VERSION_2).unwrap(), Some(&1)); + assert_eq!(counter.get(&TEST_PROTOCOL_VERSION_2).unwrap(), None); + assert_eq!(counter.get(&TEST_PROTOCOL_VERSION_3).unwrap(), Some(&1)); } // we locked in @@ -484,6 +497,7 @@ mod tests { state.current_protocol_version_in_consensus(), TEST_PROTOCOL_VERSION_2 ); + assert_eq!(state.last_committed_block_epoch().index, 2); assert_eq!(state.next_epoch_protocol_version(), TEST_PROTOCOL_VERSION_2); assert_eq!(counter.get(&1).unwrap(), None); //no one has proposed 1 yet assert_eq!(counter.get(&TEST_PROTOCOL_VERSION_2).unwrap(), Some(&1)); From b6b6b6fbdb4ec4ceddd74f1462b7f47b788ba9fb Mon Sep 17 00:00:00 2001 From: Ivan Shumkov Date: Tue, 2 Apr 2024 01:43:04 +0700 Subject: [PATCH 30/37] style: remove unused mut --- .../src/execution/engine/run_block_proposal/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/rs-drive-abci/src/execution/engine/run_block_proposal/mod.rs b/packages/rs-drive-abci/src/execution/engine/run_block_proposal/mod.rs index 501d86f4825..533e796a9d9 100644 --- a/packages/rs-drive-abci/src/execution/engine/run_block_proposal/mod.rs +++ b/packages/rs-drive-abci/src/execution/engine/run_block_proposal/mod.rs @@ -54,7 +54,7 @@ where // !!!! This EpochInfo is based on the last committed platform version // !!!! and will be used for the first block of the epoch. - let mut epoch_info = self.gather_epoch_info( + let epoch_info = self.gather_epoch_info( &block_proposal, transaction, platform_state, From 93b3bd79e333c1c0a82e54592ec1ae32638b0679 Mon Sep 17 00:00:00 2001 From: Ivan Shumkov Date: Tue, 2 Apr 2024 18:51:44 +0700 Subject: [PATCH 31/37] test: call remove_validators_proposed_app_versions on epoch change --- .../tests/strategy_tests/execution.rs | 18 +- .../strategy_tests/upgrade_fork_tests.rs | 155 ++++++++++++++++-- 2 files changed, 146 insertions(+), 27 deletions(-) diff --git a/packages/rs-drive-abci/tests/strategy_tests/execution.rs b/packages/rs-drive-abci/tests/strategy_tests/execution.rs index 66ba2f947e8..3db5a245faa 100644 --- a/packages/rs-drive-abci/tests/strategy_tests/execution.rs +++ b/packages/rs-drive-abci/tests/strategy_tests/execution.rs @@ -577,9 +577,9 @@ pub(crate) fn run_chain_for_strategy( } }; - let block_hash = *core_blocks - .get(&block_height) - .unwrap_or_else(|| panic!("expected a block hash to be known for {}", core_height)); + let Some(block_hash) = core_blocks.get(&block_height) else { + panic!("expected a block hash to be known for {}", block_height); + }; let chain_lock = if sign_chain_locks { // From DIP 8: https://github.com/dashpay/dips/blob/master/dip-0008.md#finalization-of-signed-blocks @@ -594,7 +594,7 @@ pub(crate) fn run_chain_for_strategy( .expect("expected to encode the prefix"); engine.input("clsig".as_bytes()); - engine.input(core_height.to_le_bytes().as_slice()); + engine.input(block_height.to_le_bytes().as_slice()); let request_id = QuorumSigningRequestId::from_engine(engine); @@ -617,7 +617,7 @@ pub(crate) fn run_chain_for_strategy( engine.input(&[chain_lock_quorum_type as u8]); engine.input(quorum_hash.as_slice()); engine.input(request_id.as_byte_array()); - engine.input(&block_hash); + engine.input(block_hash); let message_digest = sha256d::Hash::from_engine(engine); @@ -626,16 +626,16 @@ pub(crate) fn run_chain_for_strategy( .expect("expected to have a valid private key"); let signature = quorum_private_key.sign(message_digest.as_byte_array()); let chain_lock = ChainLock { - block_height: core_height, - block_hash: BlockHash::from_byte_array(block_hash), + block_height, + block_hash: BlockHash::from_byte_array(*block_hash), signature: (*signature.to_bytes()).into(), }; Ok(chain_lock) } else { let chain_lock = ChainLock { - block_height: core_height, - block_hash: BlockHash::from_byte_array(block_hash), + block_height, + block_hash: BlockHash::from_byte_array(*block_hash), signature: [2; 96].into(), }; diff --git a/packages/rs-drive-abci/tests/strategy_tests/upgrade_fork_tests.rs b/packages/rs-drive-abci/tests/strategy_tests/upgrade_fork_tests.rs index 13093ff74d3..24c4225385e 100644 --- a/packages/rs-drive-abci/tests/strategy_tests/upgrade_fork_tests.rs +++ b/packages/rs-drive-abci/tests/strategy_tests/upgrade_fork_tests.rs @@ -1,5 +1,6 @@ #[cfg(test)] mod tests { + use dpp::block::block_info::BlockInfo; use dpp::block::extended_block_info::v0::ExtendedBlockInfoV0Getters; use dpp::dashcore::hashes::Hash; use dpp::dashcore::{BlockHash, ChainLock}; @@ -8,14 +9,16 @@ mod tests { use crate::execution::{continue_chain_for_strategy, run_chain_for_strategy}; use crate::strategy::{ - ChainExecutionOutcome, ChainExecutionParameters, NetworkStrategy, StrategyRandomness, - UpgradingInfo, + ChainExecutionOutcome, ChainExecutionParameters, CoreHeightIncrease, + MasternodeListChangesStrategy, NetworkStrategy, StrategyRandomness, UpgradingInfo, }; use drive_abci::config::{ExecutionConfig, PlatformConfig, PlatformTestConfig}; + use drive_abci::mimic::MimicExecuteBlockOptions; use drive_abci::platform_types::platform_state::v0::PlatformStateV0Methods; use drive_abci::test::helpers::setup::TestPlatformBuilder; use platform_version::version::mocks::v2_test::TEST_PROTOCOL_VERSION_2; use platform_version::version::mocks::v3_test::TEST_PROTOCOL_VERSION_3; + use strategy_tests::frequency::Frequency; use strategy_tests::{IdentityInsertInfo, StartIdentities, Strategy}; #[test] @@ -279,7 +282,6 @@ mod tests { operations: vec![], start_identities: StartIdentities::default(), identities_inserts: IdentityInsertInfo::default(), - identity_contract_nonce_gaps: None, signer: None, }, @@ -292,7 +294,6 @@ mod tests { proposed_protocol_versions_with_weight: vec![(TEST_PROTOCOL_VERSION_2, 1)], upgrade_three_quarters_life: 0.2, }), - proposer_strategy: Default::default(), rotate_quorums: false, failure_testing: None, @@ -381,16 +382,6 @@ mod tests { //most nodes were hit (63 were not) } - // Propose a new version for next epoch - - let mut next_epoch_strategy = strategy.clone(); - - next_epoch_strategy.upgrading_info = Some(UpgradingInfo { - current_protocol_version: 1, - proposed_protocol_versions_with_weight: vec![(TEST_PROTOCOL_VERSION_3, 1)], - upgrade_three_quarters_life: 0.0, - }); - let platform = abci_app.platform; let block_start = state @@ -419,13 +410,13 @@ mod tests { proposers, quorums, current_quorum_hash, - current_proposer_versions: None, + current_proposer_versions: Some(current_proposer_versions.clone()), current_identity_nonce_counter: identity_nonce_counter, current_identity_contract_nonce_counter: identity_contract_nonce_counter, start_time_ms: 1681094380000, current_time_ms: end_time_ms, }, - next_epoch_strategy, + strategy.clone(), config.clone(), StrategyRandomness::SeedEntropy(7), ); @@ -447,8 +438,7 @@ mod tests { assert_eq!(state.current_protocol_version_in_consensus(), 1); assert_eq!(state.next_epoch_protocol_version(), TEST_PROTOCOL_VERSION_2); assert_eq!(counter.get(&1).unwrap(), None); //no one has proposed 1 yet - assert_eq!(counter.get(&TEST_PROTOCOL_VERSION_2).unwrap(), None); - assert_eq!(counter.get(&TEST_PROTOCOL_VERSION_3).unwrap(), Some(&1)); + assert_eq!(counter.get(&TEST_PROTOCOL_VERSION_2).unwrap(), Some(&1)); } // we locked in @@ -509,6 +499,135 @@ mod tests { handler.join().expect("Thread has panicked"); } + #[test] + fn run_chain_on_epoch_change_with_new_version_and_removing_votes() { + let strategy = NetworkStrategy { + total_hpmns: 50, + upgrading_info: Some(UpgradingInfo { + current_protocol_version: 1, + proposed_protocol_versions_with_weight: vec![(TEST_PROTOCOL_VERSION_2, 1)], + upgrade_three_quarters_life: 0.0, + }), + core_height_increase: CoreHeightIncrease::KnownCoreHeightIncreases(vec![1, 2, 3, 4, 5]), + // Remove HPMNs to trigger remove_validators_proposed_app_versions + proposer_strategy: MasternodeListChangesStrategy { + removed_hpmns: Frequency { + times_per_block_range: 1..2, + chance_per_block: None, + }, + ..Default::default() + }, + ..Default::default() + }; + + // 1 block is 1 epoch + let epoch_time_length_s = 60; + + let config = PlatformConfig { + validator_set_quorum_size: 30, + execution: ExecutionConfig { + // Upgrade to new version even we have only one vote + protocol_version_upgrade_percentage_needed: 1, + epoch_time_length_s, + ..Default::default() + }, + block_spacing_ms: epoch_time_length_s * 1000, + testing_configs: PlatformTestConfig::default_with_no_block_signing(), + ..Default::default() + }; + + let mut platform = TestPlatformBuilder::new() + .with_config(config.clone()) + .build_with_mock_rpc(); + + let ChainExecutionOutcome { + abci_app, + proposers, + quorums, + current_quorum_hash, + end_time_ms, + .. + } = run_chain_for_strategy(&mut platform, 1, strategy.clone(), config.clone(), 13); + + let platform = abci_app.platform; + + let state = platform.state.load(); + let counter = platform.drive.cache.protocol_versions_counter.read(); + + assert_eq!(state.last_committed_block_epoch().index, 0); + assert_eq!(state.current_protocol_version_in_consensus(), 1); + assert_eq!(state.next_epoch_protocol_version(), 1); + assert_eq!(state.last_committed_core_height(), 2); + assert_eq!(counter.get(&1).unwrap(), None); + assert_eq!(counter.get(&TEST_PROTOCOL_VERSION_2).unwrap(), Some(&1)); + assert_eq!(counter.get(&TEST_PROTOCOL_VERSION_3).unwrap(), None); + + drop(counter); + + // Next bock is epoch change. We want to test our protocol + // upgrade logic. We will propose a new version and remove HPMN + // to make sure all protocol version count functions are called during block execution. + + let last_committed_block_info = state + .last_committed_block_info() + .as_ref() + .unwrap() + .basic_info(); + + let proposer_pro_tx_hash = proposers + .first() + .expect("we should have proposers") + .masternode + .pro_tx_hash; + + let current_quorum_with_test_info = + quorums.get(¤t_quorum_hash).expect("expected quorum"); + + // We want to add proposal for a new version + let proposed_version = TEST_PROTOCOL_VERSION_3; + + let block_info = BlockInfo { + time_ms: end_time_ms + epoch_time_length_s + 1, + height: last_committed_block_info.height + 1, + core_height: last_committed_block_info.core_height, + epoch: Default::default(), + }; + + abci_app + .mimic_execute_block( + proposer_pro_tx_hash.into(), + current_quorum_with_test_info, + proposed_version, + block_info, + 0, + &[], + false, + Vec::new(), + MimicExecuteBlockOptions { + dont_finalize_block: strategy.dont_finalize_block(), + rounds_before_finalization: strategy + .failure_testing + .as_ref() + .and_then(|failure_testing| failure_testing.rounds_before_successful_block), + max_tx_bytes_per_block: strategy.max_tx_bytes_per_block, + independent_process_proposal_verification: strategy + .independent_process_proposal_verification, + }, + ) + .expect("expected to execute a block"); + + let state = platform.state.load(); + let counter = platform.drive.cache.protocol_versions_counter.read(); + + assert_eq!(state.last_committed_block_epoch().index, 1); + assert_eq!(state.current_protocol_version_in_consensus(), 1); + assert_eq!(state.next_epoch_protocol_version(), TEST_PROTOCOL_VERSION_2); + assert_eq!(counter.get(&1).unwrap(), None); + assert_eq!(counter.get(&TEST_PROTOCOL_VERSION_2).unwrap(), None); + assert_eq!(counter.get(&TEST_PROTOCOL_VERSION_3).unwrap(), Some(&1)); + assert_eq!(state.last_committed_core_height(), 3); + } + #[test] fn run_chain_version_upgrade_slow_upgrade() { // Define the desired stack size From e9a1be1b0395f21f192a0dc31c7dc9254c6360e8 Mon Sep 17 00:00:00 2001 From: Ivan Shumkov Date: Tue, 2 Apr 2024 19:11:10 +0700 Subject: [PATCH 32/37] refactor: extract protocol upgrade logic to a separate function --- .../engine/run_block_proposal/v0/mod.rs | 80 ++-------- .../upgrade_protocol_version/mod.rs | 15 +- .../upgrade_protocol_version/v0/mod.rs | 139 +++++++++++++----- .../src/version/drive_abci_versions.rs | 2 +- .../src/version/mocks/v2_test.rs | 2 +- .../src/version/mocks/v3_test.rs | 2 +- .../rs-platform-version/src/version/v1.rs | 2 +- 7 files changed, 129 insertions(+), 113 deletions(-) diff --git a/packages/rs-drive-abci/src/execution/engine/run_block_proposal/v0/mod.rs b/packages/rs-drive-abci/src/execution/engine/run_block_proposal/v0/mod.rs index 308b83d457f..39d96f1530f 100644 --- a/packages/rs-drive-abci/src/execution/engine/run_block_proposal/v0/mod.rs +++ b/packages/rs-drive-abci/src/execution/engine/run_block_proposal/v0/mod.rs @@ -1,4 +1,3 @@ -use chrono::{TimeZone, Utc}; use dpp::block::epoch::Epoch; use dpp::validation::ValidationResult; @@ -140,13 +139,6 @@ where .expect("current epoch index should be in range"), ); - // Update protocol version for this block - let previous_block_protocol_version = last_committed_platform_state - .current_platform_version()? - .protocol_version; - let current_block_protocol_version = platform_version.protocol_version; - - // Protocol version can be changed only on epoch change if epoch_info.is_epoch_change_but_not_genesis() { tracing::info!( epoch_index = epoch_info.current_epoch_index(), @@ -156,69 +148,19 @@ where .expect("must be set since we aren't on genesis"), epoch_info.current_epoch_index(), ); - - if current_block_protocol_version == previous_block_protocol_version { - tracing::info!( - epoch_index = epoch_info.current_epoch_index(), - "protocol version remains the same {}", - current_block_protocol_version, - ); - } else { - tracing::info!( - epoch_index = epoch_info.current_epoch_index(), - "protocol version changed from {} to {}", - previous_block_protocol_version, - current_block_protocol_version, - ); - - block_platform_state - .set_current_protocol_version_in_consensus(current_block_protocol_version); - }; - - // Update block platform state with current and next epoch protocol versions - // if it was proposed - // This should happen only on epoch change - self.upgrade_protocol_version( - last_committed_platform_state, - &mut block_platform_state, - transaction, - platform_version, - )?; - } else if current_block_protocol_version != previous_block_protocol_version { - return Err(Error::Execution(ExecutionError::CorruptedCodeExecution( - "unexpected protocol upgrade: it should happen only on epoch change", - ))); } - // Warn user to update software if the next protocol version is not supported - let latest_supported_protocol_version = PlatformVersion::latest().protocol_version; - let next_epoch_protocol_version = block_platform_state.next_epoch_protocol_version(); - if block_platform_state.next_epoch_protocol_version() > latest_supported_protocol_version { - let genesis_time_ms = self.get_genesis_time( - block_info.height, - block_info.time_ms, - transaction, - platform_version, - )?; - - let next_epoch_activation_datetime_ms = genesis_time_ms - + (epoch_info.current_epoch_index() as u64 - * self.config.execution.epoch_time_length_s - * 1000); - - let next_epoch_activation_datetime = Utc - .timestamp_millis_opt(next_epoch_activation_datetime_ms as i64) - .single() - .expect("next_epoch_activation_date must always be in the range"); - - tracing::warn!( - next_epoch_protocol_version, - latest_supported_protocol_version, - "The node doesn't support new protocol version {} that will be activated starting from {}. Please update your software, otherwise the node won't be able to participate in the network. https://docs.dash.org/platform-protocol-upgrade", - next_epoch_protocol_version, - next_epoch_activation_datetime.to_rfc2822(), - ); - } + // Update block platform state with current and next epoch protocol versions + // if it was proposed + // This is happening only on epoch change + self.upgrade_protocol_version_on_epoch_change( + &block_info, + &epoch_info, + last_committed_platform_state, + &mut block_platform_state, + transaction, + platform_version, + )?; // If there is a core chain lock update, we should start by verifying it if let Some(core_chain_lock_update) = core_chain_lock_update.as_ref() { diff --git a/packages/rs-drive-abci/src/execution/platform_events/protocol_upgrade/upgrade_protocol_version/mod.rs b/packages/rs-drive-abci/src/execution/platform_events/protocol_upgrade/upgrade_protocol_version/mod.rs index f7cdaa9217e..18fff0fb658 100644 --- a/packages/rs-drive-abci/src/execution/platform_events/protocol_upgrade/upgrade_protocol_version/mod.rs +++ b/packages/rs-drive-abci/src/execution/platform_events/protocol_upgrade/upgrade_protocol_version/mod.rs @@ -2,8 +2,10 @@ mod v0; use crate::error::execution::ExecutionError; use crate::error::Error; +use crate::platform_types::epoch_info::EpochInfo; use crate::platform_types::platform::Platform; use crate::platform_types::platform_state::PlatformState; +use dpp::block::block_info::BlockInfo; use dpp::version::PlatformVersion; use drive::grovedb::Transaction; @@ -13,6 +15,7 @@ impl Platform { /// This function should be called on very top of bock production before we add new proposed version for the next epoch /// /// It takes five parameters: + /// * `block_info`: Information about the current block. /// * `epoch_info`: Information about the current epoch. /// * `last_committed_platform_state`: The last committed state of the platform. /// * `block_platform_state`: The current state of the platform. @@ -22,8 +25,10 @@ impl Platform { /// # Errors /// /// This function will return an error if the previous block protocol version does not match the current block protocol version not on epoch change - pub fn upgrade_protocol_version( + pub fn upgrade_protocol_version_on_epoch_change( &self, + block_info: &BlockInfo, + epoch_info: &EpochInfo, last_committed_platform_state: &PlatformState, block_platform_state: &mut PlatformState, transaction: &Transaction, @@ -33,16 +38,18 @@ impl Platform { .drive_abci .methods .protocol_upgrade - .upgrade_protocol_version + .upgrade_protocol_version_on_epoch_change { - 0 => self.upgrade_protocol_version_v0( + 0 => self.upgrade_protocol_version_on_epoch_change_v0( + block_info, + epoch_info, last_committed_platform_state, block_platform_state, transaction, platform_version, ), version => Err(Error::Execution(ExecutionError::UnknownVersionMismatch { - method: "upgrade_protocol_version".to_string(), + method: "upgrade_protocol_version_on_epoch_change".to_string(), known_versions: vec![0], received: version, })), diff --git a/packages/rs-drive-abci/src/execution/platform_events/protocol_upgrade/upgrade_protocol_version/v0/mod.rs b/packages/rs-drive-abci/src/execution/platform_events/protocol_upgrade/upgrade_protocol_version/v0/mod.rs index 5d775e2751d..5cce6dd3242 100644 --- a/packages/rs-drive-abci/src/execution/platform_events/protocol_upgrade/upgrade_protocol_version/v0/mod.rs +++ b/packages/rs-drive-abci/src/execution/platform_events/protocol_upgrade/upgrade_protocol_version/v0/mod.rs @@ -1,7 +1,12 @@ +use crate::error::execution::ExecutionError; use crate::error::Error; +use crate::platform_types::epoch_info::v0::{EpochInfoV0Getters, EpochInfoV0Methods}; +use crate::platform_types::epoch_info::EpochInfo; use crate::platform_types::platform::Platform; use crate::platform_types::platform_state::v0::PlatformStateV0Methods; use crate::platform_types::platform_state::PlatformState; +use chrono::{TimeZone, Utc}; +use dpp::block::block_info::BlockInfo; use dpp::version::PlatformVersion; use drive::grovedb::Transaction; @@ -18,54 +23,116 @@ impl Platform { /// # Errors /// /// This function will return an error if the previous block protocol version does not match the current block protocol version not on epoch change - pub(super) fn upgrade_protocol_version_v0( + pub(super) fn upgrade_protocol_version_on_epoch_change_v0( &self, + block_info: &BlockInfo, + epoch_info: &EpochInfo, last_committed_platform_state: &PlatformState, block_platform_state: &mut PlatformState, transaction: &Transaction, platform_version: &PlatformVersion, ) -> Result<(), Error> { - // Store current protocol version in drive state - // TODO: This will be removed in #1778 - self.drive.store_current_protocol_version( - platform_version.protocol_version, - Some(transaction), - &platform_version.drive, - )?; + let previous_block_protocol_version = last_committed_platform_state + .current_platform_version()? + .protocol_version; + let current_block_protocol_version = platform_version.protocol_version; - // Determine a new protocol version for the next epoch if enough proposers voted - // otherwise keep the current one + // Protocol version can be changed only on epoch change + if epoch_info.is_epoch_change_but_not_genesis() { + if current_block_protocol_version == previous_block_protocol_version { + tracing::info!( + epoch_index = epoch_info.current_epoch_index(), + "protocol version remains the same {}", + current_block_protocol_version, + ); + } else { + tracing::info!( + epoch_index = epoch_info.current_epoch_index(), + "protocol version changed from {} to {}", + previous_block_protocol_version, + current_block_protocol_version, + ); - let hpmn_list_len = last_committed_platform_state.hpmn_list_len() as u32; + block_platform_state + .set_current_protocol_version_in_consensus(current_block_protocol_version); - let next_epoch_protocol_version = - self.check_for_desired_protocol_upgrade(hpmn_list_len, platform_version)?; + // Store current protocol version in drive state + // TODO: This will be removed in #1778 + self.drive.store_current_protocol_version( + platform_version.protocol_version, + Some(transaction), + &platform_version.drive, + )?; + }; - if let Some(protocol_version) = next_epoch_protocol_version { - block_platform_state.set_next_epoch_protocol_version(protocol_version); + // Determine a new protocol version for the next epoch if enough proposers voted + // otherwise keep the current one + + let hpmn_list_len = last_committed_platform_state.hpmn_list_len() as u32; + + let next_epoch_protocol_version = + self.check_for_desired_protocol_upgrade(hpmn_list_len, platform_version)?; + + if let Some(protocol_version) = next_epoch_protocol_version { + block_platform_state.set_next_epoch_protocol_version(protocol_version); + } + + // Since we are starting a new epoch we need to drop previously + // proposed versions + + // Remove previously proposed versions from Drive state + self.drive + .clear_version_information(Some(transaction), &platform_version.drive) + .map_err(Error::Drive)?; + + // We clean voting counter cache only on finalize block because: + // 1. The voting counter global cache uses for querying of voting information in Drive queries + // 2. There might be multiple rounds so on the next round we will lose all previous epoch votes + // + // Instead of clearing cache, the further block processing logic is using `get_if_enabled` + // to get a version counter from the global cache. We disable this getter here to prevent + // reading previous voting information for the new epoch. + // The getter must be enabled back on finalize block in [update_drive_cache] and at the very beginning + // of the block processing in [clear_drive_block_cache]. + + let mut protocol_versions_counter = self.drive.cache.protocol_versions_counter.write(); + protocol_versions_counter.block_global_cache(); + drop(protocol_versions_counter); + } else if current_block_protocol_version != previous_block_protocol_version { + return Err(Error::Execution(ExecutionError::CorruptedCodeExecution( + "unexpected protocol upgrade: it should happen only on epoch change", + ))); } - // Since we are starting a new epoch we need to drop previously - // proposed versions - - // Remove previously proposed versions from Drive state - self.drive - .clear_version_information(Some(transaction), &platform_version.drive) - .map_err(Error::Drive)?; - - // We clean voting counter cache only on finalize block because: - // 1. The voting counter global cache uses for querying of voting information in Drive queries - // 2. There might be multiple rounds so on the next round we will lose all previous epoch votes - // - // Instead of clearing cache, the further block processing logic is using `get_if_enabled` - // to get a version counter from the global cache. We disable this getter here to prevent - // reading previous voting information for the new epoch. - // The getter must be enabled back on finalize block in [update_drive_cache] and at the very beginning - // of the block processing in [clear_drive_block_cache]. - - let mut protocol_versions_counter = self.drive.cache.protocol_versions_counter.write(); - protocol_versions_counter.block_global_cache(); - drop(protocol_versions_counter); + // Warn user to update software if the next protocol version is not supported + let latest_supported_protocol_version = PlatformVersion::latest().protocol_version; + let next_epoch_protocol_version = block_platform_state.next_epoch_protocol_version(); + if block_platform_state.next_epoch_protocol_version() > latest_supported_protocol_version { + let genesis_time_ms = self.get_genesis_time( + block_info.height, + block_info.time_ms, + transaction, + platform_version, + )?; + + let next_epoch_activation_datetime_ms = genesis_time_ms + + (epoch_info.current_epoch_index() as u64 + * self.config.execution.epoch_time_length_s + * 1000); + + let next_epoch_activation_datetime = Utc + .timestamp_millis_opt(next_epoch_activation_datetime_ms as i64) + .single() + .expect("next_epoch_activation_date must always be in the range"); + + tracing::warn!( + next_epoch_protocol_version, + latest_supported_protocol_version, + "The node doesn't support new protocol version {} that will be activated starting from {}. Please update your software, otherwise the node won't be able to participate in the network. https://docs.dash.org/platform-protocol-upgrade", + next_epoch_protocol_version, + next_epoch_activation_datetime.to_rfc2822(), + ); + } Ok(()) } diff --git a/packages/rs-platform-version/src/version/drive_abci_versions.rs b/packages/rs-platform-version/src/version/drive_abci_versions.rs index 1af39a168e3..28c865a314e 100644 --- a/packages/rs-platform-version/src/version/drive_abci_versions.rs +++ b/packages/rs-platform-version/src/version/drive_abci_versions.rs @@ -276,7 +276,7 @@ pub struct DriveAbciIdentityCreditWithdrawalMethodVersions { #[derive(Clone, Debug, Default)] pub struct DriveAbciProtocolUpgradeMethodVersions { pub check_for_desired_protocol_upgrade: FeatureVersion, - pub upgrade_protocol_version: FeatureVersion, + pub upgrade_protocol_version_on_epoch_change: FeatureVersion, } #[derive(Clone, Debug, Default)] 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 d76e1d2f89f..ee85356256e 100644 --- a/packages/rs-platform-version/src/version/mocks/v2_test.rs +++ b/packages/rs-platform-version/src/version/mocks/v2_test.rs @@ -531,7 +531,7 @@ pub(crate) const TEST_PLATFORM_V2: PlatformVersion = PlatformVersion { }, protocol_upgrade: DriveAbciProtocolUpgradeMethodVersions { check_for_desired_protocol_upgrade: 0, - upgrade_protocol_version: 0, + upgrade_protocol_version_on_epoch_change: 0, }, block_fee_processing: DriveAbciBlockFeeProcessingMethodVersions { add_process_epoch_change_operations: 0, 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 655ae2c3258..b3f2555d3c5 100644 --- a/packages/rs-platform-version/src/version/mocks/v3_test.rs +++ b/packages/rs-platform-version/src/version/mocks/v3_test.rs @@ -531,7 +531,7 @@ pub(crate) const TEST_PLATFORM_V3: PlatformVersion = PlatformVersion { }, protocol_upgrade: DriveAbciProtocolUpgradeMethodVersions { check_for_desired_protocol_upgrade: 0, - upgrade_protocol_version: 0, + upgrade_protocol_version_on_epoch_change: 0, }, block_fee_processing: DriveAbciBlockFeeProcessingMethodVersions { add_process_epoch_change_operations: 0, diff --git a/packages/rs-platform-version/src/version/v1.rs b/packages/rs-platform-version/src/version/v1.rs index 58428263732..33c84dcab3d 100644 --- a/packages/rs-platform-version/src/version/v1.rs +++ b/packages/rs-platform-version/src/version/v1.rs @@ -528,7 +528,7 @@ pub(super) const PLATFORM_V1: PlatformVersion = PlatformVersion { }, protocol_upgrade: DriveAbciProtocolUpgradeMethodVersions { check_for_desired_protocol_upgrade: 0, - upgrade_protocol_version: 0, + upgrade_protocol_version_on_epoch_change: 0, }, block_fee_processing: DriveAbciBlockFeeProcessingMethodVersions { add_process_epoch_change_operations: 0, From f934d79fb29b45636ef166fbd6bc9c115dc4098e Mon Sep 17 00:00:00 2001 From: Ivan Shumkov Date: Tue, 2 Apr 2024 20:31:03 +0700 Subject: [PATCH 33/37] refactor: move `protocol_version_upgrade_percentage_needed` to versions --- packages/rs-drive-abci/src/config.rs | 11 ---- .../engine/run_block_proposal/mod.rs | 6 --- .../check_for_desired_protocol_upgrade/mod.rs | 2 +- .../v0/mod.rs | 18 ++++--- .../strategy_tests/upgrade_fork_tests.rs | 50 ++++++++++++++++--- .../src/version/drive_abci_versions.rs | 1 + .../src/version/mocks/mod.rs | 2 +- .../src/version/mocks/v2_test.rs | 7 +-- .../src/version/mocks/v3_test.rs | 7 +-- .../rs-platform-version/src/version/mod.rs | 6 ++- .../src/version/protocol_version.rs | 39 ++++++++++++--- .../rs-platform-version/src/version/v1.rs | 5 +- 12 files changed, 103 insertions(+), 51 deletions(-) diff --git a/packages/rs-drive-abci/src/config.rs b/packages/rs-drive-abci/src/config.rs index e73b14d32ff..209b9809651 100644 --- a/packages/rs-drive-abci/src/config.rs +++ b/packages/rs-drive-abci/src/config.rs @@ -112,11 +112,6 @@ pub struct ExecutionConfig { deserialize_with = "from_str_or_number" )] pub epoch_time_length_s: u64, - - /// The percentage needed of HPMNs to upgrade the protocol - /// It always needs to be higher than the rounded amount after applying the percentage - #[serde(default = "ExecutionConfig::default_protocol_version_upgrade_percentage_needed")] - pub protocol_version_upgrade_percentage_needed: u64, } fn from_str_or_number<'de, D, T>(deserializer: D) -> Result @@ -240,10 +235,6 @@ impl ExecutionConfig { fn default_epoch_time_length_s() -> u64 { 788400 } - - fn default_protocol_version_upgrade_percentage_needed() -> u64 { - 75 - } } impl PlatformConfig { @@ -326,8 +317,6 @@ impl Default for ExecutionConfig { validator_set_rotation_block_count: ExecutionConfig::default_validator_set_rotation_block_count(), epoch_time_length_s: ExecutionConfig::default_epoch_time_length_s(), - protocol_version_upgrade_percentage_needed: - Self::default_protocol_version_upgrade_percentage_needed(), } } } diff --git a/packages/rs-drive-abci/src/execution/engine/run_block_proposal/mod.rs b/packages/rs-drive-abci/src/execution/engine/run_block_proposal/mod.rs index 533e796a9d9..7a766b14f6c 100644 --- a/packages/rs-drive-abci/src/execution/engine/run_block_proposal/mod.rs +++ b/packages/rs-drive-abci/src/execution/engine/run_block_proposal/mod.rs @@ -74,13 +74,7 @@ where Please update your software to the latest version: https://docs.dash.org/platform-protocol-upgrade -{}% of evo masternodes voted to upgrade for the network protocol version from {} to {next_protocol_version}. - Your software version: {}, latest supported protocol version: {}."#, - self.config - .execution - .protocol_version_upgrade_percentage_needed, - last_committed_platform_version.protocol_version, env!("CARGO_PKG_VERSION"), PlatformVersion::latest().protocol_version ); diff --git a/packages/rs-drive-abci/src/execution/platform_events/protocol_upgrade/check_for_desired_protocol_upgrade/mod.rs b/packages/rs-drive-abci/src/execution/platform_events/protocol_upgrade/check_for_desired_protocol_upgrade/mod.rs index c6128d16e28..33805f31251 100644 --- a/packages/rs-drive-abci/src/execution/platform_events/protocol_upgrade/check_for_desired_protocol_upgrade/mod.rs +++ b/packages/rs-drive-abci/src/execution/platform_events/protocol_upgrade/check_for_desired_protocol_upgrade/mod.rs @@ -38,7 +38,7 @@ impl Platform { .protocol_upgrade .check_for_desired_protocol_upgrade { - 0 => self.check_for_desired_protocol_upgrade_v0(total_hpmns), + 0 => self.check_for_desired_protocol_upgrade_v0(total_hpmns, platform_version), version => Err(Error::Execution(ExecutionError::UnknownVersionMismatch { method: "check_for_desired_protocol_upgrade".to_string(), known_versions: vec![0], diff --git a/packages/rs-drive-abci/src/execution/platform_events/protocol_upgrade/check_for_desired_protocol_upgrade/v0/mod.rs b/packages/rs-drive-abci/src/execution/platform_events/protocol_upgrade/check_for_desired_protocol_upgrade/v0/mod.rs index e7ff73bd226..107a55bb878 100644 --- a/packages/rs-drive-abci/src/execution/platform_events/protocol_upgrade/check_for_desired_protocol_upgrade/v0/mod.rs +++ b/packages/rs-drive-abci/src/execution/platform_events/protocol_upgrade/check_for_desired_protocol_upgrade/v0/mod.rs @@ -2,6 +2,7 @@ use crate::error::execution::ExecutionError; use crate::error::Error; use crate::platform_types::platform::Platform; +use dpp::version::PlatformVersion; use drive::dpp::util::deserializer::ProtocolVersion; impl Platform { @@ -10,14 +11,17 @@ impl Platform { pub(super) fn check_for_desired_protocol_upgrade_v0( &self, total_hpmns: u32, + platform_version: &PlatformVersion, ) -> Result, Error> { - let required_upgraded_hpns = 1 + let upgrade_percentage_needed = platform_version + .drive_abci + .methods + .protocol_upgrade + .protocol_version_upgrade_percentage_needed; + + let required_upgraded_hpmns = 1 + (total_hpmns as u64) - .checked_mul( - self.config - .execution - .protocol_version_upgrade_percentage_needed, - ) + .checked_mul(upgrade_percentage_needed) .and_then(|product| product.checked_div(100)) .ok_or(Error::Execution(ExecutionError::Overflow( "overflow for required block count", @@ -27,7 +31,7 @@ impl Platform { // were on the future version let protocol_versions_counter = self.drive.cache.protocol_versions_counter.read(); let mut versions_passing_threshold = - protocol_versions_counter.versions_passing_threshold(required_upgraded_hpns); + protocol_versions_counter.versions_passing_threshold(required_upgraded_hpmns); drop(protocol_versions_counter); if versions_passing_threshold.len() > 1 { diff --git a/packages/rs-drive-abci/tests/strategy_tests/upgrade_fork_tests.rs b/packages/rs-drive-abci/tests/strategy_tests/upgrade_fork_tests.rs index 24c4225385e..b2d4e512146 100644 --- a/packages/rs-drive-abci/tests/strategy_tests/upgrade_fork_tests.rs +++ b/packages/rs-drive-abci/tests/strategy_tests/upgrade_fork_tests.rs @@ -16,8 +16,11 @@ mod tests { use drive_abci::mimic::MimicExecuteBlockOptions; use drive_abci::platform_types::platform_state::v0::PlatformStateV0Methods; use drive_abci::test::helpers::setup::TestPlatformBuilder; - use platform_version::version::mocks::v2_test::TEST_PROTOCOL_VERSION_2; - use platform_version::version::mocks::v3_test::TEST_PROTOCOL_VERSION_3; + use platform_version::version::mocks::v2_test::{TEST_PLATFORM_V2, TEST_PROTOCOL_VERSION_2}; + use platform_version::version::mocks::v3_test::{TEST_PLATFORM_V3, TEST_PROTOCOL_VERSION_3}; + use platform_version::version::mocks::TEST_PROTOCOL_VERSION_SHIFT_BYTES; + use platform_version::version::v1::{PLATFORM_V1, PROTOCOL_VERSION_1}; + use platform_version::version::PLATFORM_TEST_VERSIONS; use strategy_tests::frequency::Frequency; use strategy_tests::{IdentityInsertInfo, StartIdentities, Strategy}; @@ -501,10 +504,27 @@ mod tests { #[test] fn run_chain_on_epoch_change_with_new_version_and_removing_votes() { + // Add a new version to upgrade to new protocol version only with one vote + const TEST_PROTOCOL_VERSION_4_WITH_1_HPMN_UPGRADE: u32 = + (1 << TEST_PROTOCOL_VERSION_SHIFT_BYTES) + 4; + + let mut test_platform_v4 = PLATFORM_V1.clone(); + test_platform_v4 + .drive_abci + .methods + .protocol_upgrade + .protocol_version_upgrade_percentage_needed = 1; + + PlatformVersion::replace_test_versions(vec![ + TEST_PLATFORM_V2, + TEST_PLATFORM_V3, + test_platform_v4, + ]); + let strategy = NetworkStrategy { total_hpmns: 50, upgrading_info: Some(UpgradingInfo { - current_protocol_version: 1, + current_protocol_version: TEST_PROTOCOL_VERSION_4_WITH_1_HPMN_UPGRADE, proposed_protocol_versions_with_weight: vec![(TEST_PROTOCOL_VERSION_2, 1)], upgrade_three_quarters_life: 0.0, }), @@ -526,11 +546,10 @@ mod tests { let config = PlatformConfig { validator_set_quorum_size: 30, execution: ExecutionConfig { - // Upgrade to new version even we have only one vote - protocol_version_upgrade_percentage_needed: 1, epoch_time_length_s, ..Default::default() }, + initial_protocol_version: TEST_PROTOCOL_VERSION_4_WITH_1_HPMN_UPGRADE, block_spacing_ms: epoch_time_length_s * 1000, testing_configs: PlatformTestConfig::default_with_no_block_signing(), ..Default::default() @@ -555,12 +574,24 @@ mod tests { let counter = platform.drive.cache.protocol_versions_counter.read(); assert_eq!(state.last_committed_block_epoch().index, 0); - assert_eq!(state.current_protocol_version_in_consensus(), 1); - assert_eq!(state.next_epoch_protocol_version(), 1); + assert_eq!( + state.current_protocol_version_in_consensus(), + TEST_PROTOCOL_VERSION_4_WITH_1_HPMN_UPGRADE + ); + assert_eq!( + state.next_epoch_protocol_version(), + TEST_PROTOCOL_VERSION_4_WITH_1_HPMN_UPGRADE + ); assert_eq!(state.last_committed_core_height(), 2); assert_eq!(counter.get(&1).unwrap(), None); assert_eq!(counter.get(&TEST_PROTOCOL_VERSION_2).unwrap(), Some(&1)); assert_eq!(counter.get(&TEST_PROTOCOL_VERSION_3).unwrap(), None); + assert_eq!( + counter + .get(&TEST_PROTOCOL_VERSION_4_WITH_1_HPMN_UPGRADE) + .unwrap(), + None + ); drop(counter); @@ -620,7 +651,10 @@ mod tests { let counter = platform.drive.cache.protocol_versions_counter.read(); assert_eq!(state.last_committed_block_epoch().index, 1); - assert_eq!(state.current_protocol_version_in_consensus(), 1); + assert_eq!( + state.current_protocol_version_in_consensus(), + TEST_PROTOCOL_VERSION_4_WITH_1_HPMN_UPGRADE + ); assert_eq!(state.next_epoch_protocol_version(), TEST_PROTOCOL_VERSION_2); assert_eq!(counter.get(&1).unwrap(), None); assert_eq!(counter.get(&TEST_PROTOCOL_VERSION_2).unwrap(), None); diff --git a/packages/rs-platform-version/src/version/drive_abci_versions.rs b/packages/rs-platform-version/src/version/drive_abci_versions.rs index 28c865a314e..b077c3e70bf 100644 --- a/packages/rs-platform-version/src/version/drive_abci_versions.rs +++ b/packages/rs-platform-version/src/version/drive_abci_versions.rs @@ -277,6 +277,7 @@ pub struct DriveAbciIdentityCreditWithdrawalMethodVersions { pub struct DriveAbciProtocolUpgradeMethodVersions { pub check_for_desired_protocol_upgrade: FeatureVersion, pub upgrade_protocol_version_on_epoch_change: FeatureVersion, + pub protocol_version_upgrade_percentage_needed: u64, } #[derive(Clone, Debug, Default)] diff --git a/packages/rs-platform-version/src/version/mocks/mod.rs b/packages/rs-platform-version/src/version/mocks/mod.rs index dd77c1a8ef9..aef47dea3d5 100644 --- a/packages/rs-platform-version/src/version/mocks/mod.rs +++ b/packages/rs-platform-version/src/version/mocks/mod.rs @@ -1,4 +1,4 @@ pub mod v2_test; pub mod v3_test; -pub(crate) const TEST_BYTES: u32 = 28; +pub const TEST_PROTOCOL_VERSION_SHIFT_BYTES: u32 = 28; 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 ee85356256e..4160215e6cb 100644 --- a/packages/rs-platform-version/src/version/mocks/v2_test.rs +++ b/packages/rs-platform-version/src/version/mocks/v2_test.rs @@ -67,13 +67,13 @@ use crate::version::drive_versions::{ DriveVerifyStateTransitionMethodVersions, DriveVerifySystemMethodVersions, DriveVersion, }; use crate::version::fee::v1::FEE_VERSION1; -use crate::version::mocks::TEST_BYTES; +use crate::version::mocks::TEST_PROTOCOL_VERSION_SHIFT_BYTES; use crate::version::protocol_version::{FeatureVersionBounds, PlatformVersion}; use crate::version::{AbciStructureVersion, PlatformArchitectureVersion}; -pub const TEST_PROTOCOL_VERSION_2: u32 = (1 << TEST_BYTES) + 2; +pub const TEST_PROTOCOL_VERSION_2: u32 = (1 << TEST_PROTOCOL_VERSION_SHIFT_BYTES) + 2; -pub(crate) const TEST_PLATFORM_V2: PlatformVersion = PlatformVersion { +pub const TEST_PLATFORM_V2: PlatformVersion = PlatformVersion { protocol_version: TEST_PROTOCOL_VERSION_2, identity: FeatureVersionBounds { min_version: 0, @@ -532,6 +532,7 @@ pub(crate) const TEST_PLATFORM_V2: PlatformVersion = PlatformVersion { protocol_upgrade: DriveAbciProtocolUpgradeMethodVersions { check_for_desired_protocol_upgrade: 0, upgrade_protocol_version_on_epoch_change: 0, + protocol_version_upgrade_percentage_needed: 75, }, block_fee_processing: DriveAbciBlockFeeProcessingMethodVersions { add_process_epoch_change_operations: 0, 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 b3f2555d3c5..22097660855 100644 --- a/packages/rs-platform-version/src/version/mocks/v3_test.rs +++ b/packages/rs-platform-version/src/version/mocks/v3_test.rs @@ -67,13 +67,13 @@ use crate::version::drive_versions::{ DriveVerifyStateTransitionMethodVersions, DriveVerifySystemMethodVersions, DriveVersion, }; use crate::version::fee::v1::FEE_VERSION1; -use crate::version::mocks::TEST_BYTES; +use crate::version::mocks::TEST_PROTOCOL_VERSION_SHIFT_BYTES; use crate::version::protocol_version::{FeatureVersionBounds, PlatformVersion}; use crate::version::{AbciStructureVersion, PlatformArchitectureVersion}; -pub const TEST_PROTOCOL_VERSION_3: u32 = (1 << TEST_BYTES) + 3; +pub const TEST_PROTOCOL_VERSION_3: u32 = (1 << TEST_PROTOCOL_VERSION_SHIFT_BYTES) + 3; -pub(crate) const TEST_PLATFORM_V3: PlatformVersion = PlatformVersion { +pub const TEST_PLATFORM_V3: PlatformVersion = PlatformVersion { protocol_version: TEST_PROTOCOL_VERSION_3, identity: FeatureVersionBounds { min_version: 0, @@ -532,6 +532,7 @@ pub(crate) const TEST_PLATFORM_V3: PlatformVersion = PlatformVersion { protocol_upgrade: DriveAbciProtocolUpgradeMethodVersions { check_for_desired_protocol_upgrade: 0, upgrade_protocol_version_on_epoch_change: 0, + protocol_version_upgrade_percentage_needed: 75, }, block_fee_processing: DriveAbciBlockFeeProcessingMethodVersions { add_process_epoch_change_operations: 0, diff --git a/packages/rs-platform-version/src/version/mod.rs b/packages/rs-platform-version/src/version/mod.rs index 05864c0c9ea..b09b4a72779 100644 --- a/packages/rs-platform-version/src/version/mod.rs +++ b/packages/rs-platform-version/src/version/mod.rs @@ -1,5 +1,7 @@ mod protocol_version; +use crate::version::v1::PROTOCOL_VERSION_1; pub use protocol_version::*; + pub mod contracts; pub mod dpp_versions; pub mod drive_abci_versions; @@ -7,6 +9,6 @@ pub mod drive_versions; pub mod fee; #[cfg(feature = "mock-versions")] pub mod mocks; -mod v1; +pub mod v1; -pub const LATEST_VERSION: u32 = 1; +pub const LATEST_VERSION: u32 = PROTOCOL_VERSION_1; diff --git a/packages/rs-platform-version/src/version/protocol_version.rs b/packages/rs-platform-version/src/version/protocol_version.rs index 527964f17ac..a7b3b1f0973 100644 --- a/packages/rs-platform-version/src/version/protocol_version.rs +++ b/packages/rs-platform-version/src/version/protocol_version.rs @@ -9,8 +9,10 @@ use crate::version::mocks::v2_test::TEST_PLATFORM_V2; #[cfg(feature = "mock-versions")] use crate::version::mocks::v3_test::TEST_PLATFORM_V3; #[cfg(feature = "mock-versions")] -use crate::version::mocks::TEST_BYTES; +use crate::version::mocks::TEST_PROTOCOL_VERSION_SHIFT_BYTES; use crate::version::v1::PLATFORM_V1; +#[cfg(feature = "mock-versions")] +use std::sync::OnceLock; pub type FeatureVersion = u16; pub type OptionalFeatureVersion = Option; //This is a feature that didn't always exist @@ -57,7 +59,10 @@ pub struct PlatformVersion { pub const PLATFORM_VERSIONS: &[PlatformVersion] = &[PLATFORM_V1]; #[cfg(feature = "mock-versions")] -pub const PLATFORM_TEST_VERSIONS: &[PlatformVersion] = &[TEST_PLATFORM_V2, TEST_PLATFORM_V3]; //this starts at 2 +// We use OnceLock to be able to modify the version mocks +pub static PLATFORM_TEST_VERSIONS: OnceLock> = OnceLock::new(); +#[cfg(feature = "mock-versions")] +const DEFAULT_PLATFORM_TEST_VERSIONS: &[PlatformVersion] = &[TEST_PLATFORM_V2, TEST_PLATFORM_V3]; pub const LATEST_PLATFORM_VERSION: &PlatformVersion = &PLATFORM_V1; @@ -66,9 +71,14 @@ impl PlatformVersion { if version > 0 { #[cfg(feature = "mock-versions")] { - if version >> TEST_BYTES > 0 { - let test_version = version - (1 << TEST_BYTES); - return PLATFORM_TEST_VERSIONS.get(test_version as usize - 2).ok_or( + if version >> TEST_PROTOCOL_VERSION_SHIFT_BYTES > 0 { + let test_version = version - (1 << TEST_PROTOCOL_VERSION_SHIFT_BYTES); + + // Init default set of test versions + let versions = PLATFORM_TEST_VERSIONS + .get_or_init(|| vec![TEST_PLATFORM_V2, TEST_PLATFORM_V3]); + + return versions.get(test_version as usize - 2).ok_or( PlatformVersionError::UnknownVersionError(format!( "no test platform version {test_version}" )), @@ -92,9 +102,14 @@ impl PlatformVersion { if version > 0 { #[cfg(feature = "mock-versions")] { - if version >> TEST_BYTES > 0 { - let test_version = version - (1 << TEST_BYTES); - return PLATFORM_TEST_VERSIONS.get(test_version as usize - 2).ok_or( + if version >> TEST_PROTOCOL_VERSION_SHIFT_BYTES > 0 { + let test_version = version - (1 << TEST_PROTOCOL_VERSION_SHIFT_BYTES); + + // Init default set of test versions + let versions = PLATFORM_TEST_VERSIONS + .get_or_init(|| Vec::from(DEFAULT_PLATFORM_TEST_VERSIONS)); + + return versions.get(test_version as usize - 2).ok_or( PlatformVersionError::UnknownVersionError(format!( "no test platform version {test_version}" )), @@ -127,4 +142,12 @@ impl PlatformVersion { .last() .expect("expected to have a platform version") } + + #[cfg(feature = "mock-versions")] + /// Set mock versions for testing + pub fn replace_test_versions(versions: Vec) { + PLATFORM_TEST_VERSIONS + .set(versions) + .expect("failed to set test versions") + } } diff --git a/packages/rs-platform-version/src/version/v1.rs b/packages/rs-platform-version/src/version/v1.rs index 33c84dcab3d..2cc0a44f0cd 100644 --- a/packages/rs-platform-version/src/version/v1.rs +++ b/packages/rs-platform-version/src/version/v1.rs @@ -70,7 +70,9 @@ use crate::version::fee::v1::FEE_VERSION1; use crate::version::protocol_version::{FeatureVersionBounds, PlatformVersion}; use crate::version::{AbciStructureVersion, PlatformArchitectureVersion}; -pub(super) const PLATFORM_V1: PlatformVersion = PlatformVersion { +pub const PROTOCOL_VERSION_1: u32 = 1; + +pub const PLATFORM_V1: PlatformVersion = PlatformVersion { protocol_version: 1, identity: FeatureVersionBounds { min_version: 0, @@ -529,6 +531,7 @@ pub(super) const PLATFORM_V1: PlatformVersion = PlatformVersion { protocol_upgrade: DriveAbciProtocolUpgradeMethodVersions { check_for_desired_protocol_upgrade: 0, upgrade_protocol_version_on_epoch_change: 0, + protocol_version_upgrade_percentage_needed: 75, }, block_fee_processing: DriveAbciBlockFeeProcessingMethodVersions { add_process_epoch_change_operations: 0, From 90c52f83fe6d3a9b06d5d38b5147f306085a0ccd Mon Sep 17 00:00:00 2001 From: Ivan Shumkov Date: Tue, 2 Apr 2024 20:47:02 +0700 Subject: [PATCH 34/37] test: update app hashes --- packages/rs-drive-abci/tests/strategy_tests/main.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/rs-drive-abci/tests/strategy_tests/main.rs b/packages/rs-drive-abci/tests/strategy_tests/main.rs index cf55e3b4314..c97b8440925 100644 --- a/packages/rs-drive-abci/tests/strategy_tests/main.rs +++ b/packages/rs-drive-abci/tests/strategy_tests/main.rs @@ -554,7 +554,7 @@ mod tests { .expect("expected to fetch balances") .expect("expected to have an identity to get balance from"); - assert_eq!(balance, 99864829780) + assert_eq!(balance, 99864825980) } #[test] @@ -1144,7 +1144,7 @@ mod tests { .unwrap() .unwrap() ), - "cac443b056272dbaea24692701b49e3679ec0385d68c5810d84d2b0e537f5e4d".to_string() + "2d950355e6d8ddc3a726b211d68f79cc2d5c77a3c190b640c4ac08a00920a9b3".to_string() ) } @@ -1833,7 +1833,7 @@ mod tests { .unwrap() .unwrap() ), - "b964833c32c75719fe07f145aa20cc22e11279b5b34eae6381b7944c5b4f4623".to_string() + "de824122516f3c5cab93615569bacdb1c8ec64be99079578ef41168dcec1b7b4".to_string() ) } @@ -1958,7 +1958,7 @@ mod tests { .unwrap() .unwrap() ), - "01fe378cc38613821a09e18a16008a6f9f2c9a2a32f87b001ce35777a284bf01".to_string() + "437045e9befa9e532b65aa890e11fe98eb15d3fd95130a92504378d45f9e2a4a".to_string() ) } From 1e17b598924f1f086c5bd8e7c6e2448a7d4575f1 Mon Sep 17 00:00:00 2001 From: Ivan Shumkov Date: Thu, 4 Apr 2024 15:18:43 +0700 Subject: [PATCH 35/37] docs: fix typo in comments --- .../src/drive/verify/system/verify_epoch_infos/v0/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/rs-drive/src/drive/verify/system/verify_epoch_infos/v0/mod.rs b/packages/rs-drive/src/drive/verify/system/verify_epoch_infos/v0/mod.rs index 931eacd9750..23ff53e6f44 100644 --- a/packages/rs-drive/src/drive/verify/system/verify_epoch_infos/v0/mod.rs +++ b/packages/rs-drive/src/drive/verify/system/verify_epoch_infos/v0/mod.rs @@ -78,7 +78,7 @@ impl Drive { query.set_subquery(subquery); let path_query = PathQuery::new( pools_vec_path(), - // The multipler must be equal to requested keys count + // The multiplier must be equal to requested keys count SizedQuery::new(query, Some(count * 5), None), ); From ecd6e3114f0b973fc77b87323345ea15b140e690 Mon Sep 17 00:00:00 2001 From: Ivan Shumkov Date: Thu, 4 Apr 2024 19:13:06 +0700 Subject: [PATCH 36/37] test(sdk): update epoch info fixtures --- .../platform/v0/nodejs/platform_pbjs.js | 22 ++++++++++++ .../platform/v0/nodejs/platform_protoc.js | 32 +++++++++++++++++- .../platform/v0/objective-c/Platform.pbobjc.h | 3 ++ .../platform/v0/objective-c/Platform.pbobjc.m | 11 ++++++ .../platform/v0/python/platform_pb2.py | 19 +++++++---- .../clients/platform/v0/web/platform_pb.d.ts | 4 +++ .../clients/platform/v0/web/platform_pb.js | 32 +++++++++++++++++- ...776113debe4287515ae60d0645da450a80a1.json} | Bin 21965 -> 21988 bytes ...caf3663c40a12d3b03827006d66058e439ac.json} | Bin 1466417 -> 1466607 bytes ...bc8321622c21e4a2874ab7e481c6267201326.json | 1 + ...db039bd8eba37530edf9202046cf912eb8efd.json | 1 - ...776113debe4287515ae60d0645da450a80a1.json} | Bin 21965 -> 21988 bytes ...7089535588985622579e77969e0ffd68afc7.json} | Bin 21003 -> 21192 bytes ...bc8321622c21e4a2874ab7e481c6267201326.json | 1 + ...db039bd8eba37530edf9202046cf912eb8efd.json | 1 - ...776113debe4287515ae60d0645da450a80a1.json} | Bin 21965 -> 21988 bytes ...dd01a7428085ffdcf1e11cccf19c48c5f7a1.json} | Bin 2668627 -> 2668623 bytes ...bc8321622c21e4a2874ab7e481c6267201326.json | 1 + ...db039bd8eba37530edf9202046cf912eb8efd.json | 1 - 19 files changed, 118 insertions(+), 11 deletions(-) rename packages/rs-sdk/tests/vectors/test_epoch_fetch/{msg_2024-03-18T17:30:02.266794754Z_GetIdentityRequest_e4060c14ceaca6844d682c7393d7776113debe4287515ae60d0645da450a80a1.json => msg_2024-04-04T11:53:53.893159000Z_GetIdentityRequest_e4060c14ceaca6844d682c7393d7776113debe4287515ae60d0645da450a80a1.json} (78%) rename packages/rs-sdk/tests/vectors/test_epoch_fetch/{msg_2024-03-18T17:30:02.329977013Z_GetEpochsInfoRequest_b2b426ac4a52cb4cb08904c63386caf3663c40a12d3b03827006d66058e439ac.json => msg_2024-04-04T11:53:53.980843000Z_GetEpochsInfoRequest_b2b426ac4a52cb4cb08904c63386caf3663c40a12d3b03827006d66058e439ac.json} (99%) create mode 100644 packages/rs-sdk/tests/vectors/test_epoch_fetch/quorum_pubkey-106-2ca9a9abc345b3e592538a9ceb7bc8321622c21e4a2874ab7e481c6267201326.json delete mode 100644 packages/rs-sdk/tests/vectors/test_epoch_fetch/quorum_pubkey-106-7f5ab83561a836a5460dd8e6164db039bd8eba37530edf9202046cf912eb8efd.json rename packages/rs-sdk/tests/vectors/{test_epoch_fetch_future/msg_2024-03-18T17:30:02.315343769Z_GetIdentityRequest_e4060c14ceaca6844d682c7393d7776113debe4287515ae60d0645da450a80a1.json => test_epoch_fetch_current/msg_2024-04-04T11:53:53.893143000Z_GetIdentityRequest_e4060c14ceaca6844d682c7393d7776113debe4287515ae60d0645da450a80a1.json} (78%) rename packages/rs-sdk/tests/vectors/test_epoch_fetch_current/{msg_2024-03-18T17:30:02.282004524Z_GetEpochsInfoRequest_1b87e649557ccb609adb9e2904c67089535588985622579e77969e0ffd68afc7.json => msg_2024-04-04T11:53:53.901498000Z_GetEpochsInfoRequest_1b87e649557ccb609adb9e2904c67089535588985622579e77969e0ffd68afc7.json} (85%) create mode 100644 packages/rs-sdk/tests/vectors/test_epoch_fetch_current/quorum_pubkey-106-2ca9a9abc345b3e592538a9ceb7bc8321622c21e4a2874ab7e481c6267201326.json delete mode 100644 packages/rs-sdk/tests/vectors/test_epoch_fetch_current/quorum_pubkey-106-7f5ab83561a836a5460dd8e6164db039bd8eba37530edf9202046cf912eb8efd.json rename packages/rs-sdk/tests/vectors/{test_epoch_fetch_current/msg_2024-03-18T17:30:02.275436110Z_GetIdentityRequest_e4060c14ceaca6844d682c7393d7776113debe4287515ae60d0645da450a80a1.json => test_epoch_fetch_future/msg_2024-04-04T11:53:53.893142000Z_GetIdentityRequest_e4060c14ceaca6844d682c7393d7776113debe4287515ae60d0645da450a80a1.json} (78%) rename packages/rs-sdk/tests/vectors/test_epoch_fetch_future/{msg_2024-03-18T17:30:02.797274401Z_GetEpochsInfoRequest_6a828350e795a088dbc835260a1add01a7428085ffdcf1e11cccf19c48c5f7a1.json => msg_2024-04-04T11:53:54.194677000Z_GetEpochsInfoRequest_6a828350e795a088dbc835260a1add01a7428085ffdcf1e11cccf19c48c5f7a1.json} (99%) create mode 100644 packages/rs-sdk/tests/vectors/test_epoch_fetch_future/quorum_pubkey-106-2ca9a9abc345b3e592538a9ceb7bc8321622c21e4a2874ab7e481c6267201326.json delete mode 100644 packages/rs-sdk/tests/vectors/test_epoch_fetch_future/quorum_pubkey-106-7f5ab83561a836a5460dd8e6164db039bd8eba37530edf9202046cf912eb8efd.json diff --git a/packages/dapi-grpc/clients/platform/v0/nodejs/platform_pbjs.js b/packages/dapi-grpc/clients/platform/v0/nodejs/platform_pbjs.js index ade9877c11e..f14e6503e25 100644 --- a/packages/dapi-grpc/clients/platform/v0/nodejs/platform_pbjs.js +++ b/packages/dapi-grpc/clients/platform/v0/nodejs/platform_pbjs.js @@ -25767,6 +25767,7 @@ $root.org = (function() { * @property {number|null} [firstCoreBlockHeight] EpochInfo firstCoreBlockHeight * @property {number|Long|null} [startTime] EpochInfo startTime * @property {number|null} [feeMultiplier] EpochInfo feeMultiplier + * @property {number|null} [protocolVersion] EpochInfo protocolVersion */ /** @@ -25824,6 +25825,14 @@ $root.org = (function() { */ EpochInfo.prototype.feeMultiplier = 0; + /** + * EpochInfo protocolVersion. + * @member {number} protocolVersion + * @memberof org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.EpochInfo + * @instance + */ + EpochInfo.prototype.protocolVersion = 0; + /** * Creates a new EpochInfo instance using the specified properties. * @function create @@ -25858,6 +25867,8 @@ $root.org = (function() { writer.uint32(/* id 4, wireType 0 =*/32).uint64(message.startTime); if (message.feeMultiplier != null && Object.hasOwnProperty.call(message, "feeMultiplier")) writer.uint32(/* id 5, wireType 1 =*/41).double(message.feeMultiplier); + if (message.protocolVersion != null && Object.hasOwnProperty.call(message, "protocolVersion")) + writer.uint32(/* id 6, wireType 0 =*/48).uint32(message.protocolVersion); return writer; }; @@ -25907,6 +25918,9 @@ $root.org = (function() { case 5: message.feeMultiplier = reader.double(); break; + case 6: + message.protocolVersion = reader.uint32(); + break; default: reader.skipType(tag & 7); break; @@ -25957,6 +25971,9 @@ $root.org = (function() { if (message.feeMultiplier != null && message.hasOwnProperty("feeMultiplier")) if (typeof message.feeMultiplier !== "number") return "feeMultiplier: number expected"; + if (message.protocolVersion != null && message.hasOwnProperty("protocolVersion")) + if (!$util.isInteger(message.protocolVersion)) + return "protocolVersion: integer expected"; return null; }; @@ -25996,6 +26013,8 @@ $root.org = (function() { message.startTime = new $util.LongBits(object.startTime.low >>> 0, object.startTime.high >>> 0).toNumber(true); if (object.feeMultiplier != null) message.feeMultiplier = Number(object.feeMultiplier); + if (object.protocolVersion != null) + message.protocolVersion = object.protocolVersion >>> 0; return message; }; @@ -26026,6 +26045,7 @@ $root.org = (function() { } else object.startTime = options.longs === String ? "0" : 0; object.feeMultiplier = 0; + object.protocolVersion = 0; } if (message.number != null && message.hasOwnProperty("number")) object.number = message.number; @@ -26043,6 +26063,8 @@ $root.org = (function() { object.startTime = options.longs === String ? $util.Long.prototype.toString.call(message.startTime) : options.longs === Number ? new $util.LongBits(message.startTime.low >>> 0, message.startTime.high >>> 0).toNumber(true) : message.startTime; if (message.feeMultiplier != null && message.hasOwnProperty("feeMultiplier")) object.feeMultiplier = options.json && !isFinite(message.feeMultiplier) ? String(message.feeMultiplier) : message.feeMultiplier; + if (message.protocolVersion != null && message.hasOwnProperty("protocolVersion")) + object.protocolVersion = message.protocolVersion; return object; }; diff --git a/packages/dapi-grpc/clients/platform/v0/nodejs/platform_protoc.js b/packages/dapi-grpc/clients/platform/v0/nodejs/platform_protoc.js index 13ebdab3553..e7495b46c10 100644 --- a/packages/dapi-grpc/clients/platform/v0/nodejs/platform_protoc.js +++ b/packages/dapi-grpc/clients/platform/v0/nodejs/platform_protoc.js @@ -24494,7 +24494,8 @@ proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.Ep firstBlockHeight: jspb.Message.getFieldWithDefault(msg, 2, 0), firstCoreBlockHeight: jspb.Message.getFieldWithDefault(msg, 3, 0), startTime: jspb.Message.getFieldWithDefault(msg, 4, 0), - feeMultiplier: jspb.Message.getFloatingPointFieldWithDefault(msg, 5, 0.0) + feeMultiplier: jspb.Message.getFloatingPointFieldWithDefault(msg, 5, 0.0), + protocolVersion: jspb.Message.getFieldWithDefault(msg, 6, 0) }; if (includeInstance) { @@ -24551,6 +24552,10 @@ proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.Ep var value = /** @type {number} */ (reader.readDouble()); msg.setFeeMultiplier(value); break; + case 6: + var value = /** @type {number} */ (reader.readUint32()); + msg.setProtocolVersion(value); + break; default: reader.skipField(); break; @@ -24615,6 +24620,13 @@ proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.Ep f ); } + f = message.getProtocolVersion(); + if (f !== 0) { + writer.writeUint32( + 6, + f + ); + } }; @@ -24708,6 +24720,24 @@ proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.Ep }; +/** + * optional uint32 protocol_version = 6; + * @return {number} + */ +proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.EpochInfo.prototype.getProtocolVersion = function() { + return /** @type {number} */ (jspb.Message.getFieldWithDefault(this, 6, 0)); +}; + + +/** + * @param {number} value + * @return {!proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.EpochInfo} returns this + */ +proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.EpochInfo.prototype.setProtocolVersion = function(value) { + return jspb.Message.setProto3IntField(this, 6, value); +}; + + /** * optional EpochInfos epochs = 1; * @return {?proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.EpochInfos} diff --git a/packages/dapi-grpc/clients/platform/v0/objective-c/Platform.pbobjc.h b/packages/dapi-grpc/clients/platform/v0/objective-c/Platform.pbobjc.h index ad06a695c53..b4c0745c8bf 100644 --- a/packages/dapi-grpc/clients/platform/v0/objective-c/Platform.pbobjc.h +++ b/packages/dapi-grpc/clients/platform/v0/objective-c/Platform.pbobjc.h @@ -2575,6 +2575,7 @@ typedef GPB_ENUM(GetEpochsInfoResponse_GetEpochsInfoResponseV0_EpochInfo_FieldNu GetEpochsInfoResponse_GetEpochsInfoResponseV0_EpochInfo_FieldNumber_FirstCoreBlockHeight = 3, GetEpochsInfoResponse_GetEpochsInfoResponseV0_EpochInfo_FieldNumber_StartTime = 4, GetEpochsInfoResponse_GetEpochsInfoResponseV0_EpochInfo_FieldNumber_FeeMultiplier = 5, + GetEpochsInfoResponse_GetEpochsInfoResponseV0_EpochInfo_FieldNumber_ProtocolVersion = 6, }; GPB_FINAL @interface GetEpochsInfoResponse_GetEpochsInfoResponseV0_EpochInfo : GPBMessage @@ -2589,6 +2590,8 @@ GPB_FINAL @interface GetEpochsInfoResponse_GetEpochsInfoResponseV0_EpochInfo : G @property(nonatomic, readwrite) double feeMultiplier; +@property(nonatomic, readwrite) uint32_t protocolVersion; + @end NS_ASSUME_NONNULL_END diff --git a/packages/dapi-grpc/clients/platform/v0/objective-c/Platform.pbobjc.m b/packages/dapi-grpc/clients/platform/v0/objective-c/Platform.pbobjc.m index efdb83c3591..35feedfec3b 100644 --- a/packages/dapi-grpc/clients/platform/v0/objective-c/Platform.pbobjc.m +++ b/packages/dapi-grpc/clients/platform/v0/objective-c/Platform.pbobjc.m @@ -6926,11 +6926,13 @@ @implementation GetEpochsInfoResponse_GetEpochsInfoResponseV0_EpochInfo @dynamic firstCoreBlockHeight; @dynamic startTime; @dynamic feeMultiplier; +@dynamic protocolVersion; typedef struct GetEpochsInfoResponse_GetEpochsInfoResponseV0_EpochInfo__storage_ { uint32_t _has_storage_[1]; uint32_t number; uint32_t firstCoreBlockHeight; + uint32_t protocolVersion; uint64_t firstBlockHeight; uint64_t startTime; double feeMultiplier; @@ -6987,6 +6989,15 @@ + (GPBDescriptor *)descriptor { .flags = (GPBFieldFlags)(GPBFieldOptional | GPBFieldClearHasIvarOnZero), .dataType = GPBDataTypeDouble, }, + { + .name = "protocolVersion", + .dataTypeSpecific.clazz = Nil, + .number = GetEpochsInfoResponse_GetEpochsInfoResponseV0_EpochInfo_FieldNumber_ProtocolVersion, + .hasIndex = 5, + .offset = (uint32_t)offsetof(GetEpochsInfoResponse_GetEpochsInfoResponseV0_EpochInfo__storage_, protocolVersion), + .flags = (GPBFieldFlags)(GPBFieldOptional | GPBFieldClearHasIvarOnZero), + .dataType = GPBDataTypeUInt32, + }, }; GPBDescriptor *localDescriptor = [GPBDescriptor allocDescriptorForClass:[GetEpochsInfoResponse_GetEpochsInfoResponseV0_EpochInfo class] diff --git a/packages/dapi-grpc/clients/platform/v0/python/platform_pb2.py b/packages/dapi-grpc/clients/platform/v0/python/platform_pb2.py index 01c84f252e6..8348a045e77 100644 --- a/packages/dapi-grpc/clients/platform/v0/python/platform_pb2.py +++ b/packages/dapi-grpc/clients/platform/v0/python/platform_pb2.py @@ -22,7 +22,7 @@ syntax='proto3', serialized_options=None, create_key=_descriptor._internal_create_key, - serialized_pb=b'\n\x0eplatform.proto\x12\x19org.dash.platform.dapi.v0\x1a\x1egoogle/protobuf/wrappers.proto\x1a\x1cgoogle/protobuf/struct.proto\x1a\x1fgoogle/protobuf/timestamp.proto\"\x81\x01\n\x05Proof\x12\x15\n\rgrovedb_proof\x18\x01 \x01(\x0c\x12\x13\n\x0bquorum_hash\x18\x02 \x01(\x0c\x12\x11\n\tsignature\x18\x03 \x01(\x0c\x12\r\n\x05round\x18\x04 \x01(\r\x12\x15\n\rblock_id_hash\x18\x05 \x01(\x0c\x12\x13\n\x0bquorum_type\x18\x06 \x01(\r\"\x90\x01\n\x10ResponseMetadata\x12\x0e\n\x06height\x18\x01 \x01(\x04\x12 \n\x18\x63ore_chain_locked_height\x18\x02 \x01(\r\x12\r\n\x05\x65poch\x18\x03 \x01(\r\x12\x0f\n\x07time_ms\x18\x04 \x01(\x04\x12\x18\n\x10protocol_version\x18\x05 \x01(\r\x12\x10\n\x08\x63hain_id\x18\x06 \x01(\t\"L\n\x1dStateTransitionBroadcastError\x12\x0c\n\x04\x63ode\x18\x01 \x01(\r\x12\x0f\n\x07message\x18\x02 \x01(\t\x12\x0c\n\x04\x64\x61ta\x18\x03 \x01(\x0c\";\n\x1f\x42roadcastStateTransitionRequest\x12\x18\n\x10state_transition\x18\x01 \x01(\x0c\"\"\n BroadcastStateTransitionResponse\"\xa4\x01\n\x12GetIdentityRequest\x12P\n\x02v0\x18\x01 \x01(\x0b\x32\x42.org.dash.platform.dapi.v0.GetIdentityRequest.GetIdentityRequestV0H\x00\x1a\x31\n\x14GetIdentityRequestV0\x12\n\n\x02id\x18\x01 \x01(\x0c\x12\r\n\x05prove\x18\x02 \x01(\x08\x42\t\n\x07version\"\xc1\x01\n\x17GetIdentityNonceRequest\x12Z\n\x02v0\x18\x01 \x01(\x0b\x32L.org.dash.platform.dapi.v0.GetIdentityNonceRequest.GetIdentityNonceRequestV0H\x00\x1a?\n\x19GetIdentityNonceRequestV0\x12\x13\n\x0bidentity_id\x18\x01 \x01(\x0c\x12\r\n\x05prove\x18\x02 \x01(\x08\x42\t\n\x07version\"\xf6\x01\n\x1fGetIdentityContractNonceRequest\x12j\n\x02v0\x18\x01 \x01(\x0b\x32\\.org.dash.platform.dapi.v0.GetIdentityContractNonceRequest.GetIdentityContractNonceRequestV0H\x00\x1a\\\n!GetIdentityContractNonceRequestV0\x12\x13\n\x0bidentity_id\x18\x01 \x01(\x0c\x12\x13\n\x0b\x63ontract_id\x18\x02 \x01(\x0c\x12\r\n\x05prove\x18\x03 \x01(\x08\x42\t\n\x07version\"\xc0\x01\n\x19GetIdentityBalanceRequest\x12^\n\x02v0\x18\x01 \x01(\x0b\x32P.org.dash.platform.dapi.v0.GetIdentityBalanceRequest.GetIdentityBalanceRequestV0H\x00\x1a\x38\n\x1bGetIdentityBalanceRequestV0\x12\n\n\x02id\x18\x01 \x01(\x0c\x12\r\n\x05prove\x18\x02 \x01(\x08\x42\t\n\x07version\"\xec\x01\n$GetIdentityBalanceAndRevisionRequest\x12t\n\x02v0\x18\x01 \x01(\x0b\x32\x66.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionRequest.GetIdentityBalanceAndRevisionRequestV0H\x00\x1a\x43\n&GetIdentityBalanceAndRevisionRequestV0\x12\n\n\x02id\x18\x01 \x01(\x0c\x12\r\n\x05prove\x18\x02 \x01(\x08\x42\t\n\x07version\"\x9e\x02\n\x13GetIdentityResponse\x12R\n\x02v0\x18\x01 \x01(\x0b\x32\x44.org.dash.platform.dapi.v0.GetIdentityResponse.GetIdentityResponseV0H\x00\x1a\xa7\x01\n\x15GetIdentityResponseV0\x12\x12\n\x08identity\x18\x01 \x01(\x0cH\x00\x12\x31\n\x05proof\x18\x02 \x01(\x0b\x32 .org.dash.platform.dapi.v0.ProofH\x00\x12=\n\x08metadata\x18\x03 \x01(\x0b\x32+.org.dash.platform.dapi.v0.ResponseMetadataB\x08\n\x06resultB\t\n\x07version\"\xad\x01\n\x14GetIdentitiesRequest\x12T\n\x02v0\x18\x01 \x01(\x0b\x32\x46.org.dash.platform.dapi.v0.GetIdentitiesRequest.GetIdentitiesRequestV0H\x00\x1a\x34\n\x16GetIdentitiesRequestV0\x12\x0b\n\x03ids\x18\x01 \x03(\x0c\x12\r\n\x05prove\x18\x02 \x01(\x08\x42\t\n\x07version\"\xda\x04\n\x15GetIdentitiesResponse\x12V\n\x02v0\x18\x01 \x01(\x0b\x32H.org.dash.platform.dapi.v0.GetIdentitiesResponse.GetIdentitiesResponseV0H\x00\x1a\x1e\n\rIdentityValue\x12\r\n\x05value\x18\x01 \x01(\x0c\x1ak\n\rIdentityEntry\x12\x0b\n\x03key\x18\x01 \x01(\x0c\x12M\n\x05value\x18\x02 \x01(\x0b\x32>.org.dash.platform.dapi.v0.GetIdentitiesResponse.IdentityValue\x1a\x66\n\nIdentities\x12X\n\x10identity_entries\x18\x01 \x03(\x0b\x32>.org.dash.platform.dapi.v0.GetIdentitiesResponse.IdentityEntry\x1a\xe8\x01\n\x17GetIdentitiesResponseV0\x12Q\n\nidentities\x18\x01 \x01(\x0b\x32;.org.dash.platform.dapi.v0.GetIdentitiesResponse.IdentitiesH\x00\x12\x31\n\x05proof\x18\x02 \x01(\x0b\x32 .org.dash.platform.dapi.v0.ProofH\x00\x12=\n\x08metadata\x18\x03 \x01(\x0b\x32+.org.dash.platform.dapi.v0.ResponseMetadataB\x08\n\x06resultB\t\n\x07version\"\xb8\x02\n\x18GetIdentityNonceResponse\x12\\\n\x02v0\x18\x01 \x01(\x0b\x32N.org.dash.platform.dapi.v0.GetIdentityNonceResponse.GetIdentityNonceResponseV0H\x00\x1a\xb2\x01\n\x1aGetIdentityNonceResponseV0\x12\x18\n\x0eidentity_nonce\x18\x01 \x01(\x04H\x00\x12\x31\n\x05proof\x18\x02 \x01(\x0b\x32 .org.dash.platform.dapi.v0.ProofH\x00\x12=\n\x08metadata\x18\x03 \x01(\x0b\x32+.org.dash.platform.dapi.v0.ResponseMetadataB\x08\n\x06resultB\t\n\x07version\"\xe1\x02\n GetIdentityContractNonceResponse\x12l\n\x02v0\x18\x01 \x01(\x0b\x32^.org.dash.platform.dapi.v0.GetIdentityContractNonceResponse.GetIdentityContractNonceResponseV0H\x00\x1a\xc3\x01\n\"GetIdentityContractNonceResponseV0\x12!\n\x17identity_contract_nonce\x18\x01 \x01(\x04H\x00\x12\x31\n\x05proof\x18\x02 \x01(\x0b\x32 .org.dash.platform.dapi.v0.ProofH\x00\x12=\n\x08metadata\x18\x03 \x01(\x0b\x32+.org.dash.platform.dapi.v0.ResponseMetadataB\x08\n\x06resultB\t\n\x07version\"\xb9\x02\n\x1aGetIdentityBalanceResponse\x12`\n\x02v0\x18\x01 \x01(\x0b\x32R.org.dash.platform.dapi.v0.GetIdentityBalanceResponse.GetIdentityBalanceResponseV0H\x00\x1a\xad\x01\n\x1cGetIdentityBalanceResponseV0\x12\x11\n\x07\x62\x61lance\x18\x01 \x01(\x04H\x00\x12\x31\n\x05proof\x18\x02 \x01(\x0b\x32 .org.dash.platform.dapi.v0.ProofH\x00\x12=\n\x08metadata\x18\x03 \x01(\x0b\x32+.org.dash.platform.dapi.v0.ResponseMetadataB\x08\n\x06resultB\t\n\x07version\"\xa9\x04\n%GetIdentityBalanceAndRevisionResponse\x12v\n\x02v0\x18\x01 \x01(\x0b\x32h.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.GetIdentityBalanceAndRevisionResponseV0H\x00\x1a\xfc\x02\n\'GetIdentityBalanceAndRevisionResponseV0\x12\x9b\x01\n\x14\x62\x61lance_and_revision\x18\x01 \x01(\x0b\x32{.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.GetIdentityBalanceAndRevisionResponseV0.BalanceAndRevisionH\x00\x12\x31\n\x05proof\x18\x02 \x01(\x0b\x32 .org.dash.platform.dapi.v0.ProofH\x00\x12=\n\x08metadata\x18\x03 \x01(\x0b\x32+.org.dash.platform.dapi.v0.ResponseMetadata\x1a\x37\n\x12\x42\x61lanceAndRevision\x12\x0f\n\x07\x62\x61lance\x18\x01 \x01(\x04\x12\x10\n\x08revision\x18\x02 \x01(\x04\x42\x08\n\x06resultB\t\n\x07version\"\xd1\x01\n\x0eKeyRequestType\x12\x36\n\x08\x61ll_keys\x18\x01 \x01(\x0b\x32\".org.dash.platform.dapi.v0.AllKeysH\x00\x12@\n\rspecific_keys\x18\x02 \x01(\x0b\x32\'.org.dash.platform.dapi.v0.SpecificKeysH\x00\x12:\n\nsearch_key\x18\x03 \x01(\x0b\x32$.org.dash.platform.dapi.v0.SearchKeyH\x00\x42\t\n\x07request\"\t\n\x07\x41llKeys\"\x1f\n\x0cSpecificKeys\x12\x0f\n\x07key_ids\x18\x01 \x03(\r\"\xb6\x01\n\tSearchKey\x12I\n\x0bpurpose_map\x18\x01 \x03(\x0b\x32\x34.org.dash.platform.dapi.v0.SearchKey.PurposeMapEntry\x1a^\n\x0fPurposeMapEntry\x12\x0b\n\x03key\x18\x01 \x01(\r\x12:\n\x05value\x18\x02 \x01(\x0b\x32+.org.dash.platform.dapi.v0.SecurityLevelMap:\x02\x38\x01\"\xbf\x02\n\x10SecurityLevelMap\x12]\n\x12security_level_map\x18\x01 \x03(\x0b\x32\x41.org.dash.platform.dapi.v0.SecurityLevelMap.SecurityLevelMapEntry\x1aw\n\x15SecurityLevelMapEntry\x12\x0b\n\x03key\x18\x01 \x01(\r\x12M\n\x05value\x18\x02 \x01(\x0e\x32>.org.dash.platform.dapi.v0.SecurityLevelMap.KeyKindRequestType:\x02\x38\x01\"S\n\x12KeyKindRequestType\x12\x1f\n\x1b\x43URRENT_KEY_OF_KIND_REQUEST\x10\x00\x12\x1c\n\x18\x41LL_KEYS_OF_KIND_REQUEST\x10\x01\"\xda\x02\n\x16GetIdentityKeysRequest\x12X\n\x02v0\x18\x01 \x01(\x0b\x32J.org.dash.platform.dapi.v0.GetIdentityKeysRequest.GetIdentityKeysRequestV0H\x00\x1a\xda\x01\n\x18GetIdentityKeysRequestV0\x12\x13\n\x0bidentity_id\x18\x01 \x01(\x0c\x12?\n\x0crequest_type\x18\x02 \x01(\x0b\x32).org.dash.platform.dapi.v0.KeyRequestType\x12+\n\x05limit\x18\x03 \x01(\x0b\x32\x1c.google.protobuf.UInt32Value\x12,\n\x06offset\x18\x04 \x01(\x0b\x32\x1c.google.protobuf.UInt32Value\x12\r\n\x05prove\x18\x05 \x01(\x08\x42\t\n\x07version\"\x99\x03\n\x17GetIdentityKeysResponse\x12Z\n\x02v0\x18\x01 \x01(\x0b\x32L.org.dash.platform.dapi.v0.GetIdentityKeysResponse.GetIdentityKeysResponseV0H\x00\x1a\x96\x02\n\x19GetIdentityKeysResponseV0\x12\x61\n\x04keys\x18\x01 \x01(\x0b\x32Q.org.dash.platform.dapi.v0.GetIdentityKeysResponse.GetIdentityKeysResponseV0.KeysH\x00\x12\x31\n\x05proof\x18\x02 \x01(\x0b\x32 .org.dash.platform.dapi.v0.ProofH\x00\x12=\n\x08metadata\x18\x03 \x01(\x0b\x32+.org.dash.platform.dapi.v0.ResponseMetadata\x1a\x1a\n\x04Keys\x12\x12\n\nkeys_bytes\x18\x01 \x03(\x0c\x42\x08\n\x06resultB\t\n\x07version\"\xa1\x06\n\x10GetProofsRequest\x12L\n\x02v0\x18\x01 \x01(\x0b\x32>.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0H\x00\x1a\xb3\x05\n\x12GetProofsRequestV0\x12\x62\n\nidentities\x18\x01 \x03(\x0b\x32N.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.IdentityRequest\x12\x61\n\tcontracts\x18\x02 \x03(\x0b\x32N.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.ContractRequest\x12\x61\n\tdocuments\x18\x03 \x03(\x0b\x32N.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.DocumentRequest\x1aw\n\x0f\x44ocumentRequest\x12\x13\n\x0b\x63ontract_id\x18\x01 \x01(\x0c\x12\x15\n\rdocument_type\x18\x02 \x01(\t\x12#\n\x1b\x64ocument_type_keeps_history\x18\x03 \x01(\x08\x12\x13\n\x0b\x64ocument_id\x18\x04 \x01(\x0c\x1a\xd1\x01\n\x0fIdentityRequest\x12\x13\n\x0bidentity_id\x18\x01 \x01(\x0c\x12i\n\x0crequest_type\x18\x02 \x01(\x0e\x32S.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.IdentityRequest.Type\">\n\x04Type\x12\x11\n\rFULL_IDENTITY\x10\x00\x12\x0b\n\x07\x42\x41LANCE\x10\x01\x12\x08\n\x04KEYS\x10\x02\x12\x0c\n\x08REVISION\x10\x03\x1a&\n\x0f\x43ontractRequest\x12\x13\n\x0b\x63ontract_id\x18\x01 \x01(\x0c\x42\t\n\x07version\"\x82\x02\n\x11GetProofsResponse\x12N\n\x02v0\x18\x01 \x01(\x0b\x32@.org.dash.platform.dapi.v0.GetProofsResponse.GetProofsResponseV0H\x00\x1a\x91\x01\n\x13GetProofsResponseV0\x12\x31\n\x05proof\x18\x01 \x01(\x0b\x32 .org.dash.platform.dapi.v0.ProofH\x00\x12=\n\x08metadata\x18\x02 \x01(\x0b\x32+.org.dash.platform.dapi.v0.ResponseMetadataB\x08\n\x06resultB\t\n\x07version\"\xb4\x01\n\x16GetDataContractRequest\x12X\n\x02v0\x18\x01 \x01(\x0b\x32J.org.dash.platform.dapi.v0.GetDataContractRequest.GetDataContractRequestV0H\x00\x1a\x35\n\x18GetDataContractRequestV0\x12\n\n\x02id\x18\x01 \x01(\x0c\x12\r\n\x05prove\x18\x02 \x01(\x08\x42\t\n\x07version\"\xb3\x02\n\x17GetDataContractResponse\x12Z\n\x02v0\x18\x01 \x01(\x0b\x32L.org.dash.platform.dapi.v0.GetDataContractResponse.GetDataContractResponseV0H\x00\x1a\xb0\x01\n\x19GetDataContractResponseV0\x12\x17\n\rdata_contract\x18\x01 \x01(\x0cH\x00\x12\x31\n\x05proof\x18\x02 \x01(\x0b\x32 .org.dash.platform.dapi.v0.ProofH\x00\x12=\n\x08metadata\x18\x03 \x01(\x0b\x32+.org.dash.platform.dapi.v0.ResponseMetadataB\x08\n\x06resultB\t\n\x07version\"\xb9\x01\n\x17GetDataContractsRequest\x12Z\n\x02v0\x18\x01 \x01(\x0b\x32L.org.dash.platform.dapi.v0.GetDataContractsRequest.GetDataContractsRequestV0H\x00\x1a\x37\n\x19GetDataContractsRequestV0\x12\x0b\n\x03ids\x18\x01 \x03(\x0c\x12\r\n\x05prove\x18\x02 \x01(\x08\x42\t\n\x07version\"\xcf\x04\n\x18GetDataContractsResponse\x12\\\n\x02v0\x18\x01 \x01(\x0b\x32N.org.dash.platform.dapi.v0.GetDataContractsResponse.GetDataContractsResponseV0H\x00\x1a[\n\x11\x44\x61taContractEntry\x12\x12\n\nidentifier\x18\x01 \x01(\x0c\x12\x32\n\rdata_contract\x18\x02 \x01(\x0b\x32\x1b.google.protobuf.BytesValue\x1au\n\rDataContracts\x12\x64\n\x15\x64\x61ta_contract_entries\x18\x01 \x03(\x0b\x32\x45.org.dash.platform.dapi.v0.GetDataContractsResponse.DataContractEntry\x1a\xf5\x01\n\x1aGetDataContractsResponseV0\x12[\n\x0e\x64\x61ta_contracts\x18\x01 \x01(\x0b\x32\x41.org.dash.platform.dapi.v0.GetDataContractsResponse.DataContractsH\x00\x12\x31\n\x05proof\x18\x02 \x01(\x0b\x32 .org.dash.platform.dapi.v0.ProofH\x00\x12=\n\x08metadata\x18\x03 \x01(\x0b\x32+.org.dash.platform.dapi.v0.ResponseMetadataB\x08\n\x06resultB\t\n\x07version\"\xc1\x02\n\x1dGetDataContractHistoryRequest\x12\x66\n\x02v0\x18\x01 \x01(\x0b\x32X.org.dash.platform.dapi.v0.GetDataContractHistoryRequest.GetDataContractHistoryRequestV0H\x00\x1a\xac\x01\n\x1fGetDataContractHistoryRequestV0\x12\n\n\x02id\x18\x01 \x01(\x0c\x12+\n\x05limit\x18\x02 \x01(\x0b\x32\x1c.google.protobuf.UInt32Value\x12,\n\x06offset\x18\x03 \x01(\x0b\x32\x1c.google.protobuf.UInt32Value\x12\x13\n\x0bstart_at_ms\x18\x04 \x01(\x04\x12\r\n\x05prove\x18\x05 \x01(\x08\x42\t\n\x07version\"\xae\x05\n\x1eGetDataContractHistoryResponse\x12h\n\x02v0\x18\x01 \x01(\x0b\x32Z.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0H\x00\x1a\x96\x04\n GetDataContractHistoryResponseV0\x12\x8f\x01\n\x15\x64\x61ta_contract_history\x18\x01 \x01(\x0b\x32n.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0.DataContractHistoryH\x00\x12\x31\n\x05proof\x18\x02 \x01(\x0b\x32 .org.dash.platform.dapi.v0.ProofH\x00\x12=\n\x08metadata\x18\x03 \x01(\x0b\x32+.org.dash.platform.dapi.v0.ResponseMetadata\x1a\x37\n\x18\x44\x61taContractHistoryEntry\x12\x0c\n\x04\x64\x61te\x18\x01 \x01(\x04\x12\r\n\x05value\x18\x02 \x01(\x0c\x1a\xaa\x01\n\x13\x44\x61taContractHistory\x12\x92\x01\n\x15\x64\x61ta_contract_entries\x18\x01 \x03(\x0b\x32s.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0.DataContractHistoryEntryB\x08\n\x06resultB\t\n\x07version\"\xb2\x02\n\x13GetDocumentsRequest\x12R\n\x02v0\x18\x01 \x01(\x0b\x32\x44.org.dash.platform.dapi.v0.GetDocumentsRequest.GetDocumentsRequestV0H\x00\x1a\xbb\x01\n\x15GetDocumentsRequestV0\x12\x18\n\x10\x64\x61ta_contract_id\x18\x01 \x01(\x0c\x12\x15\n\rdocument_type\x18\x02 \x01(\t\x12\r\n\x05where\x18\x03 \x01(\x0c\x12\x10\n\x08order_by\x18\x04 \x01(\x0c\x12\r\n\x05limit\x18\x05 \x01(\r\x12\x15\n\x0bstart_after\x18\x06 \x01(\x0cH\x00\x12\x12\n\x08start_at\x18\x07 \x01(\x0cH\x00\x12\r\n\x05prove\x18\x08 \x01(\x08\x42\x07\n\x05startB\t\n\x07version\"\x95\x03\n\x14GetDocumentsResponse\x12T\n\x02v0\x18\x01 \x01(\x0b\x32\x46.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV0H\x00\x1a\x9b\x02\n\x16GetDocumentsResponseV0\x12\x65\n\tdocuments\x18\x01 \x01(\x0b\x32P.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV0.DocumentsH\x00\x12\x31\n\x05proof\x18\x02 \x01(\x0b\x32 .org.dash.platform.dapi.v0.ProofH\x00\x12=\n\x08metadata\x18\x03 \x01(\x0b\x32+.org.dash.platform.dapi.v0.ResponseMetadata\x1a\x1e\n\tDocuments\x12\x11\n\tdocuments\x18\x01 \x03(\x0c\x42\x08\n\x06resultB\t\n\x07version\"\xff\x01\n%GetIdentitiesByPublicKeyHashesRequest\x12v\n\x02v0\x18\x01 \x01(\x0b\x32h.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesRequest.GetIdentitiesByPublicKeyHashesRequestV0H\x00\x1aS\n\'GetIdentitiesByPublicKeyHashesRequestV0\x12\x19\n\x11public_key_hashes\x18\x01 \x03(\x0c\x12\r\n\x05prove\x18\x02 \x01(\x08\x42\t\n\x07version\"\xc6\x05\n&GetIdentitiesByPublicKeyHashesResponse\x12x\n\x02v0\x18\x01 \x01(\x0b\x32j.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.GetIdentitiesByPublicKeyHashesResponseV0H\x00\x1a\x61\n\x1aPublicKeyHashIdentityEntry\x12\x17\n\x0fpublic_key_hash\x18\x01 \x01(\x0c\x12*\n\x05value\x18\x02 \x01(\x0b\x32\x1b.google.protobuf.BytesValue\x1a\x95\x01\n\x1bIdentitiesByPublicKeyHashes\x12v\n\x10identity_entries\x18\x01 \x03(\x0b\x32\\.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.PublicKeyHashIdentityEntry\x1a\x9b\x02\n(GetIdentitiesByPublicKeyHashesResponseV0\x12s\n\nidentities\x18\x01 \x01(\x0b\x32].org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.IdentitiesByPublicKeyHashesH\x00\x12\x31\n\x05proof\x18\x02 \x01(\x0b\x32 .org.dash.platform.dapi.v0.ProofH\x00\x12=\n\x08metadata\x18\x03 \x01(\x0b\x32+.org.dash.platform.dapi.v0.ResponseMetadataB\x08\n\x06resultB\t\n\x07version\"\xed\x01\n!GetIdentityByPublicKeyHashRequest\x12n\n\x02v0\x18\x01 \x01(\x0b\x32`.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashRequest.GetIdentityByPublicKeyHashRequestV0H\x00\x1aM\n#GetIdentityByPublicKeyHashRequestV0\x12\x17\n\x0fpublic_key_hash\x18\x01 \x01(\x0c\x12\r\n\x05prove\x18\x02 \x01(\x08\x42\t\n\x07version\"\xda\x02\n\"GetIdentityByPublicKeyHashResponse\x12p\n\x02v0\x18\x01 \x01(\x0b\x32\x62.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashResponse.GetIdentityByPublicKeyHashResponseV0H\x00\x1a\xb6\x01\n$GetIdentityByPublicKeyHashResponseV0\x12\x12\n\x08identity\x18\x01 \x01(\x0cH\x00\x12\x31\n\x05proof\x18\x02 \x01(\x0b\x32 .org.dash.platform.dapi.v0.ProofH\x00\x12=\n\x08metadata\x18\x03 \x01(\x0b\x32+.org.dash.platform.dapi.v0.ResponseMetadataB\x08\n\x06resultB\t\n\x07version\"\xfb\x01\n#WaitForStateTransitionResultRequest\x12r\n\x02v0\x18\x01 \x01(\x0b\x32\x64.org.dash.platform.dapi.v0.WaitForStateTransitionResultRequest.WaitForStateTransitionResultRequestV0H\x00\x1aU\n%WaitForStateTransitionResultRequestV0\x12\x1d\n\x15state_transition_hash\x18\x01 \x01(\x0c\x12\r\n\x05prove\x18\x02 \x01(\x08\x42\t\n\x07version\"\x99\x03\n$WaitForStateTransitionResultResponse\x12t\n\x02v0\x18\x01 \x01(\x0b\x32\x66.org.dash.platform.dapi.v0.WaitForStateTransitionResultResponse.WaitForStateTransitionResultResponseV0H\x00\x1a\xef\x01\n&WaitForStateTransitionResultResponseV0\x12I\n\x05\x65rror\x18\x01 \x01(\x0b\x32\x38.org.dash.platform.dapi.v0.StateTransitionBroadcastErrorH\x00\x12\x31\n\x05proof\x18\x02 \x01(\x0b\x32 .org.dash.platform.dapi.v0.ProofH\x00\x12=\n\x08metadata\x18\x03 \x01(\x0b\x32+.org.dash.platform.dapi.v0.ResponseMetadataB\x08\n\x06resultB\t\n\x07version\"\xc4\x01\n\x19GetConsensusParamsRequest\x12^\n\x02v0\x18\x01 \x01(\x0b\x32P.org.dash.platform.dapi.v0.GetConsensusParamsRequest.GetConsensusParamsRequestV0H\x00\x1a<\n\x1bGetConsensusParamsRequestV0\x12\x0e\n\x06height\x18\x01 \x01(\x05\x12\r\n\x05prove\x18\x02 \x01(\x08\x42\t\n\x07version\"\x9c\x04\n\x1aGetConsensusParamsResponse\x12`\n\x02v0\x18\x01 \x01(\x0b\x32R.org.dash.platform.dapi.v0.GetConsensusParamsResponse.GetConsensusParamsResponseV0H\x00\x1aP\n\x14\x43onsensusParamsBlock\x12\x11\n\tmax_bytes\x18\x01 \x01(\t\x12\x0f\n\x07max_gas\x18\x02 \x01(\t\x12\x14\n\x0ctime_iota_ms\x18\x03 \x01(\t\x1a\x62\n\x17\x43onsensusParamsEvidence\x12\x1a\n\x12max_age_num_blocks\x18\x01 \x01(\t\x12\x18\n\x10max_age_duration\x18\x02 \x01(\t\x12\x11\n\tmax_bytes\x18\x03 \x01(\t\x1a\xda\x01\n\x1cGetConsensusParamsResponseV0\x12Y\n\x05\x62lock\x18\x01 \x01(\x0b\x32J.org.dash.platform.dapi.v0.GetConsensusParamsResponse.ConsensusParamsBlock\x12_\n\x08\x65vidence\x18\x02 \x01(\x0b\x32M.org.dash.platform.dapi.v0.GetConsensusParamsResponse.ConsensusParamsEvidenceB\t\n\x07version\"\xe4\x01\n%GetProtocolVersionUpgradeStateRequest\x12v\n\x02v0\x18\x01 \x01(\x0b\x32h.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateRequest.GetProtocolVersionUpgradeStateRequestV0H\x00\x1a\x38\n\'GetProtocolVersionUpgradeStateRequestV0\x12\r\n\x05prove\x18\x01 \x01(\x08\x42\t\n\x07version\"\xb5\x05\n&GetProtocolVersionUpgradeStateResponse\x12x\n\x02v0\x18\x01 \x01(\x0b\x32j.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0H\x00\x1a\x85\x04\n(GetProtocolVersionUpgradeStateResponseV0\x12\x87\x01\n\x08versions\x18\x01 \x01(\x0b\x32s.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0.VersionsH\x00\x12\x31\n\x05proof\x18\x02 \x01(\x0b\x32 .org.dash.platform.dapi.v0.ProofH\x00\x12=\n\x08metadata\x18\x03 \x01(\x0b\x32+.org.dash.platform.dapi.v0.ResponseMetadata\x1a\x96\x01\n\x08Versions\x12\x89\x01\n\x08versions\x18\x01 \x03(\x0b\x32w.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0.VersionEntry\x1a:\n\x0cVersionEntry\x12\x16\n\x0eversion_number\x18\x01 \x01(\r\x12\x12\n\nvote_count\x18\x02 \x01(\rB\x08\n\x06resultB\t\n\x07version\"\xa3\x02\n*GetProtocolVersionUpgradeVoteStatusRequest\x12\x80\x01\n\x02v0\x18\x01 \x01(\x0b\x32r.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusRequest.GetProtocolVersionUpgradeVoteStatusRequestV0H\x00\x1ag\n,GetProtocolVersionUpgradeVoteStatusRequestV0\x12\x19\n\x11start_pro_tx_hash\x18\x01 \x01(\x0c\x12\r\n\x05\x63ount\x18\x02 \x01(\r\x12\r\n\x05prove\x18\x03 \x01(\x08\x42\t\n\x07version\"\xef\x05\n+GetProtocolVersionUpgradeVoteStatusResponse\x12\x82\x01\n\x02v0\x18\x01 \x01(\x0b\x32t.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0H\x00\x1a\xaf\x04\n-GetProtocolVersionUpgradeVoteStatusResponseV0\x12\x98\x01\n\x08versions\x18\x01 \x01(\x0b\x32\x83\x01.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0.VersionSignalsH\x00\x12\x31\n\x05proof\x18\x02 \x01(\x0b\x32 .org.dash.platform.dapi.v0.ProofH\x00\x12=\n\x08metadata\x18\x03 \x01(\x0b\x32+.org.dash.platform.dapi.v0.ResponseMetadata\x1a\xaf\x01\n\x0eVersionSignals\x12\x9c\x01\n\x0fversion_signals\x18\x01 \x03(\x0b\x32\x82\x01.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0.VersionSignal\x1a\x35\n\rVersionSignal\x12\x13\n\x0bpro_tx_hash\x18\x01 \x01(\x0c\x12\x0f\n\x07version\x18\x02 \x01(\rB\x08\n\x06resultB\t\n\x07version\"\xf5\x01\n\x14GetEpochsInfoRequest\x12T\n\x02v0\x18\x01 \x01(\x0b\x32\x46.org.dash.platform.dapi.v0.GetEpochsInfoRequest.GetEpochsInfoRequestV0H\x00\x1a|\n\x16GetEpochsInfoRequestV0\x12\x31\n\x0bstart_epoch\x18\x01 \x01(\x0b\x32\x1c.google.protobuf.UInt32Value\x12\r\n\x05\x63ount\x18\x02 \x01(\r\x12\x11\n\tascending\x18\x03 \x01(\x08\x12\r\n\x05prove\x18\x04 \x01(\x08\x42\t\n\x07version\"\xf7\x04\n\x15GetEpochsInfoResponse\x12V\n\x02v0\x18\x01 \x01(\x0b\x32H.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0H\x00\x1a\xfa\x03\n\x17GetEpochsInfoResponseV0\x12\x65\n\x06\x65pochs\x18\x01 \x01(\x0b\x32S.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.EpochInfosH\x00\x12\x31\n\x05proof\x18\x02 \x01(\x0b\x32 .org.dash.platform.dapi.v0.ProofH\x00\x12=\n\x08metadata\x18\x03 \x01(\x0b\x32+.org.dash.platform.dapi.v0.ResponseMetadata\x1au\n\nEpochInfos\x12g\n\x0b\x65poch_infos\x18\x01 \x03(\x0b\x32R.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.EpochInfo\x1a\x84\x01\n\tEpochInfo\x12\x0e\n\x06number\x18\x01 \x01(\r\x12\x1a\n\x12\x66irst_block_height\x18\x02 \x01(\x04\x12\x1f\n\x17\x66irst_core_block_height\x18\x03 \x01(\r\x12\x12\n\nstart_time\x18\x04 \x01(\x04\x12\x16\n\x0e\x66\x65\x65_multiplier\x18\x05 \x01(\x01\x42\x08\n\x06resultB\t\n\x07version2\xd5\x15\n\x08Platform\x12\x93\x01\n\x18\x62roadcastStateTransition\x12:.org.dash.platform.dapi.v0.BroadcastStateTransitionRequest\x1a;.org.dash.platform.dapi.v0.BroadcastStateTransitionResponse\x12l\n\x0bgetIdentity\x12-.org.dash.platform.dapi.v0.GetIdentityRequest\x1a..org.dash.platform.dapi.v0.GetIdentityResponse\x12r\n\rgetIdentities\x12/.org.dash.platform.dapi.v0.GetIdentitiesRequest\x1a\x30.org.dash.platform.dapi.v0.GetIdentitiesResponse\x12x\n\x0fgetIdentityKeys\x12\x31.org.dash.platform.dapi.v0.GetIdentityKeysRequest\x1a\x32.org.dash.platform.dapi.v0.GetIdentityKeysResponse\x12{\n\x10getIdentityNonce\x12\x32.org.dash.platform.dapi.v0.GetIdentityNonceRequest\x1a\x33.org.dash.platform.dapi.v0.GetIdentityNonceResponse\x12\x93\x01\n\x18getIdentityContractNonce\x12:.org.dash.platform.dapi.v0.GetIdentityContractNonceRequest\x1a;.org.dash.platform.dapi.v0.GetIdentityContractNonceResponse\x12\x81\x01\n\x12getIdentityBalance\x12\x34.org.dash.platform.dapi.v0.GetIdentityBalanceRequest\x1a\x35.org.dash.platform.dapi.v0.GetIdentityBalanceResponse\x12\xa2\x01\n\x1dgetIdentityBalanceAndRevision\x12?.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionRequest\x1a@.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse\x12\x66\n\tgetProofs\x12+.org.dash.platform.dapi.v0.GetProofsRequest\x1a,.org.dash.platform.dapi.v0.GetProofsResponse\x12x\n\x0fgetDataContract\x12\x31.org.dash.platform.dapi.v0.GetDataContractRequest\x1a\x32.org.dash.platform.dapi.v0.GetDataContractResponse\x12\x8d\x01\n\x16getDataContractHistory\x12\x38.org.dash.platform.dapi.v0.GetDataContractHistoryRequest\x1a\x39.org.dash.platform.dapi.v0.GetDataContractHistoryResponse\x12{\n\x10getDataContracts\x12\x32.org.dash.platform.dapi.v0.GetDataContractsRequest\x1a\x33.org.dash.platform.dapi.v0.GetDataContractsResponse\x12o\n\x0cgetDocuments\x12..org.dash.platform.dapi.v0.GetDocumentsRequest\x1a/.org.dash.platform.dapi.v0.GetDocumentsResponse\x12\xa5\x01\n\x1egetIdentitiesByPublicKeyHashes\x12@.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesRequest\x1a\x41.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse\x12\x99\x01\n\x1agetIdentityByPublicKeyHash\x12<.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashRequest\x1a=.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashResponse\x12\x9f\x01\n\x1cwaitForStateTransitionResult\x12>.org.dash.platform.dapi.v0.WaitForStateTransitionResultRequest\x1a?.org.dash.platform.dapi.v0.WaitForStateTransitionResultResponse\x12\x81\x01\n\x12getConsensusParams\x12\x34.org.dash.platform.dapi.v0.GetConsensusParamsRequest\x1a\x35.org.dash.platform.dapi.v0.GetConsensusParamsResponse\x12\xa5\x01\n\x1egetProtocolVersionUpgradeState\x12@.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateRequest\x1a\x41.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse\x12\xb4\x01\n#getProtocolVersionUpgradeVoteStatus\x12\x45.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusRequest\x1a\x46.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse\x12r\n\rgetEpochsInfo\x12/.org.dash.platform.dapi.v0.GetEpochsInfoRequest\x1a\x30.org.dash.platform.dapi.v0.GetEpochsInfoResponseb\x06proto3' + serialized_pb=b'\n\x0eplatform.proto\x12\x19org.dash.platform.dapi.v0\x1a\x1egoogle/protobuf/wrappers.proto\x1a\x1cgoogle/protobuf/struct.proto\x1a\x1fgoogle/protobuf/timestamp.proto\"\x81\x01\n\x05Proof\x12\x15\n\rgrovedb_proof\x18\x01 \x01(\x0c\x12\x13\n\x0bquorum_hash\x18\x02 \x01(\x0c\x12\x11\n\tsignature\x18\x03 \x01(\x0c\x12\r\n\x05round\x18\x04 \x01(\r\x12\x15\n\rblock_id_hash\x18\x05 \x01(\x0c\x12\x13\n\x0bquorum_type\x18\x06 \x01(\r\"\x90\x01\n\x10ResponseMetadata\x12\x0e\n\x06height\x18\x01 \x01(\x04\x12 \n\x18\x63ore_chain_locked_height\x18\x02 \x01(\r\x12\r\n\x05\x65poch\x18\x03 \x01(\r\x12\x0f\n\x07time_ms\x18\x04 \x01(\x04\x12\x18\n\x10protocol_version\x18\x05 \x01(\r\x12\x10\n\x08\x63hain_id\x18\x06 \x01(\t\"L\n\x1dStateTransitionBroadcastError\x12\x0c\n\x04\x63ode\x18\x01 \x01(\r\x12\x0f\n\x07message\x18\x02 \x01(\t\x12\x0c\n\x04\x64\x61ta\x18\x03 \x01(\x0c\";\n\x1f\x42roadcastStateTransitionRequest\x12\x18\n\x10state_transition\x18\x01 \x01(\x0c\"\"\n BroadcastStateTransitionResponse\"\xa4\x01\n\x12GetIdentityRequest\x12P\n\x02v0\x18\x01 \x01(\x0b\x32\x42.org.dash.platform.dapi.v0.GetIdentityRequest.GetIdentityRequestV0H\x00\x1a\x31\n\x14GetIdentityRequestV0\x12\n\n\x02id\x18\x01 \x01(\x0c\x12\r\n\x05prove\x18\x02 \x01(\x08\x42\t\n\x07version\"\xc1\x01\n\x17GetIdentityNonceRequest\x12Z\n\x02v0\x18\x01 \x01(\x0b\x32L.org.dash.platform.dapi.v0.GetIdentityNonceRequest.GetIdentityNonceRequestV0H\x00\x1a?\n\x19GetIdentityNonceRequestV0\x12\x13\n\x0bidentity_id\x18\x01 \x01(\x0c\x12\r\n\x05prove\x18\x02 \x01(\x08\x42\t\n\x07version\"\xf6\x01\n\x1fGetIdentityContractNonceRequest\x12j\n\x02v0\x18\x01 \x01(\x0b\x32\\.org.dash.platform.dapi.v0.GetIdentityContractNonceRequest.GetIdentityContractNonceRequestV0H\x00\x1a\\\n!GetIdentityContractNonceRequestV0\x12\x13\n\x0bidentity_id\x18\x01 \x01(\x0c\x12\x13\n\x0b\x63ontract_id\x18\x02 \x01(\x0c\x12\r\n\x05prove\x18\x03 \x01(\x08\x42\t\n\x07version\"\xc0\x01\n\x19GetIdentityBalanceRequest\x12^\n\x02v0\x18\x01 \x01(\x0b\x32P.org.dash.platform.dapi.v0.GetIdentityBalanceRequest.GetIdentityBalanceRequestV0H\x00\x1a\x38\n\x1bGetIdentityBalanceRequestV0\x12\n\n\x02id\x18\x01 \x01(\x0c\x12\r\n\x05prove\x18\x02 \x01(\x08\x42\t\n\x07version\"\xec\x01\n$GetIdentityBalanceAndRevisionRequest\x12t\n\x02v0\x18\x01 \x01(\x0b\x32\x66.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionRequest.GetIdentityBalanceAndRevisionRequestV0H\x00\x1a\x43\n&GetIdentityBalanceAndRevisionRequestV0\x12\n\n\x02id\x18\x01 \x01(\x0c\x12\r\n\x05prove\x18\x02 \x01(\x08\x42\t\n\x07version\"\x9e\x02\n\x13GetIdentityResponse\x12R\n\x02v0\x18\x01 \x01(\x0b\x32\x44.org.dash.platform.dapi.v0.GetIdentityResponse.GetIdentityResponseV0H\x00\x1a\xa7\x01\n\x15GetIdentityResponseV0\x12\x12\n\x08identity\x18\x01 \x01(\x0cH\x00\x12\x31\n\x05proof\x18\x02 \x01(\x0b\x32 .org.dash.platform.dapi.v0.ProofH\x00\x12=\n\x08metadata\x18\x03 \x01(\x0b\x32+.org.dash.platform.dapi.v0.ResponseMetadataB\x08\n\x06resultB\t\n\x07version\"\xad\x01\n\x14GetIdentitiesRequest\x12T\n\x02v0\x18\x01 \x01(\x0b\x32\x46.org.dash.platform.dapi.v0.GetIdentitiesRequest.GetIdentitiesRequestV0H\x00\x1a\x34\n\x16GetIdentitiesRequestV0\x12\x0b\n\x03ids\x18\x01 \x03(\x0c\x12\r\n\x05prove\x18\x02 \x01(\x08\x42\t\n\x07version\"\xda\x04\n\x15GetIdentitiesResponse\x12V\n\x02v0\x18\x01 \x01(\x0b\x32H.org.dash.platform.dapi.v0.GetIdentitiesResponse.GetIdentitiesResponseV0H\x00\x1a\x1e\n\rIdentityValue\x12\r\n\x05value\x18\x01 \x01(\x0c\x1ak\n\rIdentityEntry\x12\x0b\n\x03key\x18\x01 \x01(\x0c\x12M\n\x05value\x18\x02 \x01(\x0b\x32>.org.dash.platform.dapi.v0.GetIdentitiesResponse.IdentityValue\x1a\x66\n\nIdentities\x12X\n\x10identity_entries\x18\x01 \x03(\x0b\x32>.org.dash.platform.dapi.v0.GetIdentitiesResponse.IdentityEntry\x1a\xe8\x01\n\x17GetIdentitiesResponseV0\x12Q\n\nidentities\x18\x01 \x01(\x0b\x32;.org.dash.platform.dapi.v0.GetIdentitiesResponse.IdentitiesH\x00\x12\x31\n\x05proof\x18\x02 \x01(\x0b\x32 .org.dash.platform.dapi.v0.ProofH\x00\x12=\n\x08metadata\x18\x03 \x01(\x0b\x32+.org.dash.platform.dapi.v0.ResponseMetadataB\x08\n\x06resultB\t\n\x07version\"\xb8\x02\n\x18GetIdentityNonceResponse\x12\\\n\x02v0\x18\x01 \x01(\x0b\x32N.org.dash.platform.dapi.v0.GetIdentityNonceResponse.GetIdentityNonceResponseV0H\x00\x1a\xb2\x01\n\x1aGetIdentityNonceResponseV0\x12\x18\n\x0eidentity_nonce\x18\x01 \x01(\x04H\x00\x12\x31\n\x05proof\x18\x02 \x01(\x0b\x32 .org.dash.platform.dapi.v0.ProofH\x00\x12=\n\x08metadata\x18\x03 \x01(\x0b\x32+.org.dash.platform.dapi.v0.ResponseMetadataB\x08\n\x06resultB\t\n\x07version\"\xe1\x02\n GetIdentityContractNonceResponse\x12l\n\x02v0\x18\x01 \x01(\x0b\x32^.org.dash.platform.dapi.v0.GetIdentityContractNonceResponse.GetIdentityContractNonceResponseV0H\x00\x1a\xc3\x01\n\"GetIdentityContractNonceResponseV0\x12!\n\x17identity_contract_nonce\x18\x01 \x01(\x04H\x00\x12\x31\n\x05proof\x18\x02 \x01(\x0b\x32 .org.dash.platform.dapi.v0.ProofH\x00\x12=\n\x08metadata\x18\x03 \x01(\x0b\x32+.org.dash.platform.dapi.v0.ResponseMetadataB\x08\n\x06resultB\t\n\x07version\"\xb9\x02\n\x1aGetIdentityBalanceResponse\x12`\n\x02v0\x18\x01 \x01(\x0b\x32R.org.dash.platform.dapi.v0.GetIdentityBalanceResponse.GetIdentityBalanceResponseV0H\x00\x1a\xad\x01\n\x1cGetIdentityBalanceResponseV0\x12\x11\n\x07\x62\x61lance\x18\x01 \x01(\x04H\x00\x12\x31\n\x05proof\x18\x02 \x01(\x0b\x32 .org.dash.platform.dapi.v0.ProofH\x00\x12=\n\x08metadata\x18\x03 \x01(\x0b\x32+.org.dash.platform.dapi.v0.ResponseMetadataB\x08\n\x06resultB\t\n\x07version\"\xa9\x04\n%GetIdentityBalanceAndRevisionResponse\x12v\n\x02v0\x18\x01 \x01(\x0b\x32h.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.GetIdentityBalanceAndRevisionResponseV0H\x00\x1a\xfc\x02\n\'GetIdentityBalanceAndRevisionResponseV0\x12\x9b\x01\n\x14\x62\x61lance_and_revision\x18\x01 \x01(\x0b\x32{.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.GetIdentityBalanceAndRevisionResponseV0.BalanceAndRevisionH\x00\x12\x31\n\x05proof\x18\x02 \x01(\x0b\x32 .org.dash.platform.dapi.v0.ProofH\x00\x12=\n\x08metadata\x18\x03 \x01(\x0b\x32+.org.dash.platform.dapi.v0.ResponseMetadata\x1a\x37\n\x12\x42\x61lanceAndRevision\x12\x0f\n\x07\x62\x61lance\x18\x01 \x01(\x04\x12\x10\n\x08revision\x18\x02 \x01(\x04\x42\x08\n\x06resultB\t\n\x07version\"\xd1\x01\n\x0eKeyRequestType\x12\x36\n\x08\x61ll_keys\x18\x01 \x01(\x0b\x32\".org.dash.platform.dapi.v0.AllKeysH\x00\x12@\n\rspecific_keys\x18\x02 \x01(\x0b\x32\'.org.dash.platform.dapi.v0.SpecificKeysH\x00\x12:\n\nsearch_key\x18\x03 \x01(\x0b\x32$.org.dash.platform.dapi.v0.SearchKeyH\x00\x42\t\n\x07request\"\t\n\x07\x41llKeys\"\x1f\n\x0cSpecificKeys\x12\x0f\n\x07key_ids\x18\x01 \x03(\r\"\xb6\x01\n\tSearchKey\x12I\n\x0bpurpose_map\x18\x01 \x03(\x0b\x32\x34.org.dash.platform.dapi.v0.SearchKey.PurposeMapEntry\x1a^\n\x0fPurposeMapEntry\x12\x0b\n\x03key\x18\x01 \x01(\r\x12:\n\x05value\x18\x02 \x01(\x0b\x32+.org.dash.platform.dapi.v0.SecurityLevelMap:\x02\x38\x01\"\xbf\x02\n\x10SecurityLevelMap\x12]\n\x12security_level_map\x18\x01 \x03(\x0b\x32\x41.org.dash.platform.dapi.v0.SecurityLevelMap.SecurityLevelMapEntry\x1aw\n\x15SecurityLevelMapEntry\x12\x0b\n\x03key\x18\x01 \x01(\r\x12M\n\x05value\x18\x02 \x01(\x0e\x32>.org.dash.platform.dapi.v0.SecurityLevelMap.KeyKindRequestType:\x02\x38\x01\"S\n\x12KeyKindRequestType\x12\x1f\n\x1b\x43URRENT_KEY_OF_KIND_REQUEST\x10\x00\x12\x1c\n\x18\x41LL_KEYS_OF_KIND_REQUEST\x10\x01\"\xda\x02\n\x16GetIdentityKeysRequest\x12X\n\x02v0\x18\x01 \x01(\x0b\x32J.org.dash.platform.dapi.v0.GetIdentityKeysRequest.GetIdentityKeysRequestV0H\x00\x1a\xda\x01\n\x18GetIdentityKeysRequestV0\x12\x13\n\x0bidentity_id\x18\x01 \x01(\x0c\x12?\n\x0crequest_type\x18\x02 \x01(\x0b\x32).org.dash.platform.dapi.v0.KeyRequestType\x12+\n\x05limit\x18\x03 \x01(\x0b\x32\x1c.google.protobuf.UInt32Value\x12,\n\x06offset\x18\x04 \x01(\x0b\x32\x1c.google.protobuf.UInt32Value\x12\r\n\x05prove\x18\x05 \x01(\x08\x42\t\n\x07version\"\x99\x03\n\x17GetIdentityKeysResponse\x12Z\n\x02v0\x18\x01 \x01(\x0b\x32L.org.dash.platform.dapi.v0.GetIdentityKeysResponse.GetIdentityKeysResponseV0H\x00\x1a\x96\x02\n\x19GetIdentityKeysResponseV0\x12\x61\n\x04keys\x18\x01 \x01(\x0b\x32Q.org.dash.platform.dapi.v0.GetIdentityKeysResponse.GetIdentityKeysResponseV0.KeysH\x00\x12\x31\n\x05proof\x18\x02 \x01(\x0b\x32 .org.dash.platform.dapi.v0.ProofH\x00\x12=\n\x08metadata\x18\x03 \x01(\x0b\x32+.org.dash.platform.dapi.v0.ResponseMetadata\x1a\x1a\n\x04Keys\x12\x12\n\nkeys_bytes\x18\x01 \x03(\x0c\x42\x08\n\x06resultB\t\n\x07version\"\xa1\x06\n\x10GetProofsRequest\x12L\n\x02v0\x18\x01 \x01(\x0b\x32>.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0H\x00\x1a\xb3\x05\n\x12GetProofsRequestV0\x12\x62\n\nidentities\x18\x01 \x03(\x0b\x32N.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.IdentityRequest\x12\x61\n\tcontracts\x18\x02 \x03(\x0b\x32N.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.ContractRequest\x12\x61\n\tdocuments\x18\x03 \x03(\x0b\x32N.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.DocumentRequest\x1aw\n\x0f\x44ocumentRequest\x12\x13\n\x0b\x63ontract_id\x18\x01 \x01(\x0c\x12\x15\n\rdocument_type\x18\x02 \x01(\t\x12#\n\x1b\x64ocument_type_keeps_history\x18\x03 \x01(\x08\x12\x13\n\x0b\x64ocument_id\x18\x04 \x01(\x0c\x1a\xd1\x01\n\x0fIdentityRequest\x12\x13\n\x0bidentity_id\x18\x01 \x01(\x0c\x12i\n\x0crequest_type\x18\x02 \x01(\x0e\x32S.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.IdentityRequest.Type\">\n\x04Type\x12\x11\n\rFULL_IDENTITY\x10\x00\x12\x0b\n\x07\x42\x41LANCE\x10\x01\x12\x08\n\x04KEYS\x10\x02\x12\x0c\n\x08REVISION\x10\x03\x1a&\n\x0f\x43ontractRequest\x12\x13\n\x0b\x63ontract_id\x18\x01 \x01(\x0c\x42\t\n\x07version\"\x82\x02\n\x11GetProofsResponse\x12N\n\x02v0\x18\x01 \x01(\x0b\x32@.org.dash.platform.dapi.v0.GetProofsResponse.GetProofsResponseV0H\x00\x1a\x91\x01\n\x13GetProofsResponseV0\x12\x31\n\x05proof\x18\x01 \x01(\x0b\x32 .org.dash.platform.dapi.v0.ProofH\x00\x12=\n\x08metadata\x18\x02 \x01(\x0b\x32+.org.dash.platform.dapi.v0.ResponseMetadataB\x08\n\x06resultB\t\n\x07version\"\xb4\x01\n\x16GetDataContractRequest\x12X\n\x02v0\x18\x01 \x01(\x0b\x32J.org.dash.platform.dapi.v0.GetDataContractRequest.GetDataContractRequestV0H\x00\x1a\x35\n\x18GetDataContractRequestV0\x12\n\n\x02id\x18\x01 \x01(\x0c\x12\r\n\x05prove\x18\x02 \x01(\x08\x42\t\n\x07version\"\xb3\x02\n\x17GetDataContractResponse\x12Z\n\x02v0\x18\x01 \x01(\x0b\x32L.org.dash.platform.dapi.v0.GetDataContractResponse.GetDataContractResponseV0H\x00\x1a\xb0\x01\n\x19GetDataContractResponseV0\x12\x17\n\rdata_contract\x18\x01 \x01(\x0cH\x00\x12\x31\n\x05proof\x18\x02 \x01(\x0b\x32 .org.dash.platform.dapi.v0.ProofH\x00\x12=\n\x08metadata\x18\x03 \x01(\x0b\x32+.org.dash.platform.dapi.v0.ResponseMetadataB\x08\n\x06resultB\t\n\x07version\"\xb9\x01\n\x17GetDataContractsRequest\x12Z\n\x02v0\x18\x01 \x01(\x0b\x32L.org.dash.platform.dapi.v0.GetDataContractsRequest.GetDataContractsRequestV0H\x00\x1a\x37\n\x19GetDataContractsRequestV0\x12\x0b\n\x03ids\x18\x01 \x03(\x0c\x12\r\n\x05prove\x18\x02 \x01(\x08\x42\t\n\x07version\"\xcf\x04\n\x18GetDataContractsResponse\x12\\\n\x02v0\x18\x01 \x01(\x0b\x32N.org.dash.platform.dapi.v0.GetDataContractsResponse.GetDataContractsResponseV0H\x00\x1a[\n\x11\x44\x61taContractEntry\x12\x12\n\nidentifier\x18\x01 \x01(\x0c\x12\x32\n\rdata_contract\x18\x02 \x01(\x0b\x32\x1b.google.protobuf.BytesValue\x1au\n\rDataContracts\x12\x64\n\x15\x64\x61ta_contract_entries\x18\x01 \x03(\x0b\x32\x45.org.dash.platform.dapi.v0.GetDataContractsResponse.DataContractEntry\x1a\xf5\x01\n\x1aGetDataContractsResponseV0\x12[\n\x0e\x64\x61ta_contracts\x18\x01 \x01(\x0b\x32\x41.org.dash.platform.dapi.v0.GetDataContractsResponse.DataContractsH\x00\x12\x31\n\x05proof\x18\x02 \x01(\x0b\x32 .org.dash.platform.dapi.v0.ProofH\x00\x12=\n\x08metadata\x18\x03 \x01(\x0b\x32+.org.dash.platform.dapi.v0.ResponseMetadataB\x08\n\x06resultB\t\n\x07version\"\xc1\x02\n\x1dGetDataContractHistoryRequest\x12\x66\n\x02v0\x18\x01 \x01(\x0b\x32X.org.dash.platform.dapi.v0.GetDataContractHistoryRequest.GetDataContractHistoryRequestV0H\x00\x1a\xac\x01\n\x1fGetDataContractHistoryRequestV0\x12\n\n\x02id\x18\x01 \x01(\x0c\x12+\n\x05limit\x18\x02 \x01(\x0b\x32\x1c.google.protobuf.UInt32Value\x12,\n\x06offset\x18\x03 \x01(\x0b\x32\x1c.google.protobuf.UInt32Value\x12\x13\n\x0bstart_at_ms\x18\x04 \x01(\x04\x12\r\n\x05prove\x18\x05 \x01(\x08\x42\t\n\x07version\"\xae\x05\n\x1eGetDataContractHistoryResponse\x12h\n\x02v0\x18\x01 \x01(\x0b\x32Z.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0H\x00\x1a\x96\x04\n GetDataContractHistoryResponseV0\x12\x8f\x01\n\x15\x64\x61ta_contract_history\x18\x01 \x01(\x0b\x32n.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0.DataContractHistoryH\x00\x12\x31\n\x05proof\x18\x02 \x01(\x0b\x32 .org.dash.platform.dapi.v0.ProofH\x00\x12=\n\x08metadata\x18\x03 \x01(\x0b\x32+.org.dash.platform.dapi.v0.ResponseMetadata\x1a\x37\n\x18\x44\x61taContractHistoryEntry\x12\x0c\n\x04\x64\x61te\x18\x01 \x01(\x04\x12\r\n\x05value\x18\x02 \x01(\x0c\x1a\xaa\x01\n\x13\x44\x61taContractHistory\x12\x92\x01\n\x15\x64\x61ta_contract_entries\x18\x01 \x03(\x0b\x32s.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0.DataContractHistoryEntryB\x08\n\x06resultB\t\n\x07version\"\xb2\x02\n\x13GetDocumentsRequest\x12R\n\x02v0\x18\x01 \x01(\x0b\x32\x44.org.dash.platform.dapi.v0.GetDocumentsRequest.GetDocumentsRequestV0H\x00\x1a\xbb\x01\n\x15GetDocumentsRequestV0\x12\x18\n\x10\x64\x61ta_contract_id\x18\x01 \x01(\x0c\x12\x15\n\rdocument_type\x18\x02 \x01(\t\x12\r\n\x05where\x18\x03 \x01(\x0c\x12\x10\n\x08order_by\x18\x04 \x01(\x0c\x12\r\n\x05limit\x18\x05 \x01(\r\x12\x15\n\x0bstart_after\x18\x06 \x01(\x0cH\x00\x12\x12\n\x08start_at\x18\x07 \x01(\x0cH\x00\x12\r\n\x05prove\x18\x08 \x01(\x08\x42\x07\n\x05startB\t\n\x07version\"\x95\x03\n\x14GetDocumentsResponse\x12T\n\x02v0\x18\x01 \x01(\x0b\x32\x46.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV0H\x00\x1a\x9b\x02\n\x16GetDocumentsResponseV0\x12\x65\n\tdocuments\x18\x01 \x01(\x0b\x32P.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV0.DocumentsH\x00\x12\x31\n\x05proof\x18\x02 \x01(\x0b\x32 .org.dash.platform.dapi.v0.ProofH\x00\x12=\n\x08metadata\x18\x03 \x01(\x0b\x32+.org.dash.platform.dapi.v0.ResponseMetadata\x1a\x1e\n\tDocuments\x12\x11\n\tdocuments\x18\x01 \x03(\x0c\x42\x08\n\x06resultB\t\n\x07version\"\xff\x01\n%GetIdentitiesByPublicKeyHashesRequest\x12v\n\x02v0\x18\x01 \x01(\x0b\x32h.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesRequest.GetIdentitiesByPublicKeyHashesRequestV0H\x00\x1aS\n\'GetIdentitiesByPublicKeyHashesRequestV0\x12\x19\n\x11public_key_hashes\x18\x01 \x03(\x0c\x12\r\n\x05prove\x18\x02 \x01(\x08\x42\t\n\x07version\"\xc6\x05\n&GetIdentitiesByPublicKeyHashesResponse\x12x\n\x02v0\x18\x01 \x01(\x0b\x32j.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.GetIdentitiesByPublicKeyHashesResponseV0H\x00\x1a\x61\n\x1aPublicKeyHashIdentityEntry\x12\x17\n\x0fpublic_key_hash\x18\x01 \x01(\x0c\x12*\n\x05value\x18\x02 \x01(\x0b\x32\x1b.google.protobuf.BytesValue\x1a\x95\x01\n\x1bIdentitiesByPublicKeyHashes\x12v\n\x10identity_entries\x18\x01 \x03(\x0b\x32\\.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.PublicKeyHashIdentityEntry\x1a\x9b\x02\n(GetIdentitiesByPublicKeyHashesResponseV0\x12s\n\nidentities\x18\x01 \x01(\x0b\x32].org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.IdentitiesByPublicKeyHashesH\x00\x12\x31\n\x05proof\x18\x02 \x01(\x0b\x32 .org.dash.platform.dapi.v0.ProofH\x00\x12=\n\x08metadata\x18\x03 \x01(\x0b\x32+.org.dash.platform.dapi.v0.ResponseMetadataB\x08\n\x06resultB\t\n\x07version\"\xed\x01\n!GetIdentityByPublicKeyHashRequest\x12n\n\x02v0\x18\x01 \x01(\x0b\x32`.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashRequest.GetIdentityByPublicKeyHashRequestV0H\x00\x1aM\n#GetIdentityByPublicKeyHashRequestV0\x12\x17\n\x0fpublic_key_hash\x18\x01 \x01(\x0c\x12\r\n\x05prove\x18\x02 \x01(\x08\x42\t\n\x07version\"\xda\x02\n\"GetIdentityByPublicKeyHashResponse\x12p\n\x02v0\x18\x01 \x01(\x0b\x32\x62.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashResponse.GetIdentityByPublicKeyHashResponseV0H\x00\x1a\xb6\x01\n$GetIdentityByPublicKeyHashResponseV0\x12\x12\n\x08identity\x18\x01 \x01(\x0cH\x00\x12\x31\n\x05proof\x18\x02 \x01(\x0b\x32 .org.dash.platform.dapi.v0.ProofH\x00\x12=\n\x08metadata\x18\x03 \x01(\x0b\x32+.org.dash.platform.dapi.v0.ResponseMetadataB\x08\n\x06resultB\t\n\x07version\"\xfb\x01\n#WaitForStateTransitionResultRequest\x12r\n\x02v0\x18\x01 \x01(\x0b\x32\x64.org.dash.platform.dapi.v0.WaitForStateTransitionResultRequest.WaitForStateTransitionResultRequestV0H\x00\x1aU\n%WaitForStateTransitionResultRequestV0\x12\x1d\n\x15state_transition_hash\x18\x01 \x01(\x0c\x12\r\n\x05prove\x18\x02 \x01(\x08\x42\t\n\x07version\"\x99\x03\n$WaitForStateTransitionResultResponse\x12t\n\x02v0\x18\x01 \x01(\x0b\x32\x66.org.dash.platform.dapi.v0.WaitForStateTransitionResultResponse.WaitForStateTransitionResultResponseV0H\x00\x1a\xef\x01\n&WaitForStateTransitionResultResponseV0\x12I\n\x05\x65rror\x18\x01 \x01(\x0b\x32\x38.org.dash.platform.dapi.v0.StateTransitionBroadcastErrorH\x00\x12\x31\n\x05proof\x18\x02 \x01(\x0b\x32 .org.dash.platform.dapi.v0.ProofH\x00\x12=\n\x08metadata\x18\x03 \x01(\x0b\x32+.org.dash.platform.dapi.v0.ResponseMetadataB\x08\n\x06resultB\t\n\x07version\"\xc4\x01\n\x19GetConsensusParamsRequest\x12^\n\x02v0\x18\x01 \x01(\x0b\x32P.org.dash.platform.dapi.v0.GetConsensusParamsRequest.GetConsensusParamsRequestV0H\x00\x1a<\n\x1bGetConsensusParamsRequestV0\x12\x0e\n\x06height\x18\x01 \x01(\x05\x12\r\n\x05prove\x18\x02 \x01(\x08\x42\t\n\x07version\"\x9c\x04\n\x1aGetConsensusParamsResponse\x12`\n\x02v0\x18\x01 \x01(\x0b\x32R.org.dash.platform.dapi.v0.GetConsensusParamsResponse.GetConsensusParamsResponseV0H\x00\x1aP\n\x14\x43onsensusParamsBlock\x12\x11\n\tmax_bytes\x18\x01 \x01(\t\x12\x0f\n\x07max_gas\x18\x02 \x01(\t\x12\x14\n\x0ctime_iota_ms\x18\x03 \x01(\t\x1a\x62\n\x17\x43onsensusParamsEvidence\x12\x1a\n\x12max_age_num_blocks\x18\x01 \x01(\t\x12\x18\n\x10max_age_duration\x18\x02 \x01(\t\x12\x11\n\tmax_bytes\x18\x03 \x01(\t\x1a\xda\x01\n\x1cGetConsensusParamsResponseV0\x12Y\n\x05\x62lock\x18\x01 \x01(\x0b\x32J.org.dash.platform.dapi.v0.GetConsensusParamsResponse.ConsensusParamsBlock\x12_\n\x08\x65vidence\x18\x02 \x01(\x0b\x32M.org.dash.platform.dapi.v0.GetConsensusParamsResponse.ConsensusParamsEvidenceB\t\n\x07version\"\xe4\x01\n%GetProtocolVersionUpgradeStateRequest\x12v\n\x02v0\x18\x01 \x01(\x0b\x32h.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateRequest.GetProtocolVersionUpgradeStateRequestV0H\x00\x1a\x38\n\'GetProtocolVersionUpgradeStateRequestV0\x12\r\n\x05prove\x18\x01 \x01(\x08\x42\t\n\x07version\"\xb5\x05\n&GetProtocolVersionUpgradeStateResponse\x12x\n\x02v0\x18\x01 \x01(\x0b\x32j.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0H\x00\x1a\x85\x04\n(GetProtocolVersionUpgradeStateResponseV0\x12\x87\x01\n\x08versions\x18\x01 \x01(\x0b\x32s.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0.VersionsH\x00\x12\x31\n\x05proof\x18\x02 \x01(\x0b\x32 .org.dash.platform.dapi.v0.ProofH\x00\x12=\n\x08metadata\x18\x03 \x01(\x0b\x32+.org.dash.platform.dapi.v0.ResponseMetadata\x1a\x96\x01\n\x08Versions\x12\x89\x01\n\x08versions\x18\x01 \x03(\x0b\x32w.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0.VersionEntry\x1a:\n\x0cVersionEntry\x12\x16\n\x0eversion_number\x18\x01 \x01(\r\x12\x12\n\nvote_count\x18\x02 \x01(\rB\x08\n\x06resultB\t\n\x07version\"\xa3\x02\n*GetProtocolVersionUpgradeVoteStatusRequest\x12\x80\x01\n\x02v0\x18\x01 \x01(\x0b\x32r.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusRequest.GetProtocolVersionUpgradeVoteStatusRequestV0H\x00\x1ag\n,GetProtocolVersionUpgradeVoteStatusRequestV0\x12\x19\n\x11start_pro_tx_hash\x18\x01 \x01(\x0c\x12\r\n\x05\x63ount\x18\x02 \x01(\r\x12\r\n\x05prove\x18\x03 \x01(\x08\x42\t\n\x07version\"\xef\x05\n+GetProtocolVersionUpgradeVoteStatusResponse\x12\x82\x01\n\x02v0\x18\x01 \x01(\x0b\x32t.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0H\x00\x1a\xaf\x04\n-GetProtocolVersionUpgradeVoteStatusResponseV0\x12\x98\x01\n\x08versions\x18\x01 \x01(\x0b\x32\x83\x01.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0.VersionSignalsH\x00\x12\x31\n\x05proof\x18\x02 \x01(\x0b\x32 .org.dash.platform.dapi.v0.ProofH\x00\x12=\n\x08metadata\x18\x03 \x01(\x0b\x32+.org.dash.platform.dapi.v0.ResponseMetadata\x1a\xaf\x01\n\x0eVersionSignals\x12\x9c\x01\n\x0fversion_signals\x18\x01 \x03(\x0b\x32\x82\x01.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0.VersionSignal\x1a\x35\n\rVersionSignal\x12\x13\n\x0bpro_tx_hash\x18\x01 \x01(\x0c\x12\x0f\n\x07version\x18\x02 \x01(\rB\x08\n\x06resultB\t\n\x07version\"\xf5\x01\n\x14GetEpochsInfoRequest\x12T\n\x02v0\x18\x01 \x01(\x0b\x32\x46.org.dash.platform.dapi.v0.GetEpochsInfoRequest.GetEpochsInfoRequestV0H\x00\x1a|\n\x16GetEpochsInfoRequestV0\x12\x31\n\x0bstart_epoch\x18\x01 \x01(\x0b\x32\x1c.google.protobuf.UInt32Value\x12\r\n\x05\x63ount\x18\x02 \x01(\r\x12\x11\n\tascending\x18\x03 \x01(\x08\x12\r\n\x05prove\x18\x04 \x01(\x08\x42\t\n\x07version\"\x91\x05\n\x15GetEpochsInfoResponse\x12V\n\x02v0\x18\x01 \x01(\x0b\x32H.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0H\x00\x1a\x94\x04\n\x17GetEpochsInfoResponseV0\x12\x65\n\x06\x65pochs\x18\x01 \x01(\x0b\x32S.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.EpochInfosH\x00\x12\x31\n\x05proof\x18\x02 \x01(\x0b\x32 .org.dash.platform.dapi.v0.ProofH\x00\x12=\n\x08metadata\x18\x03 \x01(\x0b\x32+.org.dash.platform.dapi.v0.ResponseMetadata\x1au\n\nEpochInfos\x12g\n\x0b\x65poch_infos\x18\x01 \x03(\x0b\x32R.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.EpochInfo\x1a\x9e\x01\n\tEpochInfo\x12\x0e\n\x06number\x18\x01 \x01(\r\x12\x1a\n\x12\x66irst_block_height\x18\x02 \x01(\x04\x12\x1f\n\x17\x66irst_core_block_height\x18\x03 \x01(\r\x12\x12\n\nstart_time\x18\x04 \x01(\x04\x12\x16\n\x0e\x66\x65\x65_multiplier\x18\x05 \x01(\x01\x12\x18\n\x10protocol_version\x18\x06 \x01(\rB\x08\n\x06resultB\t\n\x07version2\xd5\x15\n\x08Platform\x12\x93\x01\n\x18\x62roadcastStateTransition\x12:.org.dash.platform.dapi.v0.BroadcastStateTransitionRequest\x1a;.org.dash.platform.dapi.v0.BroadcastStateTransitionResponse\x12l\n\x0bgetIdentity\x12-.org.dash.platform.dapi.v0.GetIdentityRequest\x1a..org.dash.platform.dapi.v0.GetIdentityResponse\x12r\n\rgetIdentities\x12/.org.dash.platform.dapi.v0.GetIdentitiesRequest\x1a\x30.org.dash.platform.dapi.v0.GetIdentitiesResponse\x12x\n\x0fgetIdentityKeys\x12\x31.org.dash.platform.dapi.v0.GetIdentityKeysRequest\x1a\x32.org.dash.platform.dapi.v0.GetIdentityKeysResponse\x12{\n\x10getIdentityNonce\x12\x32.org.dash.platform.dapi.v0.GetIdentityNonceRequest\x1a\x33.org.dash.platform.dapi.v0.GetIdentityNonceResponse\x12\x93\x01\n\x18getIdentityContractNonce\x12:.org.dash.platform.dapi.v0.GetIdentityContractNonceRequest\x1a;.org.dash.platform.dapi.v0.GetIdentityContractNonceResponse\x12\x81\x01\n\x12getIdentityBalance\x12\x34.org.dash.platform.dapi.v0.GetIdentityBalanceRequest\x1a\x35.org.dash.platform.dapi.v0.GetIdentityBalanceResponse\x12\xa2\x01\n\x1dgetIdentityBalanceAndRevision\x12?.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionRequest\x1a@.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse\x12\x66\n\tgetProofs\x12+.org.dash.platform.dapi.v0.GetProofsRequest\x1a,.org.dash.platform.dapi.v0.GetProofsResponse\x12x\n\x0fgetDataContract\x12\x31.org.dash.platform.dapi.v0.GetDataContractRequest\x1a\x32.org.dash.platform.dapi.v0.GetDataContractResponse\x12\x8d\x01\n\x16getDataContractHistory\x12\x38.org.dash.platform.dapi.v0.GetDataContractHistoryRequest\x1a\x39.org.dash.platform.dapi.v0.GetDataContractHistoryResponse\x12{\n\x10getDataContracts\x12\x32.org.dash.platform.dapi.v0.GetDataContractsRequest\x1a\x33.org.dash.platform.dapi.v0.GetDataContractsResponse\x12o\n\x0cgetDocuments\x12..org.dash.platform.dapi.v0.GetDocumentsRequest\x1a/.org.dash.platform.dapi.v0.GetDocumentsResponse\x12\xa5\x01\n\x1egetIdentitiesByPublicKeyHashes\x12@.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesRequest\x1a\x41.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse\x12\x99\x01\n\x1agetIdentityByPublicKeyHash\x12<.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashRequest\x1a=.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashResponse\x12\x9f\x01\n\x1cwaitForStateTransitionResult\x12>.org.dash.platform.dapi.v0.WaitForStateTransitionResultRequest\x1a?.org.dash.platform.dapi.v0.WaitForStateTransitionResultResponse\x12\x81\x01\n\x12getConsensusParams\x12\x34.org.dash.platform.dapi.v0.GetConsensusParamsRequest\x1a\x35.org.dash.platform.dapi.v0.GetConsensusParamsResponse\x12\xa5\x01\n\x1egetProtocolVersionUpgradeState\x12@.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateRequest\x1a\x41.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse\x12\xb4\x01\n#getProtocolVersionUpgradeVoteStatus\x12\x45.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusRequest\x1a\x46.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse\x12r\n\rgetEpochsInfo\x12/.org.dash.platform.dapi.v0.GetEpochsInfoRequest\x1a\x30.org.dash.platform.dapi.v0.GetEpochsInfoResponseb\x06proto3' , dependencies=[google_dot_protobuf_dot_wrappers__pb2.DESCRIPTOR,google_dot_protobuf_dot_struct__pb2.DESCRIPTOR,google_dot_protobuf_dot_timestamp__pb2.DESCRIPTOR,]) @@ -4495,6 +4495,13 @@ message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key), + _descriptor.FieldDescriptor( + name='protocol_version', full_name='org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.EpochInfo.protocol_version', index=5, + number=6, type=13, cpp_type=3, label=1, + has_default_value=False, default_value=0, + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key), ], extensions=[ ], @@ -4508,7 +4515,7 @@ oneofs=[ ], serialized_start=15517, - serialized_end=15649, + serialized_end=15675, ) _GETEPOCHSINFORESPONSE_GETEPOCHSINFORESPONSEV0 = _descriptor.Descriptor( @@ -4558,7 +4565,7 @@ fields=[]), ], serialized_start=15153, - serialized_end=15659, + serialized_end=15685, ) _GETEPOCHSINFORESPONSE = _descriptor.Descriptor( @@ -4594,7 +4601,7 @@ fields=[]), ], serialized_start=15039, - serialized_end=15670, + serialized_end=15696, ) _GETIDENTITYREQUEST_GETIDENTITYREQUESTV0.containing_type = _GETIDENTITYREQUEST @@ -5911,8 +5918,8 @@ index=0, serialized_options=None, create_key=_descriptor._internal_create_key, - serialized_start=15673, - serialized_end=18446, + serialized_start=15699, + serialized_end=18472, methods=[ _descriptor.MethodDescriptor( name='broadcastStateTransition', diff --git a/packages/dapi-grpc/clients/platform/v0/web/platform_pb.d.ts b/packages/dapi-grpc/clients/platform/v0/web/platform_pb.d.ts index 18b2d9fb69a..199db1f45e4 100644 --- a/packages/dapi-grpc/clients/platform/v0/web/platform_pb.d.ts +++ b/packages/dapi-grpc/clients/platform/v0/web/platform_pb.d.ts @@ -3271,6 +3271,9 @@ export namespace GetEpochsInfoResponse { getFeeMultiplier(): number; setFeeMultiplier(value: number): void; + getProtocolVersion(): number; + setProtocolVersion(value: number): void; + serializeBinary(): Uint8Array; toObject(includeInstance?: boolean): EpochInfo.AsObject; static toObject(includeInstance: boolean, msg: EpochInfo): EpochInfo.AsObject; @@ -3288,6 +3291,7 @@ export namespace GetEpochsInfoResponse { firstCoreBlockHeight: number, startTime: number, feeMultiplier: number, + protocolVersion: number, } } diff --git a/packages/dapi-grpc/clients/platform/v0/web/platform_pb.js b/packages/dapi-grpc/clients/platform/v0/web/platform_pb.js index 13ebdab3553..e7495b46c10 100644 --- a/packages/dapi-grpc/clients/platform/v0/web/platform_pb.js +++ b/packages/dapi-grpc/clients/platform/v0/web/platform_pb.js @@ -24494,7 +24494,8 @@ proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.Ep firstBlockHeight: jspb.Message.getFieldWithDefault(msg, 2, 0), firstCoreBlockHeight: jspb.Message.getFieldWithDefault(msg, 3, 0), startTime: jspb.Message.getFieldWithDefault(msg, 4, 0), - feeMultiplier: jspb.Message.getFloatingPointFieldWithDefault(msg, 5, 0.0) + feeMultiplier: jspb.Message.getFloatingPointFieldWithDefault(msg, 5, 0.0), + protocolVersion: jspb.Message.getFieldWithDefault(msg, 6, 0) }; if (includeInstance) { @@ -24551,6 +24552,10 @@ proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.Ep var value = /** @type {number} */ (reader.readDouble()); msg.setFeeMultiplier(value); break; + case 6: + var value = /** @type {number} */ (reader.readUint32()); + msg.setProtocolVersion(value); + break; default: reader.skipField(); break; @@ -24615,6 +24620,13 @@ proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.Ep f ); } + f = message.getProtocolVersion(); + if (f !== 0) { + writer.writeUint32( + 6, + f + ); + } }; @@ -24708,6 +24720,24 @@ proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.Ep }; +/** + * optional uint32 protocol_version = 6; + * @return {number} + */ +proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.EpochInfo.prototype.getProtocolVersion = function() { + return /** @type {number} */ (jspb.Message.getFieldWithDefault(this, 6, 0)); +}; + + +/** + * @param {number} value + * @return {!proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.EpochInfo} returns this + */ +proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.EpochInfo.prototype.setProtocolVersion = function(value) { + return jspb.Message.setProto3IntField(this, 6, value); +}; + + /** * optional EpochInfos epochs = 1; * @return {?proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.EpochInfos} diff --git a/packages/rs-sdk/tests/vectors/test_epoch_fetch/msg_2024-03-18T17:30:02.266794754Z_GetIdentityRequest_e4060c14ceaca6844d682c7393d7776113debe4287515ae60d0645da450a80a1.json b/packages/rs-sdk/tests/vectors/test_epoch_fetch/msg_2024-04-04T11:53:53.893159000Z_GetIdentityRequest_e4060c14ceaca6844d682c7393d7776113debe4287515ae60d0645da450a80a1.json similarity index 78% rename from packages/rs-sdk/tests/vectors/test_epoch_fetch/msg_2024-03-18T17:30:02.266794754Z_GetIdentityRequest_e4060c14ceaca6844d682c7393d7776113debe4287515ae60d0645da450a80a1.json rename to packages/rs-sdk/tests/vectors/test_epoch_fetch/msg_2024-04-04T11:53:53.893159000Z_GetIdentityRequest_e4060c14ceaca6844d682c7393d7776113debe4287515ae60d0645da450a80a1.json index 0a8e8600ca09a700408f8f9ba5b813e02fd3a1c0..6bf02b5db604f4523f6e312c977079d471fce36f 100644 GIT binary patch literal 21988 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 literal 21965 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 Qca44KImI6aWAK delta 2350 zcmZ8jT}%{L6wa~>y9(@`JBwpd>kiViK@t#@3KX+LDQzvLuCd}DcDG3rnpnG7UaXA* z2~C?e2GAQgwGRs~M58Itn2NEMm6((!71s8lAwIAqK4}`3w3@aiW&52wrZIguo4Gsp zo}cf0-?@{WIrPoVLxVr~YHI3h&i+{LZK$m~`$y&4>bm-^4S23=P!*onJ+)W5Jk=g$ zT-ZWl%x}>AX;aefV*yFgSEWI#9azRrV;NlUmns#M)ZN894qGOr&if6ul81MTeo4+s z&`=W(3>rUy?E_6khD!NN%1oLDC6D3Ecn5YZ7lvG4)cr7EC~-lukv)oF<1^U6PipiN zL)m{Le0@NwoLNc7H+#iY?xOcvo~lj?mE9?>t|@u4h&Dg|`C$35 z0+=5bfUSY8g%!ezV08Z5S2YSeKQmGcP|Z8py32dSsrw8?o+ z3hLcy?NHSgzkvmw>=4wsP++U}O}0u`2sN1zbhF+H|Mz3ViAtX|sLAmOO8=E-3^@UV zCN>H*Viu6Cz5yr`_Y0(6sz#rr)I)U1{8Q|dJ+ z)dd`rXh2UH4pd1vs%pRi_NE-$9B#mw(IV`OpGM3kbX(nAGANdVhw(~mfAA4nJ21zM ziDKzEJ}w^nB^-7p3d59XwIm5AWaxHN_;d7jz7j#=@2)Xux+Ns1`d_h*dT8k@a3j0Z zpj-#o5DnmMRRK1O1>_v;!wC_CtCdFNB-X=yqR-?kL9{MZikFC3hP~MjijcrA;IkU_ z%cgZ@V25l*`96@Tc@}iJ_`D2(`5Ne@zIhJI0d^AWeBL zU(m=Th@JC=Db|9*IZ3r;KWO_1jflJq=BMwYjG%)G?hX~np$K*@w;<8w5v1K&B-I_{ z!TlMEp*9U9cx^*nA*nLQQQsoYX6sRw?p@}fCDoBlg2o>sM0Y!0?w-ZT>3jI;K89ud zO@wW_VY)P-)Itbi3z+0wM%j@$xSa$y#m^>9Jj?w)44kr!z-3^}gb<9 z0OEF+!FBvs^gmLD^ke;4rVbVuD!PFMjWmv4N7G9E=DCjr4O~HWi~Tqpxr`q>1ouf@ zw$?Lm?>qwkAaYohg8zvxY}#@LoSOV{BRN+BVM>mLN&&SPI#mK)a5JaRBWBee_~T@T z+kippC%4fmwS@U{50%*af*`#l%vph^D~@5o`*#!iyFJPYY^lStr#5XsT%y zo&~q(`=OESMU*<%5 zpwCbfqpexaJ)lGu+Y$@Rj6R%lqq0nOFJkvmf0mWVO8^I#BY1Ge@DGUL(&?FcbS$yW zU-}gE6}O5dU2C)IR8mR06GZmQ-vJFyQb%V}4DSM3P0fNxKC>)Jf$o zfkYb5$a=ic49wmIM>s3oS0U;x^9xt8P^MH%m+qWI@1TaHDZGE1qD*Nmw_f) zhU?_srCTkGJs>`D0*Gi{X&GeqS!EP1*Iq!vSS#Xi)p|hd2OeqqQ-Qw{+%Jdt5zFvy zt*xWCV%BcT&cLniiYt1)iFg>gV@_WKxKRXY9&u;+-qDj%&&S(w)Y-cqY`K9mdJgGf zJiUM{_(MVK^oNZzju%z AjsO4v diff --git a/packages/rs-sdk/tests/vectors/test_epoch_fetch/quorum_pubkey-106-2ca9a9abc345b3e592538a9ceb7bc8321622c21e4a2874ab7e481c6267201326.json b/packages/rs-sdk/tests/vectors/test_epoch_fetch/quorum_pubkey-106-2ca9a9abc345b3e592538a9ceb7bc8321622c21e4a2874ab7e481c6267201326.json new file mode 100644 index 00000000000..fb09519887b --- /dev/null +++ b/packages/rs-sdk/tests/vectors/test_epoch_fetch/quorum_pubkey-106-2ca9a9abc345b3e592538a9ceb7bc8321622c21e4a2874ab7e481c6267201326.json @@ -0,0 +1 @@ +[185,34,149,202,37,202,240,51,209,243,187,197,33,87,122,32,22,127,83,1,88,217,241,161,169,150,46,177,216,239,225,34,200,117,206,68,9,199,159,124,0,183,99,59,149,195,154,31] \ No newline at end of file diff --git a/packages/rs-sdk/tests/vectors/test_epoch_fetch/quorum_pubkey-106-7f5ab83561a836a5460dd8e6164db039bd8eba37530edf9202046cf912eb8efd.json b/packages/rs-sdk/tests/vectors/test_epoch_fetch/quorum_pubkey-106-7f5ab83561a836a5460dd8e6164db039bd8eba37530edf9202046cf912eb8efd.json deleted file mode 100644 index febf1795502..00000000000 --- a/packages/rs-sdk/tests/vectors/test_epoch_fetch/quorum_pubkey-106-7f5ab83561a836a5460dd8e6164db039bd8eba37530edf9202046cf912eb8efd.json +++ /dev/null @@ -1 +0,0 @@ -[140,166,219,3,87,141,69,160,158,153,22,179,34,58,44,164,191,240,111,196,114,27,180,199,89,247,126,103,234,93,92,229,246,192,127,27,164,78,63,100,86,79,205,231,251,65,175,178] \ No newline at end of file diff --git a/packages/rs-sdk/tests/vectors/test_epoch_fetch_future/msg_2024-03-18T17:30:02.315343769Z_GetIdentityRequest_e4060c14ceaca6844d682c7393d7776113debe4287515ae60d0645da450a80a1.json b/packages/rs-sdk/tests/vectors/test_epoch_fetch_current/msg_2024-04-04T11:53:53.893143000Z_GetIdentityRequest_e4060c14ceaca6844d682c7393d7776113debe4287515ae60d0645da450a80a1.json similarity index 78% rename from packages/rs-sdk/tests/vectors/test_epoch_fetch_future/msg_2024-03-18T17:30:02.315343769Z_GetIdentityRequest_e4060c14ceaca6844d682c7393d7776113debe4287515ae60d0645da450a80a1.json rename to packages/rs-sdk/tests/vectors/test_epoch_fetch_current/msg_2024-04-04T11:53:53.893143000Z_GetIdentityRequest_e4060c14ceaca6844d682c7393d7776113debe4287515ae60d0645da450a80a1.json index 0a8e8600ca09a700408f8f9ba5b813e02fd3a1c0..6bf02b5db604f4523f6e312c977079d471fce36f 100644 GIT binary patch literal 21988 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 literal 21965 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 diff --git a/packages/rs-sdk/tests/vectors/test_epoch_fetch_current/quorum_pubkey-106-2ca9a9abc345b3e592538a9ceb7bc8321622c21e4a2874ab7e481c6267201326.json b/packages/rs-sdk/tests/vectors/test_epoch_fetch_current/quorum_pubkey-106-2ca9a9abc345b3e592538a9ceb7bc8321622c21e4a2874ab7e481c6267201326.json new file mode 100644 index 00000000000..fb09519887b --- /dev/null +++ b/packages/rs-sdk/tests/vectors/test_epoch_fetch_current/quorum_pubkey-106-2ca9a9abc345b3e592538a9ceb7bc8321622c21e4a2874ab7e481c6267201326.json @@ -0,0 +1 @@ +[185,34,149,202,37,202,240,51,209,243,187,197,33,87,122,32,22,127,83,1,88,217,241,161,169,150,46,177,216,239,225,34,200,117,206,68,9,199,159,124,0,183,99,59,149,195,154,31] \ No newline at end of file diff --git a/packages/rs-sdk/tests/vectors/test_epoch_fetch_current/quorum_pubkey-106-7f5ab83561a836a5460dd8e6164db039bd8eba37530edf9202046cf912eb8efd.json b/packages/rs-sdk/tests/vectors/test_epoch_fetch_current/quorum_pubkey-106-7f5ab83561a836a5460dd8e6164db039bd8eba37530edf9202046cf912eb8efd.json deleted file mode 100644 index febf1795502..00000000000 --- a/packages/rs-sdk/tests/vectors/test_epoch_fetch_current/quorum_pubkey-106-7f5ab83561a836a5460dd8e6164db039bd8eba37530edf9202046cf912eb8efd.json +++ /dev/null @@ -1 +0,0 @@ -[140,166,219,3,87,141,69,160,158,153,22,179,34,58,44,164,191,240,111,196,114,27,180,199,89,247,126,103,234,93,92,229,246,192,127,27,164,78,63,100,86,79,205,231,251,65,175,178] \ No newline at end of file diff --git a/packages/rs-sdk/tests/vectors/test_epoch_fetch_current/msg_2024-03-18T17:30:02.275436110Z_GetIdentityRequest_e4060c14ceaca6844d682c7393d7776113debe4287515ae60d0645da450a80a1.json b/packages/rs-sdk/tests/vectors/test_epoch_fetch_future/msg_2024-04-04T11:53:53.893142000Z_GetIdentityRequest_e4060c14ceaca6844d682c7393d7776113debe4287515ae60d0645da450a80a1.json similarity index 78% rename from packages/rs-sdk/tests/vectors/test_epoch_fetch_current/msg_2024-03-18T17:30:02.275436110Z_GetIdentityRequest_e4060c14ceaca6844d682c7393d7776113debe4287515ae60d0645da450a80a1.json rename to packages/rs-sdk/tests/vectors/test_epoch_fetch_future/msg_2024-04-04T11:53:53.893142000Z_GetIdentityRequest_e4060c14ceaca6844d682c7393d7776113debe4287515ae60d0645da450a80a1.json index 0a8e8600ca09a700408f8f9ba5b813e02fd3a1c0..6bf02b5db604f4523f6e312c977079d471fce36f 100644 GIT binary patch literal 21988 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 literal 21965 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 Date: Thu, 4 Apr 2024 20:56:04 +0700 Subject: [PATCH 37/37] test: update app hash asserts after merge --- packages/rs-drive-abci/tests/strategy_tests/main.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/rs-drive-abci/tests/strategy_tests/main.rs b/packages/rs-drive-abci/tests/strategy_tests/main.rs index 881105ac4e5..be33e96e185 100644 --- a/packages/rs-drive-abci/tests/strategy_tests/main.rs +++ b/packages/rs-drive-abci/tests/strategy_tests/main.rs @@ -1807,7 +1807,7 @@ mod tests { .unwrap() .unwrap() ), - "de824122516f3c5cab93615569bacdb1c8ec64be99079578ef41168dcec1b7b4".to_string() + "292700696d04d77de86c835b925d139c0bb606dc71c071c84e40303ea51d4986".to_string() ) } @@ -1932,7 +1932,7 @@ mod tests { .unwrap() .unwrap() ), - "437045e9befa9e532b65aa890e11fe98eb15d3fd95130a92504378d45f9e2a4a".to_string() + "03fdb219334b7786040ed2d55bdddef35a337426fa69f83d5671ddf400824309".to_string() ) }