diff --git a/bridges/bin/millau/node/Cargo.toml b/bridges/bin/millau/node/Cargo.toml index 1696f73a48173..34044c2766305 100644 --- a/bridges/bin/millau/node/Cargo.toml +++ b/bridges/bin/millau/node/Cargo.toml @@ -26,7 +26,7 @@ pallet-message-lane-rpc = { path = "../../../modules/message-lane/rpc" } frame-benchmarking = { git = "https://github.com/paritytech/substrate.git", branch = "master" } frame-benchmarking-cli = { git = "https://github.com/paritytech/substrate.git", branch = "master" } sc-basic-authorship = { git = "https://github.com/paritytech/substrate.git", branch = "master" } -sc-cli = { git = "https://github.com/paritytech/substrate.git", branch = "master" } +sc-cli = { git = "https://github.com/paritytech/substrate.git", branch = "master", features = ["wasmtime"] } sc-client-api = { git = "https://github.com/paritytech/substrate.git", branch = "master" } sc-consensus = { git = "https://github.com/paritytech/substrate.git", branch = "master" } sc-consensus-aura = { git = "https://github.com/paritytech/substrate.git", branch = "master" } diff --git a/bridges/bin/rialto/node/Cargo.toml b/bridges/bin/rialto/node/Cargo.toml index c5453468f7b13..c2620ab9e3cec 100644 --- a/bridges/bin/rialto/node/Cargo.toml +++ b/bridges/bin/rialto/node/Cargo.toml @@ -26,7 +26,7 @@ rialto-runtime = { path = "../runtime" } frame-benchmarking = { git = "https://github.com/paritytech/substrate.git", branch = "master" } frame-benchmarking-cli = { git = "https://github.com/paritytech/substrate.git", branch = "master" } sc-basic-authorship = { git = "https://github.com/paritytech/substrate.git", branch = "master" } -sc-cli = { git = "https://github.com/paritytech/substrate.git", branch = "master" } +sc-cli = { git = "https://github.com/paritytech/substrate.git", branch = "master", features = ["wasmtime"] } sc-client-api = { git = "https://github.com/paritytech/substrate.git", branch = "master" } sc-consensus = { git = "https://github.com/paritytech/substrate.git", branch = "master" } sc-consensus-aura = { git = "https://github.com/paritytech/substrate.git", branch = "master" } diff --git a/bridges/relays/ethereum-client/Cargo.toml b/bridges/relays/ethereum-client/Cargo.toml index 4923b8a111fbc..e1ae2a8446aac 100644 --- a/bridges/relays/ethereum-client/Cargo.toml +++ b/bridges/relays/ethereum-client/Cargo.toml @@ -6,12 +6,12 @@ edition = "2018" license = "GPL-3.0-or-later WITH Classpath-exception-2.0" [dependencies] +bp-eth-poa = { path = "../../primitives/ethereum-poa" } codec = { package = "parity-scale-codec", version = "1.3.4" } -ethereum-tx-sign = "3.0" headers-relay = { path = "../headers-relay" } -hex = "0.4" +hex-literal = "0.3" jsonrpsee = { git = "https://github.com/svyatonik/jsonrpsee.git", branch = "shared-client-in-rpc-api", default-features = false, features = ["http"] } +libsecp256k1 = { version = "0.3.4", default-features = false, features = ["hmac"] } log = "0.4.11" -parity-crypto = { version = "0.6", features = ["publickey"] } relay-utils = { path = "../utils" } -web3 = "0.13" +web3 = { version = "0.14", default-features = false } diff --git a/bridges/relays/ethereum-client/src/sign.rs b/bridges/relays/ethereum-client/src/sign.rs index f5b80a34e5a7b..462cb5dbd7d27 100644 --- a/bridges/relays/ethereum-client/src/sign.rs +++ b/bridges/relays/ethereum-client/src/sign.rs @@ -16,8 +16,9 @@ use crate::types::{Address, CallRequest, U256}; use crate::{Client, Result}; - -use parity_crypto::publickey::KeyPair; +use bp_eth_poa::signatures::{secret_to_address, SignTransaction}; +use hex_literal::hex; +use secp256k1::SecretKey; /// Ethereum signing params. #[derive(Clone, Debug)] @@ -25,7 +26,7 @@ pub struct SigningParams { /// Ethereum chain id. pub chain_id: u64, /// Ethereum transactions signer. - pub signer: KeyPair, + pub signer: SecretKey, /// Gas price we agree to pay. pub gas_price: U256, } @@ -37,10 +38,9 @@ impl Default for SigningParams { // account that has a lot of ether when we run instant seal engine // address: 0x00a329c0648769a73afac7f9381e08fb43dbea72 // secret: 0x4d5db4107d237df6a3d58ee5f70ae63d73d7658d4026f2eefd2f204c81682cb7 - signer: KeyPair::from_secret_slice( - &hex::decode("4d5db4107d237df6a3d58ee5f70ae63d73d7658d4026f2eefd2f204c81682cb7") - .expect("secret is hardcoded, thus valid; qed"), - ) + signer: SecretKey::parse(&hex!( + "4d5db4107d237df6a3d58ee5f70ae63d73d7658d4026f2eefd2f204c81682cb7" + )) .expect("secret is hardcoded, thus valid; qed"), gas_price: 8_000_000_000u64.into(), // 8 Gwei } @@ -59,7 +59,7 @@ pub async fn sign_and_submit_transaction( let nonce = if let Some(n) = nonce { n } else { - let address: Address = params.signer.address().as_fixed_bytes().into(); + let address: Address = secret_to_address(¶ms.signer); client.account_nonce(address).await? }; @@ -70,15 +70,15 @@ pub async fn sign_and_submit_transaction( }; let gas = client.estimate_gas(call_request).await?; - let raw_transaction = ethereum_tx_sign::RawTransaction { + let raw_transaction = bp_eth_poa::UnsignedTransaction { nonce, to: contract_address, value: U256::zero(), gas: if double_gas { gas.saturating_mul(2.into()) } else { gas }, gas_price: params.gas_price, - data: encoded_call, + payload: encoded_call, } - .sign(¶ms.signer.secret().as_fixed_bytes().into(), ¶ms.chain_id); + .sign_by(¶ms.signer, Some(params.chain_id)); let _ = client.submit_transaction(raw_transaction).await?; Ok(()) diff --git a/bridges/relays/ethereum/Cargo.toml b/bridges/relays/ethereum/Cargo.toml index 2aff3d95ad99a..95f83453524f2 100644 --- a/bridges/relays/ethereum/Cargo.toml +++ b/bridges/relays/ethereum/Cargo.toml @@ -18,9 +18,9 @@ ethabi-derive = "12.0" futures = "0.3.8" hex = "0.4" hex-literal = "0.3" +libsecp256k1 = { version = "0.3.4", default-features = false, features = ["hmac"] } log = "0.4.11" num-traits = "0.2" -parity-crypto = { version = "0.6", features = ["publickey"] } serde = { version = "1.0", features = ["derive"] } serde_json = "1.0.60" time = "0.2" diff --git a/bridges/relays/ethereum/src/ethereum_client.rs b/bridges/relays/ethereum/src/ethereum_client.rs index 19d88199853b2..46c2c76feee08 100644 --- a/bridges/relays/ethereum/src/ethereum_client.rs +++ b/bridges/relays/ethereum/src/ethereum_client.rs @@ -18,6 +18,7 @@ use crate::rpc_errors::RpcError; use crate::substrate_sync_loop::QueuedRialtoHeader; use async_trait::async_trait; +use bp_eth_poa::signatures::secret_to_address; use codec::{Decode, Encode}; use ethabi::FunctionOutputDecoder; use headers_relay::sync_types::SubmittedHeaders; @@ -134,7 +135,7 @@ impl EthereumHighLevelRpc for EthereumClient { headers: Vec, ) -> SubmittedHeaders { // read nonce of signer - let address: Address = params.signer.address().as_fixed_bytes().into(); + let address: Address = secret_to_address(¶ms.signer); let nonce = match self.account_nonce(address).await { Ok(nonce) => nonce, Err(error) => { diff --git a/bridges/relays/ethereum/src/ethereum_exchange_submit.rs b/bridges/relays/ethereum/src/ethereum_exchange_submit.rs index 519fdba8cb99a..d2842b78a4a2e 100644 --- a/bridges/relays/ethereum/src/ethereum_exchange_submit.rs +++ b/bridges/relays/ethereum/src/ethereum_exchange_submit.rs @@ -17,7 +17,7 @@ //! Submitting Ethereum -> Substrate exchange transactions. use bp_eth_poa::{ - signatures::{SecretKey, SignTransaction}, + signatures::{secret_to_address, SignTransaction}, UnsignedTransaction, }; use relay_ethereum_client::{ @@ -56,7 +56,7 @@ pub fn run(params: EthereumExchangeSubmitParams) { let result: Result<_, String> = local_pool.run_until(async move { let eth_client = EthereumClient::new(eth_params); - let eth_signer_address = eth_sign.signer.address(); + let eth_signer_address = secret_to_address(ð_sign.signer); let sub_recipient_encoded = sub_recipient; let nonce = match eth_nonce { Some(eth_nonce) => eth_nonce, @@ -83,11 +83,9 @@ pub fn run(params: EthereumExchangeSubmitParams) { value: eth_amount, payload: sub_recipient_encoded.to_vec(), }; - let eth_tx_signed = eth_tx_unsigned.clone().sign_by( - &SecretKey::parse(eth_sign.signer.secret().as_fixed_bytes()) - .expect("key is accepted by secp256k1::KeyPair and thus is valid; qed"), - Some(eth_sign.chain_id), - ); + let eth_tx_signed = eth_tx_unsigned + .clone() + .sign_by(ð_sign.signer, Some(eth_sign.chain_id)); eth_client .submit_transaction(eth_tx_signed) .await diff --git a/bridges/relays/ethereum/src/main.rs b/bridges/relays/ethereum/src/main.rs index fd46847c6d9de..1dd5dd0442aa0 100644 --- a/bridges/relays/ethereum/src/main.rs +++ b/bridges/relays/ethereum/src/main.rs @@ -34,8 +34,8 @@ use ethereum_sync_loop::EthereumSyncParams; use headers_relay::sync::TargetTransactionMode; use hex_literal::hex; use instances::{BridgeInstance, Kovan, RialtoPoA}; -use parity_crypto::publickey::{KeyPair, Secret}; use relay_utils::{initialize::initialize_relay, metrics::MetricsParams}; +use secp256k1::SecretKey; use sp_core::crypto::Pair; use substrate_sync_loop::SubstrateSyncParams; @@ -134,10 +134,9 @@ fn ethereum_connection_params(matches: &clap::ArgMatches) -> Result Result { let mut params = EthereumSigningParams::default(); if let Some(eth_signer) = matches.value_of("eth-signer") { - params.signer = eth_signer - .parse::() - .map_err(|e| format!("Failed to parse eth-signer: {}", e)) - .and_then(|secret| KeyPair::from_secret(secret).map_err(|e| format!("Invalid eth-signer: {}", e)))?; + params.signer = + SecretKey::parse_slice(&hex::decode(eth_signer).map_err(|e| format!("Failed to parse eth-signer: {}", e))?) + .map_err(|e| format!("Invalid eth-signer: {}", e))?; } if let Some(eth_chain_id) = matches.value_of("eth-chain-id") { params.chain_id = eth_chain_id