chore: use secp fns directly (#13675)

This commit is contained in:
Matthias Seitz
2025-01-06 19:32:42 +01:00
committed by GitHub
parent 20e003f9b4
commit 4d191696ba
9 changed files with 21 additions and 18 deletions

View File

@ -332,9 +332,8 @@ mod tests {
BasicBlockExecutorProvider, BatchExecutor, BlockExecutorProvider, Executor, BasicBlockExecutorProvider, BatchExecutor, BlockExecutorProvider, Executor,
}; };
use reth_execution_types::BlockExecutionOutput; use reth_execution_types::BlockExecutionOutput;
use reth_primitives::{ use reth_primitives::{Account, Block, BlockBody, BlockExt, Transaction};
public_key_to_address, Account, Block, BlockBody, BlockExt, Transaction, use reth_primitives_traits::crypto::secp256k1::public_key_to_address;
};
use reth_revm::{ use reth_revm::{
database::StateProviderDatabase, test_utils::StateProviderTest, TransitionState, database::StateProviderDatabase, test_utils::StateProviderTest, TransitionState,
}; };

View File

@ -227,8 +227,6 @@ impl<E, P> From<BackfillJob<E, P>> for SingleBlockBackfillJob<E, P> {
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use std::sync::Arc;
use crate::{ use crate::{
backfill::test_utils::{blocks_and_execution_outputs, chain_spec, to_execution_outcome}, backfill::test_utils::{blocks_and_execution_outputs, chain_spec, to_execution_outcome},
BackfillJobFactory, BackfillJobFactory,
@ -236,12 +234,13 @@ mod tests {
use reth_blockchain_tree::noop::NoopBlockchainTree; use reth_blockchain_tree::noop::NoopBlockchainTree;
use reth_db_common::init::init_genesis; use reth_db_common::init::init_genesis;
use reth_evm_ethereum::execute::EthExecutorProvider; 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::{ use reth_provider::{
providers::BlockchainProvider, test_utils::create_test_provider_factory_with_chain_spec, providers::BlockchainProvider, test_utils::create_test_provider_factory_with_chain_spec,
}; };
use reth_testing_utils::generators; use reth_testing_utils::generators;
use secp256k1::Keypair; use secp256k1::Keypair;
use std::sync::Arc;
#[test] #[test]
fn test_backfill() -> eyre::Result<()> { fn test_backfill() -> eyre::Result<()> {

View File

@ -235,8 +235,6 @@ where
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use std::sync::Arc;
use crate::{ use crate::{
backfill::test_utils::{ backfill::test_utils::{
blocks_and_execution_outcome, blocks_and_execution_outputs, chain_spec, blocks_and_execution_outcome, blocks_and_execution_outputs, chain_spec,
@ -247,13 +245,14 @@ mod tests {
use reth_blockchain_tree::noop::NoopBlockchainTree; use reth_blockchain_tree::noop::NoopBlockchainTree;
use reth_db_common::init::init_genesis; use reth_db_common::init::init_genesis;
use reth_evm_ethereum::execute::EthExecutorProvider; 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::{ use reth_provider::{
providers::BlockchainProvider, test_utils::create_test_provider_factory_with_chain_spec, providers::BlockchainProvider, test_utils::create_test_provider_factory_with_chain_spec,
}; };
use reth_stages_api::ExecutionStageThresholds; use reth_stages_api::ExecutionStageThresholds;
use reth_testing_utils::generators; use reth_testing_utils::generators;
use secp256k1::Keypair; use secp256k1::Keypair;
use std::sync::Arc;
#[tokio::test] #[tokio::test]
async fn test_single_blocks() -> eyre::Result<()> { async fn test_single_blocks() -> eyre::Result<()> {

View File

@ -26,7 +26,7 @@ use op_alloy_consensus::{OpPooledTransaction, OpTypedTransaction, TxDeposit};
#[cfg(any(test, feature = "reth-codec"))] #[cfg(any(test, feature = "reth-codec"))]
use proptest as _; use proptest as _;
use reth_primitives_traits::{ use reth_primitives_traits::{
crypto::secp256k1::{recover_signer, recover_signer_unchecked}, crypto::secp256k1::{recover_signer, recover_signer_unchecked, sign_message},
transaction::error::TransactionConversionError, transaction::error::TransactionConversionError,
InMemorySize, SignedTransaction, InMemorySize, SignedTransaction,
}; };
@ -519,7 +519,7 @@ impl<'a> arbitrary::Arbitrary<'a> for OpTransactionSigned {
let secp = secp256k1::Secp256k1::new(); let secp = secp256k1::Secp256k1::new();
let key_pair = secp256k1::Keypair::new(&secp, &mut rand::thread_rng()); 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()[..]), B256::from_slice(&key_pair.secret_bytes()[..]),
signature_hash(&transaction), signature_hash(&transaction),
) )

View File

@ -1497,7 +1497,7 @@ impl<'a> arbitrary::Arbitrary<'a> for TransactionSigned {
let secp = secp256k1::Secp256k1::new(); let secp = secp256k1::Secp256k1::new();
let key_pair = secp256k1::Keypair::new(&secp, &mut rand::thread_rng()); 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()[..]), B256::from_slice(&key_pair.secret_bytes()[..]),
transaction.signature_hash(), transaction.signature_hash(),
) )

View File

@ -4,7 +4,8 @@ use alloy_eips::{eip1559::MIN_PROTOCOL_BASE_FEE, eip2718::Encodable2718, eip2930
use alloy_primitives::{Address, Bytes, TxKind, B256, U256}; use alloy_primitives::{Address, Bytes, TxKind, B256, U256};
use rand::Rng; use rand::Rng;
use reth_chainspec::MAINNET; 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. /// A generator for transactions for testing purposes.
#[derive(Debug)] #[derive(Debug)]

View File

@ -13,6 +13,7 @@ workspace = true
[dependencies] [dependencies]
reth-primitives = { workspace = true, features = ["secp256k1", "arbitrary"] } reth-primitives = { workspace = true, features = ["secp256k1", "arbitrary"] }
reth-primitives-traits = { workspace = true, features = ["secp256k1", "arbitrary"] }
alloy-genesis.workspace = true alloy-genesis.workspace = true
alloy-primitives.workspace = true alloy-primitives.workspace = true

View File

@ -12,9 +12,11 @@ use rand::{
distributions::uniform::SampleRange, rngs::StdRng, seq::SliceRandom, thread_rng, SeedableRng, distributions::uniform::SampleRange, rngs::StdRng, seq::SliceRandom, thread_rng, SeedableRng,
}; };
use reth_primitives::{ use reth_primitives::{
proofs, sign_message, Account, BlockBody, Log, Receipt, SealedBlock, SealedHeader, proofs, Account, BlockBody, Log, Receipt, SealedBlock, SealedHeader, StorageEntry, Transaction,
StorageEntry, Transaction, TransactionSigned, TransactionSigned,
}; };
use reth_primitives_traits::crypto::secp256k1::sign_message;
use secp256k1::{Keypair, Secp256k1}; use secp256k1::{Keypair, Secp256k1};
use std::{ use std::{
cmp::{max, min}, cmp::{max, min},
@ -469,8 +471,10 @@ mod tests {
use alloy_consensus::TxEip1559; use alloy_consensus::TxEip1559;
use alloy_eips::eip2930::AccessList; use alloy_eips::eip2930::AccessList;
use alloy_primitives::{hex, PrimitiveSignature as Signature}; use alloy_primitives::{hex, PrimitiveSignature as Signature};
use reth_primitives::public_key_to_address; use reth_primitives_traits::{
use reth_primitives_traits::SignedTransaction; crypto::secp256k1::{public_key_to_address, sign_message},
SignedTransaction,
};
use std::str::FromStr; use std::str::FromStr;
#[test] #[test]

View File

@ -3,7 +3,7 @@
use alloy_genesis::GenesisAccount; use alloy_genesis::GenesisAccount;
use alloy_primitives::{Address, Bytes, B256, U256}; 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::{ use secp256k1::{
rand::{thread_rng, RngCore}, rand::{thread_rng, RngCore},
Keypair, Secp256k1, Keypair, Secp256k1,