diff --git a/state-chain/chains/src/dot.rs b/state-chain/chains/src/dot.rs index 26c1cdd93e..db7d0d2f6d 100644 --- a/state-chain/chains/src/dot.rs +++ b/state-chain/chains/src/dot.rs @@ -341,6 +341,10 @@ impl PolkadotExtrinsicBuilder { Self { extrinsic_call, replay_protection, signer_and_signature: None } } + pub fn force_nonce(&mut self, nonce: u32) { + self.replay_protection.nonce = nonce; + } + pub fn signature(&self) -> Option { self.signer_and_signature.as_ref().map(|(_, sig)| sig.clone()) } diff --git a/state-chain/runtime/src/lib.rs b/state-chain/runtime/src/lib.rs index 793086becf..f7a91702fb 100644 --- a/state-chain/runtime/src/lib.rs +++ b/state-chain/runtime/src/lib.rs @@ -145,7 +145,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion { spec_name: create_runtime_str!("chainflip-node"), impl_name: create_runtime_str!("chainflip-node"), authoring_version: 1, - spec_version: 16, + spec_version: 17, impl_version: 1, apis: RUNTIME_API_VERSIONS, transaction_version: 4, @@ -818,9 +818,47 @@ pub type Executive = frame_executive::Executive< frame_system::ChainContext, Runtime, AllPalletsWithSystem, - (), + CustomUpgrade, >; +// TODO: remove this after upgrade. +pub struct CustomUpgrade; +impl frame_support::traits::OnRuntimeUpgrade for CustomUpgrade { + fn on_runtime_upgrade() -> Weight { + let mut api_calls = + pallet_cf_broadcast::ThresholdSignatureData::::iter() + .drain() + .filter(|&(id, _)| id > 3) + .collect::>(); + + let mut nonce = 1; + // transfers first + for (_id, (ref mut api_call, _signature)) in api_calls.iter_mut() { + match api_call { + cf_chains::dot::api::PolkadotApi::BatchFetchAndTransfer(ref mut ext_builder) => { + ext_builder.force_nonce(nonce); + }, + _ => continue, + } + nonce += 1; + PolkadotBroadcaster::threshold_sign_and_broadcast(api_call.clone(), None); + } + // then the rotation + for (_id, (ref mut api_call, _signature)) in api_calls.iter_mut() { + match api_call { + cf_chains::dot::api::PolkadotApi::RotateVaultProxy(ref mut ext_builder) => { + ext_builder.force_nonce(nonce); + }, + _ => continue, + } + nonce += 1; + PolkadotBroadcaster::threshold_sign_and_broadcast(api_call.clone(), None); + } + + Weight::zero() + } +} + #[cfg(feature = "runtime-benchmarks")] #[macro_use] extern crate frame_benchmarking;