Skip to content

Commit

Permalink
Warp sync part I (paritytech#9227)
Browse files Browse the repository at this point in the history
* Started warp sync

* BABE & GRANDPA recovery

* Warp sync protocol

* Sync warp proofs first

* Added basic documentation

* Apply suggestions from code review

Co-authored-by: André Silva <123550+andresilva@users.noreply.github.com>

* Style changes

* Apply suggestions from code review

Co-authored-by: André Silva <123550+andresilva@users.noreply.github.com>

* fmt

* Apply suggestions from code review

Co-authored-by: André Silva <123550+andresilva@users.noreply.github.com>

* Fixed chage trie pruning wrt missing blocks

* Restore parent finalization

* fmt

* fmt

* Revert pwasm-utils bump

* Change error type & check API version

* Apply suggestions from code review

Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com>

* Build fix

* Fixed target block check

* Formatting

Co-authored-by: André Silva <123550+andresilva@users.noreply.github.com>
Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com>
  • Loading branch information
3 people authored and Eric Miller committed Aug 2, 2021
1 parent d108b65 commit df0b904
Show file tree
Hide file tree
Showing 51 changed files with 1,310 additions and 450 deletions.
64 changes: 19 additions & 45 deletions Cargo.lock

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

1 change: 0 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ members = [
"client/executor/wasmi",
"client/executor/wasmtime",
"client/finality-grandpa",
"client/finality-grandpa-warp-sync",
"client/informant",
"client/keystore",
"client/light",
Expand Down
11 changes: 11 additions & 0 deletions bin/node-template/node/src/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,10 @@ pub fn new_full(mut config: Configuration) -> Result<TaskManager, ServiceError>
}

config.network.extra_sets.push(sc_finality_grandpa::grandpa_peers_set_config());
let warp_sync = Arc::new(sc_finality_grandpa::warp_proof::NetworkProvider::new(
backend.clone(),
grandpa_link.shared_authority_set().clone(),
));

let (network, system_rpc_tx, network_starter) =
sc_service::build_network(sc_service::BuildNetworkParams {
Expand All @@ -172,6 +176,7 @@ pub fn new_full(mut config: Configuration) -> Result<TaskManager, ServiceError>
import_queue,
on_demand: None,
block_announce_validator_builder: None,
warp_sync: Some(warp_sync),
})?;

if config.offchain_worker.enabled {
Expand Down Expand Up @@ -380,6 +385,11 @@ pub fn new_light(mut config: Configuration) -> Result<TaskManager, ServiceError>
telemetry: telemetry.as_ref().map(|x| x.handle()),
})?;

let warp_sync = Arc::new(sc_finality_grandpa::warp_proof::NetworkProvider::new(
backend.clone(),
grandpa_link.shared_authority_set().clone(),
));

let (network, system_rpc_tx, network_starter) =
sc_service::build_network(sc_service::BuildNetworkParams {
config: &config,
Expand All @@ -389,6 +399,7 @@ pub fn new_light(mut config: Configuration) -> Result<TaskManager, ServiceError>
import_queue,
on_demand: Some(on_demand.clone()),
block_announce_validator_builder: None,
warp_sync: Some(warp_sync),
})?;

if config.offchain_worker.enabled {
Expand Down
4 changes: 4 additions & 0 deletions bin/node-template/runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -402,6 +402,10 @@ impl_runtime_apis! {
Grandpa::grandpa_authorities()
}

fn current_set_id() -> fg_primitives::SetId {
Grandpa::current_set_id()
}

fn submit_report_equivocation_unsigned_extrinsic(
_equivocation_proof: fg_primitives::EquivocationProof<
<Block as BlockT>::Hash,
Expand Down
2 changes: 0 additions & 2 deletions bin/node/cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,6 @@ sc-service = { version = "0.10.0-dev", default-features = false, path = "../../.
sc-tracing = { version = "4.0.0-dev", path = "../../../client/tracing" }
sc-telemetry = { version = "4.0.0-dev", path = "../../../client/telemetry" }
sc-authority-discovery = { version = "0.10.0-dev", path = "../../../client/authority-discovery" }
sc-finality-grandpa-warp-sync = { version = "0.10.0-dev", path = "../../../client/finality-grandpa-warp-sync", optional = true }

# frame dependencies
pallet-indices = { version = "4.0.0-dev", path = "../../../frame/indices" }
Expand Down Expand Up @@ -161,7 +160,6 @@ cli = [
"frame-benchmarking-cli",
"substrate-frame-cli",
"sc-service/db",
"sc-finality-grandpa-warp-sync",
"structopt",
"substrate-build-script-utils",
"try-runtime-cli",
Expand Down
21 changes: 11 additions & 10 deletions bin/node/cli/src/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -228,16 +228,10 @@ pub fn new_full_base(
let auth_disc_publish_non_global_ips = config.network.allow_non_globals_in_dht;

config.network.extra_sets.push(grandpa::grandpa_peers_set_config());

#[cfg(feature = "cli")]
config.network.request_response_protocols.push(
sc_finality_grandpa_warp_sync::request_response_config_for_chain(
&config,
task_manager.spawn_handle(),
backend.clone(),
import_setup.1.shared_authority_set().clone(),
),
);
let warp_sync = Arc::new(grandpa::warp_proof::NetworkProvider::new(
backend.clone(),
import_setup.1.shared_authority_set().clone(),
));

let (network, system_rpc_tx, network_starter) =
sc_service::build_network(sc_service::BuildNetworkParams {
Expand All @@ -248,6 +242,7 @@ pub fn new_full_base(
import_queue,
on_demand: None,
block_announce_validator_builder: None,
warp_sync: Some(warp_sync),
})?;

if config.offchain_worker.enabled {
Expand Down Expand Up @@ -512,6 +507,11 @@ pub fn new_light_base(
telemetry.as_ref().map(|x| x.handle()),
)?;

let warp_sync = Arc::new(grandpa::warp_proof::NetworkProvider::new(
backend.clone(),
grandpa_link.shared_authority_set().clone(),
));

let (network, system_rpc_tx, network_starter) =
sc_service::build_network(sc_service::BuildNetworkParams {
config: &config,
Expand All @@ -521,6 +521,7 @@ pub fn new_light_base(
import_queue,
on_demand: Some(on_demand.clone()),
block_announce_validator_builder: None,
warp_sync: Some(warp_sync),
})?;

let enable_grandpa = !config.disable_grandpa;
Expand Down
4 changes: 4 additions & 0 deletions bin/node/runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1336,6 +1336,10 @@ impl_runtime_apis! {
Grandpa::grandpa_authorities()
}

fn current_set_id() -> fg_primitives::SetId {
Grandpa::current_set_id()
}

fn submit_report_equivocation_unsigned_extrinsic(
equivocation_proof: fg_primitives::EquivocationProof<
<Block as BlockT>::Hash,
Expand Down
3 changes: 3 additions & 0 deletions client/cli/src/arg_enums.rs
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,8 @@ arg_enum! {
Fast,
// Download blocks without executing them. Download latest state without proofs.
FastUnsafe,
// Prove finality and download the latest state.
Warp,
}
}

Expand All @@ -253,6 +255,7 @@ impl Into<sc_network::config::SyncMode> for SyncMode {
sc_network::config::SyncMode::Fast { skip_proofs: false, storage_chain_mode: false },
SyncMode::FastUnsafe =>
sc_network::config::SyncMode::Fast { skip_proofs: true, storage_chain_mode: false },
SyncMode::Warp => sc_network::config::SyncMode::Warp,
}
}
}
Expand Down
Loading

0 comments on commit df0b904

Please sign in to comment.