Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update ER to include SSC transfers to other chains #2510

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions Cargo.lock

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

1 change: 1 addition & 0 deletions crates/pallet-domains/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -453,6 +453,7 @@ pub(crate) fn create_dummy_receipt(
execution_trace,
execution_trace_root,
block_fees: Default::default(),
transfers: Default::default(),
}
}

Expand Down
1 change: 1 addition & 0 deletions crates/sp-domains-fraud-proof/src/bundle_equivocation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,7 @@ mod test {
execution_trace: vec![],
execution_trace_root: Default::default(),
block_fees: Default::default(),
transfers: Default::default(),
},
estimated_bundle_weight: Default::default(),
bundle_extrinsics_root: Default::default(),
Expand Down
63 changes: 63 additions & 0 deletions crates/sp-domains/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -433,6 +433,8 @@ pub struct ExecutionReceipt<Number, Hash, DomainNumber, DomainHash, Balance> {
/// Compute and Domain storage fees are shared across operators and Consensus
/// storage fees are given to the consensus block author.
pub block_fees: BlockFees<Balance>,
/// List of transfers from this Domain to other chains
pub transfers: BTreeMap<ChainId, Balance>,
}

impl<Number, Hash, DomainNumber, DomainHash, Balance>
Expand Down Expand Up @@ -510,6 +512,7 @@ impl<
execution_trace: sp_std::vec![genesis_state_root],
execution_trace_root: Default::default(),
block_fees: Default::default(),
transfers: Default::default(),
}
}

Expand Down Expand Up @@ -546,6 +549,7 @@ impl<
execution_trace,
execution_trace_root,
block_fees: Default::default(),
transfers: Default::default(),
}
}
}
Expand Down Expand Up @@ -947,6 +951,65 @@ impl ExtrinsicDigest {
}
}

/// Identifier of a chain.
#[derive(
Clone,
Copy,
Debug,
Hash,
Eq,
PartialEq,
Ord,
PartialOrd,
Encode,
Decode,
TypeInfo,
Serialize,
Deserialize,
MaxEncodedLen,
)]
pub enum ChainId {
Consensus,
Domain(DomainId),
}

impl ChainId {
#[inline]
pub fn consensus_chain_id() -> Self {
Self::Consensus
}

#[inline]
pub fn is_consensus_chain(&self) -> bool {
match self {
ChainId::Consensus => true,
ChainId::Domain(_) => false,
}
}

#[inline]
pub fn is_domain_chain(&self) -> Option<DomainId> {
match self {
ChainId::Consensus => None,
ChainId::Domain(domain_id) => Some(*domain_id),
}
}
}

impl From<u32> for ChainId {
#[inline]
fn from(x: u32) -> Self {
Self::Domain(DomainId::new(x))
}
}

impl From<DomainId> for ChainId {
#[inline]
fn from(x: DomainId) -> Self {
Self::Domain(x)
}
}

