Skip to content

Commit

Permalink
Put all the shuffling seed type conversions in one place
Browse files Browse the repository at this point in the history
  • Loading branch information
teor2345 committed Dec 16, 2024
1 parent c974cfc commit 231e06c
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
7 changes: 4 additions & 3 deletions crates/pallet-domains/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ mod pallet {
use sp_std::collections::btree_set::BTreeSet;
use sp_std::fmt::Debug;
use sp_subspace_mmr::MmrProofVerifier;
use subspace_core_primitives::U256;
use subspace_core_primitives::{Randomness, U256};
use subspace_runtime_primitives::StorageFee;

#[pallet::config]
Expand Down Expand Up @@ -1907,8 +1907,9 @@ mod pallet {
if SuccessfulBundles::<T>::iter_keys().count() > 0
|| DomainRuntimeUpgrades::<T>::exists()
{
let extrinsics_shuffling_seed =
H256::from_slice(Self::extrinsics_shuffling_seed().as_ref());
let extrinsics_shuffling_seed = Randomness::from(
Into::<H256>::into(Self::extrinsics_shuffling_seed()).to_fixed_bytes(),
);

let invalid_inherent_extrinsic_data = InvalidInherentExtrinsicData {
extrinsics_shuffling_seed,
Expand Down
3 changes: 2 additions & 1 deletion crates/sp-domains-fraud-proof/src/storage_proof.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ 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")]
Expand Down Expand Up @@ -408,7 +409,7 @@ impl MaybeDomainRuntimeUpgradedProof {
#[derive(Clone, Debug, Decode, Encode, Eq, PartialEq, TypeInfo)]
pub struct InvalidInherentExtrinsicData {
/// Extrinsics shuffling seed, derived from block randomness
pub extrinsics_shuffling_seed: H256,
pub extrinsics_shuffling_seed: Randomness,
}

impl PassBy for InvalidInherentExtrinsicData {
Expand Down
8 changes: 3 additions & 5 deletions crates/sp-domains-fraud-proof/src/verification.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ use sp_runtime::traits::{
use sp_runtime::{OpaqueExtrinsic, SaturatedConversion};
use sp_subspace_mmr::{ConsensusChainMmrLeafProof, MmrProofVerifier};
use sp_trie::{LayoutV1, StorageProof};
use subspace_core_primitives::{Randomness, U256};
use subspace_core_primitives::U256;
use trie_db::node::Value;

/// Verifies invalid domain extrinsic root fraud proof.
Expand Down Expand Up @@ -121,10 +121,8 @@ where
bundle_extrinsics_digests.extend(bundle_digest.bundle_digest.clone());
}

let mut ordered_extrinsics = deduplicate_and_shuffle_extrinsics(
bundle_extrinsics_digests,
Randomness::from(shuffling_seed.to_fixed_bytes()),
);
let mut ordered_extrinsics =
deduplicate_and_shuffle_extrinsics(bundle_extrinsics_digests, shuffling_seed);

// NOTE: the order of the inherent extrinsic MUST aligned with the
// pallets order defined in `construct_runtime` macro for domains.
Expand Down

0 comments on commit 231e06c

Please sign in to comment.