Update to latest Substrate & Polkadot (#107)

* Update to latest Substrate & Polkadot

* Replace --unsafe-rpc-export with --unsafe-rpc-external

* Add --rpc-methods=Unsafe

Documented in substrate 24486f52929e9e518eeccbc6ad6da70e9e5bdf8a

* typos

* more typo

* fixed rpc expose

* Disable the integration test

Co-authored-by: Cecile Tonglet <cecile.tonglet@cecton.com>
This commit is contained in:
Bastian Köcher
2020-06-05 16:57:02 +02:00
committed by GitHub
parent 58a41cd205
commit 0326d049c5
14 changed files with 595 additions and 498 deletions
+538 -474
View File
File diff suppressed because it is too large Load Diff
+3 -3
View File
@@ -52,7 +52,7 @@ use log::{error, trace};
use futures::task::Spawn; use futures::task::Spawn;
use futures::prelude::*; use futures::prelude::*;
use std::{fmt::Debug, marker::PhantomData, sync::Arc, time::Duration, pin::Pin}; use std::{marker::PhantomData, sync::Arc, time::Duration, pin::Pin};
use parking_lot::Mutex; use parking_lot::Mutex;
@@ -186,7 +186,7 @@ where
Box::pin(async move { Box::pin(async move {
let parent_state_root = *last_head.header.state_root(); let parent_state_root = *last_head.header.state_root();
let mut proposer = proposer_future let proposer = proposer_future
.await .await
.map_err(|e| { .map_err(|e| {
error!( error!(
@@ -453,7 +453,7 @@ mod tests {
type Transaction = sc_client_api::TransactionFor<test_client::Backend, Block>; type Transaction = sc_client_api::TransactionFor<test_client::Backend, Block>;
fn propose( fn propose(
&mut self, self,
_: InherentData, _: InherentData,
digest: DigestFor<Block>, digest: DigestFor<Block>,
_: Duration, _: Duration,
+1
View File
@@ -15,6 +15,7 @@ sp-runtime = { git = "https://github.com/paritytech/substrate", branch = "cumulu
sp-block-builder = { git = "https://github.com/paritytech/substrate", branch = "cumulus-branch" } sp-block-builder = { git = "https://github.com/paritytech/substrate", branch = "cumulus-branch" }
sp-blockchain = { git = "https://github.com/paritytech/substrate", branch = "cumulus-branch" } sp-blockchain = { git = "https://github.com/paritytech/substrate", branch = "cumulus-branch" }
sp-api = { git = "https://github.com/paritytech/substrate", branch = "cumulus-branch" } sp-api = { git = "https://github.com/paritytech/substrate", branch = "cumulus-branch" }
substrate-prometheus-endpoint = { git = "https://github.com/paritytech/substrate", branch = "cumulus-branch" }
# polkadot deps # polkadot deps
polkadot-primitives = { git = "https://github.com/paritytech/polkadot", branch = "cumulus-branch" } polkadot-primitives = { git = "https://github.com/paritytech/polkadot", branch = "cumulus-branch" }
+4
View File
@@ -101,6 +101,8 @@ pub fn import_queue<Client, Block: BlockT, I>(
client: Arc<Client>, client: Arc<Client>,
block_import: I, block_import: I,
inherent_data_providers: InherentDataProviders, inherent_data_providers: InherentDataProviders,
spawner: &impl sp_core::traits::SpawnBlocking,
registry: Option<&substrate_prometheus_endpoint::Registry>,
) -> ClientResult<BasicQueue<Block, I::Transaction>> ) -> ClientResult<BasicQueue<Block, I::Transaction>>
where where
I: BlockImport<Block, Error = ConsensusError> + Send + Sync + 'static, I: BlockImport<Block, Error = ConsensusError> + Send + Sync + 'static,
@@ -119,5 +121,7 @@ where
Box::new(block_import), Box::new(block_import),
None, None,
None, None,
spawner,
registry,
)) ))
} }
+2 -1
View File
@@ -271,7 +271,7 @@ mod tests {
pub const MaximumBlockWeight: Weight = 1024; pub const MaximumBlockWeight: Weight = 1024;
pub const MaximumBlockLength: u32 = 2 * 1024; pub const MaximumBlockLength: u32 = 2 * 1024;
pub const AvailableBlockRatio: Perbill = Perbill::from_percent(75); pub const AvailableBlockRatio: Perbill = Perbill::from_percent(75);
pub const Version: RuntimeVersion = RuntimeVersion { pub Version: RuntimeVersion = RuntimeVersion {
spec_name: sp_version::create_runtime_str!("test"), spec_name: sp_version::create_runtime_str!("test"),
impl_name: sp_version::create_runtime_str!("system-test"), impl_name: sp_version::create_runtime_str!("system-test"),
authoring_version: 1, authoring_version: 1,
@@ -294,6 +294,7 @@ mod tests {
type Event = TestEvent; type Event = TestEvent;
type BlockHashCount = BlockHashCount; type BlockHashCount = BlockHashCount;
type MaximumBlockWeight = MaximumBlockWeight; type MaximumBlockWeight = MaximumBlockWeight;
type MaximumExtrinsicWeight = MaximumBlockWeight;
type MaximumBlockLength = MaximumBlockLength; type MaximumBlockLength = MaximumBlockLength;
type AvailableBlockRatio = AvailableBlockRatio; type AvailableBlockRatio = AvailableBlockRatio;
type Version = Version; type Version = Version;
@@ -206,10 +206,10 @@ impl<B: BlockT> Storage for WitnessStorage<B> {
} }
fn storage_root(&mut self) -> Vec<u8> { fn storage_root(&mut self) -> Vec<u8> {
let root = delta_trie_root::<Layout<HashFor<B>>, _, _, _, _>( let root = delta_trie_root::<Layout<HashFor<B>>, _, _, _, _, _>(
&mut self.witness_data, &mut self.witness_data,
self.storage_root.clone(), self.storage_root.clone(),
self.overlay.drain(), self.overlay.iter().map(|(k, v)| (k.as_ref(), v.as_ref().map(|v| v.as_ref()))),
).expect("Calculates storage root"); ).expect("Calculates storage root");
root.encode() root.encode()
+1
View File
@@ -73,3 +73,4 @@ pallet-transaction-payment = { git = "https://github.com/paritytech/substrate",
sp-arithmetic = { git = "https://github.com/paritytech/substrate", branch = "cumulus-branch" } sp-arithmetic = { git = "https://github.com/paritytech/substrate", branch = "cumulus-branch" }
sp-version = { git = "https://github.com/paritytech/substrate", branch = "cumulus-branch" } sp-version = { git = "https://github.com/paritytech/substrate", branch = "cumulus-branch" }
pallet-sudo = { git = "https://github.com/paritytech/substrate", branch = "cumulus-branch" } pallet-sudo = { git = "https://github.com/paritytech/substrate", branch = "cumulus-branch" }
pallet-grandpa = { git = "https://github.com/paritytech/substrate", branch = "cumulus-branch" }
+2 -2
View File
@@ -6,7 +6,7 @@ edition = '2018'
[dependencies] [dependencies]
serde = { version = "1.0.101", optional = true, features = ["derive"] } serde = { version = "1.0.101", optional = true, features = ["derive"] }
codec = { package = "parity-scale-codec", version = "1.0.6", default-features = false, features = ["derive"] } codec = { package = "parity-scale-codec", version = "1.3.0", default-features = false, features = ["derive"] }
# Substrate dependencies # Substrate dependencies
sp-std = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "cumulus-branch" } sp-std = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "cumulus-branch" }
@@ -36,7 +36,7 @@ cumulus-runtime = { path = "../../../runtime", default-features = false }
cumulus-parachain-upgrade = { path = "../../../parachain-upgrade", default-features = false } cumulus-parachain-upgrade = { path = "../../../parachain-upgrade", default-features = false }
[build-dependencies] [build-dependencies]
wasm-builder-runner = { package = "substrate-wasm-builder-runner", version = "1.0.3" } wasm-builder-runner = { package = "substrate-wasm-builder-runner", version = "1.0.6" }
[features] [features]
default = ['std'] default = ['std']
+1 -1
View File
@@ -19,7 +19,7 @@ use wasm_builder_runner::WasmBuilder;
fn main() { fn main() {
WasmBuilder::new() WasmBuilder::new()
.with_current_project() .with_current_project()
.with_wasm_builder_from_git("https://github.com/paritytech/substrate.git", "0b30207969fdde85e0dad785750757399cd0e3e4") .with_wasm_builder_from_crates("1.0.11")
.export_heap_base() .export_heap_base()
.import_memory() .import_memory()
.build() .build()
+11 -4
View File
@@ -24,9 +24,9 @@ include!(concat!(env!("OUT_DIR"), "/wasm_binary.rs"));
use sp_api::impl_runtime_apis; use sp_api::impl_runtime_apis;
use sp_core::OpaqueMetadata; use sp_core::OpaqueMetadata;
use sp_runtime::traits::{BlakeTwo256, Block as BlockT, ConvertInto, StaticLookup, Verify};
use sp_runtime::{ use sp_runtime::{
create_runtime_str, generic, impl_opaque_keys, create_runtime_str, generic, impl_opaque_keys,
traits::{BlakeTwo256, Block as BlockT, Saturating, StaticLookup, Verify},
transaction_validity::{TransactionSource, TransactionValidity}, transaction_validity::{TransactionSource, TransactionValidity},
AnySignature, ApplyExtrinsicResult, AnySignature, ApplyExtrinsicResult,
}; };
@@ -37,7 +37,10 @@ use sp_version::RuntimeVersion;
// A few exports that help ease life for downstream crates. // A few exports that help ease life for downstream crates.
pub use frame_support::{ pub use frame_support::{
construct_runtime, parameter_types, traits::Randomness, weights::Weight, StorageValue, construct_runtime, parameter_types,
traits::Randomness,
weights::{IdentityFee, Weight},
StorageValue,
}; };
pub use pallet_balances::Call as BalancesCall; pub use pallet_balances::Call as BalancesCall;
pub use pallet_timestamp::Call as TimestampCall; pub use pallet_timestamp::Call as TimestampCall;
@@ -131,6 +134,9 @@ pub fn native_version() -> NativeVersion {
parameter_types! { parameter_types! {
pub const BlockHashCount: BlockNumber = 250; pub const BlockHashCount: BlockNumber = 250;
pub const MaximumBlockWeight: Weight = 1_000_000; pub const MaximumBlockWeight: Weight = 1_000_000;
/// Assume 10% of weight for average on_initialize calls.
pub MaximumExtrinsicWeight: Weight = AvailableBlockRatio::get()
.saturating_sub(Perbill::from_percent(10)) * MaximumBlockWeight::get();
pub const AvailableBlockRatio: Perbill = Perbill::from_percent(75); pub const AvailableBlockRatio: Perbill = Perbill::from_percent(75);
pub const MaximumBlockLength: u32 = 5 * 1024 * 1024; pub const MaximumBlockLength: u32 = 5 * 1024 * 1024;
pub const Version: RuntimeVersion = VERSION; pub const Version: RuntimeVersion = VERSION;
@@ -176,6 +182,7 @@ impl frame_system::Trait for Runtime {
type DbWeight = (); type DbWeight = ();
type ExtrinsicBaseWeight = ExtrinsicBaseWeight; type ExtrinsicBaseWeight = ExtrinsicBaseWeight;
type BlockExecutionWeight = (); type BlockExecutionWeight = ();
type MaximumExtrinsicWeight = MaximumExtrinsicWeight;
} }
parameter_types! { parameter_types! {
@@ -221,7 +228,7 @@ impl pallet_transaction_payment::Trait for Runtime {
type Currency = Balances; type Currency = Balances;
type OnTransactionPayment = (); type OnTransactionPayment = ();
type TransactionByteFee = TransactionByteFee; type TransactionByteFee = TransactionByteFee;
type WeightToFee = ConvertInto; type WeightToFee = IdentityFee<Balance>;
type FeeMultiplierUpdate = (); type FeeMultiplierUpdate = ();
} }
@@ -263,7 +270,7 @@ pub type SignedBlock = generic::SignedBlock<Block>;
pub type BlockId = generic::BlockId<Block>; pub type BlockId = generic::BlockId<Block>;
/// The SignedExtension to the basic transaction logic. /// The SignedExtension to the basic transaction logic.
pub type SignedExtra = ( pub type SignedExtra = (
frame_system::CheckVersion<Runtime>, frame_system::CheckSpecVersion<Runtime>,
frame_system::CheckGenesis<Runtime>, frame_system::CheckGenesis<Runtime>,
frame_system::CheckEra<Runtime>, frame_system::CheckEra<Runtime>,
frame_system::CheckNonce<Runtime>, frame_system::CheckNonce<Runtime>,
+13 -1
View File
@@ -50,11 +50,20 @@ macro_rules! new_full_start {
let pool = sc_transaction_pool::BasicPool::new(config, pool_api, prometheus_registry); let pool = sc_transaction_pool::BasicPool::new(config, pool_api, prometheus_registry);
Ok(pool) Ok(pool)
})? })?
.with_import_queue(|_config, client, _, _| { .with_import_queue(|
_config,
client,
_,
_,
spawn_task_handle,
registry,
| {
let import_queue = cumulus_consensus::import_queue::import_queue( let import_queue = cumulus_consensus::import_queue::import_queue(
client.clone(), client.clone(),
client, client,
inherent_data_providers.clone(), inherent_data_providers.clone(),
spawn_task_handle,
registry,
)?; )?;
Ok(import_queue) Ok(import_queue)
@@ -92,9 +101,12 @@ pub fn run_collator(
})? })?
.build()?; .build()?;
let registry = service.prometheus_registry();
let proposer_factory = sc_basic_authorship::ProposerFactory::new( let proposer_factory = sc_basic_authorship::ProposerFactory::new(
service.client(), service.client(),
service.transaction_pool(), service.transaction_pool(),
registry.as_ref(),
); );
let block_import = service.client(); let block_import = service.client();
@@ -24,8 +24,8 @@ use futures::{future::FutureExt, join, pin_mut, select};
use jsonrpsee::{raw::RawClient, transport::http::HttpTransportClient}; use jsonrpsee::{raw::RawClient, transport::http::HttpTransportClient};
use polkadot_primitives::parachain::{Info, Scheduling}; use polkadot_primitives::parachain::{Info, Scheduling};
use polkadot_primitives::Hash as PHash; use polkadot_primitives::Hash as PHash;
use polkadot_runtime::{Header, OnlyStakingAndClaims, Runtime, SignedExtra, SignedPayload}; use polkadot_runtime::{Header, Runtime, SignedExtra, SignedPayload, IsCallable};
use polkadot_runtime_common::{parachains, registrar, BlockHashCount}; use polkadot_runtime_common::{parachains, registrar, BlockHashCount, claims, TransactionCallFilter};
use serde_json::Value; use serde_json::Value;
use sp_arithmetic::traits::SaturatedConversion; use sp_arithmetic::traits::SaturatedConversion;
use sp_runtime::generic; use sp_runtime::generic;
@@ -166,6 +166,7 @@ async fn wait_for_blocks(number_of_blocks: usize, mut client: &mut RawClient<Htt
#[async_std::test] #[async_std::test]
#[ignore] #[ignore]
#[cfg(feature = "disabled")]
async fn integration_test() { async fn integration_test() {
assert!( assert!(
!net::TcpStream::connect("127.0.0.1:27015").await.is_ok(), !net::TcpStream::connect("127.0.0.1:27015").await.is_ok(),
@@ -192,7 +193,7 @@ async fn integration_test() {
.arg("--base-path") .arg("--base-path")
.arg(polkadot_alice_dir.path()) .arg(polkadot_alice_dir.path())
.arg("--alice") .arg("--alice")
.arg("--unsafe-rpc-expose") .arg("--rpc-methods=unsafe")
.arg("--rpc-port=27015") .arg("--rpc-port=27015")
.arg("--port=27115") .arg("--port=27115")
.spawn() .spawn()
@@ -208,7 +209,7 @@ async fn integration_test() {
.arg("--base-path") .arg("--base-path")
.arg(polkadot_bob_dir.path()) .arg(polkadot_bob_dir.path())
.arg("--bob") .arg("--bob")
.arg("--unsafe-rpc-expose") .arg("--rpc-methods=unsafe")
.arg("--rpc-port=27016") .arg("--rpc-port=27016")
.arg("--port=27116") .arg("--port=27116")
.spawn() .spawn()
@@ -291,8 +292,9 @@ async fn integration_test() {
.unwrap_or(2) as u64; .unwrap_or(2) as u64;
let tip = 0; let tip = 0;
let extra: SignedExtra = ( let extra: SignedExtra = (
OnlyStakingAndClaims, TransactionCallFilter::<IsCallable, polkadot_runtime::Call>::new(),
frame_system::CheckVersion::<Runtime>::new(), frame_system::CheckSpecVersion::<Runtime>::new(),
frame_system::CheckTxVersion::<Runtime>::new(),
frame_system::CheckGenesis::<Runtime>::new(), frame_system::CheckGenesis::<Runtime>::new(),
frame_system::CheckEra::<Runtime>::from(generic::Era::mortal(period, current_block)), frame_system::CheckEra::<Runtime>::from(generic::Era::mortal(period, current_block)),
frame_system::CheckNonce::<Runtime>::from(nonce), frame_system::CheckNonce::<Runtime>::from(nonce),
@@ -300,6 +302,8 @@ async fn integration_test() {
pallet_transaction_payment::ChargeTransactionPayment::<Runtime>::from(tip), pallet_transaction_payment::ChargeTransactionPayment::<Runtime>::from(tip),
registrar::LimitParathreadCommits::<Runtime>::new(), registrar::LimitParathreadCommits::<Runtime>::new(),
parachains::ValidateDoubleVoteReports::<Runtime>::new(), parachains::ValidateDoubleVoteReports::<Runtime>::new(),
pallet_grandpa::ValidateEquivocationReport::<Runtime>::new(),
claims::PrevalidateAttests::<Runtime>::new(),
); );
let raw_payload = SignedPayload::from_raw( let raw_payload = SignedPayload::from_raw(
call.clone().into(), call.clone().into(),
@@ -307,6 +311,7 @@ async fn integration_test() {
( (
(), (),
runtime_version.spec_version, runtime_version.spec_version,
runtime_version.transaction_version,
genesis_block, genesis_block,
current_block_hash, current_block_hash,
(), (),
@@ -314,6 +319,8 @@ async fn integration_test() {
(), (),
(), (),
(), (),
(),
(),
), ),
); );
let signature = raw_payload.using_encoded(|e| Alice.sign(e)); let signature = raw_payload.using_encoded(|e| Alice.sign(e));
@@ -337,7 +344,7 @@ async fn integration_test() {
.stderr(Stdio::piped()) .stderr(Stdio::piped())
.arg("--base-path") .arg("--base-path")
.arg(cumulus_charlie_dir.path()) .arg(cumulus_charlie_dir.path())
.arg("--unsafe-rpc-expose") .arg("--rpc-methods=unsafe")
.arg("--rpc-port=27017") .arg("--rpc-port=27017")
.arg("--port=27117") .arg("--port=27117")
.arg("--") .arg("--")
+2 -2
View File
@@ -7,10 +7,10 @@ build = "build.rs"
[dependencies] [dependencies]
runtime = { package = "cumulus-runtime", path = "../../runtime", default-features = false } runtime = { package = "cumulus-runtime", path = "../../runtime", default-features = false }
substrate-test-runtime = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "cumulus-branch" } substrate-test-runtime = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "cumulus-branch", version = "2.0.0-rc2" }
[build-dependencies] [build-dependencies]
wasm-builder-runner = { package = "substrate-wasm-builder-runner", version = " 1.0.2" } wasm-builder-runner = { package = "substrate-wasm-builder-runner", version = " 1.0.6" }
[features] [features]
default = ["std"] default = ["std"]
+1 -1
View File
@@ -19,7 +19,7 @@ use wasm_builder_runner::WasmBuilder;
fn main() { fn main() {
WasmBuilder::new() WasmBuilder::new()
.with_current_project() .with_current_project()
.with_wasm_builder_from_git("https://github.com/paritytech/substrate.git", "0b30207969fdde85e0dad785750757399cd0e3e4") .with_wasm_builder_from_crates("1.0.11")
.export_heap_base() .export_heap_base()
.import_memory() .import_memory()
.build() .build()