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
+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(),