-
Notifications
You must be signed in to change notification settings - Fork 379
Introduce interface for relay chain interaction #835
Conversation
…ontents` to interface
Remove polkadot-client fromcollator crate.
Introduce enum as return type for block checking
client/consensus/aura/src/lib.rs
Outdated
@@ -252,13 +244,12 @@ pub struct BuildAuraConsensusParams<PF, BI, RBackend, CIDP, Client, BS, SO> { | |||
/// Build the [`AuraConsensus`]. | |||
/// | |||
/// Returns a boxed [`ParachainConsensus`]. | |||
pub fn build_aura_consensus<P, Block, PF, BI, RBackend, CIDP, Client, SO, BS, Error>( | |||
pub fn build_aura_consensus<P, Block, PF, BI, CIDP, Client, SO, BS, Error, RCInterface>( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The new
function is essentially the same. Aka we should remove this one build_aura_consensus
function and maybe rename the new
function to build
.
However, the new
function could also use the BuildAuraConsensusParams
.
client/consensus/aura/src/lib.rs
Outdated
create_inherent_data_providers: Arc<CIDP>, | ||
relay_chain_client: Arc<RClient>, | ||
relay_chain_backend: Arc<RBackend>, | ||
relay_chain_interface: RCInterface, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we actually use this anywhere? I could not find any usage?
use sp_core::sp_std::collections::btree_map::BTreeMap; | ||
use sp_state_machine::StorageValue; | ||
|
||
pub enum BlockCheckResult { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Docs.
client/relay-chain-local/src/lib.rs
Outdated
} | ||
|
||
fn is_major_syncing(&self) -> bool { | ||
let mut network = self.sync_oracle.lock().unwrap(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No unwraps
in the code. Either use expect
with a proof or remove.
Here you can just replace std::Mutex with parking_lot::Mutex
. Parkinglot mutex isn't poisened.
client/relay-chain-local/Cargo.toml
Outdated
sc-telemetry = { git = "https://github.com/paritytech/substrate", branch = "master" } | ||
sc-tracing = { git = "https://github.com/paritytech/substrate", branch = "master" } | ||
|
||
futures = { version = "0.3.1", features = ["compat"] } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
futures = { version = "0.3.1", features = ["compat"] } |
Not used?
|
||
/// Should be used for all interaction with the relay chain in cumulus. | ||
pub trait RelayChainInterface: Send + Sync { | ||
fn get_storage_by_key(&self, block_id: &BlockId, key: &[u8]) -> Option<StorageValue>; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Docs?
Also weird that we return None
here for when the key doesn't exist or there was an error.
fn validators(&self, block_id: &BlockId) -> Result<Vec<ValidatorId>, ApiError>; | ||
|
||
fn block_status(&self, block_id: BlockId) -> Result<BlockStatus, sp_blockchain::Error>; | ||
|
||
fn best_block_hash(&self) -> PHash; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Docs please
/// Check if block is in chain. If it is, we return BlockCheckResult::InChain. | ||
/// If it is not in the chain, we return BlockCheckResult::NotFound with a listener that can be used to wait on the block. | ||
fn check_block_in_chain( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Part of the docs should go to the BlockCheckResult
type.
However, I'm not really happy with the naming here.
Maybe something like wait_for_block
and return a future that either resolves directly or waits for the block to be imported.
client/network/src/lib.rs
Outdated
/// the builder gets access to this concrete instance. | ||
struct BlockAnnounceValidatorBuilder<Block, B> { | ||
/// Builds a [`BlockAnnounceValidator`] for a parachain. | ||
struct BlockAnnounceValidatorBuilder<Block, RCInterface> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Still relevant.
Improve get_storage_value method with error handling
} | ||
|
||
// Helper function to check if a block is in chain. | ||
pub fn check_block_in_chain<Client>( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This helper function came back to solve an issue which the lock guard that was not Send
in the async function. Also makes this reusable in the test.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good! Just some last small nitpicks.
.map_err(|e| { | ||
tracing::error!( | ||
target: LOG_TARGET, | ||
error = ?e, | ||
"Cannot obtain the hrmp ingress channel index." | ||
relay_parent = ?relay_parent_block_id, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
relay_parent = ?relay_parent_block_id, | |
relay_parent = ?relay_parent, |
error = ?e, | ||
"Cannot obtain the hrmp ingress channel index." | ||
relay_parent = ?relay_parent_block_id, | ||
error = ?e, "Cannot obtain the hrmp ingress channel." |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
error = ?e, "Cannot obtain the hrmp ingress channel." | |
error = ?e, | |
"Cannot obtain the hrmp ingress channel.", |
client/network/src/lib.rs
Outdated
@@ -408,88 +379,14 @@ where | |||
/// Build a block announce validator instance. | |||
/// | |||
/// Returns a boxed [`BlockAnnounceValidator`]. | |||
pub fn build_block_announce_validator<Block: BlockT, B>( | |||
relay_chain_client: polkadot_client::Client, | |||
pub fn build_block_announce_validator<Block: BlockT, RCInterface>( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function is rather useless now, please remove.
block_proposal_slot_portion, | ||
max_block_proposal_slot_portion, | ||
}: BuildAuraConsensusParams<PF, BI, CIDP, Client, BS, SO>, | ||
) -> Box<dyn ParachainConsensus<B>> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
) -> Box<dyn ParachainConsensus<B>> | |
) -> Self |
We don't need to box anymore. This was just a short coming of the old implementation with all the ExecuteWithClient
stuff etc, that is now solved.
Changes related to: paritytech/cumulus#835
* Bump Cumulus, Polkadot, and Substrate Also bumps some other depenencies * Remove duplicate `polkadot` dependency * Update `service.rs` Changes related to: paritytech/cumulus#835 * Update `command.rs` * Add `AddressGenerator` config type From: paritytech/substrate#10521 * Allow Root to execute overweight XCMP messages From: paritytech/cumulus#799 * Add `header` argument to `collect_collation_info` From: paritytech/cumulus#882 * Update Cumulus and friends again * Add Fork ID to genesis config paritytech/cumulus#870 * Add `state_version` field paritytech/substrate#9732 * Add `MaxConsumers` config parameter paritytech/substrate#10382 * Update Substrate compatibility note in README
In this PR, I introduce an interface that exposes methods for interaction with the relay chain, as discussed in #545.
These changes are only refactoring and have no impact on functionality.
Outline of the changes:
RelayChainInterface
RelayChainInterface
forRelayChainLocal
, a status-quo implementation that uses a full node in the same processRelayChainLocal