From afe2291c4a2d7839fe6b1836dec57cf5ecb833a7 Mon Sep 17 00:00:00 2001 From: Blazej Kolad Date: Tue, 12 Sep 2023 14:05:37 +0200 Subject: [PATCH] EVM: Introduce DevSigner (#837) * Add signer * Add signers in sov-ethereum * Eth signers in the rollup * read tx signers * implement dev signer * update bench * make lint * cleanup --- Cargo.lock | 2 + examples/demo-prover/Cargo.lock | 17 +++---- examples/demo-prover/methods/guest/Cargo.lock | 45 +++++++++++++---- examples/demo-rollup/Cargo.toml | 6 ++- examples/demo-rollup/benches/rollup_bench.rs | 2 + .../benches/rollup_coarse_measure.rs | 2 + examples/demo-rollup/src/lib.rs | 28 +++++++---- examples/demo-rollup/src/rollup.rs | 36 ++++++++++++-- examples/demo-rollup/tests/evm/mod.rs | 1 + examples/demo-stf/src/genesis_config.rs | 47 ++++++++++-------- full-node/sov-ethereum/src/lib.rs | 9 +++- .../module-implementations/sov-evm/Cargo.toml | 3 +- .../sov-evm/src/evm/tests.rs | 6 +-- .../module-implementations/sov-evm/src/lib.rs | 2 + .../sov-evm/src/signer/mod.rs | 48 +++++++++++++++++++ .../sov-evm/src/tests/call_tests.rs | 8 ++-- .../sov-evm/src/tests/dev_signer.rs | 45 ++++++----------- 17 files changed, 213 insertions(+), 94 deletions(-) create mode 100644 module-system/module-implementations/sov-evm/src/signer/mod.rs diff --git a/Cargo.lock b/Cargo.lock index 32a215792..c5300d002 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -6688,7 +6688,9 @@ dependencies = [ "prometheus 0.11.0", "proptest", "reqwest", + "reth-primitives", "revm", + "secp256k1", "serde", "serde_json", "sha2 0.10.7", diff --git a/examples/demo-prover/Cargo.lock b/examples/demo-prover/Cargo.lock index 87118da03..1b389dc71 100644 --- a/examples/demo-prover/Cargo.lock +++ b/examples/demo-prover/Cargo.lock @@ -3761,6 +3761,7 @@ dependencies = [ "jsonrpsee 0.18.2", "serde", "serde_json", + "sov-celestia-adapter", "sov-cli", "sov-db", "sov-modules-api", @@ -3978,6 +3979,14 @@ dependencies = [ "syn 1.0.109", ] +[[package]] +name = "sov-zk-cycle-utils" +version = "0.1.0" +dependencies = [ + "risc0-zkvm", + "risc0-zkvm-platform", +] + [[package]] name = "spin" version = "0.5.2" @@ -4884,14 +4893,6 @@ dependencies = [ "zstd", ] -[[package]] -name = "sov-zk-cycle-utils" -version = "0.1.0" -dependencies = [ - "risc0-zkvm", - "risc0-zkvm-platform", -] - [[package]] name = "zstd" version = "0.11.2+zstd.1.5.2" diff --git a/examples/demo-prover/methods/guest/Cargo.lock b/examples/demo-prover/methods/guest/Cargo.lock index 336fe3479..214d274ed 100644 --- a/examples/demo-prover/methods/guest/Cargo.lock +++ b/examples/demo-prover/methods/guest/Cargo.lock @@ -2019,6 +2019,33 @@ dependencies = [ "tracing", ] +[[package]] +name = "sov-celestia-adapter" +version = "0.1.0" +dependencies = [ + "anyhow", + "async-trait", + "base64 0.21.2", + "bech32", + "borsh", + "hex", + "hex-literal", + "nmt-rs", + "prost", + "prost-build", + "prost-types", + "risc0-zkvm", + "risc0-zkvm-platform", + "serde", + "sha2 0.10.6", + "sov-rollup-interface", + "sov-zk-cycle-macros", + "tendermint", + "tendermint-proto", + "thiserror", + "tracing", +] + [[package]] name = "sov-chain-state" version = "0.1.0" @@ -2111,9 +2138,9 @@ dependencies = [ "sov-rollup-interface", "sov-state", "sov-zk-cycle-macros", + "sov-zk-cycle-utils", "thiserror", "tracing", - "sov-zk-cycle-utils", ] [[package]] @@ -2201,6 +2228,14 @@ dependencies = [ "syn 1.0.109", ] +[[package]] +name = "sov-zk-cycle-utils" +version = "0.1.0" +dependencies = [ + "risc0-zkvm", + "risc0-zkvm-platform", +] + [[package]] name = "spki" version = "0.7.2" @@ -2825,14 +2860,6 @@ dependencies = [ "zstd", ] -[[package]] -name = "sov-zk-cycle-utils" -version = "0.1.0" -dependencies = [ - "risc0-zkvm", - "risc0-zkvm-platform", -] - [[package]] name = "zstd" version = "0.11.2+zstd.1.5.2" diff --git a/examples/demo-rollup/Cargo.toml b/examples/demo-rollup/Cargo.toml index c9f8d6b8c..17551bc77 100644 --- a/examples/demo-rollup/Cargo.toml +++ b/examples/demo-rollup/Cargo.toml @@ -22,10 +22,11 @@ tracing = { workspace = true } hex = { workspace = true } bytes = { workspace = true } jmt = { workspace = true } +secp256k1 = { workspace = true, optional = true } futures = "0.3" -# Crates which only this package depends on tokio = { workspace = true } +reth-primitives = { workspace = true, optional = true } tracing-subscriber = { version = "0.3.17", features = ["env-filter"] } demo-stf = { path = "../demo-stf", features = ["native"] } @@ -43,6 +44,7 @@ const-rollup-config = { path = "../const-rollup-config" } sov-cli = { path = "../../module-system/sov-cli" } clap = { workspace = true } + [dev-dependencies] sov-evm = { path = "../../module-system/module-implementations/sov-evm", features = ["smart_contracts"] } sov-bank = { path = "../../module-system/module-implementations/sov-bank", features = ["native"] } @@ -69,7 +71,7 @@ sov-demo-rollup = { path = ".", features = ["experimental"] } [features] default = [] -experimental = ["sov-ethereum/experimental"] +experimental = ["sov-ethereum/experimental", "reth-primitives", "secp256k1"] [[bench]] name = "rollup_bench" diff --git a/examples/demo-rollup/benches/rollup_bench.rs b/examples/demo-rollup/benches/rollup_bench.rs index 393e387f8..52da1406c 100644 --- a/examples/demo-rollup/benches/rollup_bench.rs +++ b/examples/demo-rollup/benches/rollup_bench.rs @@ -52,6 +52,8 @@ fn rollup_bench(_bench: &mut Criterion) { sequencer_private_key.default_address(), sequencer_da_address.as_ref().to_vec(), &sequencer_private_key, + #[cfg(feature = "experimental")] + Default::default(), ); demo.init_chain(demo_genesis_config); diff --git a/examples/demo-rollup/benches/rollup_coarse_measure.rs b/examples/demo-rollup/benches/rollup_coarse_measure.rs index 5376bd72b..330b81e71 100644 --- a/examples/demo-rollup/benches/rollup_coarse_measure.rs +++ b/examples/demo-rollup/benches/rollup_coarse_measure.rs @@ -109,6 +109,8 @@ async fn main() -> Result<(), anyhow::Error> { sequencer_private_key.default_address(), sequencer_da_address.as_ref().to_vec(), &sequencer_private_key, + #[cfg(feature = "experimental")] + Default::default(), ); demo.init_chain(demo_genesis_config); diff --git a/examples/demo-rollup/src/lib.rs b/examples/demo-rollup/src/lib.rs index 343e0405c..9c05d4b66 100644 --- a/examples/demo-rollup/src/lib.rs +++ b/examples/demo-rollup/src/lib.rs @@ -7,8 +7,6 @@ mod rollup; use const_rollup_config::ROLLUP_NAMESPACE_RAW; use demo_stf::genesis_config::create_demo_genesis_config; use demo_stf::runtime::GenesisConfig; -#[cfg(feature = "experimental")] -pub use rollup::read_tx_signer_priv_key; pub use rollup::{ new_rollup_with_celestia_da, new_rollup_with_mock_da, new_rollup_with_mock_da_from_config, Rollup, @@ -40,20 +38,32 @@ pub fn initialize_ledger(path: impl AsRef) -> LedgerDB { /// ``` pub fn get_genesis_config( sequencer_da_address: <::BlobTransaction as BlobReaderTrait>::Address, + #[cfg(feature = "experimental")] eth_accounts: Vec, ) -> GenesisConfig { - let data = std::fs::read_to_string("../test-data/keys/token_deployer_private_key.json") - .expect("Unable to read file to string"); - let key_and_address: PrivateKeyAndAddress = serde_json::from_str(&data) - .unwrap_or_else(|_| panic!("Unable to convert data {} to PrivateKeyAndAddress", &data)); + let token_deployer_data = + std::fs::read_to_string("../test-data/keys/token_deployer_private_key.json") + .expect("Unable to read file to string"); + + let token_deployer: PrivateKeyAndAddress = + serde_json::from_str(&token_deployer_data).unwrap_or_else(|_| { + panic!( + "Unable to convert data {} to PrivateKeyAndAddress", + &token_deployer_data + ) + }); + assert!( - key_and_address.is_matching_to_default(), + token_deployer.is_matching_to_default(), "Inconsistent key data" ); + // TODO: #840 create_demo_genesis_config( 100000000, - key_and_address.address, + token_deployer.address, sequencer_da_address.as_ref().to_vec(), - &key_and_address.private_key, + &token_deployer.private_key, + #[cfg(feature = "experimental")] + eth_accounts, ) } diff --git a/examples/demo-rollup/src/rollup.rs b/examples/demo-rollup/src/rollup.rs index 23595eb15..029a11f46 100644 --- a/examples/demo-rollup/src/rollup.rs +++ b/examples/demo-rollup/src/rollup.rs @@ -7,6 +7,8 @@ use const_rollup_config::SEQUENCER_DA_ADDRESS; use demo_stf::app::DefaultPrivateKey; use demo_stf::app::{App, DefaultContext}; use demo_stf::runtime::{get_rpc_methods, GenesisConfig}; +#[cfg(feature = "experimental")] +use secp256k1::SecretKey; use sov_celestia_adapter::verifier::address::CelestiaAddress; use sov_celestia_adapter::verifier::RollupParams; use sov_celestia_adapter::CelestiaService; @@ -72,7 +74,14 @@ pub async fn new_rollup_with_celestia_da( let app = App::new(rollup_config.storage); let sequencer_da_address = CelestiaAddress::from_str(SEQUENCER_DA_ADDRESS)?; - let genesis_config = get_genesis_config(sequencer_da_address); + + #[cfg(feature = "experimental")] + let eth_signer = read_eth_tx_signers(); + let genesis_config = get_genesis_config( + sequencer_da_address, + #[cfg(feature = "experimental")] + eth_signer.signers(), + ); Ok(Rollup { app, @@ -83,7 +92,8 @@ pub async fn new_rollup_with_celestia_da( #[cfg(feature = "experimental")] eth_rpc_config: EthRpcConfig { min_blob_size: Some(1), - tx_signer_priv_key: read_tx_signer_priv_key()?, + sov_tx_signer_priv_key: read_sov_tx_signer_priv_key()?, + eth_signer, }, }) } @@ -108,8 +118,14 @@ pub fn new_rollup_with_mock_da_from_config( let sequencer_da_address = MockAddress::from([0u8; 32]); let da_service = MockDaService::new(sequencer_da_address); + #[cfg(feature = "experimental")] + let eth_signer = read_eth_tx_signers(); let app = App::new(rollup_config.storage); - let genesis_config = get_genesis_config(sequencer_da_address); + let genesis_config = get_genesis_config( + sequencer_da_address, + #[cfg(feature = "experimental")] + eth_signer.signers(), + ); Ok(Rollup { app, @@ -120,7 +136,8 @@ pub fn new_rollup_with_mock_da_from_config( #[cfg(feature = "experimental")] eth_rpc_config: EthRpcConfig { min_blob_size: Some(1), - tx_signer_priv_key: read_tx_signer_priv_key()?, + sov_tx_signer_priv_key: read_sov_tx_signer_priv_key()?, + eth_signer, }, }) } @@ -128,7 +145,7 @@ pub fn new_rollup_with_mock_da_from_config( #[cfg(feature = "experimental")] /// Ethereum RPC wraps EVM transaction in a rollup transaction. /// This function reads the private key of the rollup transaction signer. -pub fn read_tx_signer_priv_key() -> Result { +fn read_sov_tx_signer_priv_key() -> Result { let data = std::fs::read_to_string(TX_SIGNER_PRIV_KEY_PATH).context("Unable to read file")?; let key_and_address: PrivateKeyAndAddress = serde_json::from_str(&data) @@ -137,6 +154,15 @@ pub fn read_tx_signer_priv_key() -> Result { Ok(key_and_address.private_key) } +// TODO: #840 +#[cfg(feature = "experimental")] +fn read_eth_tx_signers() -> sov_ethereum::DevSigner { + sov_ethereum::DevSigner::new(vec![SecretKey::from_str( + "ac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80", + ) + .unwrap()]) +} + impl + Clone> Rollup { /// Runs the rollup. pub async fn run(self) -> Result<(), anyhow::Error> { diff --git a/examples/demo-rollup/tests/evm/mod.rs b/examples/demo-rollup/tests/evm/mod.rs index b4c99fc5b..7b1c18755 100644 --- a/examples/demo-rollup/tests/evm/mod.rs +++ b/examples/demo-rollup/tests/evm/mod.rs @@ -184,6 +184,7 @@ async fn send_tx_test_to_eth(rpc_address: SocketAddr) -> Result<(), Box( sequencer_address: C::Address, sequencer_da_address: Vec, value_setter_admin_private_key: &DefaultPrivateKey, + #[cfg(feature = "experimental")] evm_genesis_addresses: Vec, ) -> GenesisConfig { let token_config: sov_bank::TokenConfig = sov_bank::TokenConfig { token_name: DEMO_TOKEN_NAME.to_owned(), @@ -53,13 +54,6 @@ pub fn create_demo_genesis_config( admin: value_setter_admin_private_key.pub_key().to_address(), }; - #[cfg(feature = "experimental")] - let genesis_evm_address = reth_primitives::Address::from_slice( - hex::decode("f39Fd6e51aad88F6F4ce6aB8827279cffFb92266") - .unwrap() - .as_slice(), - ); - let chain_state_config = ChainStateConfig { // TODO: Put actual value initial_slot_height: 0, @@ -73,22 +67,33 @@ pub fn create_demo_genesis_config( value_setter_config, sov_accounts::AccountConfig { pub_keys: vec![] }, #[cfg(feature = "experimental")] - EvmConfig { - data: vec![AccountData { - address: genesis_evm_address, - balance: AccountData::balance(u64::MAX), - code_hash: AccountData::empty_code(), - code: vec![], - nonce: 0, - }], - chain_id: 1, - limit_contract_code_size: None, - spec: vec![(0, SpecId::LATEST)].into_iter().collect(), - ..Default::default() - }, + get_evm_config(evm_genesis_addresses), ) } +// TODO: #840 +#[cfg(feature = "experimental")] +fn get_evm_config(genesis_addresses: Vec) -> EvmConfig { + let data = genesis_addresses + .into_iter() + .map(|address| AccountData { + address, + balance: AccountData::balance(u64::MAX), + code_hash: AccountData::empty_code(), + code: vec![], + nonce: 0, + }) + .collect(); + + EvmConfig { + data, + chain_id: 1, + limit_contract_code_size: None, + spec: vec![(0, SpecId::LATEST)].into_iter().collect(), + ..Default::default() + } +} + pub fn create_demo_config( initial_sequencer_balance: u64, value_setter_admin_private_key: &DefaultPrivateKey, @@ -98,5 +103,7 @@ pub fn create_demo_config( generate_address::(DEMO_SEQ_PUB_KEY_STR), DEMO_SEQUENCER_DA_ADDRESS.to_vec(), value_setter_admin_private_key, + #[cfg(feature = "experimental")] + Vec::default(), ) } diff --git a/full-node/sov-ethereum/src/lib.rs b/full-node/sov-ethereum/src/lib.rs index c6a18d31c..19302bd0b 100644 --- a/full-node/sov-ethereum/src/lib.rs +++ b/full-node/sov-ethereum/src/lib.rs @@ -2,6 +2,8 @@ mod batch_builder; #[cfg(feature = "experimental")] pub use experimental::{get_ethereum_rpc, Ethereum}; +#[cfg(feature = "experimental")] +pub use sov_evm::signer::DevSigner; #[cfg(feature = "experimental")] pub mod experimental { @@ -26,12 +28,15 @@ pub mod experimental { use sov_rollup_interface::services::da::DaService; use super::batch_builder::EthBatchBuilder; + use super::DevSigner; const ETH_RPC_ERROR: &str = "ETH_RPC_ERROR"; pub struct EthRpcConfig { pub min_blob_size: Option, - pub tx_signer_priv_key: DefaultPrivateKey, + pub sov_tx_signer_priv_key: DefaultPrivateKey, + //TODO #839 + pub eth_signer: DevSigner, } pub fn get_ethereum_rpc( @@ -94,7 +99,7 @@ pub mod experimental { >>::encode_call(tx); let tx = Transaction::::new_signed_tx( - &self.eth_rpc_config.tx_signer_priv_key, + &self.eth_rpc_config.sov_tx_signer_priv_key, message, nonce, ); diff --git a/module-system/module-implementations/sov-evm/Cargo.toml b/module-system/module-implementations/sov-evm/Cargo.toml index 1ff9507ed..a1b9a15c0 100644 --- a/module-system/module-implementations/sov-evm/Cargo.toml +++ b/module-system/module-implementations/sov-evm/Cargo.toml @@ -44,7 +44,7 @@ reth-primitives = { workspace = true } reth-rpc-types = { workspace = true } reth-rpc = { workspace = true } reth-revm = { workspace = true } - +secp256k1 = { workspace = true } [dev-dependencies] sov-evm = { path = ".", features = ["smart_contracts"] } @@ -52,7 +52,6 @@ primitive-types = "0.12.1" tokio = { workspace = true } tempfile = { workspace = true } bytes = { workspace = true } -secp256k1 = { workspace = true } [features] diff --git a/module-system/module-implementations/sov-evm/src/evm/tests.rs b/module-system/module-implementations/sov-evm/src/evm/tests.rs index 13b8336c2..7c1cc7f46 100644 --- a/module-system/module-implementations/sov-evm/src/evm/tests.rs +++ b/module-system/module-implementations/sov-evm/src/evm/tests.rs @@ -12,7 +12,7 @@ use super::executor; use crate::evm::transaction::BlockEnv; use crate::evm::{contract_address, AccountInfo}; use crate::smart_contracts::SimpleStorageContract; -use crate::tests::dev_signer::DevSigner; +use crate::tests::dev_signer::TestSigner; use crate::Evm; type C = sov_modules_api::default_context::DefaultContext; @@ -47,8 +47,8 @@ fn simple_contract_execution_in_memory_state() { fn simple_contract_execution + DatabaseCommit + InitEvmDb>( mut evm_db: DB, ) { - let dev_signer = DevSigner::new_random(); - let caller = dev_signer.address; + let dev_signer = TestSigner::new_random(); + let caller = dev_signer.address(); evm_db.insert_account_info( caller, AccountInfo { diff --git a/module-system/module-implementations/sov-evm/src/lib.rs b/module-system/module-implementations/sov-evm/src/lib.rs index 80068bfc5..f0dfaadbf 100644 --- a/module-system/module-implementations/sov-evm/src/lib.rs +++ b/module-system/module-implementations/sov-evm/src/lib.rs @@ -9,6 +9,8 @@ pub mod hooks; #[cfg(feature = "native")] #[cfg(feature = "experimental")] pub mod query; +#[cfg(feature = "experimental")] +pub mod signer; #[cfg(feature = "smart_contracts")] pub mod smart_contracts; #[cfg(feature = "experimental")] diff --git a/module-system/module-implementations/sov-evm/src/signer/mod.rs b/module-system/module-implementations/sov-evm/src/signer/mod.rs new file mode 100644 index 000000000..368363c4b --- /dev/null +++ b/module-system/module-implementations/sov-evm/src/signer/mod.rs @@ -0,0 +1,48 @@ +use std::collections::HashMap; + +use reth_primitives::{sign_message, Address, Transaction, TransactionSigned, H256}; +use reth_rpc::eth::error::SignError; +use secp256k1::{PublicKey, SecretKey}; + +/// Ethereum transaction signer. +pub struct DevSigner { + signers: HashMap, +} + +impl DevSigner { + /// Creates a new DevSigner. + pub fn new(secret_keys: Vec) -> Self { + let mut signers = HashMap::with_capacity(secret_keys.len()); + + for sk in secret_keys { + let public_key = PublicKey::from_secret_key(secp256k1::SECP256K1, &sk); + let address = reth_primitives::public_key_to_address(public_key); + + signers.insert(address, sk); + } + + Self { signers } + } + + /// Signs an ethereum transaction. + pub fn sign_transaction( + &self, + transaction: Transaction, + address: Address, + ) -> Result { + let tx_signature_hash = transaction.signature_hash(); + let signer = self.signers.get(&address).ok_or(SignError::NoAccount)?; + + let signature = sign_message(H256::from_slice(signer.as_ref()), tx_signature_hash) + .map_err(|_| SignError::CouldNotSign)?; + + Ok(TransactionSigned::from_transaction_and_signature( + transaction, + signature, + )) + } + + pub fn signers(&self) -> Vec
{ + self.signers.keys().copied().collect() + } +} diff --git a/module-system/module-implementations/sov-evm/src/tests/call_tests.rs b/module-system/module-implementations/sov-evm/src/tests/call_tests.rs index f265a2993..d063ed482 100644 --- a/module-system/module-implementations/sov-evm/src/tests/call_tests.rs +++ b/module-system/module-implementations/sov-evm/src/tests/call_tests.rs @@ -7,14 +7,14 @@ use sov_state::{ProverStorage, WorkingSet}; use crate::call::CallMessage; use crate::smart_contracts::SimpleStorageContract; -use crate::tests::dev_signer::DevSigner; +use crate::tests::dev_signer::TestSigner; use crate::{AccountData, Evm, EvmConfig}; type C = DefaultContext; fn create_messages( contract_addr: Address, set_arg: u32, - dev_signer: DevSigner, + dev_signer: TestSigner, ) -> Vec { let mut transactions = Vec::default(); let contract = SimpleStorageContract::default(); @@ -56,8 +56,8 @@ fn evm_test() { let sender_addr = sender.to_address::<::Address>(); let sender_context = C::new(sender_addr); - let dev_signer: DevSigner = DevSigner::new_random(); - let caller = dev_signer.address; + let dev_signer: TestSigner = TestSigner::new_random(); + let caller = dev_signer.address(); let evm = Evm::::default(); diff --git a/module-system/module-implementations/sov-evm/src/tests/dev_signer.rs b/module-system/module-implementations/sov-evm/src/tests/dev_signer.rs index 52206b0f0..942ba34c7 100644 --- a/module-system/module-implementations/sov-evm/src/tests/dev_signer.rs +++ b/module-system/module-implementations/sov-evm/src/tests/dev_signer.rs @@ -1,29 +1,29 @@ use ethers_core::rand::rngs::StdRng; use ethers_core::rand::SeedableRng; use reth_primitives::{ - public_key_to_address, sign_message, Address, Bytes as RethBytes, - Transaction as RethTransaction, TransactionKind, TransactionSigned, TxEip1559 as RethTxEip1559, - H256, + Address, Bytes as RethBytes, Transaction as RethTransaction, TransactionKind, + TxEip1559 as RethTxEip1559, }; use reth_rpc::eth::error::SignError; use secp256k1::{PublicKey, SecretKey}; use crate::evm::RlpEvmTransaction; +use crate::signer::DevSigner; /// ETH transactions signer used in tests. -pub(crate) struct DevSigner { - secret_key: SecretKey, - pub(crate) address: Address, +pub(crate) struct TestSigner { + signer: DevSigner, + address: Address, } -impl DevSigner { +impl TestSigner { /// Creates a new signer. pub(crate) fn new(secret_key: SecretKey) -> Self { let public_key = PublicKey::from_secret_key(secp256k1::SECP256K1, &secret_key); - let addr = public_key_to_address(public_key); + let address = reth_primitives::public_key_to_address(public_key); Self { - secret_key, - address: addr, + signer: DevSigner::new(vec![secret_key]), + address, } } @@ -34,25 +34,9 @@ impl DevSigner { Self::new(secret_key) } - /// Signs Eip1559 transaction. - pub(crate) fn sign_transaction( - &self, - transaction: RethTxEip1559, - ) -> Result { - let transaction = RethTransaction::Eip1559(transaction); - - let tx_signature_hash = transaction.signature_hash(); - - let signature = sign_message( - H256::from_slice(self.secret_key.as_ref()), - tx_signature_hash, - ) - .map_err(|_| SignError::CouldNotSign)?; - - Ok(TransactionSigned::from_transaction_and_signature( - transaction, - signature, - )) + /// Address of the transaction signer. + pub(crate) fn address(&self) -> Address { + self.address } /// Signs default Eip1559 transaction with to, data and nonce overridden. @@ -71,7 +55,8 @@ impl DevSigner { ..Default::default() }; - let signed = self.sign_transaction(reth_tx)?; + let reth_tx = RethTransaction::Eip1559(reth_tx); + let signed = self.signer.sign_transaction(reth_tx, self.address)?; Ok(RlpEvmTransaction { rlp: signed.envelope_encoded().to_vec(),