From 8808cae38828e6f9d270e53575e221b177e56ba4 Mon Sep 17 00:00:00 2001 From: Ivan Shumkov Date: Tue, 3 Nov 2026 16:40:18 +0700 Subject: [PATCH] test(drive-abci): activate protocol version 14 in the credit pool backfill strategy tests MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit should_preserve_historical_token_history_flags_across_public_activation_candidates failed on v5.1-dev with `left: Some(8000), right: Some(108)`: the epoch 2 allocation of the TokenHistory contract's storage flags after activation. The tests activated PlatformVersion::latest(). Since #5579 (store contracts compiled from protocol version 15), an upgrade from 13 to 15 runs transition_to_version_14 at version 15, which re-stores TokenHistory v2 compiled: it grows by 7995 bytes instead of 105, and the activation epoch is charged 8000 instead of 108. #5579 made this change on purpose and pinned it in the TokenHistory flag-merge unit test (should_preserve_token_history_flag_owners_and_allocation_epochs runs at 14 and at the latest version), and its other version 14 activation tests now run at 14. This strategy test runs only in the push and nightly chain-simulation step, so #5579's PR CI never ran it. These tests describe the version 14 upgrade (the credit pool nullifier backfill and the TokenHistory v2 flag merge), so they now activate 14, the same pin #5531 makes in this file. Protocol version 14 is shipped, so the 108-byte allocation they pin is frozen behaviour. Bisected over v5.1-dev's first-parent history: c9c98b56de passes, 60cc5f4508 (#5579) is the first failing commit. Test would have caught this in CI: ✖ before fix (Some(8000) vs Some(108)), ✔ after (both credit_pool_backfill strategy tests pass). Co-Authored-By: Claude Opus 5.5 --- .../test_cases/credit_pool_backfill_tests.rs | 42 +++++++++++-------- 1 file changed, 25 insertions(+), 17 deletions(-) diff --git a/packages/rs-drive-abci/tests/strategy_tests/test_cases/credit_pool_backfill_tests.rs b/packages/rs-drive-abci/tests/strategy_tests/test_cases/credit_pool_backfill_tests.rs index 78f272c926b..320f1be86fc 100644 --- a/packages/rs-drive-abci/tests/strategy_tests/test_cases/credit_pool_backfill_tests.rs +++ b/packages/rs-drive-abci/tests/strategy_tests/test_cases/credit_pool_backfill_tests.rs @@ -46,6 +46,14 @@ mod tests { use tenderdash_abci::proto::FromMillis; use tenderdash_abci::Application; + /// The protocol version these tests activate: 14, whose upgrade backfills the credit pool + /// nullifiers and installs the token history contract v2 the assertions describe. Pinned, + /// as from version 15 the upgrade stores the contract compiled, and the activation epoch is + /// charged about 8000 bytes for its growth instead of the 108 the assertions expect. + fn activation_target() -> &'static PlatformVersion { + PlatformVersion::get(14).expect("expected protocol version 14") + } + /// The proposal of `round` for the next height, at chain-locked `core_chain_locked_height` fn proposal( outcome: &ChainExecutionOutcome, @@ -70,10 +78,10 @@ mod tests { core_chain_locked_height, core_chain_lock_update: None, proposer_pro_tx_hash: proposer.to_byte_array().to_vec(), - proposed_app_version: PlatformVersion::latest().protocol_version as u64, + proposed_app_version: activation_target().protocol_version as u64, version: Some(Consensus { block: 0, - app: PlatformVersion::latest().protocol_version as u64, + app: activation_target().protocol_version as u64, }), quorum_hash: outcome .current_quorum() @@ -167,7 +175,7 @@ mod tests { let pv = if version == 1 { PlatformVersion::get(13).expect("PV13") } else { - PlatformVersion::latest() + activation_target() }; let stored = platform .drive @@ -236,7 +244,7 @@ mod tests { async fn activation_lifecycle(historical_token_history: bool) { let old = PlatformVersion::get(13).expect("PV13"); - let latest = PlatformVersion::latest(); + let target = activation_target(); let config = PlatformConfig { block_spacing_ms: 1000, validator_set: ValidatorSetConfig { @@ -259,7 +267,7 @@ mod tests { chain_lock_quorum_count: 24, upgrading_info: Some(UpgradingInfo { current_protocol_version: 13, - proposed_protocol_versions_with_weight: vec![(latest.protocol_version, 1)], + proposed_protocol_versions_with_weight: vec![(target.protocol_version, 1)], upgrade_three_quarters_life: 0.0, }), ..Default::default() @@ -288,7 +296,7 @@ mod tests { .await; let state = outcome.abci_app.platform.state.load(); assert_eq!(state.current_protocol_version_in_consensus(), 13); - assert_eq!(state.next_epoch_protocol_version(), latest.protocol_version); + assert_eq!(state.next_epoch_protocol_version(), target.protocol_version); assert_eq!(state.last_committed_block_epoch().index, 1); drop(state); @@ -450,7 +458,7 @@ mod tests { .platform .drive .grove - .root_hash(None, &latest.drive.grove_version) + .root_hash(None, &target.drive.grove_version) .unwrap() .expect("unchanged committed root"), committed_root @@ -459,7 +467,7 @@ mod tests { assert!(!abci_app .platform .drive - .has_nullifier(&rho, None, &mut vec![], latest) + .has_nullifier(&rho, None, &mut vec![], target) .expect("uncommitted backfill")); } { @@ -477,7 +485,7 @@ mod tests { assert!(abci_app .platform .drive - .has_nullifier(&rho, transaction.as_ref(), &mut vec![], latest) + .has_nullifier(&rho, transaction.as_ref(), &mut vec![], target) .expect("candidate union")); } } @@ -538,7 +546,7 @@ mod tests { assert!(abci_app .platform .drive - .has_nullifier(&rho, transaction.as_ref(), &mut vec![], latest) + .has_nullifier(&rho, transaction.as_ref(), &mut vec![], target) .expect("retried candidate union")); } } @@ -560,7 +568,7 @@ mod tests { .platform .drive .grove - .root_hash(None, &latest.drive.grove_version) + .root_hash(None, &target.drive.grove_version) .unwrap() .expect("committed root after rejection"), committed_root @@ -576,7 +584,7 @@ mod tests { .platform .drive .grove - .root_hash(None, &latest.drive.grove_version) + .root_hash(None, &target.drive.grove_version) .value .expect("no speculative commit"), committed_root @@ -589,7 +597,7 @@ mod tests { assert_token_history(abci_app.platform, None, 2, historical_token_history); assert_eq!( state.current_protocol_version_in_consensus(), - latest.protocol_version + target.protocol_version ); assert_eq!( state.last_committed_block_app_hash().map(Vec::from), @@ -600,7 +608,7 @@ mod tests { assert!(abci_app .platform .drive - .has_nullifier(&rho, None, &mut vec![], latest) + .has_nullifier(&rho, None, &mut vec![], target) .expect("committed backfill")); } observations.push(accepted_root); @@ -617,16 +625,16 @@ mod tests { .state .load() .current_protocol_version_in_consensus(), - latest.protocol_version + target.protocol_version ); assert_eq!( reopened.state.load().next_epoch_protocol_version(), - latest.protocol_version + target.protocol_version ); for rho in [[1u8; 32], [3u8; 32]] { assert!(reopened .drive - .has_nullifier(&rho, None, &mut vec![], latest) + .has_nullifier(&rho, None, &mut vec![], target) .expect("backfill survives restart")); } }