Skip to content

Commit

Permalink
Custom signer support (#196)
Browse files Browse the repository at this point in the history
* Custom signer support

* Fix ts-tests block hash
  • Loading branch information
sorpaas authored Nov 16, 2020
1 parent 1ee7e6e commit 229fcc2
Show file tree
Hide file tree
Showing 16 changed files with 134 additions and 108 deletions.
12 changes: 7 additions & 5 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion consensus/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,4 @@ futures = { version = "0.3.1", features = ["compat"] }
sp-timestamp = { version = "2.0.0", git = "https://github.com/paritytech/substrate.git", branch = "frontier" }
derive_more = "0.99.2"
prometheus-endpoint = { package = "substrate-prometheus-endpoint", git = "https://github.com/paritytech/substrate.git", branch = "frontier"}
ethereum = { version = "0.4", features = ["with-codec"] }
ethereum = { version = "0.5", features = ["with-codec"] }
2 changes: 1 addition & 1 deletion frame/ethereum/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ sp-std = { version = "2.0.0-dev", default-features = false, git = "https://githu
sp-io = { version = "2.0.0-dev", default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "frontier" }
sp-evm = { version = "0.8.0", default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "frontier" }
evm = { version = "0.18.0", features = ["with-codec"], default-features = false }
ethereum = { version = "0.4", default-features = false, features = ["with-codec"] }
ethereum = { version = "0.5", default-features = false, features = ["with-codec"] }
ethereum-types = { version = "0.9", default-features = false }
rlp = { version = "0.4", default-features = false }
sha3 = { version = "0.8", default-features = false }
Expand Down
4 changes: 2 additions & 2 deletions frame/ethereum/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ use codec::Encode;
use frontier_consensus_primitives::{FRONTIER_ENGINE_ID, ConsensusLog};

pub use frontier_rpc_primitives::TransactionStatus;
pub use ethereum::{Transaction, Log, Block, Receipt, TransactionAction};
pub use ethereum::{Transaction, Log, Block, Receipt, TransactionAction, TransactionMessage};

#[cfg(all(feature = "std", test))]
mod tests;
Expand Down Expand Up @@ -236,7 +236,7 @@ impl<T: Trait> Module<T> {
sig[0..32].copy_from_slice(&transaction.signature.r()[..]);
sig[32..64].copy_from_slice(&transaction.signature.s()[..]);
sig[64] = transaction.signature.standard_v();
msg.copy_from_slice(&transaction.message_hash(Some(T::ChainId::get()))[..]);
msg.copy_from_slice(&TransactionMessage::from(transaction.clone()).hash()[..]);

let pubkey = sp_io::crypto::secp256k1_ecdsa_recover(&sig, &msg).ok()?;
Some(H160::from(H256::from_slice(Keccak256::digest(&pubkey).as_slice())))
Expand Down
4 changes: 3 additions & 1 deletion rpc/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,11 @@ sc-rpc = { git = "https://github.com/paritytech/substrate.git", branch = "fronti
sc-network = { git = "https://github.com/paritytech/substrate.git", branch = "frontier" }
pallet-evm = { git = "https://github.com/paritytech/substrate.git", branch = "frontier" }
pallet-ethereum = { path = "../frame/ethereum" }
ethereum = { version = "0.4", features = ["with-codec"] }
ethereum = { version = "0.5", features = ["with-codec"] }
codec = { package = "parity-scale-codec", version = "1.0.0" }
rlp = "0.4"
futures = { version = "0.3.1", features = ["compat"] }
sha3 = "0.8"
rustc-hex = { version = "2.1.0", default-features = false }
libsecp256k1 = "0.3"
rand = "0.7"
7 changes: 6 additions & 1 deletion rpc/core/src/eth.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ use jsonrpc_derive::rpc;

use crate::types::{
BlockNumber, Bytes, CallRequest, Filter, FilterChanges, Index, Log, Receipt,
RichBlock, SyncStatus, Transaction, Work,
RichBlock, SyncStatus, Transaction, Work, TransactionRequest,
};
pub use rpc_impl_EthApi::gen_server::EthApi as EthApiServer;

Expand Down Expand Up @@ -107,6 +107,11 @@ pub trait EthApi {
#[rpc(name = "eth_getCode")]
fn code_at(&self, _: H160, _: Option<BlockNumber>) -> Result<Bytes>;

/// Sends transaction; will block waiting for signer to return the
/// transaction hash.
#[rpc(name = "eth_sendTransaction")]
fn send_transaction(&self, _: TransactionRequest) -> BoxFuture<H256>;

/// Sends signed transaction, returning its hash.
#[rpc(name = "eth_sendRawTransaction")]
fn send_raw_transaction(&self, _: Bytes) -> BoxFuture<H256>;
Expand Down
46 changes: 0 additions & 46 deletions rpc/core/src/eth_signing.rs

This file was deleted.

2 changes: 0 additions & 2 deletions rpc/core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,10 @@ pub mod types;

mod eth;
mod eth_pubsub;
mod eth_signing;
mod net;
mod web3;

pub use eth::{EthApi, EthApiServer, EthFilterApi};
pub use eth_pubsub::{EthPubSubApi, EthPubSubApiServer};
pub use eth_signing::EthSigningApi;
pub use net::{NetApi, NetApiServer};
pub use web3::Web3Api;
2 changes: 0 additions & 2 deletions rpc/core/src/types/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ mod receipt;
mod sync;
mod transaction;
mod transaction_request;
mod transaction_condition;
mod work;

pub mod pubsub;
Expand All @@ -48,5 +47,4 @@ pub use self::sync::{
};
pub use self::transaction::{Transaction, RichRawTransaction, LocalTransactionStatus};
pub use self::transaction_request::TransactionRequest;
pub use self::transaction_condition::TransactionCondition;
pub use self::work::Work;
4 changes: 1 addition & 3 deletions rpc/core/src/types/transaction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
use serde::{Serialize, Serializer};
use serde::ser::SerializeStruct;
use ethereum_types::{H160, H256, H512, U64, U256};
use crate::types::{Bytes, TransactionCondition};
use crate::types::Bytes;

/// Transaction
#[derive(Debug, Default, Clone, PartialEq, Serialize)]
Expand Down Expand Up @@ -61,8 +61,6 @@ pub struct Transaction {
pub r: U256,
/// The S field of the signature.
pub s: U256,
/// Transaction activates at specified block.
pub condition: Option<TransactionCondition>,
}

/// Local Transaction Status
Expand Down
29 changes: 0 additions & 29 deletions rpc/core/src/types/transaction_condition.rs

This file was deleted.

4 changes: 1 addition & 3 deletions rpc/core/src/types/transaction_request.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

use serde::{Serialize, Deserialize};
use ethereum_types::{H160, U256};
use crate::types::{Bytes, TransactionCondition};
use crate::types::Bytes;

/// Transaction request coming from RPC
#[derive(Debug, Clone, Default, Eq, PartialEq, Hash, Serialize, Deserialize)]
Expand All @@ -39,6 +39,4 @@ pub struct TransactionRequest {
pub data: Option<Bytes>,
/// Transaction's nonce
pub nonce: Option<U256>,
/// Delay until this block condition.
pub condition: Option<TransactionCondition>,
}
2 changes: 1 addition & 1 deletion rpc/primitives/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ license = "GPL-3.0"
sp-core = { version = "2.0.0-dev", default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "frontier" }
sp-api = { version = "2.0.0-dev", default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "frontier" }
sp-evm = { version = "0.8.0", default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "frontier" }
ethereum = { version = "0.4", default-features = false, features = ["with-codec"] }
ethereum = { version = "0.5", default-features = false, features = ["with-codec"] }
ethereum-types = { version = "0.9", default-features = false }
codec = { package = "parity-scale-codec", version = "1.0.0", default-features = false }
sp-runtime = { version = "2.0.0-dev", default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "frontier" }
Expand Down
Loading

0 comments on commit 229fcc2

Please sign in to comment.