Skip to content

Commit

Permalink
Remove the unused extract_fraud_proofs runtime api
Browse files Browse the repository at this point in the history
Signed-off-by: linning <linningde25@gmail.com>
  • Loading branch information
NingLin-P committed May 13, 2024
1 parent f948406 commit ac44719
Show file tree
Hide file tree
Showing 7 changed files with 3 additions and 80 deletions.
5 changes: 3 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 0 additions & 12 deletions crates/pallet-domains/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -421,10 +421,6 @@ mod pallet {
#[pallet::storage]
pub type SuccessfulBundles<T> = StorageMap<_, Identity, DomainId, Vec<H256>, ValueQuery>;

/// Fraud proofs submitted successfully in current block.
#[pallet::storage]
pub(super) type SuccessfulFraudProofs<T: Config> =
StorageMap<_, Identity, DomainId, Vec<T::DomainHash>, ValueQuery>;
/// Stores the next runtime id.
#[pallet::storage]
pub(super) type NextRuntimeId<T> = StorageValue<_, RuntimeId, ValueQuery>;
Expand Down Expand Up @@ -1176,8 +1172,6 @@ mod pallet {
new_head_receipt_number: Some(new_head_receipt_number),
});

SuccessfulFraudProofs::<T>::append(domain_id, fraud_proof.hash());

Ok(Some(actual_weight).into())
}

Expand Down Expand Up @@ -1530,8 +1524,6 @@ mod pallet {
T::DomainBundleSubmitted::domain_bundle_submitted(domain_id);
}

let _ = SuccessfulFraudProofs::<T>::clear(u32::MAX, None);

Weight::zero()
}

Expand Down Expand Up @@ -1655,10 +1647,6 @@ impl<T: Config> Pallet<T> {
SuccessfulBundles::<T>::get(domain_id)
}

pub fn successful_fraud_proofs(domain_id: DomainId) -> Vec<T::DomainHash> {
SuccessfulFraudProofs::<T>::get(domain_id)
}

pub fn domain_runtime_code(domain_id: DomainId) -> Option<Vec<u8>> {
RuntimeRegistry::<T>::get(Self::runtime_id(domain_id)?)
.and_then(|mut runtime_object| runtime_object.raw_genesis.take_runtime_code())
Expand Down
6 changes: 0 additions & 6 deletions crates/sp-domains-fraud-proof/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -400,12 +400,6 @@ sp_api::decl_runtime_apis! {
/// Submit the fraud proof via an unsigned extrinsic.
fn submit_fraud_proof_unsigned(fraud_proof: FraudProof<NumberFor<Block>, Block::Hash, DomainHeader, H256>);

/// Extract the fraud proof handled successfully from the given extrinsics.
fn extract_fraud_proofs(
domain_id: DomainId,
extrinsics: Vec<Block::Extrinsic>,
) -> Vec<FraudProof<DomainHeader>>;

/// Reture the storage key used in fraud proof
fn fraud_proof_storage_key(req: FraudProofStorageKeyRequest) -> Vec<u8>;
}
Expand Down
7 changes: 0 additions & 7 deletions crates/subspace-fake-runtime-api/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -406,13 +406,6 @@ sp_api::impl_runtime_apis! {
unreachable!()
}

fn extract_fraud_proofs(
_domain_id: DomainId,
_extrinsics: Vec<<Block as BlockT>::Extrinsic>,
) -> Vec<FraudProof<DomainHeader>> {
unreachable!()
}

fn fraud_proof_storage_key(_req: FraudProofStorageKeyRequest) -> Vec<u8> {
unreachable!()
}
Expand Down
20 changes: 0 additions & 20 deletions crates/subspace-runtime/src/domains.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ use crate::{Balance, Block, Domains, RuntimeCall, UncheckedExtrinsic};
use alloc::vec::Vec;
use domain_runtime_primitives::opaque::Header as DomainHeader;
use sp_domains::DomainId;
use sp_domains_fraud_proof::fraud_proof::FraudProof;
use sp_runtime::traits::{Block as BlockT, NumberFor};

pub(crate) fn extract_successful_bundles(
Expand Down Expand Up @@ -40,22 +39,3 @@ pub(crate) fn extract_bundle(
_ => None,
}
}

pub(crate) fn extract_fraud_proofs(
domain_id: DomainId,
extrinsics: Vec<UncheckedExtrinsic>,
) -> Vec<FraudProof<DomainHeader>> {
let successful_fraud_proofs = Domains::successful_fraud_proofs(domain_id);
extrinsics
.into_iter()
.filter_map(|uxt| match uxt.function {
RuntimeCall::Domains(pallet_domains::Call::submit_fraud_proof { fraud_proof })
if fraud_proof.domain_id() == domain_id
&& successful_fraud_proofs.contains(&fraud_proof.hash()) =>
{
Some(*fraud_proof)
}
_ => None,
})
.collect()
}
7 changes: 0 additions & 7 deletions crates/subspace-runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1366,13 +1366,6 @@ impl_runtime_apis! {
Domains::submit_fraud_proof_unsigned(fraud_proof)
}

fn extract_fraud_proofs(
domain_id: DomainId,
extrinsics: Vec<<Block as BlockT>::Extrinsic>,
) -> Vec<FraudProof<DomainHeader>> {
crate::domains::extract_fraud_proofs(domain_id, extrinsics)
}

fn fraud_proof_storage_key(req: FraudProofStorageKeyRequest) -> Vec<u8> {
<StorageKeyProvider as FraudProofStorageKeyProvider>::storage_key(req)
}
Expand Down
26 changes: 0 additions & 26 deletions test/subspace-test-runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1068,25 +1068,6 @@ fn extract_bundle(
}
}

pub(crate) fn extract_fraud_proofs(
domain_id: DomainId,
extrinsics: Vec<UncheckedExtrinsic>,
) -> Vec<FraudProof<DomainHeader>> {
let successful_fraud_proofs = Domains::successful_fraud_proofs(domain_id);
extrinsics
.into_iter()
.filter_map(|uxt| match uxt.function {
RuntimeCall::Domains(pallet_domains::Call::submit_fraud_proof { fraud_proof })
if fraud_proof.domain_id() == domain_id
&& successful_fraud_proofs.contains(&fraud_proof.hash()) =>
{
Some(*fraud_proof)
}
_ => None,
})
.collect()
}

struct RewardAddress([u8; 32]);

impl From<FarmerPublicKey> for RewardAddress {
Expand Down Expand Up @@ -1534,13 +1515,6 @@ impl_runtime_apis! {
Domains::submit_fraud_proof_unsigned(fraud_proof)
}

fn extract_fraud_proofs(
domain_id: DomainId,
extrinsics: Vec<<Block as BlockT>::Extrinsic>,
) -> Vec<FraudProof<DomainHeader>> {
extract_fraud_proofs(domain_id, extrinsics)
}

fn fraud_proof_storage_key(req: FraudProofStorageKeyRequest) -> Vec<u8> {
<StorageKeyProvider as FraudProofStorageKeyProvider>::storage_key(req)
}
Expand Down

0 comments on commit ac44719

Please sign in to comment.