-
Notifications
You must be signed in to change notification settings - Fork 704
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
Move import queue from ChainSync
to SyncingEngine
#1736
Conversation
enum BlockRequestEvent<B: BlockT> { | ||
/// Action that [`engine::SyncingEngine`] should perform after reporting imported blocks with | ||
/// [`ChainSync::on_blocks_processed`]. | ||
enum BlockRequestAction<B: BlockT> { |
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.
Ideally all these block/import/response actions would be under one SyncAction
enum. SyncingEngine
calls ChainSync
, ChainSync
pushes the actions it wants SyncingEngine
to perform to its internal action queue and after each call to ChainSync
, SyncingEngine
would do while let Some(action) = self.chain_sync.next_action() { match action ... }
until all actions are consumed. We'd get rid of the OnBlockResponse::Nothing
for free.
Not in this PR though but a future task
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.
Makes sense, but may be returning actions from every call to ChainSync
instead of fetching them from next_action()
? Otherwise we'll need to be extremely careful to call next_action()
after every call to ChainSync
.
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.
I wouldn't go with returning an action from every function. Some calls to ChainSync
could result in more than one action so we'd have to return an iterator of actions from every call or make exceptions that some calls return an iterator where others return an Option<Action>
and then handle those differently on the call site. Doesn't seem too elegant.
If ChainSync
is only called when there's an I/O-related event, the handling of actions can be a simple loop after select!
self.network_service | ||
.disconnect_peer(id, self.block_announce_protocol_name.clone()); | ||
self.network_service.report_peer(id, repu); |
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.
Needs a deeper analysis but I'm not sure if ChainSync
requires a handle to NetworkService
anymore. Disconnecting & reporting a peer could be another action.
We could probably get rid of the NetworkServiceProvider
hack if the handle to NetworkService
was only passed to SyncingEngine::run()
.
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.
Disconnecting & reporting a peer could be another action.
It's probably fine as long as these actions will be handled synchornously. Just want to make sure we won't end up with reputation changes being pushed to an async queue again. We had problems with that in the past.
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.
In fact, right now they are pushed to an async queue:
let _ = self.tx.unbounded_send(ToServiceCommand::ReportPeer(who, cost_benefit)); |
But luckily after removing NetworkServiceProvider
we will be able to update reputations synchronously, because PeerStore
(formerly PeerSet
) has a sync implementation now:
self.inner.lock().report_peer(peer_id, change) |
@arkpar I've assigned you as a reviewer for this PR because you made some changes to syncing in the past. Let me know if you are not the right person to ask for review of |
* master: (24 commits) Init System Parachain storage versions and add migration check jobs to CI (#1344) no-bound derives: Use absolute path for `core` (#1763) migrate alliance, fast-unstake and bags list to use derive-impl (#1636) Tvl pool staking (#1322) improve service error (#1734) frame-support: `RuntimeDebug\Eq\PartialEq` impls for `Imbalance` (#1717) Point documentation links to monorepo (#1741) [NPoS] Fix for Reward Deficit in the pool (#1255) Move import queue from `ChainSync` to `SyncingEngine` (#1736) Enable mocking contracts (#1331) Revert "fix(review-bot): pull secrets from `master` environment" (#1748) Remove kusama and polkadot runtime crates (#1731) Use `Extensions` to register offchain worker custom extensions (#1719) [RPC-Spec-V2] chainHead: use integer for block index and adjust RuntimeVersion JSON format (#1666) fix(review-bot): pull secrets from `master` environment (#1745) Fix `subkey inspect` output text padding (#1744) archive: Implement height, hashByHeight and call (#1582) rpc/client: Propagate `rpc_methods` method to reported methods (#1713) rococo-runtime: `RococoGenesisExt` removed (#1490) PVF: more filesystem sandboxing (#1373) ...
* tsv-disabling-node-side: (24 commits) Init System Parachain storage versions and add migration check jobs to CI (#1344) no-bound derives: Use absolute path for `core` (#1763) migrate alliance, fast-unstake and bags list to use derive-impl (#1636) Tvl pool staking (#1322) improve service error (#1734) frame-support: `RuntimeDebug\Eq\PartialEq` impls for `Imbalance` (#1717) Point documentation links to monorepo (#1741) [NPoS] Fix for Reward Deficit in the pool (#1255) Move import queue from `ChainSync` to `SyncingEngine` (#1736) Enable mocking contracts (#1331) Revert "fix(review-bot): pull secrets from `master` environment" (#1748) Remove kusama and polkadot runtime crates (#1731) Use `Extensions` to register offchain worker custom extensions (#1719) [RPC-Spec-V2] chainHead: use integer for block index and adjust RuntimeVersion JSON format (#1666) fix(review-bot): pull secrets from `master` environment (#1745) Fix `subkey inspect` output text padding (#1744) archive: Implement height, hashByHeight and call (#1582) rpc/client: Propagate `rpc_methods` method to reported methods (#1713) rococo-runtime: `RococoGenesisExt` removed (#1490) PVF: more filesystem sandboxing (#1373) ...
This PR is part of [Sync 2.0](paritytech#534) refactoring aimed at making `ChainSync` a pure state machine. Resolves paritytech#501.
This PR is part of Sync 2.0 refactoring aimed at making
ChainSync
a pure state machine.Resolves #501.