diff --git a/crates/pallet-domains/src/block_tree.rs b/crates/pallet-domains/src/block_tree.rs index eeb653743c7..4052c8e0b8e 100644 --- a/crates/pallet-domains/src/block_tree.rs +++ b/crates/pallet-domains/src/block_tree.rs @@ -1,6 +1,5 @@ //! Domain block tree -use crate::pallet::StateRoots; use crate::{ BalanceOf, BlockTree, BlockTreeNodes, Config, ConsensusBlockHash, DomainBlockNumberFor, DomainHashingFor, ExecutionInbox, ExecutionReceiptOf, HeadReceiptExtended, HeadReceiptNumber, @@ -313,12 +312,6 @@ pub(crate) fn process_execution_receipt( operator_ids, } = BlockTreeNodes::::take(receipt_hash).ok_or(Error::MissingDomainBlock)?; - _ = StateRoots::::take(( - domain_id, - to_prune, - execution_receipt.domain_block_hash, - )); - // Collect the paid bundle storage fees and the invalid bundle author let mut paid_bundle_storage_fees = BTreeMap::new(); let mut invalid_bundle_authors = Vec::new(); @@ -395,14 +388,6 @@ fn add_new_receipt_to_block_tree( // Construct and add a new domain block to the block tree let er_hash = execution_receipt.hash::>(); let domain_block_number = execution_receipt.domain_block_number; - StateRoots::::insert( - ( - domain_id, - domain_block_number, - execution_receipt.domain_block_hash, - ), - execution_receipt.final_state_root, - ); BlockTree::::insert(domain_id, domain_block_number, er_hash); let block_tree_node = BlockTreeNode { @@ -425,14 +410,6 @@ pub(crate) fn import_genesis_receipt( }; // NOTE: no need to update the head receipt number as `HeadReceiptNumber` is using `ValueQuery` BlockTree::::insert(domain_id, domain_block_number, er_hash); - StateRoots::::insert( - ( - domain_id, - domain_block_number, - block_tree_node.execution_receipt.domain_block_hash, - ), - block_tree_node.execution_receipt.final_state_root, - ); BlockTreeNodes::::insert(er_hash, block_tree_node); } diff --git a/crates/pallet-domains/src/lib.rs b/crates/pallet-domains/src/lib.rs index 415cca17ea2..e74175f67ba 100644 --- a/crates/pallet-domains/src/lib.rs +++ b/crates/pallet-domains/src/lib.rs @@ -502,17 +502,6 @@ mod pallet { pub(super) type HeadReceiptExtended = StorageMap<_, Identity, DomainId, bool, ValueQuery>; - /// State root mapped again each domain (block, hash) - /// This acts as an index for other protocols like XDM to fetch state roots faster. - #[pallet::storage] - pub(super) type StateRoots = StorageMap< - _, - Identity, - (DomainId, DomainBlockNumberFor, T::DomainHash), - T::DomainHash, - OptionQuery, - >; - /// The consensus block hash used to verify ER, /// only store the consensus block hash for a domain /// if that consensus block contains bundle of the domain, the hash will be pruned when the ER @@ -996,17 +985,9 @@ mod pallet { let receipt_hash = BlockTree::::take(domain_id, to_prune) .ok_or::>(FraudProofError::BadReceiptNotFound.into())?; - let BlockTreeNode { - execution_receipt, - operator_ids, - } = BlockTreeNodes::::take(receipt_hash) - .ok_or::>(FraudProofError::BadReceiptNotFound.into())?; - - let _ = StateRoots::::take(( - domain_id, - execution_receipt.domain_block_number, - execution_receipt.domain_block_hash, - )); + let BlockTreeNode { operator_ids, .. } = + BlockTreeNodes::::take(receipt_hash) + .ok_or::>(FraudProofError::BadReceiptNotFound.into())?; // NOTE: the operator id will be deduplicated since we are using `BTreeMap` // and slashed reason will hold earliest bad execution receipt hash which this @@ -1506,14 +1487,6 @@ impl Pallet { Some(HeadDomainNumber::::get(domain_id)) } - pub fn domain_state_root( - domain_id: DomainId, - domain_block_number: DomainBlockNumberFor, - domain_block_hash: T::DomainHash, - ) -> Option { - StateRoots::::get((domain_id, domain_block_number, domain_block_hash)) - } - pub fn runtime_id(domain_id: DomainId) -> Option { DomainRegistry::::get(domain_id) .map(|domain_object| domain_object.domain_config.runtime_id) diff --git a/crates/sp-domains/src/lib.rs b/crates/sp-domains/src/lib.rs index 159c55501a4..91fe69cc6f6 100644 --- a/crates/sp-domains/src/lib.rs +++ b/crates/sp-domains/src/lib.rs @@ -1044,12 +1044,6 @@ sp_api::decl_runtime_apis! { /// Returns the current best number of the domain. fn domain_best_number(domain_id: DomainId) -> Option>; - /// Returns the chain state root at the given block. - fn domain_state_root( - domain_id: DomainId, - number: HeaderNumberFor, - hash: HeaderHashFor) -> Option>; - /// Returns the execution receipt fn execution_receipt(receipt_hash: HeaderHashFor) -> Option>; diff --git a/crates/sp-subspace-mmr/Cargo.toml b/crates/sp-subspace-mmr/Cargo.toml index ed56656783a..bb1c3c95ab2 100644 --- a/crates/sp-subspace-mmr/Cargo.toml +++ b/crates/sp-subspace-mmr/Cargo.toml @@ -22,7 +22,7 @@ sp-api = { version = "4.0.0-dev", default-features = false, git = "https://githu sp-blockchain = { version = "4.0.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "d6b500960579d73c43fc4ef550b703acfa61c4c8", optional = true } sp-core = { version = "21.0.0", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "d6b500960579d73c43fc4ef550b703acfa61c4c8" } sp-externalities = { version = "0.19.0", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "d6b500960579d73c43fc4ef550b703acfa61c4c8" } -sp-mmr-primitives = { version = "4.0.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "d6b500960579d73c43fc4ef550b703acfa61c4c8" } +sp-mmr-primitives = { version = "4.0.0-dev", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "d6b500960579d73c43fc4ef550b703acfa61c4c8" } sp-runtime = { version = "24.0.0", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "d6b500960579d73c43fc4ef550b703acfa61c4c8" } sp-runtime-interface = { version = "17.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" } diff --git a/crates/sp-subspace-mmr/src/runtime_interface.rs b/crates/sp-subspace-mmr/src/runtime_interface.rs index c5d826e65ee..6dfb321f681 100644 --- a/crates/sp-subspace-mmr/src/runtime_interface.rs +++ b/crates/sp-subspace-mmr/src/runtime_interface.rs @@ -7,6 +7,7 @@ use sp_core::H256; use sp_externalities::ExternalitiesExt; use sp_mmr_primitives::EncodableOpaqueLeaf; use sp_runtime_interface::runtime_interface; +use sp_std::vec::Vec; /// MMR related runtime interface #[runtime_interface] @@ -29,7 +30,6 @@ pub struct LeafData { #[runtime_interface] pub trait DomainMmrRuntimeInterface { /// Verifies the given MMR proof using the leaves provided - #[allow(dead_code)] fn verify_mmr_proof( &mut self, leaves: Vec, diff --git a/crates/subspace-runtime/src/lib.rs b/crates/subspace-runtime/src/lib.rs index 4833074a2cf..61a874878c7 100644 --- a/crates/subspace-runtime/src/lib.rs +++ b/crates/subspace-runtime/src/lib.rs @@ -1076,10 +1076,6 @@ impl_runtime_apis! { Domains::domain_best_number(domain_id) } - fn domain_state_root(domain_id: DomainId, number: DomainNumber, hash: DomainHash) -> Option{ - Domains::domain_state_root(domain_id, number, hash) - } - fn execution_receipt(receipt_hash: DomainHash) -> Option> { Domains::execution_receipt(receipt_hash) } diff --git a/domains/client/relayer/src/lib.rs b/domains/client/relayer/src/lib.rs index 70aed4f6359..8e9ab5be800 100644 --- a/domains/client/relayer/src/lib.rs +++ b/domains/client/relayer/src/lib.rs @@ -53,8 +53,6 @@ pub enum Error { ApiError(sp_api::ApiError), /// Emits when the core domain block is not yet confirmed on the system domain. DomainNonConfirmedOnConsensusChain, - /// Emits when the core domain block state root is invalid. - DomainStateRootInvalid, /// Failed to submit a cross domain message UnableToSubmitCrossDomainMessage(TrySendError), /// Invalid ChainId @@ -321,36 +319,11 @@ where return Ok(()); } - // verify if the state root is matching. - let domain_number = *domain_block_header.number(); - if !consensus_chain_api - .domain_state_root( - best_consensus_chain_hash, - domain_id, - domain_number, - confirmed_block_hash, - )? - .map(|state_root| state_root == (*domain_block_header.state_root())) - .unwrap_or_else(|| { - // if this is genesis block, ignore as state root of genesis for domain is not tracked on runtime - domain_number.is_zero() - }) - { - tracing::error!( - target: LOG_TARGET, - "Domain state root mismatch at: Number: {:?}, Hash: {:?}", - domain_number, - confirmed_block_hash - ); - return Err(Error::DomainStateRootInvalid); - } - - // generate domain proof that points to the state root of the domain block on Consensus chain. + // generate domain proof that points to the confirmed domain block on consensus chain let storage_key = consensus_chain_api .confirmed_domain_block_storage_key(best_consensus_chain_hash, domain_id)?; - // construct storage proof for the core domain state root using system domain backend. - let domain_state_root_proof = consensus_chain_client.read_proof( + let domain_proof = consensus_chain_client.read_proof( best_consensus_chain_hash, &mut [storage_key.as_ref()].into_iter(), )?; @@ -365,7 +338,7 @@ where block_hash, key, *best_consensus_chain_block_header.state_root(), - domain_state_root_proof.clone(), + domain_proof.clone(), ) }, |msg| Self::gossip_outbox_message(domain_client, msg, gossip_message_sink), @@ -381,7 +354,7 @@ where block_id, key, *best_consensus_chain_block_header.state_root(), - domain_state_root_proof.clone(), + domain_proof.clone(), ) }, |msg| Self::gossip_inbox_message_response(domain_client, msg, gossip_message_sink), diff --git a/domains/primitives/messenger-host-functions/Cargo.toml b/domains/primitives/messenger-host-functions/Cargo.toml index 68f826788b0..6c90ddf6d14 100644 --- a/domains/primitives/messenger-host-functions/Cargo.toml +++ b/domains/primitives/messenger-host-functions/Cargo.toml @@ -23,7 +23,7 @@ sp-blockchain = { version = "4.0.0-dev", git = "https://github.com/subspace/polk 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-externalities = { version = "0.19.0", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "d6b500960579d73c43fc4ef550b703acfa61c4c8" } -sp-messenger = { version = "0.1.0", path = "../../primitives/messenger" } +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-runtime-interface = { version = "17.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" } @@ -46,4 +46,4 @@ std = [ "sp-std/std", ] -runtime-benchmarks = [] \ No newline at end of file +runtime-benchmarks = [] diff --git a/domains/primitives/messenger-host-functions/src/runtime_interface.rs b/domains/primitives/messenger-host-functions/src/runtime_interface.rs index bc9a969441e..f1eefb1bcfa 100644 --- a/domains/primitives/messenger-host-functions/src/runtime_interface.rs +++ b/domains/primitives/messenger-host-functions/src/runtime_interface.rs @@ -4,6 +4,7 @@ use crate::StorageKeyRequest; #[cfg(feature = "std")] use sp_externalities::ExternalitiesExt; use sp_runtime_interface::runtime_interface; +use sp_std::vec::Vec; /// Messenger related runtime interface #[runtime_interface] diff --git a/domains/primitives/messenger/src/messages.rs b/domains/primitives/messenger/src/messages.rs index 0ccea339356..d2c35f6fd94 100644 --- a/domains/primitives/messenger/src/messages.rs +++ b/domains/primitives/messenger/src/messages.rs @@ -8,6 +8,7 @@ use sp_runtime::app_crypto::sp_core::U256; use sp_runtime::{sp_std, DispatchError}; use sp_std::vec::Vec; use sp_trie::StorageProof; +use sp_std::vec; /// Channel identity. pub type ChannelId = U256; diff --git a/test/subspace-test-runtime/src/lib.rs b/test/subspace-test-runtime/src/lib.rs index 7f3d054cf43..e8eb156e018 100644 --- a/test/subspace-test-runtime/src/lib.rs +++ b/test/subspace-test-runtime/src/lib.rs @@ -1268,10 +1268,6 @@ impl_runtime_apis! { Domains::domain_best_number(domain_id) } - fn domain_state_root(domain_id: DomainId, number: DomainNumber, hash: DomainHash) -> Option{ - Domains::domain_state_root(domain_id, number, hash) - } - fn execution_receipt(receipt_hash: DomainHash) -> Option> { Domains::execution_receipt(receipt_hash) }