Skip to content

Commit

Permalink
chore: use secp fns directly (#13675)
Browse files Browse the repository at this point in the history
  • Loading branch information
mattsse authored Jan 6, 2025
1 parent 20e003f commit 4d19169
Show file tree
Hide file tree
Showing 9 changed files with 21 additions and 18 deletions.
5 changes: 2 additions & 3 deletions crates/ethereum/evm/src/execute.rs
Original file line number Diff line number Diff line change
Expand Up @@ -332,9 +332,8 @@ mod tests {
BasicBlockExecutorProvider, BatchExecutor, BlockExecutorProvider, Executor,
};
use reth_execution_types::BlockExecutionOutput;
use reth_primitives::{
public_key_to_address, Account, Block, BlockBody, BlockExt, Transaction,
};
use reth_primitives::{Account, Block, BlockBody, BlockExt, Transaction};
use reth_primitives_traits::crypto::secp256k1::public_key_to_address;
use reth_revm::{
database::StateProviderDatabase, test_utils::StateProviderTest, TransitionState,
};
Expand Down
5 changes: 2 additions & 3 deletions crates/exex/exex/src/backfill/job.rs
Original file line number Diff line number Diff line change
Expand Up @@ -227,21 +227,20 @@ impl<E, P> From<BackfillJob<E, P>> for SingleBlockBackfillJob<E, P> {

#[cfg(test)]
mod tests {
use std::sync::Arc;

use crate::{
backfill::test_utils::{blocks_and_execution_outputs, chain_spec, to_execution_outcome},
BackfillJobFactory,
};
use reth_blockchain_tree::noop::NoopBlockchainTree;
use reth_db_common::init::init_genesis;
use reth_evm_ethereum::execute::EthExecutorProvider;
use reth_primitives::public_key_to_address;
use reth_primitives_traits::crypto::secp256k1::public_key_to_address;
use reth_provider::{
providers::BlockchainProvider, test_utils::create_test_provider_factory_with_chain_spec,
};
use reth_testing_utils::generators;
use secp256k1::Keypair;
use std::sync::Arc;

#[test]
fn test_backfill() -> eyre::Result<()> {
Expand Down
5 changes: 2 additions & 3 deletions crates/exex/exex/src/backfill/stream.rs
Original file line number Diff line number Diff line change
Expand Up @@ -235,8 +235,6 @@ where

#[cfg(test)]
mod tests {
use std::sync::Arc;

use crate::{
backfill::test_utils::{
blocks_and_execution_outcome, blocks_and_execution_outputs, chain_spec,
Expand All @@ -247,13 +245,14 @@ mod tests {
use reth_blockchain_tree::noop::NoopBlockchainTree;
use reth_db_common::init::init_genesis;
use reth_evm_ethereum::execute::EthExecutorProvider;
use reth_primitives::public_key_to_address;
use reth_primitives_traits::crypto::secp256k1::public_key_to_address;
use reth_provider::{
providers::BlockchainProvider, test_utils::create_test_provider_factory_with_chain_spec,
};
use reth_stages_api::ExecutionStageThresholds;
use reth_testing_utils::generators;
use secp256k1::Keypair;
use std::sync::Arc;

#[tokio::test]
async fn test_single_blocks() -> eyre::Result<()> {
Expand Down
4 changes: 2 additions & 2 deletions crates/optimism/primitives/src/transaction/signed.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ use op_alloy_consensus::{OpPooledTransaction, OpTypedTransaction, TxDeposit};
#[cfg(any(test, feature = "reth-codec"))]
use proptest as _;
use reth_primitives_traits::{
crypto::secp256k1::{recover_signer, recover_signer_unchecked},
crypto::secp256k1::{recover_signer, recover_signer_unchecked, sign_message},
transaction::error::TransactionConversionError,
InMemorySize, SignedTransaction,
};
Expand Down Expand Up @@ -519,7 +519,7 @@ impl<'a> arbitrary::Arbitrary<'a> for OpTransactionSigned {

let secp = secp256k1::Secp256k1::new();
let key_pair = secp256k1::Keypair::new(&secp, &mut rand::thread_rng());
let signature = reth_primitives::transaction::util::secp256k1::sign_message(
let signature = sign_message(
B256::from_slice(&key_pair.secret_bytes()[..]),
signature_hash(&transaction),
)
Expand Down
2 changes: 1 addition & 1 deletion crates/primitives/src/transaction/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1497,7 +1497,7 @@ impl<'a> arbitrary::Arbitrary<'a> for TransactionSigned {

let secp = secp256k1::Secp256k1::new();
let key_pair = secp256k1::Keypair::new(&secp, &mut rand::thread_rng());
let signature = crate::sign_message(
let signature = reth_primitives_traits::crypto::secp256k1::sign_message(
B256::from_slice(&key_pair.secret_bytes()[..]),
transaction.signature_hash(),
)
Expand Down
3 changes: 2 additions & 1 deletion crates/transaction-pool/src/test_utils/gen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ use alloy_eips::{eip1559::MIN_PROTOCOL_BASE_FEE, eip2718::Encodable2718, eip2930
use alloy_primitives::{Address, Bytes, TxKind, B256, U256};
use rand::Rng;
use reth_chainspec::MAINNET;
use reth_primitives::{sign_message, Transaction, TransactionSigned};
use reth_primitives::{Transaction, TransactionSigned};
use reth_primitives_traits::crypto::secp256k1::sign_message;

/// A generator for transactions for testing purposes.
#[derive(Debug)]
Expand Down
1 change: 1 addition & 0 deletions testing/testing-utils/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ workspace = true

[dependencies]
reth-primitives = { workspace = true, features = ["secp256k1", "arbitrary"] }
reth-primitives-traits = { workspace = true, features = ["secp256k1", "arbitrary"] }

alloy-genesis.workspace = true
alloy-primitives.workspace = true
Expand Down
12 changes: 8 additions & 4 deletions testing/testing-utils/src/generators.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,11 @@ use rand::{
distributions::uniform::SampleRange, rngs::StdRng, seq::SliceRandom, thread_rng, SeedableRng,
};
use reth_primitives::{
proofs, sign_message, Account, BlockBody, Log, Receipt, SealedBlock, SealedHeader,
StorageEntry, Transaction, TransactionSigned,
proofs, Account, BlockBody, Log, Receipt, SealedBlock, SealedHeader, StorageEntry, Transaction,
TransactionSigned,
};

use reth_primitives_traits::crypto::secp256k1::sign_message;
use secp256k1::{Keypair, Secp256k1};
use std::{
cmp::{max, min},
Expand Down Expand Up @@ -469,8 +471,10 @@ mod tests {
use alloy_consensus::TxEip1559;
use alloy_eips::eip2930::AccessList;
use alloy_primitives::{hex, PrimitiveSignature as Signature};
use reth_primitives::public_key_to_address;
use reth_primitives_traits::SignedTransaction;
use reth_primitives_traits::{
crypto::secp256k1::{public_key_to_address, sign_message},
SignedTransaction,
};
use std::str::FromStr;

#[test]
Expand Down
2 changes: 1 addition & 1 deletion testing/testing-utils/src/genesis_allocator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
use alloy_genesis::GenesisAccount;
use alloy_primitives::{Address, Bytes, B256, U256};
use reth_primitives::public_key_to_address;
use reth_primitives_traits::crypto::secp256k1::public_key_to_address;
use secp256k1::{
rand::{thread_rng, RngCore},
Keypair, Secp256k1,
Expand Down

0 comments on commit 4d19169

Please sign in to comment.