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
+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/"