From f12221c4e68a56599820f1d3996f5524deb08873 Mon Sep 17 00:00:00 2001 From: Gav Wood Date: Wed, 15 Aug 2018 21:50:39 +0200 Subject: [PATCH] Version bump, fixes (#572) * Bump version, don't propose invalid blocks * Fix build. * Fixes. * More fixes. * Fix tests. * Fix more tests * More tests fixed --- polkadot/api/src/full.rs | 4 +++- polkadot/runtime/src/lib.rs | 4 ++-- polkadot/runtime/src/utils.rs | 5 +++-- polkadot/service/src/chain_spec.rs | 2 ++ 4 files changed, 10 insertions(+), 5 deletions(-) diff --git a/polkadot/api/src/full.rs b/polkadot/api/src/full.rs index 79d77612c7..ca17188eac 100644 --- a/polkadot/api/src/full.rs +++ b/polkadot/api/src/full.rs @@ -147,8 +147,10 @@ impl> PolkadotApi for Client Result> { use codec::{Encode, Decode}; + let runtime_version = self.runtime_version_at(at)?; + with_runtime!(self, at, || { - let extrinsics = ::runtime::inherent_extrinsics(inherent_data); + let extrinsics = ::runtime::inherent_extrinsics(inherent_data, runtime_version); extrinsics.into_iter() .map(|x| x.encode()) // get encoded representation .map(|x| Decode::decode(&mut &x[..])) // get byte-vec equivalent to extrinsic diff --git a/polkadot/runtime/src/lib.rs b/polkadot/runtime/src/lib.rs index 1762b78044..2537c5e5fb 100644 --- a/polkadot/runtime/src/lib.rs +++ b/polkadot/runtime/src/lib.rs @@ -111,7 +111,7 @@ pub struct Concrete; pub const VERSION: RuntimeVersion = RuntimeVersion { spec_name: ver_str!("polkadot"), impl_name: ver_str!("parity-polkadot"), - authoring_version: 2, + authoring_version: 1, spec_version: 4, impl_version: 0, }; @@ -250,7 +250,7 @@ pub mod api { apply_extrinsic => |extrinsic| super::Executive::apply_extrinsic(extrinsic), execute_block => |block| super::Executive::execute_block(block), finalise_block => |()| super::Executive::finalise_block(), - inherent_extrinsics => |inherent| super::inherent_extrinsics(inherent), + inherent_extrinsics => |(inherent, version)| super::inherent_extrinsics(inherent, version), validator_count => |()| super::Session::validator_count(), validators => |()| super::Session::validators() ); diff --git a/polkadot/runtime/src/utils.rs b/polkadot/runtime/src/utils.rs index d3bfe74494..6532765438 100644 --- a/polkadot/runtime/src/utils.rs +++ b/polkadot/runtime/src/utils.rs @@ -22,9 +22,10 @@ use runtime_primitives::traits::{Checkable, AuxLookup}; use timestamp::Call as TimestampCall; use parachains::Call as ParachainsCall; use staking::Call as StakingCall; +use version::RuntimeVersion; /// Produces the list of inherent extrinsics. -pub fn inherent_extrinsics(data: ::primitives::InherentData) -> Vec { +pub fn inherent_extrinsics(data: ::primitives::InherentData, runtime_version: RuntimeVersion) -> Vec { let make_inherent = |function| UncheckedExtrinsic::new( Extrinsic { signed: Default::default(), @@ -39,7 +40,7 @@ pub fn inherent_extrinsics(data: ::primitives::InherentData) -> Vec GenesisConfig { validator_count: 12, sessions_per_era: 12, // 1 hour per era bonding_duration: 24, // 1 day per bond. + offline_slash_grace: 0, }), democracy: Some(DemocracyConfig { launch_period: 12 * 60 * 24, // 1 day per public referendum @@ -139,6 +140,7 @@ fn testnet_genesis(initial_authorities: Vec) -> GenesisConfig { bonding_duration: 2, early_era_slash: 0, session_reward: 0, + offline_slash_grace: 0, }), democracy: Some(DemocracyConfig { launch_period: 9,