Get Ethereum Relay to Compile (#21)

* Update dependencies

Upgrades Substrate based dependencies from v2.0.0 -> v2.0.0-alpha.1
and uses the `jsonrpsee`'s new feature flags. The actual code hasn't
been updated though, so this won't compile.

* Use `RawClient`s from `jsonrpsee`

* Update to use jsonrpsee's new API

* Hook up Ethereum Bridge Runtime, Relay, and Node Runtime

* Bump `parity-crypto` from v0.4 to v0.6

Fixes error when trying to compile tests. This was caused by
`parity-crypto` v0.4's use of `parity-secp256k1` over `secp256k1'.
Using the Parity fork meant multiple version of the same underlying
C library were being pulled in. `parity-crypto` v0.6 moved away from
this, only relying on `secp256k1` thus fixing the issue.
This commit is contained in:
Hernando Castano
2020-03-17 07:47:21 -04:00
committed by Bastian Köcher
parent 392582f3d5
commit 8232bdfe30
11 changed files with 203 additions and 48 deletions
+1
View File
@@ -15,6 +15,7 @@ futures = "0.3.1"
log = "0.4.8"
structopt = "0.3.8"
bridge-node-runtime = { version = "0.1.0", path = "../runtime" }
sp-bridge-eth-poa = { version = "0.1.0", path = "../../../primitives/ethereum-poa" }
[dependencies.sc-cli]
version = "0.8.0-alpha.2"
+49 -2
View File
@@ -16,8 +16,9 @@
use sp_core::{Pair, Public, sr25519};
use bridge_node_runtime::{
AccountId, AuraConfig, BalancesConfig, GenesisConfig, GrandpaConfig,
SudoConfig, SystemConfig, WASM_BINARY, Signature
AccountId, AuraConfig, BalancesConfig, BridgeEthPoAConfig,
GenesisConfig, GrandpaConfig, SudoConfig, SystemConfig,
WASM_BINARY, Signature
};
use sp_consensus_aura::sr25519::{AuthorityId as AuraId};
use grandpa_primitives::{AuthorityId as GrandpaId};
@@ -112,6 +113,7 @@ fn testnet_genesis(initial_authorities: Vec<(AuraId, GrandpaId)>,
pallet_aura: Some(AuraConfig {
authorities: initial_authorities.iter().map(|x| (x.0.clone())).collect(),
}),
pallet_bridge_eth_poa: load_kovan_config(),
pallet_grandpa: Some(GrandpaConfig {
authorities: initial_authorities.iter().map(|x| (x.1.clone(), 1)).collect(),
}),
@@ -127,3 +129,48 @@ pub fn load_spec(id: &str) -> Result<Option<ChainSpec>, String> {
None => None,
})
}
fn load_kovan_config() -> Option<BridgeEthPoAConfig> {
Some(BridgeEthPoAConfig {
initial_header: sp_bridge_eth_poa::Header {
parent_hash: Default::default(),
timestamp: 0,
number: 0,
author: Default::default(),
transactions_root: "56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421".parse().unwrap(),
uncles_hash: "1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347".parse().unwrap(),
extra_data: vec![],
state_root: "2480155b48a1cea17d67dbfdfaafe821c1d19cdd478c5358e8ec56dec24502b2".parse().unwrap(),
receipts_root: "56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421".parse().unwrap(),
log_bloom: Default::default(),
gas_used: Default::default(),
gas_limit: 6000000.into(),
difficulty: 131072.into(),
seal: vec![
vec![128].into(),
vec![184, 65, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0].into(),
],
},
initial_difficulty: 0.into(),
initial_validators: vec![
[0x00, 0xD6, 0xCc, 0x1B, 0xA9, 0xcf, 0x89, 0xBD, 0x2e, 0x58,
0x00, 0x97, 0x41, 0xf4, 0xF7, 0x32, 0x5B, 0xAd, 0xc0, 0xED].into(),
[0x00, 0x42, 0x7f, 0xea, 0xe2, 0x41, 0x9c, 0x15, 0xb8, 0x9d,
0x1c, 0x21, 0xaf, 0x10, 0xd1, 0xb6, 0x65, 0x0a, 0x4d, 0x3d].into(),
[0x4E, 0xd9, 0xB0, 0x8e, 0x63, 0x54, 0xC7, 0x0f, 0xE6, 0xF8,
0xCB, 0x04, 0x11, 0xb0, 0xd3, 0x24, 0x6b, 0x42, 0x4d, 0x6c].into(),
[0x00, 0x20, 0xee, 0x4B, 0xe0, 0xe2, 0x02, 0x7d, 0x76, 0x60,
0x3c, 0xB7, 0x51, 0xeE, 0x06, 0x95, 0x19, 0xbA, 0x81, 0xA1].into(),
[0x00, 0x10, 0xf9, 0x4b, 0x29, 0x6a, 0x85, 0x2a, 0xaa, 0xc5,
0x2e, 0xa6, 0xc5, 0xac, 0x72, 0xe0, 0x3a, 0xfd, 0x03, 0x2d].into(),
[0x00, 0x77, 0x33, 0xa1, 0xFE, 0x69, 0xCF, 0x3f, 0x2C, 0xF9,
0x89, 0xF8, 0x1C, 0x7b, 0x4c, 0xAc, 0x16, 0x93, 0x38, 0x7A].into(),
[0x00, 0xE6, 0xd2, 0xb9, 0x31, 0xF5, 0x5a, 0x3f, 0x17, 0x01,
0xc7, 0x38, 0x9d, 0x59, 0x2a, 0x77, 0x78, 0x89, 0x78, 0x79].into(),
[0x00, 0xe4, 0xa1, 0x06, 0x50, 0xe5, 0xa6, 0xD6, 0x00, 0x1C,
0x38, 0xff, 0x8E, 0x64, 0xF9, 0x70, 0x16, 0xa1, 0x64, 0x5c].into(),
[0x00, 0xa0, 0xa2, 0x4b, 0x9f, 0x0e, 0x5e, 0xc7, 0xaa, 0x4c,
0x73, 0x89, 0xb8, 0x30, 0x2f, 0xd0, 0x12, 0x31, 0x94, 0xde].into(),
],
})
}
+12
View File
@@ -30,6 +30,11 @@ default-features = false
rev = "2afecf81ee19b8a6edb364b419190ea47c4a4a31"
git = "https://github.com/paritytech/substrate/"
[dependencies.pallet-bridge-eth-poa]
version = "0.1.0"
default-features = false
path = "../../../modules/ethereum"
[dependencies.frame-support]
version = "2.0.0-alpha.2"
default-features = false
@@ -91,6 +96,11 @@ default-features = false
rev = "2afecf81ee19b8a6edb364b419190ea47c4a4a31"
git = "https://github.com/paritytech/substrate/"
[dependencies.sp-bridge-eth-poa]
version = "0.1.0"
default-features = false
path = "../../../primitives/ethereum-poa"
[dependencies.sp-consensus-aura]
version = "0.8.0-alpha.2"
default-features = false
@@ -162,6 +172,7 @@ default = ["std"]
std = [
"pallet-aura/std",
"pallet-balances/std",
"pallet-bridge-eth-poa/std",
"codec/std",
"frame-executive/std",
"frame-support/std",
@@ -171,6 +182,7 @@ std = [
"serde",
"sp-api/std",
"sp-block-builder/std",
"sp-bridge-eth-poa/std",
"sp-consensus-aura/std",
"sp-core/std",
"sp-inherents/std",
+22
View File
@@ -52,6 +52,7 @@ pub use frame_support::{
traits::Randomness,
weights::Weight,
};
pub use pallet_bridge_eth_poa::Call as BridgeEthPoACall;
/// An index to a block.
pub type BlockNumber = u32;
@@ -186,6 +187,10 @@ impl pallet_aura::Trait for Runtime {
type AuthorityId = AuraId;
}
impl pallet_bridge_eth_poa::Trait for Runtime {
type OnHeadersSubmitted = ();
}
impl pallet_grandpa::Trait for Runtime {
type Event = Event;
}
@@ -248,6 +253,7 @@ construct_runtime!(
Balances: pallet_balances::{Module, Call, Storage, Config<T>, Event<T>},
TransactionPayment: pallet_transaction_payment::{Module, Storage},
Sudo: pallet_sudo::{Module, Call, Config<T>, Storage, Event<T>},
BridgeEthPoA: pallet_bridge_eth_poa::{Module, Call, Config, Storage},
}
);
@@ -270,6 +276,8 @@ pub type SignedExtra = (
frame_system::CheckWeight<Runtime>,
pallet_transaction_payment::ChargeTransactionPayment<Runtime>
);
/// The payload being signed in transactions.
pub type SignedPayload = generic::SignedPayload<Call, SignedExtra>;
/// Unchecked extrinsic type as expected by this runtime.
pub type UncheckedExtrinsic = generic::UncheckedExtrinsic<Address, Call, Signature, SignedExtra>;
/// Extrinsic type that has already been checked.
@@ -327,6 +335,20 @@ impl_runtime_apis! {
}
}
impl sp_bridge_eth_poa::EthereumHeadersApi<Block> for Runtime {
fn best_block() -> (u64, sp_bridge_eth_poa::H256) {
BridgeEthPoA::best_block()
}
fn is_import_requires_receipts(header: sp_bridge_eth_poa::Header) -> bool {
BridgeEthPoA::is_import_requires_receipts(header)
}
fn is_known_block(hash: sp_bridge_eth_poa::H256) -> bool {
BridgeEthPoA::is_known_block(hash)
}
}
impl sp_transaction_pool::runtime_api::TaggedTransactionQueue<Block> for Runtime {
fn validate_transaction(tx: <Block as BlockT>::Extrinsic) -> TransactionValidity {
Executive::validate_transaction(tx)
+1 -1
View File
@@ -45,7 +45,7 @@ git = "https://github.com/paritytech/substrate/"
[dev-dependencies]
# TODO: Stop renaming this on import
primitives = { package = "sp-bridge-eth-poa", path = "../../primitives/ethereum-poa", features = ["std", "test-helpers"] }
parity-crypto = { version = "0.4", features = ["publickey"] }
parity-crypto = { version = "0.6", features = ["publickey"] }
[features]
default = ["std"]
-1
View File
@@ -24,7 +24,6 @@ default-features = false
rev = "2afecf81ee19b8a6edb364b419190ea47c4a4a31"
git = "https://github.com/paritytech/substrate/"
[dependencies.pallet-session]
version = "2.0.0-alpha.2"
default-features = false
+25 -6
View File
@@ -16,16 +16,35 @@ impl-rlp = { version = "0.2", default-features = false }
impl-serde = { version = "0.2.3", optional = true }
codec = { package = "parity-scale-codec", version = "1.0.0", default-features = false }
rlp = { version = "0.4", default-features = false }
sp-std = { version = "2.0.0-alpha.2", git = "https://github.com/paritytech/substrate.git", default-features = false, rev = "2afecf81ee19b8a6edb364b419190ea47c4a4a31" }
sp-runtime = { version = "2.0.0-alpha.2", git = "https://github.com/paritytech/substrate.git", default-features = false, rev = "2afecf81ee19b8a6edb364b419190ea47c4a4a31" }
sp-api = { version = "2.0.0-alpha.2", git = "https://github.com/paritytech/substrate.git", default-features = false, rev = "2afecf81ee19b8a6edb364b419190ea47c4a4a31" }
sp-io = { version = "2.0.0-alpha.2", git = "https://github.com/paritytech/substrate.git", default-features = false, rev = "2afecf81ee19b8a6edb364b419190ea47c4a4a31" }
hash-db = { version = "0.15.2", default-features = false }
triehash = { version = "0.8.2", default-features = false }
plain_hasher = { version = "0.2.2", default-features = false }
# Substrate Based Dependencies
[dependencies.sp-api]
version = "2.0.0-alpha.2"
default-features = false
rev = "2afecf81ee19b8a6edb364b419190ea47c4a4a31"
git = "https://github.com/paritytech/substrate.git"
[dependencies.sp-std]
version = "2.0.0-alpha.2"
default-features = false
rev = "2afecf81ee19b8a6edb364b419190ea47c4a4a31"
git = "https://github.com/paritytech/substrate.git"
[dependencies.sp-runtime]
version = "2.0.0-alpha.2"
default-features = false
rev = "2afecf81ee19b8a6edb364b419190ea47c4a4a31"
git = "https://github.com/paritytech/substrate.git"
[dependencies.sp-io]
version = "2.0.0-alpha.2"
default-features = false
rev = "2afecf81ee19b8a6edb364b419190ea47c4a4a31"
git = "https://github.com/paritytech/substrate.git"
[features]
default = ["std"]
test-helpers = []
+43 -11
View File
@@ -1,5 +1,5 @@
[package]
name = "async-bridge"
name = "ethereum-poa-relay"
version = "0.1.0"
authors = ["Parity Technologies <admin@parity.io>"]
edition = "2018"
@@ -11,22 +11,54 @@ async-stream = "0.2.0"
clap = { version = "2.33.0", features = ["yaml"] }
codec = { package = "parity-scale-codec", version = "1.0.0" }
env_logger = "0.7.0"
frame-system = { git = "https://github.com/svyatonik/substrate.git", branch = "bridge_runtime" }
futures = "0.3.1"
jsonrpsee-core = { git = "https://github.com/paritytech/jsonrpsee.git" }
jsonrpsee-http = { git = "https://github.com/paritytech/jsonrpsee.git" }
jsonrpsee = { git = "https://github.com/paritytech/jsonrpsee.git", default-features = false, features = ["http"] }
linked-hash-map = "0.5.2"
log = "0.4.8"
node-primitives = { git = "https://github.com/svyatonik/substrate.git", branch = "bridge_runtime" }
node-runtime = { git = "https://github.com/svyatonik/substrate.git", branch = "bridge_runtime" }
pallet-transaction-payment = { git = "https://github.com/svyatonik/substrate.git", branch = "bridge_runtime" }
parking_lot = "0.9.0"
rustc-hex = "2.0.1"
serde = { version = "1.0.40", features = ["derive"] }
serde_json = "1.0.40"
sp-bridge-eth-poa = { git = "https://github.com/svyatonik/substrate.git", branch = "bridge_runtime" }
sp-core = { git = "https://github.com/svyatonik/substrate.git", branch = "bridge_runtime" }
sp-keyring = { git = "https://github.com/svyatonik/substrate.git", branch = "bridge_runtime" }
sp-runtime = { git = "https://github.com/svyatonik/substrate.git", branch = "bridge_runtime" }
sp-bridge-eth-poa = { path = "../../primitives/ethereum-poa" }
time = "0.1"
web3 = { git = "https://github.com/svyatonik/rust-web3.git", branch = "fix_receipt" }
# Substrate Based Dependencies
[dependencies.frame-system]
version = "2.0.0-alpha.2"
rev = "2afecf81ee19b8a6edb364b419190ea47c4a4a31"
git = "https://github.com/paritytech/substrate/"
[dependencies.pallet-transaction-payment]
version = "2.0.0-alpha.2"
rev = "2afecf81ee19b8a6edb364b419190ea47c4a4a31"
git = "https://github.com/paritytech/substrate.git"
# I think this is used for sr-io and stuff
[dependencies.node-primitives]
version = "2.0.0-alpha.2"
rev = "2afecf81ee19b8a6edb364b419190ea47c4a4a31"
git = "https://github.com/paritytech/substrate.git"
# Branch used for keccack256 hasher code
# Could probably move the keccack hasher stuff to our own primitives
[dependencies.sp-core]
version = "2.0.0-alpha.2"
rev = "2afecf81ee19b8a6edb364b419190ea47c4a4a31"
git = "https://github.com/paritytech/substrate.git"
[dependencies.sp-keyring]
version = "2.0.0-alpha.2"
rev = "2afecf81ee19b8a6edb364b419190ea47c4a4a31"
git = "https://github.com/paritytech/substrate.git"
[dependencies.sp-runtime]
version = "2.0.0-alpha.2"
rev = "2afecf81ee19b8a6edb364b419190ea47c4a4a31"
git = "https://github.com/paritytech/substrate.git"
# This should get moved to our `bin` folder
[dependencies.bridge-node-runtime]
version = "0.1.0"
path = "../../bin/node/runtime"
# node-runtime = { git = "https://github.com/svyatonik/substrate.git", branch = "bridge_runtime" }
+12 -5
View File
@@ -30,8 +30,14 @@
// You should have received a copy of the GNU General Public License
// along with Parity-Bridge. If not, see <http://www.gnu.org/licenses/>.
use jsonrpsee_core::{client::ClientError, common::Params};
use jsonrpsee_http::{HttpClient, RequestError, http_client};
use jsonrpsee::common::Params;
use jsonrpsee::raw::{
RawClient,
RawClientError,
};
use jsonrpsee::transport::http::{
HttpTransportClient, RequestError
};
use serde::de::DeserializeOwned;
use serde_json::{from_value, to_value};
use crate::ethereum_sync_loop::MaybeConnectionError;
@@ -45,7 +51,7 @@ const INT_SERIALIZATION_PROOF: &'static str = "integer serialization never fails
const BOOL_SERIALIZATION_PROOF: &'static str = "bool serialization never fails; qed";
/// Ethereum client type.
pub type Client = HttpClient;
pub type Client = RawClient<HttpTransportClient>;
/// All possible errors that can occur during interacting with Ethereum node.
#[derive(Debug)]
@@ -55,7 +61,7 @@ pub enum Error {
/// Request not found (should never occur?).
RequestNotFound,
/// Failed to receive response.
ResponseRetrievalFailed(ClientError<RequestError>),
ResponseRetrievalFailed(RawClientError<RequestError>),
/// Failed to parse response.
ResponseParseFailed(serde_json::Error),
/// We have received header with missing number and hash fields.
@@ -75,7 +81,8 @@ impl MaybeConnectionError for Error {
/// Returns client that is able to call RPCs on Ethereum node.
pub fn client(uri: &str) -> Client {
http_client(uri)
let transport = HttpTransportClient::new(uri);
RawClient::new(transport)
}
/// Retrieve best known block number from Ethereum node.
+23 -19
View File
@@ -31,8 +31,13 @@
// along with Parity-Bridge. If not, see <http://www.gnu.org/licenses/>.
use codec::{Encode, Decode};
use jsonrpsee_core::{client::ClientError, common::Params};
use jsonrpsee_http::{HttpClient, RequestError, http_client};
use jsonrpsee::common::Params;
use jsonrpsee::raw::{
RawClient, RawClientError
};
use jsonrpsee::transport::http::{
HttpTransportClient, RequestError
};
use serde_json::{from_value, to_value};
use sp_core::crypto::Pair;
use sp_runtime::traits::IdentifyAccount;
@@ -52,7 +57,7 @@ use crate::substrate_types::{
/// Substrate client type.
pub struct Client {
/// Substrate RPC client.
rpc_client: HttpClient,
rpc_client: RawClient<HttpTransportClient>,
/// Transactions signer.
signer: sp_core::sr25519::Pair,
/// Genesis block hash.
@@ -67,7 +72,7 @@ pub enum Error {
/// Request not found (should never occur?).
RequestNotFound,
/// Failed to receive response.
ResponseRetrievalFailed(ClientError<RequestError>),
ResponseRetrievalFailed(RawClientError<RequestError>),
/// Failed to parse response.
ResponseParseFailed,
}
@@ -83,8 +88,9 @@ impl MaybeConnectionError for Error {
/// Returns client that is able to call RPCs on Substrate node.
pub fn client(uri: &str, signer: sp_core::sr25519::Pair) -> Client {
let transport = HttpTransportClient::new(uri);
Client {
rpc_client: http_client(uri),
rpc_client: RawClient::new(transport),
signer,
genesis_hash: None,
}
@@ -283,9 +289,9 @@ fn create_submit_transaction(
signer: &sp_core::sr25519::Pair,
index: node_primitives::Index,
genesis_hash: H256,
) -> node_runtime::UncheckedExtrinsic {
let function = node_runtime::Call::BridgeEthPoa(
node_runtime::BridgeEthPoaCall::import_headers(
) -> bridge_node_runtime::UncheckedExtrinsic {
let function = bridge_node_runtime::Call::BridgeEthPoA(
bridge_node_runtime::BridgeEthPoACall::import_headers(
headers
.into_iter()
.map(|header| {
@@ -301,33 +307,31 @@ fn create_submit_transaction(
let extra = |i: node_primitives::Index, f: node_primitives::Balance| {
(
frame_system::CheckVersion::<node_runtime::Runtime>::new(),
frame_system::CheckGenesis::<node_runtime::Runtime>::new(),
frame_system::CheckEra::<node_runtime::Runtime>::from(sp_runtime::generic::Era::Immortal),
frame_system::CheckNonce::<node_runtime::Runtime>::from(i),
frame_system::CheckWeight::<node_runtime::Runtime>::new(),
pallet_transaction_payment::ChargeTransactionPayment::<node_runtime::Runtime>::from(f),
Default::default(),
frame_system::CheckVersion::<bridge_node_runtime::Runtime>::new(),
frame_system::CheckGenesis::<bridge_node_runtime::Runtime>::new(),
frame_system::CheckEra::<bridge_node_runtime::Runtime>::from(sp_runtime::generic::Era::Immortal),
frame_system::CheckNonce::<bridge_node_runtime::Runtime>::from(i),
frame_system::CheckWeight::<bridge_node_runtime::Runtime>::new(),
pallet_transaction_payment::ChargeTransactionPayment::<bridge_node_runtime::Runtime>::from(f),
)
};
let raw_payload = node_runtime::SignedPayload::from_raw(
let raw_payload = bridge_node_runtime::SignedPayload::from_raw(
function,
extra(index, 0),
(
198, // VERSION.spec_version as u32,
bridge_node_runtime::VERSION.spec_version as u32,
genesis_hash,
genesis_hash,
(),
(),
(),
(),
),
);
let signature = raw_payload.using_encoded(|payload| signer.sign(payload));
let signer: sp_runtime::MultiSigner = signer.public().into();
let (function, extra, _) = raw_payload.deconstruct();
node_runtime::UncheckedExtrinsic::new_signed(
bridge_node_runtime::UncheckedExtrinsic::new_signed(
function,
signer.into_account().into(),
signature.into(),
+15 -3
View File
@@ -13,8 +13,20 @@ env_logger = "0.7.1"
futures = "0.3.1"
jsonrpsee = { git = "https://github.com/paritytech/jsonrpsee", features = ["ws"] }
log = "0.4.8"
node-primitives = { version = "2.0.0", git = "https://github.com/paritytech/substrate" }
serde_json = "1.0.41"
sp-core = { version = "2.0.0", git = "https://github.com/paritytech/substrate.git" }
sp-rpc = { version = "2.0.0", git = "https://github.com/paritytech/substrate.git" }
url = "2.1.0"
[dependencies.sp-core]
version = "2.0.0-alpha.2"
rev = "2afecf81ee19b8a6edb364b419190ea47c4a4a31"
git = "https://github.com/paritytech/substrate/"
[dependencies.sp-rpc]
version = "2.0.0-alpha.2"
rev = "2afecf81ee19b8a6edb364b419190ea47c4a4a31"
git = "https://github.com/paritytech/substrate/"
[dependencies.node-primitives]
version = "2.0.0-alpha.2"
rev = "2afecf81ee19b8a6edb364b419190ea47c4a4a31"
git = "https://github.com/paritytech/substrate/"