Skip to content

Commit

Permalink
Merge pull request #1635 from subspace/remove-pallet-settlement
Browse files Browse the repository at this point in the history
Remove pallet settlement
  • Loading branch information
liuchengxu authored Jul 3, 2023
2 parents 907d9b8 + 2ee4d5b commit f1cc493
Show file tree
Hide file tree
Showing 38 changed files with 236 additions and 1,443 deletions.
39 changes: 0 additions & 39 deletions Cargo.lock

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

2 changes: 0 additions & 2 deletions crates/pallet-domains/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ frame-benchmarking = { version = "4.0.0-dev", default-features = false, git = "h
frame-support = { version = "4.0.0-dev", default-features = false, git = "https://github.com/subspace/substrate", rev = "55c157cff49b638a59d81a9f971f0f9a66829c71" }
frame-system = { version = "4.0.0-dev", default-features = false, git = "https://github.com/subspace/substrate", rev = "55c157cff49b638a59d81a9f971f0f9a66829c71" }
log = { version = "0.4.19", default-features = false }
pallet-settlement = { version = "0.1.0", default-features = false, path = "../pallet-settlement" }
scale-info = { version = "2.7.0", default-features = false, features = ["derive"] }
sp-core = { version = "21.0.0", default-features = false, git = "https://github.com/subspace/substrate", rev = "55c157cff49b638a59d81a9f971f0f9a66829c71" }
sp-domains = { version = "0.1.0", default-features = false, path = "../sp-domains" }
Expand All @@ -39,7 +38,6 @@ std = [
"frame-support/std",
"frame-system/std",
"log/std",
"pallet-settlement/std",
"scale-info/std",
"sp-core/std",
"sp-domains/std",
Expand Down
54 changes: 23 additions & 31 deletions crates/pallet-domains/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,22 +51,38 @@ mod pallet {
use frame_support::weights::Weight;
use frame_support::{Identity, PalletError};
use frame_system::pallet_prelude::*;
use pallet_settlement::{Error as SettlementError, FraudProofError};
use sp_core::H256;
use sp_domains::fraud_proof::FraudProof;
use sp_domains::transaction::InvalidTransactionCode;
use sp_domains::{
DomainId, ExecutorPublicKey, GenesisDomainRuntime, OpaqueBundle, RuntimeId, RuntimeType,
};
use sp_runtime::traits::{BlockNumberProvider, Zero};
use sp_runtime::traits::{BlockNumberProvider, CheckEqual, MaybeDisplay, SimpleBitOps, Zero};
use sp_std::fmt::Debug;
use sp_std::vec::Vec;
use subspace_core_primitives::U256;

#[pallet::config]
pub trait Config: frame_system::Config + pallet_settlement::Config {
pub trait Config: frame_system::Config {
type RuntimeEvent: From<Event<Self>> + IsType<<Self as frame_system::Config>::RuntimeEvent>;

/// Domain block hash type.
type DomainHash: Parameter
+ Member
+ MaybeSerializeDeserialize
+ Debug
+ MaybeDisplay
+ SimpleBitOps
+ Ord
+ Default
+ Copy
+ CheckEqual
+ sp_std::hash::Hash
+ AsRef<[u8]>
+ AsMut<[u8]>
+ MaxEncodedLen
+ Into<H256>;

/// Same with `pallet_subspace::Config::ConfirmationDepthK`.
type ConfirmationDepthK: Get<Self::BlockNumber>;

Expand Down Expand Up @@ -160,19 +176,6 @@ mod pallet {
Empty,
}

impl<T> From<SettlementError> for Error<T> {
#[inline]
fn from(error: SettlementError) -> Self {
match error {
SettlementError::MissingParent => {
Self::Bundle(BundleError::Receipt(ExecutionReceiptError::MissingParent))
}
SettlementError::FraudProof(err) => Self::FraudProof(err),
SettlementError::UnavailablePrimaryBlockHash => Self::UnavailablePrimaryBlockHash,
}
}
}

impl<T> From<RuntimeRegistryError> for Error<T> {
fn from(err: RuntimeRegistryError) -> Self {
Error::RuntimeRegistry(err)
Expand All @@ -186,7 +189,7 @@ mod pallet {
/// Invalid bundle.
Bundle(BundleError),
/// Invalid fraud proof.
FraudProof(FraudProofError),
FraudProof,
/// Runtime registry specific errors
RuntimeRegistry(RuntimeRegistryError),
}
Expand Down Expand Up @@ -275,9 +278,7 @@ mod pallet {

let domain_id = opaque_bundle.domain_id();

// TODO: Implement the receipts processing v2.
pallet_settlement::Pallet::<T>::track_receipt(domain_id, &opaque_bundle.receipt)
.map_err(Error::<T>::from)?;
// TODO: Implement the block tree v2.

let bundle_hash = opaque_bundle.hash();

Expand Down Expand Up @@ -313,8 +314,7 @@ mod pallet {

log::trace!(target: "runtime::domains", "Processing fraud proof: {fraud_proof:?}");

pallet_settlement::Pallet::<T>::process_fraud_proof(fraud_proof)
.map_err(Error::<T>::from)?;
// TODO: Implement fraud proof processing.

Ok(())
}
Expand Down Expand Up @@ -454,15 +454,7 @@ mod pallet {
.build()
}
Call::submit_fraud_proof { fraud_proof } => {
if let Err(e) =
pallet_settlement::Pallet::<T>::validate_fraud_proof(fraud_proof)
{
log::debug!(
target: "runtime::domains",
"Bad fraud proof: {fraud_proof:?}, error: {e:?}",
);
return InvalidTransactionCode::FraudProof.into();
}
// TODO: Validate fraud proof

// TODO: proper tag value.
unsigned_validity("SubspaceSubmitFraudProof", fraud_proof)
Expand Down
9 changes: 1 addition & 8 deletions crates/pallet-domains/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ frame_support::construct_runtime!(
UncheckedExtrinsic = UncheckedExtrinsic,
{
System: frame_system,
Settlement: pallet_settlement,
Domains: pallet_domains,
}
);
Expand Down Expand Up @@ -92,6 +91,7 @@ impl Get<BlockNumber> for ConfirmationDepthK {

impl pallet_domains::Config for Test {
type RuntimeEvent = RuntimeEvent;
type DomainHash = sp_core::H256;
type ConfirmationDepthK = ConfirmationDepthK;
type DomainRuntimeUpgradeDelay = DomainRuntimeUpgradeDelay;
type WeightInfo = pallet_domains::weights::SubstrateWeight<Test>;
Expand All @@ -100,13 +100,6 @@ impl pallet_domains::Config for Test {
type ExpectedBundlesPerInterval = ExpectedBundlesPerInterval;
}

impl pallet_settlement::Config for Test {
type RuntimeEvent = RuntimeEvent;
type DomainHash = H256;
type MaximumReceiptDrift = MaximumReceiptDrift;
type ReceiptsPruningDepth = ReceiptsPruningDepth;
}

pub(crate) fn new_test_ext() -> sp_io::TestExternalities {
let t = frame_system::GenesisConfig::default()
.build_storage::<Test>()
Expand Down
36 changes: 0 additions & 36 deletions crates/pallet-settlement/Cargo.toml

This file was deleted.

Loading

0 comments on commit f1cc493

Please sign in to comment.