Skip to content

Commit

Permalink
update ER type to include transfers field.
Browse files Browse the repository at this point in the history
Marked a TODO where necessary to fetch the data from Runtime when we have XDM enabled
  • Loading branch information
vedhavyas committed Feb 7, 2024
1 parent ea1e002 commit 8969219
Show file tree
Hide file tree
Showing 6 changed files with 63 additions and 53 deletions.
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
55 changes: 55 additions & 0 deletions crates/sp-domains/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,57 @@ impl PassBy for DomainId {
type PassBy = pass_by::Codec<Self>;
}

/// 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,
}
}
}

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)
}
}

#[derive(Debug, Decode, Encode, TypeInfo, PartialEq, Eq, Clone)]
pub struct BundleHeader<Number, Hash, DomainHeader: HeaderT, Balance> {
/// Proof of bundle producer election.
Expand Down Expand Up @@ -433,6 +484,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 +563,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 +600,7 @@ impl<
execution_trace,
execution_trace_root,
block_fees: Default::default(),
transfers: Default::default(),
}
}
}
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
55 changes: 2 additions & 53 deletions domains/primitives/messenger/src/messages.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
use crate::endpoint::{Endpoint, EndpointRequest, EndpointResponse};
use codec::{Decode, Encode, FullCodec, MaxEncodedLen};
use codec::{Decode, Encode, FullCodec};
use frame_support::storage::generator::StorageMap;
use frame_support::storage::storage_prefix;
use frame_support::Identity;
use scale_info::TypeInfo;
use serde::{Deserialize, Serialize};
use sp_core::storage::StorageKey;
use sp_domains::proof_provider_and_verifier::StorageProofVerifier;
pub use sp_domains::ChainId;
use sp_domains::DomainId;
use sp_runtime::app_crypto::sp_core::U256;
use sp_runtime::{sp_std, DispatchError};
Expand Down Expand Up @@ -120,57 +120,6 @@ impl MessageWeightTag {
}
}

/// 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,
}
}
}

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)
}
}

/// Message contains information to be sent to or received from another chain.
#[derive(Debug, Encode, Decode, Clone, Eq, PartialEq, TypeInfo)]
pub struct Message<Balance> {
Expand Down

0 comments on commit 8969219

Please sign in to comment.