Skip to content

Commit 4d19169

Browse files
authored
chore: use secp fns directly (#13675)
1 parent 20e003f commit 4d19169

File tree

9 files changed

+21
-18
lines changed

9 files changed

+21
-18
lines changed

crates/ethereum/evm/src/execute.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -332,9 +332,8 @@ mod tests {
332332
BasicBlockExecutorProvider, BatchExecutor, BlockExecutorProvider, Executor,
333333
};
334334
use reth_execution_types::BlockExecutionOutput;
335-
use reth_primitives::{
336-
public_key_to_address, Account, Block, BlockBody, BlockExt, Transaction,
337-
};
335+
use reth_primitives::{Account, Block, BlockBody, BlockExt, Transaction};
336+
use reth_primitives_traits::crypto::secp256k1::public_key_to_address;
338337
use reth_revm::{
339338
database::StateProviderDatabase, test_utils::StateProviderTest, TransitionState,
340339
};

crates/exex/exex/src/backfill/job.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -227,21 +227,20 @@ impl<E, P> From<BackfillJob<E, P>> for SingleBlockBackfillJob<E, P> {
227227

228228
#[cfg(test)]
229229
mod tests {
230-
use std::sync::Arc;
231-
232230
use crate::{
233231
backfill::test_utils::{blocks_and_execution_outputs, chain_spec, to_execution_outcome},
234232
BackfillJobFactory,
235233
};
236234
use reth_blockchain_tree::noop::NoopBlockchainTree;
237235
use reth_db_common::init::init_genesis;
238236
use reth_evm_ethereum::execute::EthExecutorProvider;
239-
use reth_primitives::public_key_to_address;
237+
use reth_primitives_traits::crypto::secp256k1::public_key_to_address;
240238
use reth_provider::{
241239
providers::BlockchainProvider, test_utils::create_test_provider_factory_with_chain_spec,
242240
};
243241
use reth_testing_utils::generators;
244242
use secp256k1::Keypair;
243+
use std::sync::Arc;
245244

246245
#[test]
247246
fn test_backfill() -> eyre::Result<()> {

crates/exex/exex/src/backfill/stream.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -235,8 +235,6 @@ where
235235

236236
#[cfg(test)]
237237
mod tests {
238-
use std::sync::Arc;
239-
240238
use crate::{
241239
backfill::test_utils::{
242240
blocks_and_execution_outcome, blocks_and_execution_outputs, chain_spec,
@@ -247,13 +245,14 @@ mod tests {
247245
use reth_blockchain_tree::noop::NoopBlockchainTree;
248246
use reth_db_common::init::init_genesis;
249247
use reth_evm_ethereum::execute::EthExecutorProvider;
250-
use reth_primitives::public_key_to_address;
248+
use reth_primitives_traits::crypto::secp256k1::public_key_to_address;
251249
use reth_provider::{
252250
providers::BlockchainProvider, test_utils::create_test_provider_factory_with_chain_spec,
253251
};
254252
use reth_stages_api::ExecutionStageThresholds;
255253
use reth_testing_utils::generators;
256254
use secp256k1::Keypair;
255+
use std::sync::Arc;
257256

258257
#[tokio::test]
259258
async fn test_single_blocks() -> eyre::Result<()> {

crates/optimism/primitives/src/transaction/signed.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ use op_alloy_consensus::{OpPooledTransaction, OpTypedTransaction, TxDeposit};
2626
#[cfg(any(test, feature = "reth-codec"))]
2727
use proptest as _;
2828
use reth_primitives_traits::{
29-
crypto::secp256k1::{recover_signer, recover_signer_unchecked},
29+
crypto::secp256k1::{recover_signer, recover_signer_unchecked, sign_message},
3030
transaction::error::TransactionConversionError,
3131
InMemorySize, SignedTransaction,
3232
};
@@ -519,7 +519,7 @@ impl<'a> arbitrary::Arbitrary<'a> for OpTransactionSigned {
519519

520520
let secp = secp256k1::Secp256k1::new();
521521
let key_pair = secp256k1::Keypair::new(&secp, &mut rand::thread_rng());
522-
let signature = reth_primitives::transaction::util::secp256k1::sign_message(
522+
let signature = sign_message(
523523
B256::from_slice(&key_pair.secret_bytes()[..]),
524524
signature_hash(&transaction),
525525
)

crates/primitives/src/transaction/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1497,7 +1497,7 @@ impl<'a> arbitrary::Arbitrary<'a> for TransactionSigned {
14971497

14981498
let secp = secp256k1::Secp256k1::new();
14991499
let key_pair = secp256k1::Keypair::new(&secp, &mut rand::thread_rng());
1500-
let signature = crate::sign_message(
1500+
let signature = reth_primitives_traits::crypto::secp256k1::sign_message(
15011501
B256::from_slice(&key_pair.secret_bytes()[..]),
15021502
transaction.signature_hash(),
15031503
)

crates/transaction-pool/src/test_utils/gen.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@ use alloy_eips::{eip1559::MIN_PROTOCOL_BASE_FEE, eip2718::Encodable2718, eip2930
44
use alloy_primitives::{Address, Bytes, TxKind, B256, U256};
55
use rand::Rng;
66
use reth_chainspec::MAINNET;
7-
use reth_primitives::{sign_message, Transaction, TransactionSigned};
7+
use reth_primitives::{Transaction, TransactionSigned};
8+
use reth_primitives_traits::crypto::secp256k1::sign_message;
89

910
/// A generator for transactions for testing purposes.
1011
#[derive(Debug)]

testing/testing-utils/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ workspace = true
1313

1414
[dependencies]
1515
reth-primitives = { workspace = true, features = ["secp256k1", "arbitrary"] }
16+
reth-primitives-traits = { workspace = true, features = ["secp256k1", "arbitrary"] }
1617

1718
alloy-genesis.workspace = true
1819
alloy-primitives.workspace = true

testing/testing-utils/src/generators.rs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,11 @@ use rand::{
1212
distributions::uniform::SampleRange, rngs::StdRng, seq::SliceRandom, thread_rng, SeedableRng,
1313
};
1414
use reth_primitives::{
15-
proofs, sign_message, Account, BlockBody, Log, Receipt, SealedBlock, SealedHeader,
16-
StorageEntry, Transaction, TransactionSigned,
15+
proofs, Account, BlockBody, Log, Receipt, SealedBlock, SealedHeader, StorageEntry, Transaction,
16+
TransactionSigned,
1717
};
18+
19+
use reth_primitives_traits::crypto::secp256k1::sign_message;
1820
use secp256k1::{Keypair, Secp256k1};
1921
use std::{
2022
cmp::{max, min},
@@ -469,8 +471,10 @@ mod tests {
469471
use alloy_consensus::TxEip1559;
470472
use alloy_eips::eip2930::AccessList;
471473
use alloy_primitives::{hex, PrimitiveSignature as Signature};
472-
use reth_primitives::public_key_to_address;
473-
use reth_primitives_traits::SignedTransaction;
474+
use reth_primitives_traits::{
475+
crypto::secp256k1::{public_key_to_address, sign_message},
476+
SignedTransaction,
477+
};
474478
use std::str::FromStr;
475479

476480
#[test]

testing/testing-utils/src/genesis_allocator.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
44
use alloy_genesis::GenesisAccount;
55
use alloy_primitives::{Address, Bytes, B256, U256};
6-
use reth_primitives::public_key_to_address;
6+
use reth_primitives_traits::crypto::secp256k1::public_key_to_address;
77
use secp256k1::{
88
rand::{thread_rng, RngCore},
99
Keypair, Secp256k1,

0 commit comments

Comments
 (0)