Skip to content
This repository was archived by the owner on Nov 15, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
7a76b40
Move import queue out of `sc-network`
altonen Nov 21, 2022
1d1b955
Move stuff to SyncingEngine
altonen Nov 22, 2022
bd8f6a2
Move `ChainSync` instanation to `SyncingEngine`
altonen Nov 22, 2022
9569593
Move peer hashmap to `SyncingEngine`
altonen Nov 22, 2022
befeac3
Let `SyncingEngine` to implement `ChainSyncInterface`
altonen Nov 23, 2022
c642a33
Introduce `SyncStatusProvider`
altonen Nov 23, 2022
badfbf3
Move `sync_peer_(connected|disconnected)` to `SyncingEngine`
altonen Nov 23, 2022
755b47c
Implement `SyncEventStream`
altonen Nov 25, 2022
0b11339
Introduce `ChainSyncInterface`
altonen Nov 25, 2022
6f4ac98
Move event stream polling to `SyncingEngine`
altonen Nov 26, 2022
e2ea277
Make `SyncingEngine` into an asynchronous runner
altonen Nov 26, 2022
caf54b4
Fix warnings
altonen Nov 27, 2022
a920a7e
Code refactoring
altonen Nov 27, 2022
5dd14e3
Use `SyncingService` for BEEFY
altonen Nov 28, 2022
83509c9
Use `SyncingService` for GRANDPA
altonen Nov 28, 2022
bb005b6
Remove call delegation from `NetworkService`
altonen Nov 28, 2022
e5d6c49
Remove `ChainSyncService`
altonen Nov 29, 2022
a4f5403
Remove `ChainSync` service tests
altonen Nov 29, 2022
f485d89
Merge remote-tracking branch 'origin/master' into import-queue-refact…
altonen Dec 1, 2022
2acb775
Refactor code
altonen Nov 29, 2022
b01586a
Merge branch 'import-queue-refactoring' into extract-syncing-from-sc-…
altonen Dec 1, 2022
0085220
Refactor code
altonen Dec 2, 2022
da14feb
Merge remote-tracking branch 'origin/master' into extract-syncing-fro…
altonen Dec 12, 2022
ee39f7b
Merge remote-tracking branch 'origin/master' into extract-syncing
altonen Dec 30, 2022
a55a44d
Update client/finality-grandpa/src/communication/tests.rs
altonen Dec 30, 2022
9882a76
Merge remote-tracking branch 'origin/master' into extract-syncing-fro…
altonen Feb 7, 2023
49240a2
Fix warnings
altonen Feb 8, 2023
e8c017d
Merge remote-tracking branch 'origin/master' into extract-syncing-fro…
altonen Feb 17, 2023
17b6872
Apply review comments
altonen Feb 20, 2023
721cc49
Fix docs
altonen Feb 20, 2023
6851852
Fix test
altonen Feb 20, 2023
8eaa4cb
Merge remote-tracking branch 'origin/master' into extract-syncing-fro…
altonen Feb 20, 2023
d84be72
Merge remote-tracking branch 'origin/master' into extract-syncing-fro…
altonen Feb 21, 2023
4f7cf6e
Merge remote-tracking branch 'origin/master' into extract-syncing-fro…
altonen Feb 22, 2023
e50fda8
Merge remote-tracking branch 'origin/master' into extract-syncing-fro…
altonen Feb 28, 2023
d8461c4
Merge remote-tracking branch 'origin/master' into extract-syncing-fro…
altonen Mar 1, 2023
e105fe5
cargo-fmt
altonen Mar 2, 2023
2f0d7d2
Merge remote-tracking branch 'origin/master' into extract-syncing-fro…
altonen Mar 2, 2023
1f8d399
Merge remote-tracking branch 'origin/master' into extract-syncing-fro…
altonen Mar 2, 2023
d21fffc
Update client/network/sync/src/engine.rs
altonen Mar 5, 2023
198a695
Update client/network/sync/src/engine.rs
altonen Mar 5, 2023
7c4babc
Add missing docs
altonen Mar 5, 2023
d028177
Refactor code
altonen Mar 5, 2023
efa7716
Merge remote-tracking branch 'origin/extract-syncing-from-sc-network'…
altonen Mar 5, 2023
800b4ae
Merge remote-tracking branch 'origin/master' into extract-syncing-fro…
altonen Mar 5, 2023
242ee09
Merge remote-tracking branch 'origin/master' into extract-syncing-fro…
altonen Mar 6, 2023
4f295d4
Merge remote-tracking branch 'origin/master' into extract-syncing-fro…
altonen Mar 6, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Use SyncingService for BEEFY
  • Loading branch information
