Migrate to new substrate (#79)

* new substrate version + actually verify justification

* cargo update + fix remaining stuff

* add weight=0 comments

* cargo fmt --all

* fix hash types
This commit is contained in:
Svyatoslav Nikolsky
2020-04-28 16:40:23 +03:00
committed by Bastian Köcher
parent 4bbef4d45a
commit 50d6ed186f
14 changed files with 282 additions and 235 deletions
+43 -38
View File
@@ -19,95 +19,100 @@ bridge-node-runtime = { version = "0.1.0", path = "../runtime" }
sp-bridge-eth-poa = { version = "0.1.0", path = "../../../primitives/ethereum-poa" } sp-bridge-eth-poa = { version = "0.1.0", path = "../../../primitives/ethereum-poa" }
[dependencies.sc-cli] [dependencies.sc-cli]
version = "0.8.0-alpha.2" version = "0.8.0-alpha.6"
rev = "2afecf81ee19b8a6edb364b419190ea47c4a4a31" rev = "c13ad41634d0bd7cf07897c2aa062b917d520520"
git = "https://github.com/paritytech/substrate.git" git = "https://github.com/paritytech/substrate.git"
[dependencies.sc-rpc] [dependencies.sc-rpc]
version = "2.0.0-alpha.2" version = "2.0.0-alpha.6"
rev = "2afecf81ee19b8a6edb364b419190ea47c4a4a31" rev = "c13ad41634d0bd7cf07897c2aa062b917d520520"
git = "https://github.com/paritytech/substrate.git" git = "https://github.com/paritytech/substrate.git"
[dependencies.sp-core] [dependencies.sp-core]
version = "2.0.0-alpha.2" version = "2.0.0-alpha.6"
rev = "2afecf81ee19b8a6edb364b419190ea47c4a4a31" rev = "c13ad41634d0bd7cf07897c2aa062b917d520520"
git = "https://github.com/paritytech/substrate.git" git = "https://github.com/paritytech/substrate.git"
[dependencies.sc-executor] [dependencies.sc-executor]
version = "0.8.0-alpha.2" version = "0.8.0-alpha.6"
rev = "2afecf81ee19b8a6edb364b419190ea47c4a4a31" rev = "c13ad41634d0bd7cf07897c2aa062b917d520520"
git = "https://github.com/paritytech/substrate.git" git = "https://github.com/paritytech/substrate.git"
[dependencies.sc-service] [dependencies.sc-service]
version = "0.8.0-alpha.2" version = "0.8.0-alpha.6"
rev = "2afecf81ee19b8a6edb364b419190ea47c4a4a31" rev = "c13ad41634d0bd7cf07897c2aa062b917d520520"
git = "https://github.com/paritytech/substrate.git" git = "https://github.com/paritytech/substrate.git"
[dependencies.sp-inherents] [dependencies.sp-inherents]
version = "2.0.0-alpha.2" version = "2.0.0-alpha.6"
rev = "2afecf81ee19b8a6edb364b419190ea47c4a4a31" rev = "c13ad41634d0bd7cf07897c2aa062b917d520520"
git = "https://github.com/paritytech/substrate.git" git = "https://github.com/paritytech/substrate.git"
[dependencies.sc-transaction-pool] [dependencies.sc-transaction-pool]
version = "2.0.0-alpha.2" version = "2.0.0-alpha.6"
rev = "2afecf81ee19b8a6edb364b419190ea47c4a4a31" rev = "c13ad41634d0bd7cf07897c2aa062b917d520520"
git = "https://github.com/paritytech/substrate.git" git = "https://github.com/paritytech/substrate.git"
[dependencies.sp-transaction-pool] [dependencies.sp-transaction-pool]
version = "2.0.0-alpha.2" version = "2.0.0-alpha.6"
rev = "2afecf81ee19b8a6edb364b419190ea47c4a4a31" rev = "c13ad41634d0bd7cf07897c2aa062b917d520520"
git = "https://github.com/paritytech/substrate.git" git = "https://github.com/paritytech/substrate.git"
[dependencies.sc-network] [dependencies.sc-network]
version = "0.8.0-alpha.2" version = "0.8.0-alpha.6"
rev = "2afecf81ee19b8a6edb364b419190ea47c4a4a31" rev = "c13ad41634d0bd7cf07897c2aa062b917d520520"
git = "https://github.com/paritytech/substrate.git" git = "https://github.com/paritytech/substrate.git"
[dependencies.sc-consensus-aura] [dependencies.sc-consensus-aura]
version = "0.8.0-alpha.2" version = "0.8.0-alpha.6"
rev = "2afecf81ee19b8a6edb364b419190ea47c4a4a31" rev = "c13ad41634d0bd7cf07897c2aa062b917d520520"
git = "https://github.com/paritytech/substrate.git" git = "https://github.com/paritytech/substrate.git"
[dependencies.sp-consensus-aura] [dependencies.sp-consensus-aura]
version = "0.8.0-alpha.2" version = "0.8.0-alpha.6"
rev = "2afecf81ee19b8a6edb364b419190ea47c4a4a31" rev = "c13ad41634d0bd7cf07897c2aa062b917d520520"
git = "https://github.com/paritytech/substrate.git" git = "https://github.com/paritytech/substrate.git"
[dependencies.sp-consensus] [dependencies.sp-consensus]
version = "0.8.0-alpha.2" version = "0.8.0-alpha.6"
rev = "2afecf81ee19b8a6edb364b419190ea47c4a4a31" rev = "c13ad41634d0bd7cf07897c2aa062b917d520520"
git = "https://github.com/paritytech/substrate.git" git = "https://github.com/paritytech/substrate.git"
[dependencies.grandpa] [dependencies.grandpa]
package = "sc-finality-grandpa" package = "sc-finality-grandpa"
version = "0.8.0-alpha.2" version = "0.8.0-alpha.6"
rev = "2afecf81ee19b8a6edb364b419190ea47c4a4a31" rev = "c13ad41634d0bd7cf07897c2aa062b917d520520"
git = "https://github.com/paritytech/substrate.git" git = "https://github.com/paritytech/substrate.git"
[dependencies.grandpa-primitives] [dependencies.grandpa-primitives]
package = "sp-finality-grandpa" package = "sp-finality-grandpa"
version = "2.0.0-alpha.2" version = "2.0.0-alpha.6"
rev = "2afecf81ee19b8a6edb364b419190ea47c4a4a31" rev = "c13ad41634d0bd7cf07897c2aa062b917d520520"
git = "https://github.com/paritytech/substrate.git"
[dependencies.sc-client-api]
version = "2.0.0-alpha.6"
rev = "c13ad41634d0bd7cf07897c2aa062b917d520520"
git = "https://github.com/paritytech/substrate.git" git = "https://github.com/paritytech/substrate.git"
[dependencies.sc-client] [dependencies.sc-client]
version = "0.8.0-alpha.2" version = "0.8.0-alpha.6"
rev = "2afecf81ee19b8a6edb364b419190ea47c4a4a31" rev = "c13ad41634d0bd7cf07897c2aa062b917d520520"
git = "https://github.com/paritytech/substrate.git" git = "https://github.com/paritytech/substrate.git"
[dependencies.sp-runtime] [dependencies.sp-runtime]
version = "2.0.0-alpha.2" version = "2.0.0-alpha.6"
rev = "2afecf81ee19b8a6edb364b419190ea47c4a4a31" rev = "c13ad41634d0bd7cf07897c2aa062b917d520520"
git = "https://github.com/paritytech/substrate.git" git = "https://github.com/paritytech/substrate.git"
[dependencies.sc-basic-authorship] [dependencies.sc-basic-authorship]
version = "0.8.0-alpha.2" version = "0.8.0-alpha.6"
rev = "2afecf81ee19b8a6edb364b419190ea47c4a4a31" rev = "c13ad41634d0bd7cf07897c2aa062b917d520520"
git = "https://github.com/paritytech/substrate.git" git = "https://github.com/paritytech/substrate.git"
[dependencies.substrate-frame-rpc-system] [dependencies.substrate-frame-rpc-system]
version = "2.0.0-alpha.2" version = "2.0.0-alpha.6"
rev = "2afecf81ee19b8a6edb364b419190ea47c4a4a31" rev = "c13ad41634d0bd7cf07897c2aa062b917d520520"
git = "https://github.com/paritytech/substrate.git" git = "https://github.com/paritytech/substrate.git"
[build-dependencies] [build-dependencies]
@@ -115,6 +120,6 @@ vergen = "3.1.0"
[build-dependencies.build-script-utils] [build-dependencies.build-script-utils]
package = "substrate-build-script-utils" package = "substrate-build-script-utils"
version = "2.0.0-alpha.2" version = "2.0.0-alpha.6"
rev = "2afecf81ee19b8a6edb364b419190ea47c4a4a31" rev = "c13ad41634d0bd7cf07897c2aa062b917d520520"
git = "https://github.com/paritytech/substrate.git" git = "https://github.com/paritytech/substrate.git"
+3 -16
View File
@@ -25,7 +25,7 @@ use sp_core::{sr25519, Pair, Public};
use sp_runtime::traits::{IdentifyAccount, Verify}; use sp_runtime::traits::{IdentifyAccount, Verify};
/// Specialized `ChainSpec`. This is a specialization of the general Substrate ChainSpec type. /// Specialized `ChainSpec`. This is a specialization of the general Substrate ChainSpec type.
pub type ChainSpec = sc_service::ChainSpec<GenesisConfig>; pub type ChainSpec = sc_service::GenericChainSpec<GenesisConfig>;
/// The chain specification option. This is expected to come in from the CLI and /// The chain specification option. This is expected to come in from the CLI and
/// is little more than one of a number of alternatives which can easily be converted /// is little more than one of a number of alternatives which can easily be converted
@@ -71,6 +71,7 @@ impl Alternative {
Alternative::Development => ChainSpec::from_genesis( Alternative::Development => ChainSpec::from_genesis(
"Development", "Development",
"dev", "dev",
sc_service::ChainType::Development,
|| { || {
testnet_genesis( testnet_genesis(
vec![get_authority_keys_from_seed("Alice")], vec![get_authority_keys_from_seed("Alice")],
@@ -93,6 +94,7 @@ impl Alternative {
Alternative::LocalTestnet => ChainSpec::from_genesis( Alternative::LocalTestnet => ChainSpec::from_genesis(
"Local Testnet", "Local Testnet",
"local_testnet", "local_testnet",
sc_service::ChainType::Local,
|| { || {
testnet_genesis( testnet_genesis(
vec![ vec![
@@ -128,14 +130,6 @@ impl Alternative {
), ),
}) })
} }
pub(crate) fn from(s: &str) -> Option<Self> {
match s {
"" | "dev" => Some(Alternative::Development),
"local" => Some(Alternative::LocalTestnet),
_ => None,
}
}
} }
fn session_keys(aura: AuraId, grandpa: GrandpaId) -> SessionKeys { fn session_keys(aura: AuraId, grandpa: GrandpaId) -> SessionKeys {
@@ -173,13 +167,6 @@ fn testnet_genesis(
} }
} }
pub fn load_spec(id: &str) -> Result<Option<ChainSpec>, String> {
Ok(match Alternative::from(id) {
Some(spec) => Some(spec.load()?),
None => None,
})
}
fn load_kovan_config() -> Option<BridgeEthPoAConfig> { fn load_kovan_config() -> Option<BridgeEthPoAConfig> {
Some(BridgeEthPoAConfig { Some(BridgeEthPoAConfig {
initial_header: sp_bridge_eth_poa::Header { initial_header: sp_bridge_eth_poa::Header {
+49 -13
View File
@@ -30,28 +30,64 @@
// You should have received a copy of the GNU General Public License // You should have received a copy of the GNU General Public License
// along with Parity Bridges Common. If not, see <http://www.gnu.org/licenses/>. // along with Parity Bridges Common. If not, see <http://www.gnu.org/licenses/>.
use crate::chain_spec;
use crate::cli::Cli; use crate::cli::Cli;
use crate::service; use crate::service;
use sc_cli::VersionInfo; use sc_cli::SubstrateCli;
use sp_consensus_aura::sr25519::AuthorityPair as AuraPair; use sp_consensus_aura::sr25519::AuthorityPair as AuraPair;
impl SubstrateCli for Cli {
fn impl_name() -> &'static str {
"Bridge Node"
}
fn impl_version() -> &'static str {
env!("CARGO_PKG_VERSION")
}
fn description() -> &'static str {
"Bridge Node"
}
fn author() -> &'static str {
"Parity Technologies"
}
fn support_url() -> &'static str {
"https://github.com/paritytech/parity-bridges-common/"
}
fn copyright_start_year() -> i32 {
2019
}
fn executable_name() -> &'static str {
"bridge-node"
}
fn load_spec(&self, id: &str) -> Result<Box<dyn sc_service::ChainSpec>, String> {
Ok(Box::new(
match id {
"" | "dev" => crate::chain_spec::Alternative::Development,
"local" => crate::chain_spec::Alternative::LocalTestnet,
_ => return Err(format!("Unsupported chain specification: {}", id)),
}
.load()?,
))
}
}
/// Parse and run command line arguments /// Parse and run command line arguments
pub fn run(version: VersionInfo) -> sc_cli::Result<()> { pub fn run() -> sc_cli::Result<()> {
let opt = sc_cli::from_args::<Cli>(&version); let cli = Cli::from_args();
let mut config = sc_service::Configuration::from_version(&version); match &cli.subcommand {
match opt.subcommand {
Some(subcommand) => { Some(subcommand) => {
subcommand.init(&version)?; let runner = cli.create_runner(subcommand)?;
subcommand.update_config(&mut config, chain_spec::load_spec, &version)?; runner.run_subcommand(subcommand, |config| Ok(new_full_start!(config).0))
subcommand.run(config, |config: _| Ok(new_full_start!(config).0))
} }
None => { None => {
opt.run.init(&version)?; let runner = cli.create_runner(&cli.run)?;
opt.run.update_config(&mut config, chain_spec::load_spec, &version)?; runner.run_node(service::new_light, service::new_full, bridge_node_runtime::VERSION)
opt.run.run(config, service::new_light, service::new_full, &version)
} }
} }
} }
+1 -12
View File
@@ -24,16 +24,5 @@ mod cli;
mod command; mod command;
fn main() -> sc_cli::Result<()> { fn main() -> sc_cli::Result<()> {
let version = sc_cli::VersionInfo { command::run()
name: "Bridge Node",
commit: env!("VERGEN_SHA_SHORT"),
version: env!("CARGO_PKG_VERSION"),
executable_name: "bridge-node",
author: "Parity Technologies",
description: "Bridge Node",
support_url: "https://github.com/paritytech/parity-bridges-common/",
copyright_start_year: 2019,
};
command::run(version)
} }
+30 -26
View File
@@ -16,9 +16,10 @@
//! Service and ServiceFactory implementation. Specialized wrapper over substrate service. //! Service and ServiceFactory implementation. Specialized wrapper over substrate service.
use bridge_node_runtime::{self, opaque::Block, GenesisConfig, RuntimeApi}; use bridge_node_runtime::{self, opaque::Block, RuntimeApi};
use grandpa::{self, FinalityProofProvider as GrandpaFinalityProofProvider}; use grandpa::{self, FinalityProofProvider as GrandpaFinalityProofProvider, StorageAndProofProvider};
use sc_client::LongestChain; use sc_client::LongestChain;
use sc_client_api::ExecutorProvider;
use sc_executor::native_executor_instance; use sc_executor::native_executor_instance;
pub use sc_executor::NativeExecutor; pub use sc_executor::NativeExecutor;
use sc_service::{error::Error as ServiceError, AbstractService, Configuration, ServiceBuilder}; use sc_service::{error::Error as ServiceError, AbstractService, Configuration, ServiceBuilder};
@@ -40,6 +41,8 @@ native_executor_instance!(
/// be able to perform chain operations. /// be able to perform chain operations.
macro_rules! new_full_start { macro_rules! new_full_start {
($config:expr) => {{ ($config:expr) => {{
use std::sync::Arc;
let mut import_setup = None; let mut import_setup = None;
let inherent_data_providers = sp_inherents::InherentDataProviders::new(); let inherent_data_providers = sp_inherents::InherentDataProviders::new();
@@ -49,11 +52,12 @@ macro_rules! new_full_start {
crate::service::Executor, crate::service::Executor,
>($config)? >($config)?
.with_select_chain(|_config, backend| Ok(sc_client::LongestChain::new(backend.clone())))? .with_select_chain(|_config, backend| Ok(sc_client::LongestChain::new(backend.clone())))?
.with_transaction_pool(|config, client, _fetcher| { .with_transaction_pool(|config, client, _fetcher, prometheus_registry| {
let pool_api = sc_transaction_pool::FullChainApi::new(client.clone()); let pool_api = sc_transaction_pool::FullChainApi::new(client.clone());
Ok(sc_transaction_pool::BasicPool::new( Ok(sc_transaction_pool::BasicPool::new(
config, config,
std::sync::Arc::new(pool_api), std::sync::Arc::new(pool_api),
prometheus_registry,
)) ))
})? })?
.with_import_queue(|_config, client, mut select_chain, _transaction_pool| { .with_import_queue(|_config, client, mut select_chain, _transaction_pool| {
@@ -61,7 +65,8 @@ macro_rules! new_full_start {
.take() .take()
.ok_or_else(|| sc_service::Error::SelectChainRequired)?; .ok_or_else(|| sc_service::Error::SelectChainRequired)?;
let (grandpa_block_import, grandpa_link) = grandpa::block_import(client.clone(), &*client, select_chain)?; let (grandpa_block_import, grandpa_link) =
grandpa::block_import(client.clone(), &(client.clone() as Arc<_>), select_chain)?;
let aura_block_import = sc_consensus_aura::AuraBlockImport::<_, _, _, AuraPair>::new( let aura_block_import = sc_consensus_aura::AuraBlockImport::<_, _, _, AuraPair>::new(
grandpa_block_import.clone(), grandpa_block_import.clone(),
@@ -97,17 +102,12 @@ macro_rules! new_full_start {
} }
/// Builds a new service for a full client. /// Builds a new service for a full client.
pub fn new_full(config: Configuration<GenesisConfig>) -> Result<impl AbstractService, ServiceError> { pub fn new_full(config: Configuration) -> Result<impl AbstractService, ServiceError> {
let is_authority = config.roles.is_authority(); let role = config.role.clone();
let force_authoring = config.force_authoring; let force_authoring = config.force_authoring;
let name = config.name.clone(); let name = config.network.node_name.clone();
let disable_grandpa = config.disable_grandpa; let disable_grandpa = config.disable_grandpa;
// sentry nodes announce themselves as authorities to the network
// and should run the same protocols authorities do, but it should
// never actively participate in any consensus process.
let participates_in_consensus = is_authority && !config.sentry_mode;
let (builder, mut import_setup, inherent_data_providers) = new_full_start!(config); let (builder, mut import_setup, inherent_data_providers) = new_full_start!(config);
let (block_import, grandpa_link) = import_setup let (block_import, grandpa_link) = import_setup
@@ -116,15 +116,13 @@ pub fn new_full(config: Configuration<GenesisConfig>) -> Result<impl AbstractSer
let service = builder let service = builder
.with_finality_proof_provider(|client, backend| { .with_finality_proof_provider(|client, backend| {
Ok(Arc::new(GrandpaFinalityProofProvider::new(backend, client)) as _) let provider = client as Arc<dyn StorageAndProofProvider<_, _>>;
Ok(Arc::new(GrandpaFinalityProofProvider::new(backend, provider)) as _)
})? })?
.build()?; .build()?;
if participates_in_consensus { if role.is_authority() {
let proposer = sc_basic_authorship::ProposerFactory { let proposer = sc_basic_authorship::ProposerFactory::new(service.client(), service.transaction_pool());
client: service.client(),
transaction_pool: service.transaction_pool(),
};
let client = service.client(); let client = service.client();
let select_chain = service.select_chain().ok_or(ServiceError::SelectChainRequired)?; let select_chain = service.select_chain().ok_or(ServiceError::SelectChainRequired)?;
@@ -151,7 +149,7 @@ pub fn new_full(config: Configuration<GenesisConfig>) -> Result<impl AbstractSer
// if the node isn't actively participating in consensus then it doesn't // if the node isn't actively participating in consensus then it doesn't
// need a keystore, regardless of which protocol we use below. // need a keystore, regardless of which protocol we use below.
let keystore = if participates_in_consensus { let keystore = if role.is_authority() {
Some(service.keystore()) Some(service.keystore())
} else { } else {
None None
@@ -164,7 +162,7 @@ pub fn new_full(config: Configuration<GenesisConfig>) -> Result<impl AbstractSer
name: Some(name), name: Some(name),
observer_enabled: false, observer_enabled: false,
keystore, keystore,
is_authority, is_authority: role.is_network_authority(),
}; };
let enable_grandpa = !disable_grandpa; let enable_grandpa = !disable_grandpa;
@@ -180,9 +178,9 @@ pub fn new_full(config: Configuration<GenesisConfig>) -> Result<impl AbstractSer
link: grandpa_link, link: grandpa_link,
network: service.network(), network: service.network(),
inherent_data_providers: inherent_data_providers.clone(), inherent_data_providers: inherent_data_providers.clone(),
on_exit: service.on_exit(),
telemetry_on_connect: Some(service.telemetry_on_connect_stream()), telemetry_on_connect: Some(service.telemetry_on_connect_stream()),
voting_rule: grandpa::VotingRulesBuilder::default().build(), voting_rule: grandpa::VotingRulesBuilder::default().build(),
prometheus_registry: service.prometheus_registry(),
}; };
// the GRANDPA voter task is considered infallible, i.e. // the GRANDPA voter task is considered infallible, i.e.
@@ -196,18 +194,19 @@ pub fn new_full(config: Configuration<GenesisConfig>) -> Result<impl AbstractSer
} }
/// Builds a new service for a light client. /// Builds a new service for a light client.
pub fn new_light(config: Configuration<GenesisConfig>) -> Result<impl AbstractService, ServiceError> { pub fn new_light(config: Configuration) -> Result<impl AbstractService, ServiceError> {
let inherent_data_providers = InherentDataProviders::new(); let inherent_data_providers = InherentDataProviders::new();
ServiceBuilder::new_light::<Block, RuntimeApi, Executor>(config)? ServiceBuilder::new_light::<Block, RuntimeApi, Executor>(config)?
.with_select_chain(|_config, backend| Ok(LongestChain::new(backend.clone())))? .with_select_chain(|_config, backend| Ok(LongestChain::new(backend.clone())))?
.with_transaction_pool(|config, client, fetcher| { .with_transaction_pool(|config, client, fetcher, prometheus_registry| {
let fetcher = fetcher.ok_or_else(|| "Trying to start light transaction pool without active fetcher")?; let fetcher = fetcher.ok_or_else(|| "Trying to start light transaction pool without active fetcher")?;
let pool_api = sc_transaction_pool::LightChainApi::new(client.clone(), fetcher.clone()); let pool_api = sc_transaction_pool::LightChainApi::new(client.clone(), fetcher.clone());
let pool = sc_transaction_pool::BasicPool::with_revalidation_type( let pool = sc_transaction_pool::BasicPool::with_revalidation_type(
config, config,
Arc::new(pool_api), Arc::new(pool_api),
prometheus_registry,
sc_transaction_pool::RevalidationType::Light, sc_transaction_pool::RevalidationType::Light,
); );
Ok(pool) Ok(pool)
@@ -216,8 +215,12 @@ pub fn new_light(config: Configuration<GenesisConfig>) -> Result<impl AbstractSe
let fetch_checker = fetcher let fetch_checker = fetcher
.map(|fetcher| fetcher.checker().clone()) .map(|fetcher| fetcher.checker().clone())
.ok_or_else(|| "Trying to start light import queue without active fetch checker")?; .ok_or_else(|| "Trying to start light import queue without active fetch checker")?;
let grandpa_block_import = let grandpa_block_import = grandpa::light_block_import(
grandpa::light_block_import(client.clone(), backend, &*client.clone(), Arc::new(fetch_checker))?; client.clone(),
backend,
&(client.clone() as Arc<_>),
Arc::new(fetch_checker),
)?;
let finality_proof_import = grandpa_block_import.clone(); let finality_proof_import = grandpa_block_import.clone();
let finality_proof_request_builder = finality_proof_import.create_finality_proof_request_builder(); let finality_proof_request_builder = finality_proof_import.create_finality_proof_request_builder();
@@ -233,7 +236,8 @@ pub fn new_light(config: Configuration<GenesisConfig>) -> Result<impl AbstractSe
Ok((import_queue, finality_proof_request_builder)) Ok((import_queue, finality_proof_request_builder))
})? })?
.with_finality_proof_provider(|client, backend| { .with_finality_proof_provider(|client, backend| {
Ok(Arc::new(GrandpaFinalityProofProvider::new(backend, client)) as _) let provider = client as Arc<dyn StorageAndProofProvider<_, _>>;
Ok(Arc::new(GrandpaFinalityProofProvider::new(backend, provider)) as _)
})? })?
.build() .build()
} }
+51 -51
View File
@@ -19,15 +19,15 @@ features = ["derive"]
# Substrate Dependencies # Substrate Dependencies
[dependencies.pallet-aura] [dependencies.pallet-aura]
version = "2.0.0-alpha.2" version = "2.0.0-alpha.6"
default-features = false default-features = false
rev = "2afecf81ee19b8a6edb364b419190ea47c4a4a31" rev = "c13ad41634d0bd7cf07897c2aa062b917d520520"
git = "https://github.com/paritytech/substrate/" git = "https://github.com/paritytech/substrate/"
[dependencies.pallet-balances] [dependencies.pallet-balances]
version = "2.0.0-alpha.2" version = "2.0.0-alpha.6"
default-features = false default-features = false
rev = "2afecf81ee19b8a6edb364b419190ea47c4a4a31" rev = "c13ad41634d0bd7cf07897c2aa062b917d520520"
git = "https://github.com/paritytech/substrate/" git = "https://github.com/paritytech/substrate/"
[dependencies.pallet-bridge-eth-poa] [dependencies.pallet-bridge-eth-poa]
@@ -36,76 +36,76 @@ default-features = false
path = "../../../modules/ethereum" path = "../../../modules/ethereum"
[dependencies.frame-support] [dependencies.frame-support]
version = "2.0.0-alpha.2" version = "2.0.0-alpha.6"
default-features = false default-features = false
rev = "2afecf81ee19b8a6edb364b419190ea47c4a4a31" rev = "c13ad41634d0bd7cf07897c2aa062b917d520520"
git = "https://github.com/paritytech/substrate/" git = "https://github.com/paritytech/substrate/"
[dependencies.pallet-grandpa] [dependencies.pallet-grandpa]
version = "2.0.0-alpha.2" version = "2.0.0-alpha.6"
default-features = false default-features = false
rev = "2afecf81ee19b8a6edb364b419190ea47c4a4a31" rev = "c13ad41634d0bd7cf07897c2aa062b917d520520"
git = "https://github.com/paritytech/substrate/" git = "https://github.com/paritytech/substrate/"
[dependencies.pallet-randomness-collective-flip] [dependencies.pallet-randomness-collective-flip]
version = "2.0.0-alpha.2" version = "2.0.0-alpha.6"
default-features = false default-features = false
rev = "2afecf81ee19b8a6edb364b419190ea47c4a4a31" rev = "c13ad41634d0bd7cf07897c2aa062b917d520520"
git = "https://github.com/paritytech/substrate/" git = "https://github.com/paritytech/substrate/"
[dependencies.pallet-sudo] [dependencies.pallet-sudo]
version = "2.0.0-alpha.2" version = "2.0.0-alpha.6"
default-features = false default-features = false
rev = "2afecf81ee19b8a6edb364b419190ea47c4a4a31" rev = "c13ad41634d0bd7cf07897c2aa062b917d520520"
git = "https://github.com/paritytech/substrate/" git = "https://github.com/paritytech/substrate/"
[dependencies.pallet-session] [dependencies.pallet-session]
version = "2.0.0-alpha.2" version = "2.0.0-alpha.6"
default-features = false default-features = false
rev = "2afecf81ee19b8a6edb364b419190ea47c4a4a31" rev = "c13ad41634d0bd7cf07897c2aa062b917d520520"
git = "https://github.com/paritytech/substrate/" git = "https://github.com/paritytech/substrate/"
[dependencies.frame-system] [dependencies.frame-system]
version = "2.0.0-alpha.2" version = "2.0.0-alpha.6"
default-features = false default-features = false
rev = "2afecf81ee19b8a6edb364b419190ea47c4a4a31" rev = "c13ad41634d0bd7cf07897c2aa062b917d520520"
git = "https://github.com/paritytech/substrate/" git = "https://github.com/paritytech/substrate/"
[dependencies.frame-system-rpc-runtime-api] [dependencies.frame-system-rpc-runtime-api]
version = "2.0.0-alpha.2" version = "2.0.0-alpha.6"
default-features = false default-features = false
rev = "2afecf81ee19b8a6edb364b419190ea47c4a4a31" rev = "c13ad41634d0bd7cf07897c2aa062b917d520520"
git = "https://github.com/paritytech/substrate/" git = "https://github.com/paritytech/substrate/"
[dependencies.pallet-timestamp] [dependencies.pallet-timestamp]
version = "2.0.0-alpha.2" version = "2.0.0-alpha.6"
default-features = false default-features = false
rev = "2afecf81ee19b8a6edb364b419190ea47c4a4a31" rev = "c13ad41634d0bd7cf07897c2aa062b917d520520"
git = "https://github.com/paritytech/substrate/" git = "https://github.com/paritytech/substrate/"
[dependencies.pallet-transaction-payment] [dependencies.pallet-transaction-payment]
version = "2.0.0-alpha.2" version = "2.0.0-alpha.6"
default-features = false default-features = false
rev = "2afecf81ee19b8a6edb364b419190ea47c4a4a31" rev = "c13ad41634d0bd7cf07897c2aa062b917d520520"
git = "https://github.com/paritytech/substrate/" git = "https://github.com/paritytech/substrate/"
[dependencies.frame-executive] [dependencies.frame-executive]
version = "2.0.0-alpha.2" version = "2.0.0-alpha.6"
default-features = false default-features = false
rev = "2afecf81ee19b8a6edb364b419190ea47c4a4a31" rev = "c13ad41634d0bd7cf07897c2aa062b917d520520"
git = "https://github.com/paritytech/substrate/" git = "https://github.com/paritytech/substrate/"
# Substrate Primitives # Substrate Primitives
[dependencies.sp-api] [dependencies.sp-api]
version = "2.0.0-alpha.2" version = "2.0.0-alpha.6"
default-features = false default-features = false
rev = "2afecf81ee19b8a6edb364b419190ea47c4a4a31" rev = "c13ad41634d0bd7cf07897c2aa062b917d520520"
git = "https://github.com/paritytech/substrate/" git = "https://github.com/paritytech/substrate/"
[dependencies.sp-block-builder] [dependencies.sp-block-builder]
version = "2.0.0-alpha.2" version = "2.0.0-alpha.6"
default-features = false default-features = false
rev = "2afecf81ee19b8a6edb364b419190ea47c4a4a31" rev = "c13ad41634d0bd7cf07897c2aa062b917d520520"
git = "https://github.com/paritytech/substrate/" git = "https://github.com/paritytech/substrate/"
[dependencies.sp-bridge-eth-poa] [dependencies.sp-bridge-eth-poa]
@@ -114,75 +114,75 @@ default-features = false
path = "../../../primitives/ethereum-poa" path = "../../../primitives/ethereum-poa"
[dependencies.sp-consensus-aura] [dependencies.sp-consensus-aura]
version = "0.8.0-alpha.2" version = "0.8.0-alpha.6"
default-features = false default-features = false
rev = "2afecf81ee19b8a6edb364b419190ea47c4a4a31" rev = "c13ad41634d0bd7cf07897c2aa062b917d520520"
git = "https://github.com/paritytech/substrate/" git = "https://github.com/paritytech/substrate/"
[dependencies.sp-core] [dependencies.sp-core]
version = "2.0.0-alpha.2" version = "2.0.0-alpha.6"
default-features = false default-features = false
rev = "2afecf81ee19b8a6edb364b419190ea47c4a4a31" rev = "c13ad41634d0bd7cf07897c2aa062b917d520520"
git = "https://github.com/paritytech/substrate/" git = "https://github.com/paritytech/substrate/"
[dependencies.sp-inherents] [dependencies.sp-inherents]
version = "2.0.0-alpha.2" version = "2.0.0-alpha.6"
default-features = false default-features = false
rev = "2afecf81ee19b8a6edb364b419190ea47c4a4a31" rev = "c13ad41634d0bd7cf07897c2aa062b917d520520"
git = "https://github.com/paritytech/substrate/" git = "https://github.com/paritytech/substrate/"
[dependencies.sp-io] [dependencies.sp-io]
version = "2.0.0-alpha.2" version = "2.0.0-alpha.6"
default-features = false default-features = false
rev = "2afecf81ee19b8a6edb364b419190ea47c4a4a31" rev = "c13ad41634d0bd7cf07897c2aa062b917d520520"
git = "https://github.com/paritytech/substrate/" git = "https://github.com/paritytech/substrate/"
[dependencies.sp-offchain] [dependencies.sp-offchain]
version = "2.0.0-alpha.2" version = "2.0.0-alpha.6"
default-features = false default-features = false
rev = "2afecf81ee19b8a6edb364b419190ea47c4a4a31" rev = "c13ad41634d0bd7cf07897c2aa062b917d520520"
git = "https://github.com/paritytech/substrate/" git = "https://github.com/paritytech/substrate/"
[dependencies.sp-runtime] [dependencies.sp-runtime]
version = "2.0.0-alpha.2" version = "2.0.0-alpha.6"
default-features = false default-features = false
rev = "2afecf81ee19b8a6edb364b419190ea47c4a4a31" rev = "c13ad41634d0bd7cf07897c2aa062b917d520520"
git = "https://github.com/paritytech/substrate/" git = "https://github.com/paritytech/substrate/"
[dependencies.sp-session] [dependencies.sp-session]
version = "2.0.0-alpha.2" version = "2.0.0-alpha.6"
default-features = false default-features = false
rev = "2afecf81ee19b8a6edb364b419190ea47c4a4a31" rev = "c13ad41634d0bd7cf07897c2aa062b917d520520"
git = "https://github.com/paritytech/substrate/" git = "https://github.com/paritytech/substrate/"
[dependencies.sp-staking] [dependencies.sp-staking]
version = "2.0.0-alpha.2" version = "2.0.0-alpha.6"
default-features = false default-features = false
rev = "2afecf81ee19b8a6edb364b419190ea47c4a4a31" rev = "c13ad41634d0bd7cf07897c2aa062b917d520520"
git = "https://github.com/paritytech/substrate/" git = "https://github.com/paritytech/substrate/"
[dependencies.sp-std] [dependencies.sp-std]
version = "2.0.0-alpha.2" version = "2.0.0-alpha.6"
default-features = false default-features = false
rev = "2afecf81ee19b8a6edb364b419190ea47c4a4a31" rev = "c13ad41634d0bd7cf07897c2aa062b917d520520"
git = "https://github.com/paritytech/substrate/" git = "https://github.com/paritytech/substrate/"
[dependencies.sp-transaction-pool] [dependencies.sp-transaction-pool]
version = "2.0.0-alpha.2" version = "2.0.0-alpha.6"
default-features = false default-features = false
rev = "2afecf81ee19b8a6edb364b419190ea47c4a4a31" rev = "c13ad41634d0bd7cf07897c2aa062b917d520520"
git = "https://github.com/paritytech/substrate/" git = "https://github.com/paritytech/substrate/"
[dependencies.sp-version] [dependencies.sp-version]
version = "2.0.0-alpha.2" version = "2.0.0-alpha.6"
default-features = false default-features = false
rev = "2afecf81ee19b8a6edb364b419190ea47c4a4a31" rev = "c13ad41634d0bd7cf07897c2aa062b917d520520"
git = "https://github.com/paritytech/substrate/" git = "https://github.com/paritytech/substrate/"
[build-dependencies.wasm-builder-runner] [build-dependencies.wasm-builder-runner]
version = "1.0.5" version = "1.0.5"
package = "substrate-wasm-builder-runner" package = "substrate-wasm-builder-runner"
rev = "2afecf81ee19b8a6edb364b419190ea47c4a4a31" rev = "c13ad41634d0bd7cf07897c2aa062b917d520520"
git = "https://github.com/paritytech/substrate/" git = "https://github.com/paritytech/substrate/"
[features] [features]
+31 -11
View File
@@ -34,8 +34,9 @@ use sp_runtime::traits::{
BlakeTwo256, Block as BlockT, ConvertInto, IdentifyAccount, IdentityLookup, OpaqueKeys, Verify, BlakeTwo256, Block as BlockT, ConvertInto, IdentifyAccount, IdentityLookup, OpaqueKeys, Verify,
}; };
use sp_runtime::{ use sp_runtime::{
create_runtime_str, generic, impl_opaque_keys, transaction_validity::TransactionValidity, ApplyExtrinsicResult, create_runtime_str, generic, impl_opaque_keys,
MultiSignature, transaction_validity::{TransactionSource, TransactionValidity},
ApplyExtrinsicResult, MultiSignature,
}; };
use sp_std::prelude::*; use sp_std::prelude::*;
#[cfg(feature = "std")] #[cfg(feature = "std")]
@@ -43,7 +44,12 @@ use sp_version::NativeVersion;
use sp_version::RuntimeVersion; 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::{construct_runtime, parameter_types, traits::Randomness, weights::Weight, StorageValue}; pub use frame_support::{
construct_runtime, parameter_types,
traits::Randomness,
weights::{RuntimeDbWeight, Weight},
StorageValue,
};
pub use pallet_balances::Call as BalancesCall; pub use pallet_balances::Call as BalancesCall;
pub use pallet_bridge_eth_poa::Call as BridgeEthPoACall; pub use pallet_bridge_eth_poa::Call as BridgeEthPoACall;
pub use pallet_timestamp::Call as TimestampCall; pub use pallet_timestamp::Call as TimestampCall;
@@ -109,6 +115,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion {
spec_version: 1, spec_version: 1,
impl_version: 1, impl_version: 1,
apis: RUNTIME_API_VERSIONS, apis: RUNTIME_API_VERSIONS,
transaction_version: 1,
}; };
pub const MILLISECS_PER_BLOCK: u64 = 6000; pub const MILLISECS_PER_BLOCK: u64 = 6000;
@@ -131,10 +138,15 @@ 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 = 2_000_000_000_000;
pub const ExtrinsicBaseWeight: Weight = 10_000_000;
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;
pub const DbWeight: RuntimeDbWeight = RuntimeDbWeight {
read: 60_000_000, // ~0.06 ms = ~60 µs
write: 200_000_000, // ~0.2 ms = 200 µs
};
} }
impl frame_system::Trait for Runtime { impl frame_system::Trait for Runtime {
@@ -162,6 +174,14 @@ impl frame_system::Trait for Runtime {
type BlockHashCount = BlockHashCount; type BlockHashCount = BlockHashCount;
/// Maximum weight of each block. /// Maximum weight of each block.
type MaximumBlockWeight = MaximumBlockWeight; type MaximumBlockWeight = MaximumBlockWeight;
/// The weight of database operations that the runtime can invoke.
type DbWeight = DbWeight;
/// The weight of the overhead invoked on the block import process, independent of the
/// extrinsics included in that block.
type BlockExecutionWeight = ();
/// The base weight of any extrinsic processed by the runtime, independent of the
/// logic of that extrinsic. (Signature verification, nonce increment, fee, etc...)
type ExtrinsicBaseWeight = ExtrinsicBaseWeight;
/// Maximum size of all encoded transactions (in bytes) that are allowed in one block. /// Maximum size of all encoded transactions (in bytes) that are allowed in one block.
type MaximumBlockLength = MaximumBlockLength; type MaximumBlockLength = MaximumBlockLength;
/// Portion of the block weight that is available to all normal transactions. /// Portion of the block weight that is available to all normal transactions.
@@ -225,7 +245,6 @@ parameter_types! {
impl pallet_transaction_payment::Trait for Runtime { impl pallet_transaction_payment::Trait for Runtime {
type Currency = pallet_balances::Module<Runtime>; type Currency = pallet_balances::Module<Runtime>;
type OnTransactionPayment = (); type OnTransactionPayment = ();
type TransactionBaseFee = TransactionBaseFee;
type TransactionByteFee = TransactionByteFee; type TransactionByteFee = TransactionByteFee;
type WeightToFee = ConvertInto; type WeightToFee = ConvertInto;
type FeeMultiplierUpdate = (); type FeeMultiplierUpdate = ();
@@ -246,6 +265,7 @@ impl pallet_session::Trait for Runtime {
type ValidatorId = <Self as frame_system::Trait>::AccountId; type ValidatorId = <Self as frame_system::Trait>::AccountId;
type ValidatorIdOf = (); type ValidatorIdOf = ();
type ShouldEndSession = pallet_session::PeriodicSessions<Period, Offset>; type ShouldEndSession = pallet_session::PeriodicSessions<Period, Offset>;
type NextSessionRotation = pallet_session::PeriodicSessions<Period, Offset>;
type SessionManager = ShiftSessionManager; type SessionManager = ShiftSessionManager;
type SessionHandler = <SessionKeys as OpaqueKeys>::KeyTypeIdProviders; type SessionHandler = <SessionKeys as OpaqueKeys>::KeyTypeIdProviders;
type Keys = SessionKeys; type Keys = SessionKeys;
@@ -279,6 +299,7 @@ impl ShiftSessionManager {
impl pallet_session::SessionManager<AccountId> for ShiftSessionManager { impl pallet_session::SessionManager<AccountId> for ShiftSessionManager {
fn end_session(_: sp_staking::SessionIndex) {} fn end_session(_: sp_staking::SessionIndex) {}
fn start_session(_: sp_staking::SessionIndex) {}
fn new_session(session_index: sp_staking::SessionIndex) -> Option<Vec<AccountId>> { fn new_session(session_index: sp_staking::SessionIndex) -> Option<Vec<AccountId>> {
// can't access genesis config here :/ // can't access genesis config here :/
if session_index == 0 || session_index == 1 { if session_index == 0 || session_index == 1 {
@@ -376,10 +397,6 @@ impl_runtime_apis! {
Executive::apply_extrinsic(extrinsic) 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 { fn finalize_block() -> <Block as BlockT>::Header {
Executive::finalize_block() Executive::finalize_block()
} }
@@ -421,8 +438,11 @@ impl_runtime_apis! {
} }
impl sp_transaction_pool::runtime_api::TaggedTransactionQueue<Block> for Runtime { impl sp_transaction_pool::runtime_api::TaggedTransactionQueue<Block> for Runtime {
fn validate_transaction(tx: <Block as BlockT>::Extrinsic) -> TransactionValidity { fn validate_transaction(
Executive::validate_transaction(tx) source: TransactionSource,
tx: <Block as BlockT>::Extrinsic,
) -> TransactionValidity {
Executive::validate_transaction(source, tx)
} }
} }
+10 -10
View File
@@ -12,33 +12,33 @@ primitives = { package = "sp-bridge-eth-poa", path = "../../primitives/ethereum-
# Substrate Based Dependencies # Substrate Based Dependencies
[dependencies.frame-support] [dependencies.frame-support]
version = "2.0.0-alpha.2" version = "2.0.0-alpha.6"
default-features = false default-features = false
rev = "2afecf81ee19b8a6edb364b419190ea47c4a4a31" rev = "c13ad41634d0bd7cf07897c2aa062b917d520520"
git = "https://github.com/paritytech/substrate/" git = "https://github.com/paritytech/substrate/"
[dependencies.frame-system] [dependencies.frame-system]
version = "2.0.0-alpha.2" version = "2.0.0-alpha.6"
default-features = false default-features = false
rev = "2afecf81ee19b8a6edb364b419190ea47c4a4a31" rev = "c13ad41634d0bd7cf07897c2aa062b917d520520"
git = "https://github.com/paritytech/substrate/" git = "https://github.com/paritytech/substrate/"
[dependencies.sp-std] [dependencies.sp-std]
version = "2.0.0-alpha.2" version = "2.0.0-alpha.6"
default-features = false default-features = false
rev = "2afecf81ee19b8a6edb364b419190ea47c4a4a31" rev = "c13ad41634d0bd7cf07897c2aa062b917d520520"
git = "https://github.com/paritytech/substrate/" git = "https://github.com/paritytech/substrate/"
[dependencies.sp-io] [dependencies.sp-io]
version = "2.0.0-alpha.2" version = "2.0.0-alpha.6"
default-features = false default-features = false
rev = "2afecf81ee19b8a6edb364b419190ea47c4a4a31" rev = "c13ad41634d0bd7cf07897c2aa062b917d520520"
git = "https://github.com/paritytech/substrate/" git = "https://github.com/paritytech/substrate/"
[dependencies.sp-runtime] [dependencies.sp-runtime]
version = "2.0.0-alpha.2" version = "2.0.0-alpha.6"
default-features = false default-features = false
rev = "2afecf81ee19b8a6edb364b419190ea47c4a4a31" rev = "c13ad41634d0bd7cf07897c2aa062b917d520520"
git = "https://github.com/paritytech/substrate/" git = "https://github.com/paritytech/substrate/"
# Dev Dependencies # Dev Dependencies
+10 -8
View File
@@ -21,8 +21,8 @@ use frame_support::{decl_module, decl_storage};
use primitives::{Address, Header, Receipt, H256, U256}; use primitives::{Address, Header, Receipt, H256, U256};
use sp_runtime::{ use sp_runtime::{
transaction_validity::{ transaction_validity::{
InvalidTransaction, TransactionLongevity, TransactionPriority, TransactionValidity, UnknownTransaction, InvalidTransaction, TransactionLongevity, TransactionPriority, TransactionSource, TransactionValidity,
ValidTransaction, UnknownTransaction, ValidTransaction,
}, },
RuntimeDebug, RuntimeDebug,
}; };
@@ -293,6 +293,7 @@ pub trait Trait: frame_system::Trait {
decl_module! { decl_module! {
pub struct Module<T: Trait> for enum Call where origin: T::Origin { pub struct Module<T: Trait> for enum Call where origin: T::Origin {
/// Import single Aura header. Requires transaction to be **UNSIGNED**. /// Import single Aura header. Requires transaction to be **UNSIGNED**.
#[weight = 0] // TODO: update me (https://github.com/paritytech/parity-bridges-common/issues/78)
pub fn import_unsigned_header(origin, header: Header, receipts: Option<Vec<Receipt>>) { pub fn import_unsigned_header(origin, header: Header, receipts: Option<Vec<Receipt>>) {
frame_system::ensure_none(origin)?; frame_system::ensure_none(origin)?;
@@ -313,6 +314,7 @@ decl_module! {
/// ///
/// This should be used with caution - passing too many headers could lead to /// This should be used with caution - passing too many headers could lead to
/// enormous block production/import time. /// enormous block production/import time.
#[weight = 0] // TODO: update me (https://github.com/paritytech/parity-bridges-common/issues/78)
pub fn import_signed_headers(origin, headers_with_receipts: Vec<(Header, Option<Vec<Receipt>>)>) { pub fn import_signed_headers(origin, headers_with_receipts: Vec<(Header, Option<Vec<Receipt>>)>) {
let submitter = frame_system::ensure_signed(origin)?; let submitter = frame_system::ensure_signed(origin)?;
let mut finalized_headers = BTreeMap::new(); let mut finalized_headers = BTreeMap::new();
@@ -359,19 +361,19 @@ decl_storage! {
/// Oldest unpruned block(s) number. /// Oldest unpruned block(s) number.
OldestUnprunedBlock: u64; OldestUnprunedBlock: u64;
/// Map of imported headers by hash. /// Map of imported headers by hash.
Headers: map hasher(blake2_256) H256 => Option<StoredHeader<T::AccountId>>; Headers: map hasher(identity) H256 => Option<StoredHeader<T::AccountId>>;
/// Map of imported header hashes by number. /// Map of imported header hashes by number.
HeadersByNumber: map hasher(blake2_256) u64 => Option<Vec<H256>>; HeadersByNumber: map hasher(blake2_128_concat) u64 => Option<Vec<H256>>;
/// The ID of next validator set. /// The ID of next validator set.
NextValidatorsSetId: u64; NextValidatorsSetId: u64;
/// Map of validators sets by their id. /// Map of validators sets by their id.
ValidatorsSets: map hasher(blake2_256) u64 => Option<ValidatorsSet>; ValidatorsSets: map hasher(twox_64_concat) u64 => Option<ValidatorsSet>;
/// Validators sets reference count. Each header that is authored by this set increases /// Validators sets reference count. Each header that is authored by this set increases
/// the reference count. When we prune this header, we decrease the reference count. /// the reference count. When we prune this header, we decrease the reference count.
/// When it reaches zero, we are free to prune validator set as well. /// When it reaches zero, we are free to prune validator set as well.
ValidatorsSetsRc: map hasher(blake2_256) u64 => Option<u64>; ValidatorsSetsRc: map hasher(twox_64_concat) u64 => Option<u64>;
/// Map of validators set changes scheduled by given header. /// Map of validators set changes scheduled by given header.
ScheduledChanges: map hasher(blake2_256) H256 => Option<ScheduledChange>; ScheduledChanges: map hasher(identity) H256 => Option<ScheduledChange>;
} }
add_extra_genesis { add_extra_genesis {
config(initial_header): Header; config(initial_header): Header;
@@ -434,7 +436,7 @@ impl<T: Trait> Module<T> {
impl<T: Trait> frame_support::unsigned::ValidateUnsigned for Module<T> { impl<T: Trait> frame_support::unsigned::ValidateUnsigned for Module<T> {
type Call = Call<T>; type Call = Call<T>;
fn validate_unsigned(call: &Self::Call) -> TransactionValidity { fn validate_unsigned(_source: TransactionSource, call: &Self::Call) -> TransactionValidity {
match *call { match *call {
Self::Call::import_unsigned_header(ref header, ref receipts) => { Self::Call::import_unsigned_header(ref header, ref receipts) => {
let accept_result = verification::accept_aura_header_into_pool( let accept_result = verification::accept_aura_header_into_pool(
+18 -18
View File
@@ -13,57 +13,57 @@ hash-db = { version = "0.15.2", default-features = false }
# Substrate Based Dependencies # Substrate Based Dependencies
[dependencies.frame-support] [dependencies.frame-support]
version = "2.0.0-alpha.2" version = "2.0.0-alpha.6"
default-features = false default-features = false
rev = "2afecf81ee19b8a6edb364b419190ea47c4a4a31" rev = "c13ad41634d0bd7cf07897c2aa062b917d520520"
git = "https://github.com/paritytech/substrate/" git = "https://github.com/paritytech/substrate/"
[dependencies.frame-system] [dependencies.frame-system]
version = "2.0.0-alpha.2" version = "2.0.0-alpha.6"
default-features = false default-features = false
rev = "2afecf81ee19b8a6edb364b419190ea47c4a4a31" rev = "c13ad41634d0bd7cf07897c2aa062b917d520520"
git = "https://github.com/paritytech/substrate/" git = "https://github.com/paritytech/substrate/"
[dependencies.pallet-session] [dependencies.pallet-session]
version = "2.0.0-alpha.2" version = "2.0.0-alpha.6"
default-features = false default-features = false
rev = "2afecf81ee19b8a6edb364b419190ea47c4a4a31" rev = "c13ad41634d0bd7cf07897c2aa062b917d520520"
git = "https://github.com/paritytech/substrate/" git = "https://github.com/paritytech/substrate/"
[dependencies.sp-core] [dependencies.sp-core]
version = "2.0.0-alpha.2" version = "2.0.0-alpha.6"
default-features = false default-features = false
rev = "2afecf81ee19b8a6edb364b419190ea47c4a4a31" rev = "c13ad41634d0bd7cf07897c2aa062b917d520520"
git = "https://github.com/paritytech/substrate/" git = "https://github.com/paritytech/substrate/"
[dependencies.sp-finality-grandpa] [dependencies.sp-finality-grandpa]
version = "2.0.0-alpha.2" version = "2.0.0-alpha.6"
default-features = false default-features = false
rev = "2afecf81ee19b8a6edb364b419190ea47c4a4a31" rev = "c13ad41634d0bd7cf07897c2aa062b917d520520"
git = "https://github.com/paritytech/substrate/" git = "https://github.com/paritytech/substrate/"
[dependencies.sp-runtime] [dependencies.sp-runtime]
version = "2.0.0-alpha.2" version = "2.0.0-alpha.6"
default-features = false default-features = false
rev = "2afecf81ee19b8a6edb364b419190ea47c4a4a31" rev = "c13ad41634d0bd7cf07897c2aa062b917d520520"
git = "https://github.com/paritytech/substrate/" git = "https://github.com/paritytech/substrate/"
[dependencies.sp-trie] [dependencies.sp-trie]
version = "2.0.0-alpha.2" version = "2.0.0-alpha.6"
default-features = false default-features = false
rev = "2afecf81ee19b8a6edb364b419190ea47c4a4a31" rev = "c13ad41634d0bd7cf07897c2aa062b917d520520"
git = "https://github.com/paritytech/substrate/" git = "https://github.com/paritytech/substrate/"
# Dev Dependencies # Dev Dependencies
[dev-dependencies.sp-io] [dev-dependencies.sp-io]
version = "2.0.0-alpha.2" version = "2.0.0-alpha.6"
default-features = false default-features = false
rev = "2afecf81ee19b8a6edb364b419190ea47c4a4a31" rev = "c13ad41634d0bd7cf07897c2aa062b917d520520"
git = "https://github.com/paritytech/substrate/" git = "https://github.com/paritytech/substrate/"
[dev-dependencies.sp-state-machine] [dev-dependencies.sp-state-machine]
version = "0.8.0-alpha.2" version = "0.8.0-alpha.6"
rev = "2afecf81ee19b8a6edb364b419190ea47c4a4a31" rev = "c13ad41634d0bd7cf07897c2aa062b917d520520"
git = "https://github.com/paritytech/substrate/" git = "https://github.com/paritytech/substrate/"
[features] [features]
+8 -4
View File
@@ -96,11 +96,11 @@ pub trait Trait: system::Trait {}
decl_storage! { decl_storage! {
trait Store for Module<T: Trait> as Bridge { trait Store for Module<T: Trait> as Bridge {
/// The number of current bridges managed by the module. /// The number of current bridges managed by the module.
pub NumBridges get(num_bridges) config(): BridgeId; pub NumBridges get(fn num_bridges) config(): BridgeId;
/// Maps a bridge id to a bridge struct. Allows a single /// Maps a bridge id to a bridge struct. Allows a single
/// `bridge` module to manage multiple bridges. /// `bridge` module to manage multiple bridges.
pub TrackedBridges get(tracked_bridges): map hasher(blake2_256) BridgeId => Option<BridgeInfo<T>>; pub TrackedBridges get(fn tracked_bridges): map hasher(blake2_128_concat) BridgeId => Option<BridgeInfo<T>>;
} }
} }
@@ -108,6 +108,7 @@ decl_module! {
pub struct Module<T: Trait> for enum Call where origin: T::Origin { pub struct Module<T: Trait> for enum Call where origin: T::Origin {
type Error = Error<T>; type Error = Error<T>;
#[weight = 0] // TODO: update me
fn initialize_bridge( fn initialize_bridge(
origin, origin,
block_header: T::Header, block_header: T::Header,
@@ -131,6 +132,7 @@ decl_module! {
NumBridges::put(new_bridge_id); NumBridges::put(new_bridge_id);
} }
#[weight = 0] // TODO: update me
fn submit_finalized_headers(origin) { fn submit_finalized_headers(origin) {
let _sender = ensure_signed(origin)?; let _sender = ensure_signed(origin)?;
} }
@@ -155,8 +157,7 @@ impl<T: Trait> Module<T> {
proof: StorageProof, proof: StorageProof,
validator_set: &Vec<(AuthorityId, AuthorityWeight)>, validator_set: &Vec<(AuthorityId, AuthorityWeight)>,
) -> DispatchResult { ) -> DispatchResult {
let checker = let checker = <StorageProofChecker<T::Hashing>>::new(*state_root, proof.clone());
<StorageProofChecker<<T::Hashing as sp_runtime::traits::Hash>::Hasher>>::new(*state_root, proof.clone());
let checker = checker.map_err(Self::map_storage_err)?; let checker = checker.map_err(Self::map_storage_err)?;
@@ -259,6 +260,9 @@ mod tests {
type Event = (); type Event = ();
type BlockHashCount = (); type BlockHashCount = ();
type MaximumBlockWeight = (); type MaximumBlockWeight = ();
type DbWeight = ();
type BlockExecutionWeight = ();
type ExtrinsicBaseWeight = ();
type AvailableBlockRatio = (); type AvailableBlockRatio = ();
type MaximumBlockLength = (); type MaximumBlockLength = ();
type Version = (); type Version = ();
+9 -9
View File
@@ -10,7 +10,7 @@ serde = { version = "1.0", optional = true }
serde-big-array = { version = "0.2", optional = true } serde-big-array = { version = "0.2", optional = true }
ethbloom = { version = "0.8", default-features = false } ethbloom = { version = "0.8", default-features = false }
parity-bytes = { version = "0.1", default-features = false } parity-bytes = { version = "0.1", default-features = false }
primitive-types = { version = "0.6", default-features = false, features = ["codec", "rlp"] } primitive-types = { version = "0.7", default-features = false, features = ["codec", "rlp"] }
fixed-hash = { version = "0.5", default-features = false } fixed-hash = { version = "0.5", default-features = false }
impl-rlp = { version = "0.2", default-features = false } impl-rlp = { version = "0.2", default-features = false }
impl-serde = { version = "0.2.3", optional = true } impl-serde = { version = "0.2.3", optional = true }
@@ -22,27 +22,27 @@ plain_hasher = { version = "0.2.2", default-features = false }
# Substrate Based Dependencies # Substrate Based Dependencies
[dependencies.sp-api] [dependencies.sp-api]
version = "2.0.0-alpha.2" version = "2.0.0-alpha.6"
default-features = false default-features = false
rev = "2afecf81ee19b8a6edb364b419190ea47c4a4a31" rev = "c13ad41634d0bd7cf07897c2aa062b917d520520"
git = "https://github.com/paritytech/substrate.git" git = "https://github.com/paritytech/substrate.git"
[dependencies.sp-std] [dependencies.sp-std]
version = "2.0.0-alpha.2" version = "2.0.0-alpha.6"
default-features = false default-features = false
rev = "2afecf81ee19b8a6edb364b419190ea47c4a4a31" rev = "c13ad41634d0bd7cf07897c2aa062b917d520520"
git = "https://github.com/paritytech/substrate.git" git = "https://github.com/paritytech/substrate.git"
[dependencies.sp-runtime] [dependencies.sp-runtime]
version = "2.0.0-alpha.2" version = "2.0.0-alpha.6"
default-features = false default-features = false
rev = "2afecf81ee19b8a6edb364b419190ea47c4a4a31" rev = "c13ad41634d0bd7cf07897c2aa062b917d520520"
git = "https://github.com/paritytech/substrate.git" git = "https://github.com/paritytech/substrate.git"
[dependencies.sp-io] [dependencies.sp-io]
version = "2.0.0-alpha.2" version = "2.0.0-alpha.6"
default-features = false default-features = false
rev = "2afecf81ee19b8a6edb364b419190ea47c4a4a31" rev = "c13ad41634d0bd7cf07897c2aa062b917d520520"
git = "https://github.com/paritytech/substrate.git" git = "https://github.com/paritytech/substrate.git"
[features] [features]
+13 -13
View File
@@ -22,40 +22,40 @@ serde = { version = "1.0.106", features = ["derive"] }
serde_json = "1.0.51" serde_json = "1.0.51"
sp-bridge-eth-poa = { path = "../../primitives/ethereum-poa" } sp-bridge-eth-poa = { path = "../../primitives/ethereum-poa" }
time = "0.2" time = "0.2"
web3 = { git = "https://github.com/svyatonik/rust-web3.git", branch = "fix_receipt" } web3 = { git = "https://github.com/svyatonik/rust-web3.git", branch = "add-receipt-root" }
# Substrate Based Dependencies # Substrate Based Dependencies
[dependencies.frame-system] [dependencies.frame-system]
version = "2.0.0-alpha.2" version = "2.0.0-alpha.6"
rev = "2afecf81ee19b8a6edb364b419190ea47c4a4a31" rev = "c13ad41634d0bd7cf07897c2aa062b917d520520"
git = "https://github.com/paritytech/substrate/" git = "https://github.com/paritytech/substrate/"
[dependencies.pallet-transaction-payment] [dependencies.pallet-transaction-payment]
version = "2.0.0-alpha.2" version = "2.0.0-alpha.6"
rev = "2afecf81ee19b8a6edb364b419190ea47c4a4a31" rev = "c13ad41634d0bd7cf07897c2aa062b917d520520"
git = "https://github.com/paritytech/substrate.git" git = "https://github.com/paritytech/substrate.git"
# I think this is used for sr-io and stuff # I think this is used for sr-io and stuff
[dependencies.node-primitives] [dependencies.node-primitives]
version = "2.0.0-alpha.2" version = "2.0.0-alpha.6"
rev = "2afecf81ee19b8a6edb364b419190ea47c4a4a31" rev = "c13ad41634d0bd7cf07897c2aa062b917d520520"
git = "https://github.com/paritytech/substrate.git" git = "https://github.com/paritytech/substrate.git"
# Branch used for keccack256 hasher code # Branch used for keccack256 hasher code
# Could probably move the keccack hasher stuff to our own primitives # Could probably move the keccack hasher stuff to our own primitives
[dependencies.sp-core] [dependencies.sp-core]
version = "2.0.0-alpha.2" version = "2.0.0-alpha.6"
rev = "2afecf81ee19b8a6edb364b419190ea47c4a4a31" rev = "c13ad41634d0bd7cf07897c2aa062b917d520520"
git = "https://github.com/paritytech/substrate.git" git = "https://github.com/paritytech/substrate.git"
[dependencies.sp-keyring] [dependencies.sp-keyring]
version = "2.0.0-alpha.2" version = "2.0.0-alpha.6"
rev = "2afecf81ee19b8a6edb364b419190ea47c4a4a31" rev = "c13ad41634d0bd7cf07897c2aa062b917d520520"
git = "https://github.com/paritytech/substrate.git" git = "https://github.com/paritytech/substrate.git"
[dependencies.sp-runtime] [dependencies.sp-runtime]
version = "2.0.0-alpha.2" version = "2.0.0-alpha.6"
rev = "2afecf81ee19b8a6edb364b419190ea47c4a4a31" rev = "c13ad41634d0bd7cf07897c2aa062b917d520520"
git = "https://github.com/paritytech/substrate.git" git = "https://github.com/paritytech/substrate.git"
# This should get moved to our `bin` folder # This should get moved to our `bin` folder
+6 -6
View File
@@ -17,16 +17,16 @@ serde_json = "1.0.51"
url = "2.1.0" url = "2.1.0"
[dependencies.sp-core] [dependencies.sp-core]
version = "2.0.0-alpha.2" version = "2.0.0-alpha.6"
rev = "2afecf81ee19b8a6edb364b419190ea47c4a4a31" rev = "c13ad41634d0bd7cf07897c2aa062b917d520520"
git = "https://github.com/paritytech/substrate/" git = "https://github.com/paritytech/substrate/"
[dependencies.sp-rpc] [dependencies.sp-rpc]
version = "2.0.0-alpha.2" version = "2.0.0-alpha.6"
rev = "2afecf81ee19b8a6edb364b419190ea47c4a4a31" rev = "c13ad41634d0bd7cf07897c2aa062b917d520520"
git = "https://github.com/paritytech/substrate/" git = "https://github.com/paritytech/substrate/"
[dependencies.node-primitives] [dependencies.node-primitives]
version = "2.0.0-alpha.2" version = "2.0.0-alpha.6"
rev = "2afecf81ee19b8a6edb364b419190ea47c4a4a31" rev = "c13ad41634d0bd7cf07897c2aa062b917d520520"
git = "https://github.com/paritytech/substrate/" git = "https://github.com/paritytech/substrate/"