mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-30 05:51:02 +00:00
Update polkadot and substrate (#71)
This commit is contained in:
Generated
+2243
-2238
File diff suppressed because it is too large
Load Diff
+24
-29
@@ -31,7 +31,7 @@ use polkadot_collator::{
|
||||
PolkadotClient,
|
||||
};
|
||||
use polkadot_primitives::{
|
||||
parachain::{self, BlockData, Status as ParachainStatus, Id as ParaId}, Block as PBlock,
|
||||
parachain::{self, BlockData, LocalValidationData, Id as ParaId}, Block as PBlock,
|
||||
Hash as PHash,
|
||||
};
|
||||
|
||||
@@ -65,14 +65,14 @@ impl<Block, PF, BI> Collator<Block, PF, BI> {
|
||||
fn new(
|
||||
proposer_factory: PF,
|
||||
inherent_data_providers: InherentDataProviders,
|
||||
collator_network: Arc<dyn CollatorNetwork>,
|
||||
collator_network: impl CollatorNetwork + Clone + 'static,
|
||||
block_import: BI,
|
||||
) -> Self {
|
||||
Self {
|
||||
proposer_factory: Arc::new(Mutex::new(proposer_factory)),
|
||||
inherent_data_providers,
|
||||
_phantom: PhantomData,
|
||||
collator_network,
|
||||
collator_network: Arc::new(collator_network),
|
||||
block_import: Arc::new(Mutex::new(block_import)),
|
||||
}
|
||||
}
|
||||
@@ -111,7 +111,7 @@ where
|
||||
fn produce_candidate(
|
||||
&mut self,
|
||||
_relay_chain_parent: PHash,
|
||||
status: ParachainStatus,
|
||||
status: LocalValidationData,
|
||||
) -> Self::ProduceCandidate {
|
||||
let factory = self.proposer_factory.clone();
|
||||
let inherent_providers = self.inherent_data_providers.clone();
|
||||
@@ -119,7 +119,7 @@ where
|
||||
|
||||
trace!(target: "cumulus-collator", "Producing candidate");
|
||||
|
||||
let last_head = match HeadData::<Block>::decode(&mut &status.head_data.0[..]) {
|
||||
let last_head = match HeadData::<Block>::decode(&mut &status.parent_head.0[..]) {
|
||||
Ok(x) => x,
|
||||
Err(e) => {
|
||||
error!(target: "cumulus-collator", "Could not decode the head data: {:?}", e);
|
||||
@@ -285,7 +285,7 @@ where
|
||||
self,
|
||||
polkadot_client: Arc<PolkadotClient<B, E, R>>,
|
||||
spawner: Spawner,
|
||||
network: Arc<dyn CollatorNetwork>,
|
||||
network: impl CollatorNetwork + Clone + 'static,
|
||||
) -> Result<Self::ParachainContext, ()>
|
||||
where
|
||||
PolkadotClient<B, E, R>: sp_api::ProvideRuntimeApi<PBlock>,
|
||||
@@ -296,11 +296,11 @@ where
|
||||
Extrinsic: codec::Codec + Send + Sync + 'static,
|
||||
<<PolkadotClient<B, E, R> as sp_api::ProvideRuntimeApi<PBlock>>::Api as sp_api::ApiExt<
|
||||
PBlock,
|
||||
>>::StateBackend: sp_api::StateBackend<sp_core::Blake2Hasher>,
|
||||
>>::StateBackend: sp_api::StateBackend<sp_runtime::traits::BlakeTwo256>,
|
||||
R: Send + Sync + 'static,
|
||||
B: sc_client_api::Backend<PBlock> + 'static,
|
||||
// Rust bug: https://github.com/rust-lang/rust/issues/24159
|
||||
B::State: sp_api::StateBackend<sp_core::Blake2Hasher>,
|
||||
B::State: sp_api::StateBackend<sp_runtime::traits::BlakeTwo256>,
|
||||
{
|
||||
let follow =
|
||||
match cumulus_consensus::follow_polkadot(self.para_id, self.client, polkadot_client) {
|
||||
@@ -333,8 +333,8 @@ mod tests {
|
||||
use super::*;
|
||||
use std::time::Duration;
|
||||
|
||||
use polkadot_collator::{collate, CollatorId, PeerId, SignedStatement};
|
||||
use polkadot_primitives::parachain::{FeeSchedule, HeadData, Id as ParaId};
|
||||
use polkadot_collator::{collate, SignedStatement};
|
||||
use polkadot_primitives::parachain::{HeadData, Id as ParaId};
|
||||
|
||||
use sp_blockchain::Result as ClientResult;
|
||||
use sp_inherents::InherentData;
|
||||
@@ -406,17 +406,11 @@ mod tests {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone)]
|
||||
struct DummyCollatorNetwork;
|
||||
|
||||
impl CollatorNetwork for DummyCollatorNetwork {
|
||||
fn collator_id_to_peer_id(
|
||||
&self,
|
||||
_: CollatorId,
|
||||
) -> Box<dyn Future<Output = Option<PeerId>> + Send> {
|
||||
unimplemented!("Not required in tests")
|
||||
}
|
||||
|
||||
fn checked_statements(&self, _: PHash) -> Box<dyn Stream<Item = SignedStatement>> {
|
||||
fn checked_statements(&self, _: PHash) -> Pin<Box<dyn Stream<Item = SignedStatement>>> {
|
||||
unimplemented!("Not required in tests")
|
||||
}
|
||||
}
|
||||
@@ -455,16 +449,21 @@ mod tests {
|
||||
Arc::new(TestClientBuilder::new().build()),
|
||||
);
|
||||
let context = builder
|
||||
.build::<_, _, polkadot_service::polkadot_runtime::RuntimeApi, _, _>(
|
||||
.build(
|
||||
Arc::new(
|
||||
substrate_test_client::TestClientBuilder::<_, _, _, ()>::default()
|
||||
.build_with_native_executor(Some(NativeExecutor::<
|
||||
polkadot_service::PolkadotExecutor,
|
||||
>::new(Interpreted, None)))
|
||||
.build_with_native_executor::<polkadot_service::polkadot_runtime::RuntimeApi, _>(
|
||||
Some(
|
||||
NativeExecutor::<polkadot_service::PolkadotExecutor>::new(
|
||||
Interpreted,
|
||||
None,
|
||||
)
|
||||
)
|
||||
)
|
||||
.0,
|
||||
),
|
||||
spawner,
|
||||
Arc::new(DummyCollatorNetwork),
|
||||
DummyCollatorNetwork,
|
||||
)
|
||||
.expect("Creates parachain context");
|
||||
|
||||
@@ -479,13 +478,9 @@ mod tests {
|
||||
let collation = collate(
|
||||
Default::default(),
|
||||
id,
|
||||
ParachainStatus {
|
||||
head_data: HeadData(header.encode()),
|
||||
LocalValidationData {
|
||||
parent_head: HeadData(header.encode()),
|
||||
balance: 10,
|
||||
fee_schedule: FeeSchedule {
|
||||
base: 0,
|
||||
per_byte: 1,
|
||||
},
|
||||
},
|
||||
context,
|
||||
Arc::new(Sr25519Keyring::Alice.pair().into()),
|
||||
|
||||
@@ -154,7 +154,7 @@ where
|
||||
<Client<B, E, PBlock, RA> as ProvideRuntimeApi<PBlock>>::Api:
|
||||
ParachainHost<PBlock, Error = ClientError>,
|
||||
// Rust bug: https://github.com/rust-lang/rust/issues/24159
|
||||
StateBackendFor<B, PBlock>: StateBackend<sp_core::Blake2Hasher>,
|
||||
StateBackendFor<B, PBlock>: StateBackend<sp_runtime::traits::BlakeTwo256>,
|
||||
{
|
||||
type Error = ClientError;
|
||||
|
||||
@@ -181,8 +181,8 @@ where
|
||||
para_id: ParaId,
|
||||
) -> ClientResult<Option<Vec<u8>>> {
|
||||
self.runtime_api()
|
||||
.parachain_status(at, para_id)
|
||||
.map(|s| s.map(|s| s.head_data.0))
|
||||
.local_validation_data(at, para_id)
|
||||
.map(|s| s.map(|s| s.parent_head.0))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -24,6 +24,7 @@ sp-trie = { git = "https://github.com/paritytech/substrate", default-features =
|
||||
parachain = { package = "polkadot-parachain", git = "https://github.com/paritytech/polkadot", branch = "cumulus-branch", default-features = false, features = [ "wasm-api" ] }
|
||||
|
||||
[dev-dependencies]
|
||||
sc-block-builder = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "cumulus-branch" }
|
||||
sp-keyring = { git = "https://github.com/paritytech/substrate", branch = "cumulus-branch" }
|
||||
sp-blockchain = { git = "https://github.com/paritytech/substrate", branch = "cumulus-branch" }
|
||||
sc-executor = { git = "https://github.com/paritytech/substrate", branch = "cumulus-branch" }
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
|
||||
use crate::WitnessData;
|
||||
use frame_executive::ExecuteBlock;
|
||||
use sp_runtime::traits::{Block as BlockT, HasherFor, Header as HeaderT};
|
||||
use sp_runtime::traits::{Block as BlockT, HashFor, Header as HeaderT};
|
||||
|
||||
use sp_trie::{delta_trie_root, read_trie_value, Layout, MemoryDB};
|
||||
|
||||
@@ -116,7 +116,7 @@ pub fn validate_block<B: BlockT, E: ExecuteBlock<B>>(params: ValidationParams) -
|
||||
/// The storage implementation used when validating a block that is using the
|
||||
/// witness data as source.
|
||||
struct WitnessStorage<B: BlockT> {
|
||||
witness_data: MemoryDB<HasherFor<B>>,
|
||||
witness_data: MemoryDB<HashFor<B>>,
|
||||
overlay: hashbrown::HashMap<Vec<u8>, Option<Vec<u8>>>,
|
||||
storage_root: B::Hash,
|
||||
}
|
||||
@@ -149,7 +149,7 @@ impl<B: BlockT> Storage for WitnessStorage<B> {
|
||||
.get(key)
|
||||
.cloned()
|
||||
.or_else(|| {
|
||||
read_trie_value::<Layout<HasherFor<B>>, _>(
|
||||
read_trie_value::<Layout<HashFor<B>>, _>(
|
||||
&self.witness_data,
|
||||
&self.storage_root,
|
||||
key,
|
||||
@@ -168,7 +168,7 @@ impl<B: BlockT> Storage for WitnessStorage<B> {
|
||||
}
|
||||
|
||||
fn storage_root(&mut self) -> Vec<u8> {
|
||||
let root = delta_trie_root::<Layout<HasherFor<B>>, _, _, _, _>(
|
||||
let root = delta_trie_root::<Layout<HashFor<B>>, _, _, _, _>(
|
||||
&mut self.witness_data,
|
||||
self.storage_root.clone(),
|
||||
self.overlay.drain(),
|
||||
@@ -184,7 +184,7 @@ impl<B: BlockT> Storage for WitnessStorage<B> {
|
||||
}
|
||||
});
|
||||
|
||||
let trie = match TrieDB::<Layout<HasherFor<B>>>::new(&self.witness_data, &self.storage_root)
|
||||
let trie = match TrieDB::<Layout<HashFor<B>>>::new(&self.witness_data, &self.storage_root)
|
||||
{
|
||||
Ok(r) => r,
|
||||
Err(_) => panic!(),
|
||||
|
||||
@@ -17,9 +17,13 @@
|
||||
use crate::{ParachainBlockData, WitnessData};
|
||||
|
||||
use parachain::{ValidationParams, ValidationResult};
|
||||
use sc_executor::{call_in_wasm, error::Result, WasmExecutionMethod};
|
||||
use sc_executor::{
|
||||
error::Result, WasmExecutionMethod, WasmExecutor, sp_wasm_interface::HostFunctions,
|
||||
};
|
||||
use sc_block_builder::BlockBuilderProvider;
|
||||
use sp_blockchain::HeaderBackend;
|
||||
use sp_consensus::SelectChain;
|
||||
use sp_core::traits::CallInWasm;
|
||||
use sp_io::TestExternalities;
|
||||
use sp_keyring::AccountKeyring;
|
||||
use sp_runtime::{
|
||||
@@ -45,22 +49,22 @@ fn call_validate_block(
|
||||
}
|
||||
.encode();
|
||||
|
||||
call_in_wasm::<
|
||||
(
|
||||
sp_io::SubstrateHostFunctions,
|
||||
sc_executor::deprecated_host_interface::SubstrateExternals,
|
||||
),
|
||||
>(
|
||||
let executor = WasmExecutor::new(
|
||||
WasmExecutionMethod::Interpreted,
|
||||
Some(1024),
|
||||
sp_io::SubstrateHostFunctions::host_functions(),
|
||||
false,
|
||||
);
|
||||
|
||||
executor.call_in_wasm(
|
||||
&WASM_BINARY,
|
||||
"validate_block",
|
||||
¶ms,
|
||||
WasmExecutionMethod::Interpreted,
|
||||
&mut ext_ext,
|
||||
&WASM_BINARY,
|
||||
1024,
|
||||
false,
|
||||
)
|
||||
.map(|v| ValidationResult::decode(&mut &v[..]).expect("Decode `ValidationResult`."))
|
||||
.map(|v| Header::decode(&mut &v.head_data[..]).expect("Decode `Header`."))
|
||||
.map_err(|err| err.into())
|
||||
}
|
||||
|
||||
fn create_extrinsics() -> Vec<<Block as BlockT>::Extrinsic> {
|
||||
|
||||
@@ -37,6 +37,7 @@ sc-network = { git = "https://github.com/paritytech/substrate", branch = "cumulu
|
||||
sc-client = { git = "https://github.com/paritytech/substrate", branch = "cumulus-branch" }
|
||||
sc-basic-authorship = { git = "https://github.com/paritytech/substrate", branch = "cumulus-branch" }
|
||||
sp-timestamp = { git = "https://github.com/paritytech/substrate", branch = "cumulus-branch" }
|
||||
sc-finality-grandpa = { git = "https://github.com/paritytech/substrate", branch = "cumulus-branch" }
|
||||
|
||||
# Cumulus dependencies
|
||||
cumulus-consensus = { path = "../../consensus" }
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -171,7 +171,7 @@ impl frame_system::Trait for Runtime {
|
||||
type ModuleToIndex = ModuleToIndex;
|
||||
type AccountData = pallet_balances::AccountData<Balance>;
|
||||
type OnNewAccount = ();
|
||||
type OnReapAccount = Balances;
|
||||
type OnKilledAccount = Balances;
|
||||
}
|
||||
|
||||
parameter_types! {
|
||||
@@ -303,10 +303,6 @@ impl_runtime_apis! {
|
||||
Executive::apply_extrinsic(extrinsic)
|
||||
}
|
||||
|
||||
fn apply_trusted_extrinsic(extrinsic: <Block as BlockT>::Extrinsic) -> ApplyExtrinsicResult {
|
||||
Executive::apply_trusted_extrinsic(extrinsic)
|
||||
}
|
||||
|
||||
fn finalize_block() -> <Block as BlockT>::Header {
|
||||
Executive::finalize_block()
|
||||
}
|
||||
|
||||
@@ -21,9 +21,8 @@ use std::sync::Arc;
|
||||
|
||||
use parachain_runtime::Block;
|
||||
|
||||
use sc_cli::{error, VersionInfo};
|
||||
use sc_client::genesis;
|
||||
use sc_service::{Configuration, Roles as ServiceRoles};
|
||||
use sc_service::{Configuration, Roles as ServiceRoles, config::PrometheusConfig};
|
||||
use sp_core::hexdisplay::HexDisplay;
|
||||
use sp_runtime::{
|
||||
traits::{Block as BlockT, Hash as HashT, Header as HeaderT},
|
||||
@@ -37,23 +36,24 @@ use log::info;
|
||||
|
||||
const DEFAULT_POLKADOT_RPC_HTTP: &'static str = "127.0.0.1:9934";
|
||||
const DEFAULT_POLKADOT_RPC_WS: &'static str = "127.0.0.1:9945";
|
||||
const DEFAULT_POLKADOT_GRAFANA_PORT: &'static str = "127.0.0.1:9956";
|
||||
const DEFAULT_POLKADOT_PROMETHEUS_PORT: &'static str = "127.0.0.1:9616";
|
||||
|
||||
/// Parse command line arguments into service configuration.
|
||||
pub fn run(version: VersionInfo) -> error::Result<()> {
|
||||
pub fn run(version: sc_cli::VersionInfo) -> sc_cli::Result<()> {
|
||||
let opt: Cli = sc_cli::from_args(&version);
|
||||
|
||||
let mut config = sc_service::Configuration::new(&version);
|
||||
let mut polkadot_config = Configuration::new(&version);
|
||||
let mut config = sc_service::Configuration::from_version(&version);
|
||||
let mut polkadot_config = Configuration::from_version(&version);
|
||||
|
||||
match opt.subcommand {
|
||||
Some(Subcommand::Base(subcommand)) => sc_cli::run_subcommand(
|
||||
Some(Subcommand::Base(subcommand)) => {
|
||||
subcommand.init(&version)?;
|
||||
subcommand.update_config(&mut config, load_spec, &version)?;
|
||||
subcommand.run(
|
||||
config,
|
||||
subcommand,
|
||||
load_spec,
|
||||
|config: Configuration<_, _>| Ok(new_full_start!(config).0),
|
||||
&version,
|
||||
),
|
||||
)
|
||||
},
|
||||
Some(Subcommand::ExportGenesisState(params)) => {
|
||||
sc_cli::init_logger("");
|
||||
|
||||
@@ -81,9 +81,8 @@ pub fn run(version: VersionInfo) -> error::Result<()> {
|
||||
Ok(())
|
||||
},
|
||||
None => {
|
||||
sc_cli::init(&opt.run.shared_params, &version)?;
|
||||
sc_cli::init_config(&mut config, &opt.run.shared_params, &version, load_spec)?;
|
||||
sc_cli::update_config_for_running_node(&mut config, opt.run)?;
|
||||
opt.run.init(&version)?;
|
||||
opt.run.update_config(&mut config, load_spec, &version)?;
|
||||
|
||||
info!("{}", version.name);
|
||||
info!(" version {}", config.full_version());
|
||||
@@ -106,15 +105,17 @@ pub fn run(version: VersionInfo) -> error::Result<()> {
|
||||
|
||||
polkadot_config.rpc_http = Some(DEFAULT_POLKADOT_RPC_HTTP.parse().unwrap());
|
||||
polkadot_config.rpc_ws = Some(DEFAULT_POLKADOT_RPC_WS.parse().unwrap());
|
||||
polkadot_config.grafana_port = Some(DEFAULT_POLKADOT_GRAFANA_PORT.parse().unwrap());
|
||||
polkadot_config.prometheus_config = Some(
|
||||
PrometheusConfig::new_with_default_registry(
|
||||
DEFAULT_POLKADOT_PROMETHEUS_PORT.parse().unwrap(),
|
||||
)
|
||||
);
|
||||
|
||||
sc_cli::init_config(
|
||||
polkadot_opt.run.update_config(
|
||||
&mut polkadot_config,
|
||||
&polkadot_opt.run.shared_params,
|
||||
&version,
|
||||
load_spec_polkadot,
|
||||
&version,
|
||||
)?;
|
||||
sc_cli::update_config_for_running_node(&mut polkadot_config, polkadot_opt.run)?;
|
||||
|
||||
// TODO: we disable mdns for the polkadot node because it prevents the process to exit
|
||||
// properly. See https://github.com/paritytech/cumulus/issues/57
|
||||
@@ -133,11 +134,11 @@ pub fn run(version: VersionInfo) -> error::Result<()> {
|
||||
}
|
||||
}
|
||||
|
||||
fn load_spec(_: &str) -> std::result::Result<Option<chain_spec::ChainSpec>, String> {
|
||||
fn load_spec(_: &str) -> Result<Option<chain_spec::ChainSpec>, String> {
|
||||
Ok(Some(chain_spec::get_chain_spec()))
|
||||
}
|
||||
|
||||
fn load_spec_polkadot(_: &str) -> std::result::Result<Option<ChainSpecPolkadot>, String> {
|
||||
fn load_spec_polkadot(_: &str) -> Result<Option<ChainSpecPolkadot>, String> {
|
||||
Some(polkadot_service::ChainSpec::from_json_bytes(
|
||||
&include_bytes!("../res/polkadot_chainspec.json")[..],
|
||||
)).transpose()
|
||||
|
||||
@@ -27,8 +27,6 @@ mod service;
|
||||
mod cli;
|
||||
mod command;
|
||||
|
||||
pub use sc_cli::{error, VersionInfo};
|
||||
|
||||
/// The parachain id of this parachain.
|
||||
pub const PARA_ID: ParaId = ParaId::new(100);
|
||||
const EXECUTABLE_NAME: &'static str = "cumulus-test-parachain-collator";
|
||||
@@ -38,8 +36,8 @@ const DESCRIPTION: &'static str =
|
||||
to the relaychain node.\n\n\
|
||||
cumulus-test-parachain-collator [parachain-args] -- [relaychain-args]";
|
||||
|
||||
fn main() -> Result<(), error::Error> {
|
||||
let version = VersionInfo {
|
||||
fn main() -> sc_cli::Result<()> {
|
||||
let version = sc_cli::VersionInfo {
|
||||
name: "Cumulus Test Parachain Collator",
|
||||
commit: env!("VERGEN_SHA_SHORT"),
|
||||
version: env!("CARGO_PKG_VERSION"),
|
||||
|
||||
@@ -16,11 +16,11 @@
|
||||
|
||||
use std::sync::Arc;
|
||||
|
||||
use parachain_runtime::{self, opaque::Block, GenesisConfig};
|
||||
use parachain_runtime::{self, GenesisConfig};
|
||||
|
||||
use sc_executor::native_executor_instance;
|
||||
use sc_network::construct_simple_protocol;
|
||||
use sc_service::{AbstractService, Configuration};
|
||||
use sc_finality_grandpa::{FinalityProofProvider as GrandpaFinalityProofProvider, StorageAndProofProvider};
|
||||
|
||||
use polkadot_primitives::parachain::CollatorPair;
|
||||
|
||||
@@ -37,11 +37,6 @@ native_executor_instance!(
|
||||
parachain_runtime::native_version,
|
||||
);
|
||||
|
||||
construct_simple_protocol! {
|
||||
/// Demo protocol attachment for substrate.
|
||||
pub struct NodeProtocol where Block = Block { }
|
||||
}
|
||||
|
||||
/// Starts a `ServiceBuilder` for a full service.
|
||||
///
|
||||
/// Use this macro if you don't actually need the full service, but just the builder in order to
|
||||
@@ -82,7 +77,7 @@ pub fn run_collator<E: sc_service::ChainSpecExtension>(
|
||||
parachain_config: Configuration<GenesisConfig, E>,
|
||||
key: Arc<CollatorPair>,
|
||||
mut polkadot_config: polkadot_collator::Configuration,
|
||||
) -> sc_cli::error::Result<()> {
|
||||
) -> sc_cli::Result<()> {
|
||||
sc_cli::run_service_until_exit(parachain_config, move |parachain_config| {
|
||||
polkadot_config.task_executor = parachain_config.task_executor.clone();
|
||||
|
||||
@@ -92,13 +87,17 @@ pub fn run_collator<E: sc_service::ChainSpecExtension>(
|
||||
.unwrap();
|
||||
|
||||
let service = builder
|
||||
.with_network_protocol(|_| Ok(NodeProtocol::new()))?
|
||||
.with_finality_proof_provider(|client, backend| {
|
||||
// GenesisAuthoritySetProvider is implemented for StorageAndProofProvider
|
||||
let provider = client as Arc<dyn StorageAndProofProvider<_, _>>;
|
||||
Ok(Arc::new(GrandpaFinalityProofProvider::new(backend, provider)) as _)
|
||||
})?
|
||||
.build()?;
|
||||
|
||||
let proposer_factory = sc_basic_authorship::ProposerFactory {
|
||||
client: service.client(),
|
||||
transaction_pool: service.transaction_pool(),
|
||||
};
|
||||
let proposer_factory = sc_basic_authorship::ProposerFactory::new(
|
||||
service.client(),
|
||||
service.transaction_pool(),
|
||||
);
|
||||
|
||||
let block_import = service.client();
|
||||
let client = service.client();
|
||||
|
||||
Reference in New Issue
Block a user