grandpa: Use storage proofs for Grandpa authorities (#3734)

* grandpa: Write Grandpa authorities to well known key.

Instead of requiring execution proofs for Grandpa authorities, this
enables much simpler storage proofs.

* grandpa: Introduce named AuthorityList type.

* grandpa: Storage migration for srml-grandpa module.

* Remove no-longer-used GrandpaApi runtime API.

* grandpa: Write AuthorityList to storage with encoding version.

We expect the AuthorityList type may change (eg. key changes). To make
upgrades smoother, include a version in the stored value.

* Bump node runtime spec version.

* Update srml/grandpa/src/lib.rs

Co-Authored-By: André Silva <andre.beat@gmail.com>
This commit is contained in:
Jim Posen
2019-10-31 14:33:34 +01:00
committed by GitHub
parent 3cbc28ab59
commit c0a1926704
18 changed files with 263 additions and 195 deletions
+2 -9
View File
@@ -29,7 +29,6 @@ use node_primitives::{
AccountId, AccountIndex, Balance, BlockNumber, Hash, Index,
Moment, Signature,
};
use grandpa::fg_primitives;
use client::{
block_builder::api::{self as block_builder_api, InherentData, CheckInherentsResult},
runtime_api as client_api, impl_runtime_apis
@@ -46,7 +45,7 @@ use version::RuntimeVersion;
#[cfg(any(feature = "std", test))]
use version::NativeVersion;
use primitives::OpaqueMetadata;
use grandpa::{AuthorityId as GrandpaId, AuthorityWeight as GrandpaWeight};
use grandpa::AuthorityId as GrandpaId;
use im_online::sr25519::{AuthorityId as ImOnlineId};
use transaction_payment_rpc_runtime_api::RuntimeDispatchInfo;
use contracts_rpc_runtime_api::ContractExecResult;
@@ -81,7 +80,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion {
// and set impl_version to equal spec_version. If only runtime
// implementation changes and behavior does not, then leave spec_version as
// is and increment impl_version.
spec_version: 190,
spec_version: 191,
impl_version: 191,
apis: RUNTIME_API_VERSIONS,
};
@@ -611,12 +610,6 @@ impl_runtime_apis! {
}
}
impl fg_primitives::GrandpaApi<Block> for Runtime {
fn grandpa_authorities() -> Vec<(GrandpaId, GrandpaWeight)> {
Grandpa::grandpa_authorities()
}
}
impl babe_primitives::BabeApi<Block> for Runtime {
fn configuration() -> babe_primitives::BabeConfiguration {
// The choice of `c` parameter (where `1 - c` represents the