mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-07 10:48:04 +00:00
Enable Wasmtime and Remove secp256k1 (#593)
Co-authored-by: Hernando Castano <castano.ha@gmail.com>
This commit is contained in:
committed by
Bastian Köcher
parent
5e4358a727
commit
595481f02e
@@ -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" }
|
||||
|
||||
@@ -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" }
|
||||
|
||||
@@ -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 }
|
||||
|
||||
@@ -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(())
|
||||
|
||||
@@ -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"
|
||||
|
||||
@@ -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<QueuedRialtoHeader>,
|
||||
) -> SubmittedHeaders<RialtoHeaderId, RpcError> {
|
||||
// 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) => {
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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<EthereumConn
|
||||
fn ethereum_signing_params(matches: &clap::ArgMatches) -> Result<EthereumSigningParams, String> {
|
||||
let mut params = EthereumSigningParams::default();
|
||||
if let Some(eth_signer) = matches.value_of("eth-signer") {
|
||||
params.signer = eth_signer
|
||||
.parse::<Secret>()
|
||||
.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
|
||||
|
||||
Reference in New Issue
Block a user