Skip to content

Commit

Permalink
remove on_exit from grandpa (paritytech#5098)
Browse files Browse the repository at this point in the history
  • Loading branch information
gavofyork authored Mar 5, 2020
1 parent f74589e commit 3272f26
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 30 deletions.
1 change: 0 additions & 1 deletion bin/node-template/node/src/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,6 @@ pub fn new_full(config: Configuration<GenesisConfig>)
link: grandpa_link,
network: service.network(),
inherent_data_providers: inherent_data_providers.clone(),
on_exit: service.on_exit(),
telemetry_on_connect: Some(service.telemetry_on_connect_stream()),
voting_rule: grandpa::VotingRulesBuilder::default().build(),
prometheus_registry: service.prometheus_registry()
Expand Down
1 change: 0 additions & 1 deletion bin/node/cli/src/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,6 @@ macro_rules! new_full {
link: grandpa_link,
network: service.network(),
inherent_data_providers: inherent_data_providers.clone(),
on_exit: service.on_exit(),
telemetry_on_connect: Some(service.telemetry_on_connect_stream()),
voting_rule: grandpa::VotingRulesBuilder::default().build(),
prometheus_registry: service.prometheus_registry(),
Expand Down
12 changes: 4 additions & 8 deletions client/finality-grandpa/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -536,7 +536,7 @@ fn register_finality_tracker_inherent_data_provider<Block: BlockT, Client>(
}

/// Parameters used to run Grandpa.
pub struct GrandpaParams<Block: BlockT, C, N, SC, VR, X> {
pub struct GrandpaParams<Block: BlockT, C, N, SC, VR> {
/// Configuration for the GRANDPA service.
pub config: Config,
/// A link to the block import worker.
Expand All @@ -545,8 +545,6 @@ pub struct GrandpaParams<Block: BlockT, C, N, SC, VR, X> {
pub network: N,
/// The inherent data providers.
pub inherent_data_providers: InherentDataProviders,
/// Handle to a future that will resolve on exit.
pub on_exit: X,
/// If supplied, can be used to hook on telemetry connection established events.
pub telemetry_on_connect: Option<futures::channel::mpsc::UnboundedReceiver<()>>,
/// A voting rule used to potentially restrict target votes.
Expand All @@ -557,8 +555,8 @@ pub struct GrandpaParams<Block: BlockT, C, N, SC, VR, X> {

/// Run a GRANDPA voter as a task. Provide configuration and a link to a
/// block import worker that has already been instantiated with `block_import`.
pub fn run_grandpa_voter<Block: BlockT, BE: 'static, C, N, SC, VR, X>(
grandpa_params: GrandpaParams<Block, C, N, SC, VR, X>,
pub fn run_grandpa_voter<Block: BlockT, BE: 'static, C, N, SC, VR>(
grandpa_params: GrandpaParams<Block, C, N, SC, VR>,
) -> sp_blockchain::Result<impl Future<Output = ()> + Unpin + Send + 'static> where
Block::Hash: Ord,
BE: Backend<Block> + 'static,
Expand All @@ -567,15 +565,13 @@ pub fn run_grandpa_voter<Block: BlockT, BE: 'static, C, N, SC, VR, X>(
VR: VotingRule<Block, C> + Clone + 'static,
NumberFor<Block>: BlockNumberOps,
DigestFor<Block>: Encode,
X: futures::Future<Output=()> + Clone + Send + Unpin + 'static,
C: ClientForGrandpa<Block, BE> + 'static,
{
let GrandpaParams {
mut config,
link,
network,
inherent_data_providers,
on_exit,
telemetry_on_connect,
voting_rule,
prometheus_registry,
Expand Down Expand Up @@ -647,7 +643,7 @@ pub fn run_grandpa_voter<Block: BlockT, BE: 'static, C, N, SC, VR, X>(
let telemetry_task = telemetry_task
.then(|_| future::pending::<()>());

Ok(future::select(future::select(voter_work, on_exit), telemetry_task).map(drop))
Ok(future::select(voter_work, telemetry_task).map(drop))
}

/// Future that powers the voter.
Expand Down
6 changes: 3 additions & 3 deletions client/finality-grandpa/src/observer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -159,8 +159,8 @@ pub fn run_grandpa_observer<BE, Block: BlockT, Client, N, SC>(
config: Config,
link: LinkHalf<Block, Client, SC>,
network: N,
on_exit: impl futures::Future<Output=()> + Clone + Send + Unpin + 'static,
) -> sp_blockchain::Result<impl Future<Output = ()> + Unpin + Send + 'static> where
) -> sp_blockchain::Result<impl Future<Output = ()> + Unpin + Send + 'static>
where
BE: Backend<Block> + Unpin + 'static,
N: NetworkT<Block> + Send + Clone + 'static,
SC: SelectChain<Block> + 'static,
Expand Down Expand Up @@ -194,7 +194,7 @@ pub fn run_grandpa_observer<BE, Block: BlockT, Client, N, SC>(
warn!("GRANDPA Observer failed: {:?}", e);
});

Ok(future::select(observer_work, on_exit).map(drop))
Ok(observer_work.map(drop))
}

/// Future that powers the observer.
Expand Down
17 changes: 0 additions & 17 deletions client/finality-grandpa/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -190,17 +190,6 @@ impl TestNetFactory for GrandpaTestNet {
}
}

#[derive(Clone)]
struct Exit;

impl futures::Future for Exit {
type Output = ();

fn poll(self: Pin<&mut Self>, _: &mut task::Context) -> task::Poll<()> {
task::Poll::Pending
}
}

#[derive(Default, Clone)]
pub(crate) struct TestApi {
genesis_authorities: AuthorityList,
Expand Down Expand Up @@ -444,7 +433,6 @@ fn run_to_completion_with<F>(
link: link,
network: net_service,
inherent_data_providers: InherentDataProviders::new(),
on_exit: Exit,
telemetry_on_connect: None,
voting_rule: (),
prometheus_registry: None,
Expand Down Expand Up @@ -576,7 +564,6 @@ fn finalize_3_voters_1_full_observer() {
link: link,
network: net_service,
inherent_data_providers: InherentDataProviders::new(),
on_exit: Exit,
telemetry_on_connect: None,
voting_rule: (),
prometheus_registry: None,
Expand Down Expand Up @@ -740,7 +727,6 @@ fn transition_3_voters_twice_1_full_observer() {
link: link,
network: net_service,
inherent_data_providers: InherentDataProviders::new(),
on_exit: Exit,
telemetry_on_connect: None,
voting_rule: (),
prometheus_registry: None,
Expand Down Expand Up @@ -1166,7 +1152,6 @@ fn voter_persists_its_votes() {
link,
network: this.net.lock().peers[0].network_service().clone(),
inherent_data_providers: InherentDataProviders::new(),
on_exit: Exit,
telemetry_on_connect: None,
voting_rule: VotingRulesBuilder::default().build(),
prometheus_registry: None,
Expand Down Expand Up @@ -1382,7 +1367,6 @@ fn finalize_3_voters_1_light_observer() {
},
link,
net.lock().peers[3].network_service().clone(),
Exit,
).unwrap()
);

Expand Down Expand Up @@ -1512,7 +1496,6 @@ fn voter_catches_up_to_latest_round_when_behind() {
link,
network: net.lock().peer(peer_id).network_service().clone(),
inherent_data_providers: InherentDataProviders::new(),
on_exit: Exit,
telemetry_on_connect: None,
voting_rule: (),
prometheus_registry: None,
Expand Down

0 comments on commit 3272f26

Please sign in to comment.