pub type ExecutionReceiptFor<DomainHeader, CBlock, Balance> = ExecutionReceipt<
NumberFor<CBlock>,
<CBlock as BlockT>::Hash,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,7 @@ use sc_utils::mpsc::tracing_unbounded;
use serde_json::Value;
use sp_core::crypto::Ss58AddressFormat;
use sp_core::traits::SpawnEssentialNamed;
use sp_domains::DomainId;
use sp_messenger::messages::ChainId;
use sp_domains::{ChainId, DomainId};
use std::collections::HashMap;
use subspace_malicious_operator::malicious_domain_instance_starter::DomainInstanceStarter;
use subspace_malicious_operator::{Cli, DomainCli};
Expand Down
2 changes: 1 addition & 1 deletion crates/subspace-node/src/commands/run.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ use sc_storage_monitor::StorageMonitorService;
use sc_transaction_pool_api::OffchainTransactionPoolFactory;
use sc_utils::mpsc::tracing_unbounded;
use sp_core::traits::SpawnEssentialNamed;
use sp_messenger::messages::ChainId;
use sp_domains::ChainId;
use std::env;
use subspace_runtime::{Block, RuntimeApi};
use tracing::{debug, error, info, info_span, warn};
Expand Down
6 changes: 3 additions & 3 deletions crates/subspace-runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,12 +60,12 @@ use sp_core::crypto::{ByteArray, KeyTypeId};
use sp_core::{OpaqueMetadata, H256};
use sp_domains::bundle_producer_election::BundleProducerElectionParams;
use sp_domains::{
DomainId, DomainInstanceData, DomainsHoldIdentifier, ExecutionReceiptFor, OpaqueBundle,
OperatorId, OperatorPublicKey, StakingHoldIdentifier,
ChainId, DomainId, DomainInstanceData, DomainsHoldIdentifier, ExecutionReceiptFor,
OpaqueBundle, OperatorId, OperatorPublicKey, StakingHoldIdentifier,
};
use sp_domains_fraud_proof::fraud_proof::FraudProof;
use sp_messenger::endpoint::{Endpoint, EndpointHandler as EndpointHandlerT, EndpointId};
use sp_messenger::messages::{BlockMessagesWithStorageKey, ChainId, CrossDomainMessage, MessageId};
use sp_messenger::messages::{BlockMessagesWithStorageKey, CrossDomainMessage, MessageId};
use sp_messenger_host_functions::{get_storage_key, StorageKeyRequest};
use sp_mmr_primitives::{EncodableOpaqueLeaf, Proof};
use sp_runtime::traits::{
Expand Down
1 change: 1 addition & 0 deletions domains/client/cross-domain-message-gossip/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ sc-transaction-pool-api = { version = "4.0.0-dev", git = "https://github.com/sub
sc-utils = { version = "4.0.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "d6b500960579d73c43fc4ef550b703acfa61c4c8" }
sp-blockchain = { version = "4.0.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "d6b500960579d73c43fc4ef550b703acfa61c4c8" }
sp-core = { version = "21.0.0", git = "https://github.com/subspace/polkadot-sdk", rev = "d6b500960579d73c43fc4ef550b703acfa61c4c8" }
sp-domains = { version = "0.1.0", default-features = false, path = "../../../crates/sp-domains" }
sp-messenger = { version = "0.1.0", default-features = false, path = "../../primitives/messenger" }
sp-runtime = { version = "24.0.0", git = "https://github.com/subspace/polkadot-sdk", rev = "d6b500960579d73c43fc4ef550b703acfa61c4c8" }
tracing = "0.1.40"
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use sc_network_gossip::{
};
use sc_utils::mpsc::{tracing_unbounded, TracingUnboundedReceiver, TracingUnboundedSender};
use sp_core::twox_256;
use sp_messenger::messages::ChainId;
use sp_domains::ChainId;
use sp_runtime::traits::{Block as BlockT, Hash as HashT, Header as HeaderT};
use std::collections::{BTreeMap, HashSet};
use std::future::poll_fn;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use futures::{Stream, StreamExt};
use sc_network::NetworkPeers;
use sc_transaction_pool_api::{TransactionPool, TransactionSource};
use sp_blockchain::HeaderBackend;
use sp_messenger::messages::ChainId;
use sp_domains::ChainId;
use sp_runtime::codec::Decode;
use sp_runtime::traits::Block as BlockT;
use std::sync::Arc;
Expand Down
1 change: 1 addition & 0 deletions domains/client/domain-operator/src/aux_schema.rs
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,7 @@ mod tests {
execution_trace: Default::default(),
execution_trace_root: Default::default(),
block_fees: Default::default(),
transfers: Default::default(),
}
}

Expand Down
3 changes: 3 additions & 0 deletions domains/client/domain-operator/src/domain_block_processor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -396,6 +396,8 @@ where
execution_trace: trace,
execution_trace_root: sp_core::H256(trace_root),
block_fees,
// TODO: Fetch transfers from the runtime
transfers: Default::default(),
};

Ok(DomainBlockResult {
Expand Down Expand Up @@ -973,6 +975,7 @@ mod tests {
execution_trace: sp_std::vec![],
execution_trace_root: Default::default(),
block_fees: Default::default(),
transfers: Default::default(),
}
}

Expand Down
4 changes: 2 additions & 2 deletions domains/client/relayer/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ use sc_client_api::{AuxStore, HeaderBackend, ProofProvider, StorageProof};
use sc_utils::mpsc::TracingUnboundedSender;
use scale_info::TypeInfo;
use sp_api::ProvideRuntimeApi;
use sp_domains::DomainsApi;
use sp_domains::{ChainId, DomainsApi};
use sp_messenger::messages::{
BlockMessageWithStorageKey, BlockMessagesWithStorageKey, ChainId, ConsensusChainMmrLeafProof,
BlockMessageWithStorageKey, BlockMessagesWithStorageKey, ConsensusChainMmrLeafProof,
CrossDomainMessage, Proof,
};
use sp_messenger::{MessengerApi, RelayerApi};
Expand Down
3 changes: 1 addition & 2 deletions domains/client/relayer/src/worker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@ use sc_client_api::{AuxStore, BlockchainEvents, ProofProvider};
use sc_state_db::PruningMode;
use sp_api::{ApiError, ProvideRuntimeApi};
use sp_consensus::SyncOracle;
use sp_domains::DomainsApi;
use sp_messenger::messages::ChainId;
use sp_domains::{ChainId, DomainsApi};
use sp_messenger::{MessengerApi, RelayerApi};
use sp_runtime::scale_info::TypeInfo;
use sp_runtime::traits::{CheckedSub, NumberFor, Zero};
Expand Down
3 changes: 2 additions & 1 deletion domains/pallets/messenger/src/fees.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@ use crate::{BalanceOf, Config, Error, Pallet};
use frame_support::traits::fungible::Mutate;
use frame_support::traits::tokens::{Fortitude, Precision};
use frame_support::weights::WeightToFee;
use sp_domains::ChainId;
use sp_messenger::endpoint::Endpoint;
use sp_messenger::messages::{ChainId, ChannelId, FeeModel, MessageId, Nonce};
use sp_messenger::messages::{ChannelId, FeeModel, MessageId, Nonce};
use sp_messenger::OnXDMRewards;
use sp_runtime::traits::CheckedAdd;
use sp_runtime::DispatchResult;
Expand Down
10 changes: 5 additions & 5 deletions domains/pallets/messenger/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,8 @@ use frame_support::traits::fungible::Inspect;
pub use pallet::*;
use scale_info::TypeInfo;
use sp_core::U256;
use sp_messenger::messages::{
ChainId, ChannelId, CrossDomainMessage, FeeModel, Message, MessageId, Nonce,
};
use sp_domains::ChainId;
use sp_messenger::messages::{ChannelId, CrossDomainMessage, FeeModel, Message, MessageId, Nonce};
use sp_runtime::traits::{Extrinsic, Hash};
use sp_runtime::DispatchError;

Expand Down Expand Up @@ -108,10 +107,11 @@ mod pallet {
use frame_system::pallet_prelude::*;
use sp_core::storage::StorageKey;
use sp_domains::proof_provider_and_verifier::{StorageProofVerifier, VerificationError};
use sp_domains::ChainId;
use sp_messenger::endpoint::{Endpoint, EndpointHandler, EndpointRequest, Sender};
use sp_messenger::messages::{
ChainId, CrossDomainMessage, InitiateChannelParams, Message, MessageId, MessageWeightTag,
Payload, ProtocolMessageRequest, RequestResponse, VersionedPayload,
CrossDomainMessage, InitiateChannelParams, Message, MessageId, MessageWeightTag, Payload,
ProtocolMessageRequest, RequestResponse, VersionedPayload,
};
use sp_messenger::{MmrProofVerifier, OnXDMRewards, StorageKeys};
use sp_mmr_primitives::EncodableOpaqueLeaf;
Expand Down
6 changes: 3 additions & 3 deletions domains/pallets/messenger/src/messages.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ use crate::{
use codec::{Decode, Encode};
use frame_support::ensure;
use scale_info::TypeInfo;
use sp_domains::ChainId;
use sp_messenger::messages::{
BlockMessageWithStorageKey, BlockMessagesWithStorageKey, ChainId, Message, MessageId,
MessageWeightTag, Payload, ProtocolMessageRequest, ProtocolMessageResponse, RequestResponse,
VersionedPayload,
BlockMessageWithStorageKey, BlockMessagesWithStorageKey, Message, MessageId, MessageWeightTag,
Payload, ProtocolMessageRequest, ProtocolMessageResponse, RequestResponse, VersionedPayload,
};
use sp_runtime::traits::Get;
use sp_runtime::{ArithmeticError, DispatchError, DispatchResult};
Expand Down
4 changes: 2 additions & 2 deletions domains/pallets/messenger/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ use crate::{ChannelId, Channels, Config, InboxResponses, Nonce, Outbox, StateRoo
use frame_support::storage::generator::StorageDoubleMap;
use frame_support::weights::Weight;
use sp_core::storage::StorageKey;
use sp_domains::ChainId;
use sp_messenger::endpoint::{EndpointHandler, EndpointRequest, EndpointResponse};
use sp_messenger::messages::ChainId;
use sp_runtime::traits::BlakeTwo256;
use sp_runtime::DispatchResult;
use sp_state_machine::backend::Backend;
Expand All @@ -27,8 +27,8 @@ macro_rules! impl_runtime {
use frame_support::parameter_types;
use pallet_balances::AccountData;
use sp_core::H256;
use sp_domains::ChainId;
use sp_messenger::endpoint::{Endpoint, EndpointHandler, EndpointId};
use sp_messenger::messages::ChainId;
use sp_runtime::traits::{
BlakeTwo256, ConstU16, ConstU32, ConstU64, Convert, IdentityLookup,
};
Expand Down
3 changes: 2 additions & 1 deletion domains/pallets/messenger/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,10 @@ use pallet_transporter::Location;
use sp_core::storage::StorageKey;
use sp_core::{Blake2Hasher, H256};
use sp_domains::proof_provider_and_verifier::{StorageProofVerifier, VerificationError};
use sp_domains::ChainId;
use sp_messenger::endpoint::{Endpoint, EndpointPayload, EndpointRequest, Sender};
use sp_messenger::messages::{
ChainId, ConsensusChainMmrLeafProof, CrossDomainMessage, InitiateChannelParams, Payload, Proof,
ConsensusChainMmrLeafProof, CrossDomainMessage, InitiateChannelParams, Payload, Proof,
ProtocolMessageRequest, RequestResponse, VersionedPayload,
};
use sp_runtime::traits::{Convert, ValidateUnsigned};
Expand Down
40 changes: 21 additions & 19 deletions domains/pallets/transporter/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,20 @@ homepage = "https://subspace.network"
repository = "https://github.com/subspace/subspace"
description = "Subspace node pallet to move funds between domains."
include = [
"/src",
"/Cargo.toml",
"/README.md",
"/src",
"/Cargo.toml",
"/README.md",
]

[dependencies]
codec = { package = "parity-scale-codec", version = "3.6.5", default-features = false, features = ["derive"] }
domain-runtime-primitives = { path = "../../primitives/runtime" , default-features = false }
domain-runtime-primitives = { path = "../../primitives/runtime", default-features = false }
frame-benchmarking = { version = "4.0.0-dev", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "d6b500960579d73c43fc4ef550b703acfa61c4c8", optional = true }
frame-support = { version = "4.0.0-dev", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "d6b500960579d73c43fc4ef550b703acfa61c4c8" }
frame-system = { version = "4.0.0-dev", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "d6b500960579d73c43fc4ef550b703acfa61c4c8" }
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/polkadot-sdk", rev = "d6b500960579d73c43fc4ef550b703acfa61c4c8" }
sp-domains = { version = "0.1.0", default-features = false, path = "../../../crates/sp-domains" }
sp-messenger = { version = "0.1.0", default-features = false, path = "../../primitives/messenger" }
sp-runtime = { version = "24.0.0", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "d6b500960579d73c43fc4ef550b703acfa61c4c8" }
sp-std = { version = "8.0.0", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "d6b500960579d73c43fc4ef550b703acfa61c4c8" }
Expand All @@ -32,22 +33,23 @@ sp-io = { version = "23.0.0", git = "https://github.com/subspace/polkadot-sdk",
[features]
default = ["std"]
std = [
"codec/std",
"domain-runtime-primitives/std",
"frame-benchmarking?/std",
"frame-support/std",
"frame-system/std",
"scale-info/std",
"sp-core/std",
"sp-messenger/std",
"sp-runtime/std",
"sp-std/std",
"codec/std",
"domain-runtime-primitives/std",
"frame-benchmarking?/std",
"frame-support/std",
"frame-system/std",
"scale-info/std",
"sp-core/std",
"sp-domains/std",
"sp-messenger/std",
"sp-runtime/std",
"sp-std/std",
]
try-runtime = ["frame-support/try-runtime"]
runtime-benchmarks = [
"frame-benchmarking",
"frame-benchmarking/runtime-benchmarks",
"frame-support/runtime-benchmarks",
"frame-system/runtime-benchmarks",
"sp-messenger/runtime-benchmarks",
"frame-benchmarking",
"frame-benchmarking/runtime-benchmarks",
"frame-support/runtime-benchmarks",
"frame-system/runtime-benchmarks",
"sp-messenger/runtime-benchmarks",
]
Loading
Loading