From 00fb663aeee6f0d82eef676a40386f5a7609336a Mon Sep 17 00:00:00 2001 From: Ivan Shumkov Date: Sat, 5 Oct 2024 20:24:23 +0300 Subject: [PATCH] feat: start network with latest version if genesis version not set (#2206) --- .yarnrc.yml | 1 + .../configs/defaults/getBaseConfigFactory.js | 4 - .../defaults/getMainnetConfigFactory.js | 5 + .../defaults/getTestnetConfigFactory.js | 5 + .../configs/getConfigFileMigrationsFactory.js | 110 +++++++++++++++++- packages/rs-drive-abci/src/config.rs | 8 -- .../engine/consensus_params_update/mod.rs | 10 +- .../engine/consensus_params_update/v1/mod.rs | 74 ++++++++++++ .../engine/initialization/init_chain/mod.rs | 29 ++++- .../initialization/init_chain/v0/mod.rs | 28 ++++- .../rs-drive-abci/src/test/fixture/abci.rs | 12 +- .../tests/strategy_tests/execution.rs | 9 +- .../tests/strategy_tests/main.rs | 5 +- .../strategy_tests/patch_platform_tests.rs | 2 + .../strategy_tests/upgrade_fork_tests.rs | 3 +- .../tests/strategy_tests/withdrawal_tests.rs | 13 +-- .../src/version/mocks/v3_test.rs | 2 +- .../src/version/protocol_version.rs | 4 + .../rs-platform-version/src/version/v3.rs | 3 +- .../rs-platform-version/src/version/v4.rs | 2 +- 20 files changed, 283 insertions(+), 46 deletions(-) create mode 100644 packages/rs-drive-abci/src/execution/engine/consensus_params_update/v1/mod.rs diff --git a/.yarnrc.yml b/.yarnrc.yml index 34231a77e3..dd002648b0 100644 --- a/.yarnrc.yml +++ b/.yarnrc.yml @@ -15,6 +15,7 @@ npmAuditExcludePackages: - "@humanwhocodes/config-array" # TODO: Update eslint - "@humanwhocodes/object-schema" # TODO: Update eslint - micromatch # TODO: remove when new micromatch will be released https://github.com/advisories/GHSA-952p-6rrq-rcjv + - eslint # TODO: Update eslint https://github.com/dashpay/platform/issues/2212 packageExtensions: "@dashevo/protobufjs@*": diff --git a/packages/dashmate/configs/defaults/getBaseConfigFactory.js b/packages/dashmate/configs/defaults/getBaseConfigFactory.js index f1e9237ba9..e26e67ca50 100644 --- a/packages/dashmate/configs/defaults/getBaseConfigFactory.js +++ b/packages/dashmate/configs/defaults/getBaseConfigFactory.js @@ -11,7 +11,6 @@ import { const { version } = JSON.parse(fs.readFileSync(path.join(PACKAGE_ROOT_DIR, 'package.json'), 'utf8')); /** - * @param {HomeDir} homeDir * @returns {getBaseConfig} */ export default function getBaseConfigFactory() { @@ -398,9 +397,6 @@ export default function getBaseConfigFactory() { validator: { pub_key_types: ['bls12381'], }, - version: { - app_version: '1', - }, timeout: { propose: '50000000000', propose_delta: '5000000000', diff --git a/packages/dashmate/configs/defaults/getMainnetConfigFactory.js b/packages/dashmate/configs/defaults/getMainnetConfigFactory.js index 0f83c4a7a1..0159941d2f 100644 --- a/packages/dashmate/configs/defaults/getMainnetConfigFactory.js +++ b/packages/dashmate/configs/defaults/getMainnetConfigFactory.js @@ -66,6 +66,11 @@ export default function getMainnetConfigFactory(homeDir, getBaseConfig) { genesis: { chain_id: 'evo1', validator_quorum_type: 4, + consensus_params: { + version: { + app_version: '1', + }, + }, }, }, abci: { diff --git a/packages/dashmate/configs/defaults/getTestnetConfigFactory.js b/packages/dashmate/configs/defaults/getTestnetConfigFactory.js index a8aec0152b..3558c1daa4 100644 --- a/packages/dashmate/configs/defaults/getTestnetConfigFactory.js +++ b/packages/dashmate/configs/defaults/getTestnetConfigFactory.js @@ -110,6 +110,11 @@ export default function getTestnetConfigFactory(homeDir, getBaseConfig) { genesis: { chain_id: 'dash-testnet-51', validator_quorum_type: 6, + consensus_params: { + version: { + app_version: '1', + }, + }, }, }, }, diff --git a/packages/dashmate/configs/getConfigFileMigrationsFactory.js b/packages/dashmate/configs/getConfigFileMigrationsFactory.js index 4b04f1376e..5fa706c7c4 100644 --- a/packages/dashmate/configs/getConfigFileMigrationsFactory.js +++ b/packages/dashmate/configs/getConfigFileMigrationsFactory.js @@ -448,12 +448,63 @@ export default function getConfigFileMigrationsFactory(homeDir, defaultConfigs) return configFile; }, '1.0.0-dev.2': (configFile) => { + const consensusParams = { + block: { + max_bytes: '2097152', + max_gas: '57631392000', + time_iota_ms: '5000', + }, + evidence: { + max_age: '100000', + max_age_num_blocks: '100000', + max_age_duration: '172800000000000', + }, + validator: { + pub_key_types: ['bls12381'], + }, + timeout: { + propose: '50000000000', + propose_delta: '5000000000', + vote: '10000000000', + vote_delta: '1000000000', + }, + synchrony: { + message_delay: '70000000000', + precision: '1000000000', + }, + abci: { + recheck_tx: true, + }, + version: { + app_version: '1', + }, + }; + + const genesis = { + base: { + consensus_params: lodash.cloneDeep(consensusParams), + }, + local: { + consensus_params: lodash.cloneDeep(consensusParams), + }, + testnet: { + chain_id: 'dash-testnet-51', + validator_quorum_type: 6, + consensus_params: lodash.cloneDeep(consensusParams), + }, + mainnet: { + chain_id: 'evo1', + validator_quorum_type: 4, + consensus_params: lodash.cloneDeep(consensusParams), + }, + }; + Object.entries(configFile.configs) .forEach(([name, options]) => { - if (defaultConfigs.has(name)) { - options.platform.drive.tenderdash.genesis = defaultConfigs.get(name) - .get('platform.drive.tenderdash.genesis'); + if (genesis[name]) { + options.platform.drive.tenderdash.genesis = genesis[name]; } + options.platform.dapi.api.docker.deploy = base.get('platform.dapi.api.docker.deploy'); let baseConfigName = name; @@ -774,6 +825,38 @@ export default function getConfigFileMigrationsFactory(homeDir, defaultConfigs) return configFile; }, '1.1.0-dev.1': (configFile) => { + const consensusParams = { + block: { + max_bytes: '2097152', + max_gas: '57631392000', + time_iota_ms: '5000', + }, + evidence: { + max_age: '100000', + max_age_num_blocks: '100000', + max_age_duration: '172800000000000', + }, + validator: { + pub_key_types: ['bls12381'], + }, + timeout: { + propose: '50000000000', + propose_delta: '5000000000', + vote: '10000000000', + vote_delta: '1000000000', + }, + synchrony: { + message_delay: '70000000000', + precision: '1000000000', + }, + abci: { + recheck_tx: true, + }, + version: { + app_version: '1', + }, + }; + Object.entries(configFile.configs) .forEach(([name, options]) => { if (name === 'local') { @@ -792,8 +875,12 @@ export default function getConfigFileMigrationsFactory(homeDir, defaultConfigs) options.platform.drive.tenderdash.p2p.maxConnections = 64; options.platform.drive.tenderdash.p2p.maxOutgoingConnections = 30; - options.platform.drive.tenderdash.genesis - .consensus_params = base.get('platform.drive.tenderdash.genesis.consensus_params'); + + if (defaultConfigs.has(name)) { + options.platform.drive.tenderdash.genesis + .consensus_params = lodash.cloneDeep(consensusParams); + } + options.platform.drive.tenderdash.docker.image = base.get('platform.drive.tenderdash.docker.image'); }); return configFile; @@ -911,6 +998,19 @@ export default function getConfigFileMigrationsFactory(homeDir, defaultConfigs) }); return configFile; }, + '1.4.0-dev.4': (configFile) => { + Object.entries(configFile.configs) + .forEach(([name, options]) => { + if (name === 'base' || name === 'local') { + delete options.platform.drive.tenderdash.genesis.consensus_params.version; + } else if (options.network === NETWORK_TESTNET) { + options.platform.drive.tenderdash.genesis.consensus_params.version = { + app_version: '1', + }; + } + }); + return configFile; + }, }; } diff --git a/packages/rs-drive-abci/src/config.rs b/packages/rs-drive-abci/src/config.rs index 8e8f449aac..1e8f5f3c26 100644 --- a/packages/rs-drive-abci/src/config.rs +++ b/packages/rs-drive-abci/src/config.rs @@ -180,9 +180,6 @@ pub struct PlatformConfig { /// Approximately how often are blocks produced pub block_spacing_ms: u64, - /// Initial protocol version - pub initial_protocol_version: ProtocolVersion, - /// Path to data storage pub db_path: PathBuf, @@ -276,7 +273,6 @@ impl<'de> Deserialize<'de> for PlatformConfig { chain_lock: config.chain_lock, instant_lock: config.instant_lock, block_spacing_ms: config.block_spacing_ms, - initial_protocol_version: config.initial_protocol_version, db_path: config.db_path, rejections_path: config.rejections_path, #[cfg(feature = "testing-config")] @@ -734,7 +730,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: Self::default_initial_protocol_version(), prometheus_bind_address: None, grpc_bind_address: "127.0.0.1:26670".to_string(), } @@ -777,7 +772,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: Self::default_initial_protocol_version(), prometheus_bind_address: None, grpc_bind_address: "127.0.0.1:26670".to_string(), } @@ -817,7 +811,6 @@ impl PlatformConfig { rejections_path: Some(PathBuf::from("/var/log/dash/rejected")), #[cfg(feature = "testing-config")] testing_configs: PlatformTestConfig::default(), - initial_protocol_version: Self::default_initial_protocol_version(), prometheus_bind_address: None, grpc_bind_address: "127.0.0.1:26670".to_string(), tokio_console_enabled: false, @@ -860,7 +853,6 @@ impl PlatformConfig { rejections_path: Some(PathBuf::from("/var/log/dash/rejected")), #[cfg(feature = "testing-config")] testing_configs: PlatformTestConfig::default(), - initial_protocol_version: Self::default_initial_protocol_version(), prometheus_bind_address: None, grpc_bind_address: "127.0.0.1:26670".to_string(), tokio_console_enabled: false, diff --git a/packages/rs-drive-abci/src/execution/engine/consensus_params_update/mod.rs b/packages/rs-drive-abci/src/execution/engine/consensus_params_update/mod.rs index 16319d7746..e3163039f1 100644 --- a/packages/rs-drive-abci/src/execution/engine/consensus_params_update/mod.rs +++ b/packages/rs-drive-abci/src/execution/engine/consensus_params_update/mod.rs @@ -7,6 +7,8 @@ use dpp::version::PlatformVersion; use tenderdash_abci::proto::types::ConsensusParams; mod v0; +mod v1; + pub(crate) fn consensus_params_update( network: Network, original_platform_version: &PlatformVersion, @@ -25,9 +27,15 @@ pub(crate) fn consensus_params_update( new_platform_version, epoch_info, )), + 1 => Ok(v1::consensus_params_update_v1( + network, + original_platform_version, + new_platform_version, + epoch_info, + )), version => Err(Error::Execution(ExecutionError::UnknownVersionMismatch { method: "consensus_params_update".to_string(), - known_versions: vec![0], + known_versions: vec![0, 1], received: version, })), } diff --git a/packages/rs-drive-abci/src/execution/engine/consensus_params_update/v1/mod.rs b/packages/rs-drive-abci/src/execution/engine/consensus_params_update/v1/mod.rs new file mode 100644 index 0000000000..85e9d40180 --- /dev/null +++ b/packages/rs-drive-abci/src/execution/engine/consensus_params_update/v1/mod.rs @@ -0,0 +1,74 @@ +use crate::platform_types::epoch_info::v0::EpochInfoV0Methods; +use crate::platform_types::epoch_info::EpochInfo; +use dpp::dashcore::Network; +use dpp::version::PlatformVersion; +use tenderdash_abci::proto::types::{ConsensusParams, VersionParams}; + +#[inline(always)] +pub(super) fn consensus_params_update_v1( + network: Network, + original_platform_version: &PlatformVersion, + new_platform_version: &PlatformVersion, + epoch_info: &EpochInfo, +) -> Option { + // These are emergency consensus updates + match network { + Network::Dash => { + if epoch_info.is_first_block_of_epoch(3) { + return Some(ConsensusParams { + block: None, + evidence: None, + validator: None, + version: Some(VersionParams { + app_version: new_platform_version.protocol_version as u64, + consensus_version: 1, + }), + synchrony: None, + timeout: None, + abci: None, + }); + } + } + Network::Testnet => { + if epoch_info.is_first_block_of_epoch(1480) { + return Some(ConsensusParams { + block: None, + evidence: None, + validator: None, + version: Some(VersionParams { + app_version: new_platform_version.protocol_version as u64, + consensus_version: 1, + }), + synchrony: None, + timeout: None, + abci: None, + }); + } + } + _ => {} + } + + // Update versions if any of them changed + if original_platform_version + .consensus + .tenderdash_consensus_version + == new_platform_version.consensus.tenderdash_consensus_version + && original_platform_version.protocol_version == new_platform_version.protocol_version + { + None + } else { + Some(ConsensusParams { + block: None, + evidence: None, + validator: None, + version: Some(VersionParams { + app_version: new_platform_version.protocol_version as u64, + consensus_version: new_platform_version.consensus.tenderdash_consensus_version + as i32, + }), + synchrony: None, + timeout: None, + abci: None, + }) + } +} 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 57ec814c04..1b580ba38d 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,8 +5,10 @@ use crate::platform_types::platform::Platform; use crate::rpc::core::CoreRPCLike; +use crate::abci::AbciError; use crate::error::execution::ExecutionError; use dpp::version::PlatformVersion; +use dpp::version::ProtocolVersion; use drive::grovedb::Transaction; use tenderdash_abci::proto::abci::{RequestInitChain, ResponseInitChain}; @@ -22,8 +24,31 @@ 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)?; + 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: protocol_version, + .. + } = consensus_params + .version + .as_ref() + .ok_or(AbciError::BadRequest( + "consensus params version is required in init chain".to_string(), + ))?; + + let platform_version = if *protocol_version == 0 { + // Protocol version is not set. + // We are starting the chain with the desired version + PlatformVersion::desired() + } else { + // Use the version from the genesis + PlatformVersion::get(*protocol_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/execution/engine/initialization/init_chain/v0/mod.rs b/packages/rs-drive-abci/src/execution/engine/initialization/init_chain/v0/mod.rs index 3d0bc673a1..b67cd01253 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 @@ -7,7 +7,10 @@ use dpp::block::block_info::BlockInfo; use drive::error::Error::GroveDB; use drive::grovedb::Transaction; +use crate::execution::engine::consensus_params_update::consensus_params_update; use crate::platform_types::cleaned_abci_messages::request_init_chain_cleaned_params; +use crate::platform_types::epoch_info::v0::EpochInfoV0; +use crate::platform_types::epoch_info::EpochInfo; use crate::platform_types::platform_state::v0::PlatformStateV0Methods; use crate::platform_types::platform_state::PlatformState; use crate::platform_types::validator_set::ValidatorSetExt; @@ -68,8 +71,8 @@ where // Create platform execution state let mut initial_platform_state = PlatformState::default_with_protocol_versions( - request.initial_protocol_version, - request.initial_protocol_version, + platform_version.protocol_version, + platform_version.protocol_version, &self.config, )?; @@ -113,9 +116,6 @@ where initial_platform_state.set_genesis_block_info(Some(genesis_block_info)); - initial_platform_state - .set_current_protocol_version_in_consensus(request.initial_protocol_version); - if tracing::enabled!(tracing::Level::TRACE) { tracing::trace!( platform_state_fingerprint = hex::encode(initial_platform_state.fingerprint()?), @@ -132,8 +132,24 @@ where .unwrap() .map_err(GroveDB)?; + // We use first platform version because Tenderdash starts genesis with first versions + // by default + let first_platform_version = PlatformVersion::first(); + + let epoch_info = EpochInfo::V0(EpochInfoV0::calculate( + genesis_time, + genesis_time, + None, + self.config.execution.epoch_time_length_s, + )?); + Ok(ResponseInitChain { - consensus_params: None, + consensus_params: consensus_params_update( + self.config.network, + first_platform_version, + platform_version, + &epoch_info, + )?, app_hash: app_hash.to_vec(), validator_set_update: Some(validator_set), next_core_chain_lock_update: None, diff --git a/packages/rs-drive-abci/src/test/fixture/abci.rs b/packages/rs-drive-abci/src/test/fixture/abci.rs index 26a7803a6e..45abd250ca 100644 --- a/packages/rs-drive-abci/src/test/fixture/abci.rs +++ b/packages/rs-drive-abci/src/test/fixture/abci.rs @@ -3,14 +3,18 @@ use crate::config::PlatformConfig; use dpp::version::PlatformVersion; +use dpp::version::ProtocolVersion; use tenderdash_abci::proto::abci::RequestInitChain; use tenderdash_abci::proto::google::protobuf::Timestamp; use tenderdash_abci::proto::types::{ConsensusParams, VersionParams}; /// Creates static init chain request fixture -pub fn static_init_chain_request(config: &PlatformConfig) -> RequestInitChain { - let platform_version = PlatformVersion::get(config.initial_protocol_version) - .expect("expected to get platform version"); +pub fn static_init_chain_request( + config: &PlatformConfig, + protocol_version: ProtocolVersion, +) -> RequestInitChain { + let platform_version = + PlatformVersion::get(protocol_version).expect("expected to get platform version"); RequestInitChain { time: Some(Timestamp { seconds: 0, @@ -19,7 +23,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: protocol_version as u64, consensus_version: platform_version.consensus.tenderdash_consensus_version as i32, }), ..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 8b6b5767ec..777dc361a2 100644 --- a/packages/rs-drive-abci/tests/strategy_tests/execution.rs +++ b/packages/rs-drive-abci/tests/strategy_tests/execution.rs @@ -829,8 +829,15 @@ pub(crate) fn start_chain_for_strategy( .get::(¤t_validator_quorum_hash) .expect("expected a quorum to be found"); + let platform_state = abci_application.platform.state.load(); + let protocol_version = platform_state + .current_platform_version() + .unwrap() + .protocol_version; + drop(platform_state); + // init chain - let mut init_chain_request = static_init_chain_request(&config); + let mut init_chain_request = static_init_chain_request(&config, protocol_version); init_chain_request.initial_core_height = config.abci.genesis_core_height; init_chain_request.validator_set = Some(ValidatorSetUpdate { diff --git a/packages/rs-drive-abci/tests/strategy_tests/main.rs b/packages/rs-drive-abci/tests/strategy_tests/main.rs index 98e2b518a2..2312241cc6 100644 --- a/packages/rs-drive-abci/tests/strategy_tests/main.rs +++ b/packages/rs-drive-abci/tests/strategy_tests/main.rs @@ -47,7 +47,6 @@ mod tests { use crate::execution::{continue_chain_for_strategy, run_chain_for_strategy}; use crate::query::QueryStrategy; use crate::strategy::{FailureStrategy, MasternodeListChangesStrategy}; - use assert_matches::assert_matches; use dashcore_rpc::dashcore::hashes::Hash; use dashcore_rpc::dashcore::BlockHash; use dashcore_rpc::json::QuorumType; @@ -87,6 +86,7 @@ mod tests { }; use dpp::identity::{Identity, KeyType, Purpose, SecurityLevel}; use dpp::state_transition::StateTransition; + use platform_version::version::v1::PROTOCOL_VERSION_1; use platform_version::version::PlatformVersion; use simple_signer::signer::SimpleSigner; use strategy_tests::transitions::create_state_transitions_for_identities; @@ -1159,6 +1159,7 @@ mod tests { let mut platform = TestPlatformBuilder::new() .with_config(config.clone()) + .with_initial_protocol_version(PROTOCOL_VERSION_1) .build_with_mock_rpc(); let outcome = run_chain_for_strategy(&mut platform, 150, strategy, config, 15, &mut None); @@ -1885,6 +1886,7 @@ mod tests { let block_count = 120; let mut platform = TestPlatformBuilder::new() .with_config(config.clone()) + .with_initial_protocol_version(PROTOCOL_VERSION_1) .build_with_mock_rpc(); let outcome = @@ -2015,6 +2017,7 @@ mod tests { let block_count = 120; let mut platform = TestPlatformBuilder::new() .with_config(config.clone()) + .with_initial_protocol_version(PROTOCOL_VERSION_1) .build_with_mock_rpc(); let outcome = diff --git a/packages/rs-drive-abci/tests/strategy_tests/patch_platform_tests.rs b/packages/rs-drive-abci/tests/strategy_tests/patch_platform_tests.rs index 2e5fd9fe26..6a68330cae 100644 --- a/packages/rs-drive-abci/tests/strategy_tests/patch_platform_tests.rs +++ b/packages/rs-drive-abci/tests/strategy_tests/patch_platform_tests.rs @@ -18,6 +18,7 @@ mod tests { use platform_version::version; use platform_version::version::mocks::v2_test::TEST_PROTOCOL_VERSION_2; use platform_version::version::patches::PatchFn; + use platform_version::version::v1::PROTOCOL_VERSION_1; use platform_version::version::PlatformVersion; #[test] @@ -105,6 +106,7 @@ mod tests { let mut platform = TestPlatformBuilder::new() .with_config(config.clone()) + .with_initial_protocol_version(PROTOCOL_VERSION_1) .build_with_mock_rpc(); // Run chain before the first patch 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 928fc0a6a7..554394956b 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 @@ -621,7 +621,6 @@ mod tests { epoch_time_length_s, ..Default::default() }, - initial_protocol_version: PROTOCOL_VERSION_1, block_spacing_ms: epoch_time_length_s * 1000, testing_configs: PlatformTestConfig::default_minimal_verifications(), ..Default::default() @@ -629,7 +628,7 @@ mod tests { let mut platform = TestPlatformBuilder::new() .with_config(config.clone()) - .with_initial_protocol_version(INITIAL_PROTOCOL_VERSION) + .with_initial_protocol_version(PROTOCOL_VERSION_1) .build_with_mock_rpc(); let ChainExecutionOutcome { diff --git a/packages/rs-drive-abci/tests/strategy_tests/withdrawal_tests.rs b/packages/rs-drive-abci/tests/strategy_tests/withdrawal_tests.rs index ccbcae5d73..1748498709 100644 --- a/packages/rs-drive-abci/tests/strategy_tests/withdrawal_tests.rs +++ b/packages/rs-drive-abci/tests/strategy_tests/withdrawal_tests.rs @@ -4,7 +4,6 @@ mod tests { use crate::strategy::{ ChainExecutionOutcome, ChainExecutionParameters, NetworkStrategy, StrategyRandomness, }; - use assert_matches::assert_matches; use dashcore_rpc::dashcore_rpc_json::{AssetUnlockStatus, AssetUnlockStatusResult}; use dpp::dashcore::bls_sig_utils::BLSSignature; use dpp::dashcore::hashes::Hash; @@ -95,13 +94,13 @@ mod tests { ..Default::default() }, block_spacing_ms: hour_in_ms, - initial_protocol_version: TEST_PLATFORM_V3.protocol_version, testing_configs: PlatformTestConfig::default_minimal_verifications(), ..Default::default() }; let mut platform = TestPlatformBuilder::new() .with_config(config.clone()) + .with_initial_protocol_version(TEST_PLATFORM_V3.protocol_version) .build_with_mock_rpc(); platform @@ -776,13 +775,13 @@ mod tests { ..Default::default() }, block_spacing_ms: hour_in_ms, - initial_protocol_version: TEST_PLATFORM_V3.protocol_version, testing_configs: PlatformTestConfig::default_minimal_verifications(), ..Default::default() }; let mut platform = TestPlatformBuilder::new() .with_config(config.clone()) + .with_initial_protocol_version(TEST_PLATFORM_V3.protocol_version) .build_with_mock_rpc(); platform @@ -1144,7 +1143,6 @@ mod tests { current_validator_quorum_hash: current_quorum_hash, current_proposer_versions, end_time_ms, - withdrawals: last_block_withdrawals, identity_nonce_counter, identity_contract_nonce_counter, instant_lock_quorums, @@ -1481,12 +1479,12 @@ mod tests { ..Default::default() }, block_spacing_ms: minute_in_ms, - initial_protocol_version: TEST_PLATFORM_V3.protocol_version, testing_configs: PlatformTestConfig::default_minimal_verifications(), ..Default::default() }; let mut platform = TestPlatformBuilder::new() + .with_initial_protocol_version(TEST_PLATFORM_V3.protocol_version) .with_config(config.clone()) .build_with_mock_rpc(); @@ -1902,7 +1900,6 @@ mod tests { ..Default::default() }, block_spacing_ms: hour_in_ms, - initial_protocol_version: TEST_PLATFORM_V3.protocol_version, testing_configs: PlatformTestConfig::default_minimal_verifications(), ..Default::default() }, @@ -2037,7 +2034,6 @@ mod tests { ..Default::default() }, block_spacing_ms: hour_in_ms, - initial_protocol_version: TEST_PLATFORM_V3.protocol_version, testing_configs: PlatformTestConfig::default_minimal_verifications(), ..Default::default() }, @@ -2199,13 +2195,13 @@ mod tests { ..Default::default() }, block_spacing_ms: minute_in_ms, - initial_protocol_version: TEST_PLATFORM_V3.protocol_version, testing_configs: PlatformTestConfig::default_minimal_verifications(), ..Default::default() }; let mut platform = TestPlatformBuilder::new() .with_config(config.clone()) + .with_initial_protocol_version(TEST_PLATFORM_V3.protocol_version) .build_with_mock_rpc(); platform @@ -2598,7 +2594,6 @@ mod tests { ..Default::default() }, block_spacing_ms: hour_in_ms, - initial_protocol_version: TEST_PLATFORM_V3.protocol_version, testing_configs: PlatformTestConfig::default_minimal_verifications(), ..Default::default() }, 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 aab569b63e..1f9c5eb579 100644 --- a/packages/rs-platform-version/src/version/mocks/v3_test.rs +++ b/packages/rs-platform-version/src/version/mocks/v3_test.rs @@ -615,7 +615,7 @@ pub const TEST_PLATFORM_V3: PlatformVersion = PlatformVersion { check_tx: 0, run_block_proposal: 0, finalize_block_proposal: 0, - consensus_params_update: 0, + consensus_params_update: 1, }, initialization: DriveAbciInitializationMethodVersions { initial_core_height_and_time: 0, diff --git a/packages/rs-platform-version/src/version/protocol_version.rs b/packages/rs-platform-version/src/version/protocol_version.rs index c6af2ec88c..f3d4a1871d 100644 --- a/packages/rs-platform-version/src/version/protocol_version.rs +++ b/packages/rs-platform-version/src/version/protocol_version.rs @@ -152,6 +152,10 @@ impl PlatformVersion { .expect("expected to have a platform version") } + pub fn desired<'a>() -> &'a Self { + DESIRED_PLATFORM_VERSION + } + #[cfg(feature = "mock-versions")] /// Set mock versions for testing pub fn replace_test_versions(versions: Vec) { diff --git a/packages/rs-platform-version/src/version/v3.rs b/packages/rs-platform-version/src/version/v3.rs index 8a57cb65a6..b3c7cf3cc4 100644 --- a/packages/rs-platform-version/src/version/v3.rs +++ b/packages/rs-platform-version/src/version/v3.rs @@ -621,7 +621,8 @@ pub const PLATFORM_V3: PlatformVersion = PlatformVersion { check_tx: 0, run_block_proposal: 0, finalize_block_proposal: 0, - consensus_params_update: 0, + // Update app version if changed as well + consensus_params_update: 1, }, initialization: DriveAbciInitializationMethodVersions { initial_core_height_and_time: 0, diff --git a/packages/rs-platform-version/src/version/v4.rs b/packages/rs-platform-version/src/version/v4.rs index 0082ec2743..c607170dec 100644 --- a/packages/rs-platform-version/src/version/v4.rs +++ b/packages/rs-platform-version/src/version/v4.rs @@ -616,7 +616,7 @@ pub const PLATFORM_V4: PlatformVersion = PlatformVersion { check_tx: 0, run_block_proposal: 0, finalize_block_proposal: 0, - consensus_params_update: 0, + consensus_params_update: 1, }, initialization: DriveAbciInitializationMethodVersions { initial_core_height_and_time: 0,