-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Ensure that table router is always built #952
Conversation
This pr ensures that the table router is always build, aka the future is resolved. This is important, as the table router internally spawns tasks to handle gossip messages. Handling gossip messages is not only required on parachain validators, but also on relay chain validators to receive collations. Tests are added to ensure that the assumptions hold.
@@ -236,6 +232,57 @@ impl<C, N, P, SC, SP> ServiceBuilder<C, N, P, SC, SP> where | |||
} | |||
} | |||
|
|||
/// Abstraction over `collation_fetch`. | |||
pub trait CollationFetch { |
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.
CollationFetch
is already a wrapper around the Collators
abstraction. I say we only need one or the other
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 doesn't need to be pub
, does it? The user of the trait is pub(crate)
only
let availability_store = self.availability_store.clone(); | ||
// launch parachain work asynchronously. | ||
async fn launch_work<Client>( | ||
collation_fetch: impl CollationFetch, |
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 function has way too many parameters. what about refactoring it to a struct *Params
?
Was the table router not always built before? |
Launch work was only called when the duty of the local validator is some parachain. However we need to build the router also for relay chain validators. Otherwise we don't spawn the task that handles gossip messages and thus the relay chain validator doesn't receive the candidate message. (I debugged why parachains don't work anymore and found multiple bugs. This one, the other pr about updating the parachain header and I will need to open another one to fix the last issue) |
Client::Api: ParachainHost<Block, Error = sp_blockchain::Error>, | ||
{ | ||
// fetch a local collation from connected collators. | ||
let (collation_info, full_output) = match collation_fetch.collation_fetch( |
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.
One simplification would be to accept the collation_fetch
future as an argument rather than the CollationFetch
trait. then this function doesn't need all those parameters
@rphmeier I changed the implementation a little bit, not sure if that makes you more happy :) |
<N::TableRouter as TableRouter>::SendLocalCollation: Send, | ||
N::BuildTableRouter: Unpin + Send + 'static, | ||
SP: Spawn + Send + 'static, | ||
CFB: Fn() -> CF + Send, | ||
CF: FnOnce(ParaId, Hash, Arc<P>, Option<u64>, usize) -> CFF + Send + 'static, |
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 code is less readable than before. It's not clear what all of those parameters are from the signature
} | ||
|
||
#[test] | ||
fn router_is_build_on_relay_chain_validator() { |
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.
fn router_is_build_on_relay_chain_validator() { | |
fn router_is_built_on_relay_chain_validator() { |
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.
baut
vs. gebaut
} | ||
|
||
// launch parachain work asynchronously. | ||
async fn launch_work<CF, Error>( |
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.
👍 that this is rewritten as async
@rphmeier comments addressed! |
f43c92430 Fix account derivation in CLI (#952) 9ac07e733 Add backbone configuration of cargo-spellcheck (#924) 2761c3fef Message dispatch support multiple instances (#942) 801c99f3d Add Wococo<>Rococo Header Relayer (#925) 21f490514 Remove Westend<>Rococo header sync (#940) 06235f162 do not panic if pallet is not yet initialized (#937) a13ee0bc3 Bump Substrate (#939) f8680cbfc jsonrpsee alpha6 (#938) 6163bcbf4 reonnect to failed client in on-demand relay background task (#936) 14e82bea3 Do not spawn additional task for on-demand relays (#933) b1557b882 Relay at least one header for every source chain session (#923) 9420649c1 Remove deprecated Runtime Header APIs (#932) 9627011e1 Update README.md (#931) 7b736b9cc Truncate output in logs. (#930) faad06e39 Make sure that relayers have dates in logs. (#927) 077345351 Update dump-logs script. (#928) c2d56b2e9 Add pruning to bechmarks & update weights. (#918) a30c51dc9 Add properties to Chain Spec (#917) d691c73e9 Fix issue with on-demand headers relay not starting (#921) 8ee55c1e1 Fix image publishing. (#922) f51fb59d0 Prefix in relay loops logs (#920) git-subtree-dir: bridges git-subtree-split: f43c924301c227d29ec161f6815d9bac458a211d
b2099c5c Bump Substrate to `b094edaf` (#958) 3f037094 Bump endowment amounts on Rialto and Millau (#957) b21fd07c Bump Substrate WASM builder (#947) 30ccd07c Bump Substrate to `ec180313` (#955) a7422ab1 Upgrade to GitHub-native Dependabot (#945) ed20ef34 Move pallet-bridge-dispatch types to primitives (#948) 2070c4d6 Endow accounts and add `bridgeIds` to chainspec. (#951) f43c9243 Fix account derivation in CLI (#952) 9ac07e73 Add backbone configuration of cargo-spellcheck (#924) 2761c3fe Message dispatch support multiple instances (#942) 801c99f3 Add Wococo<>Rococo Header Relayer (#925) 21f49051 Remove Westend<>Rococo header sync (#940) 06235f16 do not panic if pallet is not yet initialized (#937) a13ee0bc Bump Substrate (#939) f8680cbf jsonrpsee alpha6 (#938) 6163bcbf reonnect to failed client in on-demand relay background task (#936) 14e82bea Do not spawn additional task for on-demand relays (#933) b1557b88 Relay at least one header for every source chain session (#923) 9420649c Remove deprecated Runtime Header APIs (#932) 9627011e Update README.md (#931) 7b736b9c Truncate output in logs. (#930) faad06e3 Make sure that relayers have dates in logs. (#927) 07734535 Update dump-logs script. (#928) c2d56b2e Add pruning to bechmarks & update weights. (#918) a30c51dc Add properties to Chain Spec (#917) d691c73e Fix issue with on-demand headers relay not starting (#921) 8ee55c1e Fix image publishing. (#922) f51fb59d Prefix in relay loops logs (#920) git-subtree-dir: bridges git-subtree-split: b2099c5c0baf569e2ec7228507b6e4f3972143cc
This pr ensures that the table router is always build, aka the future is
resolved. This is important, as the table router internally spawns tasks
to handle gossip messages. Handling gossip messages is not only required
on parachain validators, but also on relay chain validators to receive collations.
Tests are added to ensure that the assumptions hold.
Requires: paritytech/substrate#5448