diff --git a/crates/pallet-domains/src/lib.rs b/crates/pallet-domains/src/lib.rs index 68f21a0491..afc71fbfc9 100644 --- a/crates/pallet-domains/src/lib.rs +++ b/crates/pallet-domains/src/lib.rs @@ -1903,6 +1903,20 @@ mod pallet { } fn on_finalize(_: BlockNumberFor) { + // If this consensus block will derive any domain block, gather the necessary storage for potential fraud proof usage + if SuccessfulBundles::::iter_keys().count() > 0 + || DomainRuntimeUpgrades::::exists() + { + let extrinsics_shuffling_seed = + H256::from_slice(Self::extrinsics_shuffling_seed().as_ref()); + + let invalid_inherent_extrinsic_data = InvalidInherentExtrinsicData { + extrinsics_shuffling_seed, + }; + + BlockInvalidInherentExtrinsicData::::set(Some(invalid_inherent_extrinsic_data)); + } + let _ = LastEpochStakingDistribution::::clear(u32::MAX, None); let _ = NewAddedHeadReceipt::::clear(u32::MAX, None); } diff --git a/crates/sp-domains-fraud-proof/src/host_functions.rs b/crates/sp-domains-fraud-proof/src/host_functions.rs index ad6dd97412..51aa3f2ec2 100644 --- a/crates/sp-domains-fraud-proof/src/host_functions.rs +++ b/crates/sp-domains-fraud-proof/src/host_functions.rs @@ -266,7 +266,7 @@ where ) -> Option { let InvalidInherentExtrinsicData { // Used by caller - block_randomness: _, + extrinsics_shuffling_seed: _, } = invalid_inherent_extrinsic_data; let DomainInherentExtrinsicData { timestamp, diff --git a/crates/sp-domains-fraud-proof/src/storage_proof.rs b/crates/sp-domains-fraud-proof/src/storage_proof.rs index a50d06962c..ca9a244190 100644 --- a/crates/sp-domains-fraud-proof/src/storage_proof.rs +++ b/crates/sp-domains-fraud-proof/src/storage_proof.rs @@ -18,7 +18,6 @@ use sp_runtime_interface::pass_by::PassBy; use sp_std::marker::PhantomData; use sp_std::vec::Vec; use sp_trie::StorageProof; -use subspace_core_primitives::Randomness; use subspace_runtime_primitives::{Balance, BlockTransactionByteFee, Moment}; #[cfg(feature = "std")] @@ -408,8 +407,8 @@ impl MaybeDomainRuntimeUpgradedProof { #[derive(Clone, Debug, Decode, Encode, Eq, PartialEq, TypeInfo)] pub struct InvalidInherentExtrinsicData { - /// Block randomness - pub block_randomness: Randomness, + /// Extrinsics shuffling seed, derived from block randomness + pub extrinsics_shuffling_seed: H256, } impl PassBy for InvalidInherentExtrinsicData { diff --git a/crates/sp-domains-fraud-proof/src/verification.rs b/crates/sp-domains-fraud-proof/src/verification.rs index a883521c1a..3d048c9240 100644 --- a/crates/sp-domains-fraud-proof/src/verification.rs +++ b/crates/sp-domains-fraud-proof/src/verification.rs @@ -17,7 +17,7 @@ use domain_runtime_primitives::BlockNumber; use hash_db::Hasher; use sp_core::storage::StorageKey; use sp_core::H256; -use sp_domains::extrinsics::{deduplicate_and_shuffle_extrinsics, extrinsics_shuffling_seed}; +use sp_domains::extrinsics::deduplicate_and_shuffle_extrinsics; use sp_domains::proof_provider_and_verifier::StorageProofVerifier; use sp_domains::valued_trie::valued_ordered_trie_root; use sp_domains::{ @@ -87,10 +87,7 @@ where )?; domain_inherent_extrinsic_data.maybe_sudo_runtime_call = domain_sudo_call.maybe_call; - let shuffling_seed = H256::from_slice( - extrinsics_shuffling_seed::(invalid_inherent_extrinsic_data.block_randomness) - .as_ref(), - ); + let shuffling_seed = invalid_inherent_extrinsic_data.extrinsics_shuffling_seed; let DomainInherentExtrinsic { domain_timestamp_extrinsic,