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 ca23d0175b7..da4e2eb2382 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 @@ -638,7 +638,32 @@ mod evidence_policy_tests { assert_eq!((duration.seconds, duration.nanos), (172_800, 0)); let version = response.version.unwrap(); assert_eq!(version.app_version, latest.protocol_version as u64); - assert_eq!(version.consensus_version, 1); + assert_eq!(version.consensus_version, 2); + } + } + } + + #[test] + fn should_activate_tenderdash_consensus_version_2_with_protocol_version_15() { + let v14 = PlatformVersion::get(14).unwrap(); + let v15 = PlatformVersion::get(15).unwrap(); + assert_eq!(v14.consensus.tenderdash_consensus_version, 1); + assert_eq!(v15.consensus.tenderdash_consensus_version, 2); + for network in [ + Network::Mainnet, + Network::Testnet, + Network::Regtest, + Network::Devnet, + ] { + for is_epoch_change in [false, true] { + let version = + consensus_params_update(network, v14, v15, &epoch_info(is_epoch_change, 20)) + .unwrap() + .expect("activation update") + .version + .expect("version params on activation"); + assert_eq!(version.app_version, 15); + assert_eq!(version.consensus_version, 2); } } } @@ -766,7 +791,11 @@ mod evidence_policy_tests { .max_bytes, 0 ); - assert_eq!(params.version.unwrap().consensus_version, 1); + assert_eq!( + params.version.unwrap().consensus_version, + 2, + "an emergency update must not lower the consensus version" + ); let params = consensus_params_update( network, PlatformVersion::latest(), @@ -776,6 +805,7 @@ mod evidence_policy_tests { .unwrap() .unwrap(); assert!(params.evidence.is_none()); + assert_eq!(params.version.unwrap().consensus_version, 2); } } diff --git a/packages/rs-drive-abci/src/execution/engine/consensus_params_update/v2/mod.rs b/packages/rs-drive-abci/src/execution/engine/consensus_params_update/v2/mod.rs index 1a4f1c5e7ae..df1a325c76d 100644 --- a/packages/rs-drive-abci/src/execution/engine/consensus_params_update/v2/mod.rs +++ b/packages/rs-drive-abci/src/execution/engine/consensus_params_update/v2/mod.rs @@ -37,7 +37,11 @@ pub(super) fn consensus_params_update_v2( _ => false, }; let consensus_version = if emergency_update { - 1 + // Forces at least version 1 without lowering a newer one. + new_platform_version + .consensus + .tenderdash_consensus_version + .max(1) as i32 } else { // Update versions or the evidence policy when they change if original_platform_version diff --git a/packages/rs-drive-abci/tests/strategy_tests/test_cases/upgrade_fork_tests.rs b/packages/rs-drive-abci/tests/strategy_tests/test_cases/upgrade_fork_tests.rs index a92cec2e3fc..25dd1334d56 100644 --- a/packages/rs-drive-abci/tests/strategy_tests/test_cases/upgrade_fork_tests.rs +++ b/packages/rs-drive-abci/tests/strategy_tests/test_cases/upgrade_fork_tests.rs @@ -3539,6 +3539,10 @@ mod tests { params.version.as_ref().unwrap().app_version, latest.protocol_version as u64 ); + assert_eq!( + params.version.as_ref().unwrap().consensus_version, + latest.consensus.tenderdash_consensus_version as i32 + ); let after_parameters = continuation_parameters(&activated, 2); drop(activated); diff --git a/packages/rs-platform-version/src/version/v15.rs b/packages/rs-platform-version/src/version/v15.rs index 4407188f234..2f606199f3a 100644 --- a/packages/rs-platform-version/src/version/v15.rs +++ b/packages/rs-platform-version/src/version/v15.rs @@ -925,12 +925,21 @@ pub const PROTOCOL_VERSION_15: ProtocolVersion = 15; /// public key already refuse high-S. Protocol v14 and earlier keep /// `verify_hash_signature` 0, so the blocks committed under them replay with the same /// results. +/// +/// 44. **Tenderdash consensus version 2**: the activation block's consensus parameter update +/// raises Tenderdash's `consensus_version` from 1 to 2, which turns on proposer liveness +/// and round skipping: the proposer of a round waiting for transactions sends signed +/// heartbeats, and validators that stop hearing them hand the round to the next proposer +/// with a round skip certificate. The heartbeat and silence timeouts take Tenderdash's +/// defaults (1 s and 5 s). Only Tenderdash 2.0 and later follows such a chain. The +/// emergency updates of consensus parameter update 2 force at least version 1 instead of +/// exactly 1, so they never undo this. Protocol v14 and earlier keep version 1. pub const PLATFORM_V15: PlatformVersion = PlatformVersion { protocol_version: PROTOCOL_VERSION_15, drive: DRIVE_VERSION_V10, // changed: calculate_fee 1 prices a refund at the storing epoch's rate (note 27); apply_contract_with_serialization 1 writes nothing for a contract whose format version 1 bytes match the stored one's (note 8); vote method versions v4: register_identity_vote 1 registers a yes/no vote, remove_all_votes_given_by_identities 1 also removes the yes/no votes of a masternode that left the list, every yes_no method and remove_vote_poll_end_date_query_operations Some(0) make yes/no polls active, add_vote_poll_end_date_query_operations 1 adds only the entry when the batch already queues the end date's tree with other storage flags, and verify methods v4 make the yes/no proof verifiers active (note 10) and verify_private_document_entries Some(0) a page of a private type's store (note 13); state transition method versions v5: document_create_transition 1 deletes a consumed document from what its lookup read (note 11); document method versions v5: insert_empty_private_document_store_operation Some(0) creates a private document type's store, and fetch_private_document_entries and prove_private_document_entries Some(0) read and prove a page of it (note 13); apply_drive_operations 2 resolves a batch's estimate, remove_reference_for_index_level_for_contract_operations 2, add_reference_for_index_level_for_contract_operations 1, stateless_delete_of_non_tree_for_costs 1 and for_total_system_credits_update 1 describe their layers as they are (note 14); fetch_core_fork_activation_height and store_core_fork_activation_height Some(0) keep the Core fork activations (note 18); document method versions v5: append_private_document_entries_operations Some(0) appends a private document create's entries (note 25); grove_version GROVE_V5 (note 26); verify methods v4: verify_proof_keep_serialized 1 verifies a document that may be contested (note 29); document method versions v5: single_document_path_query 1 selects the latest retained revision at or before a block time, and verify_proof_keep_serialized 1 verifies it (note 31); retained-history writers, readers, estimates and verifiers select the per-type revision layout (note 35); add_new_keys_to_masternode_identity 1 adds a masternode key whose hash the identity already holds a reference for (note 32); document method versions v5: insert.add_document_for_contract_operations 2, delete.delete_document_for_contract_operations 1, delete.remove_document_from_primary_storage 1 and its estimate 1, query.fetch_document_lifecycle Some(0), and the erase/lifecycle estimate and erase_refund_recipient_cost selectors Some(0); batch_operations.convert_drive_operations_to_grove_operations 2; state transition method versions v5: document_delete_transition 1 and document_erase_transition Some(0); verify methods v4: single_document.verify_proof 1 extend retained history (note 41); document method versions v5: add_indices_for_top_index_level_for_contract_operations 3 writes no entry in an expired time range bucket (note 36) drive_abci: DriveAbciVersion { structs: DRIVE_ABCI_STRUCTURE_VERSIONS_V2, - methods: DRIVE_ABCI_METHOD_VERSIONS_V11, // changed: perform_events_on_first_block_of_protocol_change 3 migrates retained history after operator-payout reconciliation and other activation work (note 35); the yes/no poll's tally, record, clean-up and finish hook are Some(0) (note 10); verify_chain_lock_locally 1 rejects a chain lock locally only when Platform holds the quorums active at its signing height, and verify_chain_lock_through_core 1 has Core's verifychainlock check the others before submitchainlock; consensus_params_update 2 installs the full evidence policy (note 16); update_core_info 1 records the chain locked height at which Core's V24 is first seen active (note 18); build_untied_withdrawal_transactions_from_documents 1 emits asset unlock payload version 2 once V24 is recorded as active (note 20); update_voter_identity 1 re-enables the voter key of the address a masternode returns to (note 22); update_masternode_list 2 and update_operator_identity 1 make operator payouts and the operator identities' TRANSFER keys follow Core's diffs (note 32) + methods: DRIVE_ABCI_METHOD_VERSIONS_V11, // changed: perform_events_on_first_block_of_protocol_change 3 migrates retained history after operator-payout reconciliation and other activation work (note 35); the yes/no poll's tally, record, clean-up and finish hook are Some(0) (note 10); verify_chain_lock_locally 1 rejects a chain lock locally only when Platform holds the quorums active at its signing height, and verify_chain_lock_through_core 1 has Core's verifychainlock check the others before submitchainlock; consensus_params_update 2 installs the full evidence policy (note 16) and never lowers the Tenderdash consensus version on an emergency update (note 44); update_core_info 1 records the chain locked height at which Core's V24 is first seen active (note 18); build_untied_withdrawal_transactions_from_documents 1 emits asset unlock payload version 2 once V24 is recorded as active (note 20); update_voter_identity 1 re-enables the voter key of the address a masternode returns to (note 22); update_masternode_list 2 and update_operator_identity 1 make operator payouts and the operator identities' TRANSFER keys follow Core's diffs (note 32) validation_and_processing: DRIVE_ABCI_VALIDATION_VERSIONS_V11, // changed: identity update advanced_structure 1 refuses unpaid an identity update whose added key's proof of possession does not verify (note 2); create_domain_data_trigger 2 (note 3); contract update transform_into_action 1 holds an update to the compiled size cap in check_tx (note 8); batch advanced_structure 2 refuses a token config update on a read-only contract (note 9); masternode vote transform_into_action 1 looks up a masternode's previous answer on a yes/no poll (note 10); document_reference_validation 1 keeps what a consumed commitment's lookup read (note 11); document create structure_validation 2 holds a decision proposal to its fund, rule and end date (note 12); data trigger bindings 3 drop the DashPay bindings (note 24); document create state_validation 3 keeps a create outside a contest off the values of a live one its index values do not decide (note 19); identity create basic_structure 1 checks the identity id before the asset lock proof and advanced_structure 2 no longer does (note 23); contract user moderation transform_into_action 1 writes a moderator's field change in the name of whoever holds the document's storage (note 28); validate_state_transition_identity_signed 2 refuses a contract create or update signed by a key with a budget or an expiry (note 34); batch_state_transition.document_delete_transition_structure_validation 2 and document_erase_transition_structure_validation/document_erase_transition_state_validation Some(0) admit the lifecycle (note 41) withdrawal_constants: DRIVE_ABCI_WITHDRAWAL_CONSTANTS_V3, query: DRIVE_ABCI_QUERY_VERSIONS_V3, // changed: getDocumentHistory accepts V1 only @@ -956,7 +965,7 @@ pub const PLATFORM_V15: PlatformVersion = PlatformVersion { fee_version: FEE_VERSION4, // changed: decision proposals prefund their poll with 0.5 Dash (note 12); a private document entry pays its storage and 10,000,000 credits (note 25); a multiple choice proposal pays a 0.2 Dash processing fee on create (note 40) system_limits: SYSTEM_LIMITS_V5, // changed: max_compiled_contract_size caps a contract stored compiled at 1 MiB (note 8); max_private_document_entry_size caps a private type's entries at 4096 bytes, and the private document store limits size its store (note 13); max_private_document_entries_per_transition caps a private document create at 16 entries (note 25); max_document_revisions_erased_per_transition caps an erase at 100 revisions (note 41) consensus: ConsensusVersions { - tenderdash_consensus_version: 1, + tenderdash_consensus_version: 2, // changed: Tenderdash proposer liveness and round skipping (note 44) evidence: Some(ConsensusEvidenceParams { max_bytes: 0, max_age_num_blocks: 100_000,