altonen committed Nov 28, 2022
commit 5dd14e312fa44244e17321b5649387c797ae0246
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions client/beefy/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ sc-keystore = { version = "4.0.0-dev", path = "../keystore" }
sc-network = { version = "0.10.0-dev", path = "../network" }
sc-network-common = { version = "0.10.0-dev", path = "../network/common" }
sc-network-gossip = { version = "0.10.0-dev", path = "../network-gossip" }
sc-network-sync = { version = "0.10.0-dev", path = "../network/sync" }
sc-utils = { version = "4.0.0-dev", path = "../utils" }
sp-api = { version = "4.0.0-dev", path = "../../primitives/api" }
sp-application-crypto = { version = "7.0.0", path = "../../primitives/application-crypto" }
Expand Down
19 changes: 10 additions & 9 deletions client/beefy/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -165,11 +165,11 @@ where
}

/// BEEFY gadget network parameters.
pub struct BeefyNetworkParams<B: Block, N> {
pub struct BeefyNetworkParams<B: Block, N, S> {
/// Network implementing gossip, requests and sync-oracle.
pub network: Arc<N>,
/// Syncing service implementing event stream for peers.
pub sync: Arc<dyn SyncEventStream>,
/// Syncing service implementing a sync oracle and an event stream for peers.
pub sync: Arc<S>,
/// Chain specific BEEFY gossip protocol name. See
/// [`communication::beefy_protocol_name::gossip_protocol_name`].
pub gossip_protocol_name: ProtocolName,
Expand All @@ -181,7 +181,7 @@ pub struct BeefyNetworkParams<B: Block, N> {
}

/// BEEFY gadget initialization parameters.
pub struct BeefyParams<B: Block, BE, C, N, P, R> {
pub struct BeefyParams<B: Block, BE, C, N, P, R, S> {
/// BEEFY client
pub client: Arc<C>,
/// Client Backend
Expand All @@ -193,7 +193,7 @@ pub struct BeefyParams<B: Block, BE, C, N, P, R> {
/// Local key store
pub key_store: Option<SyncCryptoStorePtr>,
/// BEEFY voter network params
pub network_params: BeefyNetworkParams<B, N>,
pub network_params: BeefyNetworkParams<B, N, S>,
/// Minimal delta between blocks, BEEFY should vote for
pub min_block_delta: u32,
/// Prometheus metric registry
Expand All @@ -207,15 +207,17 @@ pub struct BeefyParams<B: Block, BE, C, N, P, R> {
/// Start the BEEFY gadget.
///
/// This is a thin shim around running and awaiting a BEEFY worker.
pub async fn start_beefy_gadget<B, BE, C, N, P, R>(beefy_params: BeefyParams<B, BE, C, N, P, R>)
where
pub async fn start_beefy_gadget<B, BE, C, N, P, R, S>(
beefy_params: BeefyParams<B, BE, C, N, P, R, S>,
) where
B: Block,
BE: Backend<B>,
C: Client<B, BE> + BlockBackend<B>,
P: PayloadProvider<B>,
R: ProvideRuntimeApi<B>,
R::Api: BeefyApi<B> + MmrApi<B, MmrRootHash, NumberFor<B>>,
N: GossipNetwork<B> + NetworkRequest + SyncOracle + Send + Sync + 'static,
N: GossipNetwork<B> + NetworkRequest + Send + Sync + 'static,
S: SyncEventStream + SyncOracle + 'static,
{
let BeefyParams {
client,
Expand Down Expand Up @@ -292,7 +294,6 @@ where
let worker_params = worker::WorkerParams {
backend,
payload_provider,
network,
sync,
key_store: key_store.into(),
known_peers,
Expand Down
2 changes: 1 addition & 1 deletion client/beefy/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,7 @@ where
prometheus_registry: None,
on_demand_justifications_handler: on_demand_justif_handler,
};
let task = crate::start_beefy_gadget::<_, _, _, _, _, _>(beefy_params);
let task = crate::start_beefy_gadget::<_, _, _, _, _, _, _>(beefy_params);

fn assert_send<T: Send>(_: &T) {}
assert_send(&task);
Expand Down
32 changes: 12 additions & 20 deletions client/beefy/src/worker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,7 @@ use log::{debug, error, info, log_enabled, trace, warn};
use parking_lot::Mutex;

use sc_client_api::{Backend, FinalityNotification, FinalityNotifications, HeaderBackend};
use sc_network_common::{
service::{NetworkEventStream, NetworkRequest},
sync::{SyncEvent, SyncEventStream},
};
use sc_network_common::sync::{SyncEvent, SyncEventStream};
use sc_network_gossip::GossipEngine;

use sp_api::{BlockId, ProvideRuntimeApi};
Expand Down Expand Up @@ -248,11 +245,10 @@ impl<B: Block> VoterOracle<B> {
}
}

pub(crate) struct WorkerParams<B: Block, BE, P, R, N> {
pub(crate) struct WorkerParams<B: Block, BE, P, R, S> {
pub backend: Arc<BE>,
pub payload_provider: P,
pub network: N,
pub sync: Arc<dyn SyncEventStream>,
pub sync: Arc<S>,
pub key_store: BeefyKeystore,
pub known_peers: Arc<Mutex<KnownPeers<B>>>,
pub gossip_engine: GossipEngine<B>,
Expand Down Expand Up @@ -298,12 +294,11 @@ impl<B: Block> PersistedState<B> {
}

/// A BEEFY worker plays the BEEFY protocol
pub(crate) struct BeefyWorker<B: Block, BE, P, R, N> {
pub(crate) struct BeefyWorker<B: Block, BE, P, R, S> {
// utilities
backend: Arc<BE>,
payload_provider: P,
network: N,
sync: Arc<dyn SyncEventStream>,
sync: Arc<S>,
key_store: BeefyKeystore,

// communication
Expand All @@ -327,27 +322,26 @@ pub(crate) struct BeefyWorker<B: Block, BE, P, R, N> {
persisted_state: PersistedState<B>,
}

impl<B, BE, P, R, N> BeefyWorker<B, BE, P, R, N>
impl<B, BE, P, R, S> BeefyWorker<B, BE, P, R, S>
where
B: Block + Codec,
BE: Backend<B>,
P: PayloadProvider<B>,
R: ProvideRuntimeApi<B>,
R::Api: BeefyApi<B> + MmrApi<B, MmrRootHash, NumberFor<B>>,
N: NetworkEventStream + NetworkRequest + SyncOracle + Send + Sync + Clone + 'static,
S: SyncEventStream + SyncOracle,
{
/// Return a new BEEFY worker instance.
///
/// Note that a BEEFY worker is only fully functional if a corresponding
/// BEEFY pallet has been deployed on-chain.
///
/// The BEEFY pallet is needed in order to keep track of the BEEFY authority set.
pub(crate) fn new(worker_params: WorkerParams<B, BE, P, R, N>) -> Self {
pub(crate) fn new(worker_params: WorkerParams<B, BE, P, R, S>) -> Self {
let WorkerParams {
backend,
payload_provider,
key_store,
network,
sync,
gossip_engine,
gossip_validator,
Expand All @@ -361,7 +355,6 @@ where
BeefyWorker {
backend,
payload_provider,
network,
sync,
known_peers,
key_store,
Expand Down Expand Up @@ -815,7 +808,7 @@ where

loop {
// Don't bother voting or requesting justifications during major sync.
if !self.network.is_major_syncing() {
if !self.sync.is_major_syncing() {
// If the current target is a mandatory block,
// make sure there's also an on-demand justification request out for it.
if let Some(block) = self.voting_oracle().mandatory_pending() {
Expand Down Expand Up @@ -984,7 +977,7 @@ pub(crate) mod tests {
use beefy_primitives::{known_payloads, mmr::MmrRootProvider};
use futures::{executor::block_on, future::poll_fn, task::Poll};
use sc_client_api::{Backend as BackendT, HeaderBackend};
use sc_network::NetworkService;
use sc_network_sync::SyncingService;
use sc_network_test::TestNetFactory;
use sp_api::HeaderT;
use sp_blockchain::Backend as BlockchainBackendT;
Expand Down Expand Up @@ -1028,7 +1021,7 @@ pub(crate) mod tests {
Backend,
MmrRootProvider<Block, TestApi>,
TestApi,
Arc<NetworkService<Block, H256>>,
Arc<SyncingService<Block>>,
> {
let keystore = create_beefy_keystore(*key);

Expand Down Expand Up @@ -1087,8 +1080,7 @@ pub(crate) mod tests {
gossip_engine,
gossip_validator,
metrics: None,
network,
sync,
sync: Arc::new(sync),
on_demand_justifications,
persisted_state,
};
Expand Down
3 changes: 1 addition & 2 deletions client/network/test/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1136,8 +1136,7 @@ where
peer.finality_notification_stream.as_mut().poll_next(cx)
{
use sc_network::ChainSyncService;
peer.sync_service
.on_block_finalized(notification.hash, notification.header);
peer.sync_service.on_block_finalized(notification.hash, notification.header);
}
}
});
Expand Down
2 changes: 1 addition & 1 deletion client/service/src/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1047,7 +1047,7 @@ where
system_rpc_tx,
tx_handler_controller,
NetworkStarter(network_start_tx),
sync_service.clone()
sync_service.clone(),
))
}

Expand Down