mirror of
https://github.com/paradigmxyz/reth.git
synced 2026-04-30 03:01:58 -04:00
fix: transaction calls on the reth-provider should not generate a hash by default (#3675)
This commit is contained in:
@@ -228,6 +228,10 @@ impl<DB: Database> TransactionsProvider for ProviderFactory<DB> {
|
||||
self.provider()?.transaction_by_id(id)
|
||||
}
|
||||
|
||||
fn transaction_by_id_no_hash(&self, id: TxNumber) -> Result<Option<TransactionSignedNoHash>> {
|
||||
self.provider()?.transaction_by_id_no_hash(id)
|
||||
}
|
||||
|
||||
fn transaction_by_hash(&self, hash: TxHash) -> Result<Option<TransactionSigned>> {
|
||||
self.provider()?.transaction_by_hash(hash)
|
||||
}
|
||||
|
||||
@@ -934,6 +934,10 @@ impl<'this, TX: DbTx<'this>> TransactionsProvider for DatabaseProvider<'this, TX
|
||||
Ok(self.tx.get::<tables::Transactions>(id)?.map(Into::into))
|
||||
}
|
||||
|
||||
fn transaction_by_id_no_hash(&self, id: TxNumber) -> Result<Option<TransactionSignedNoHash>> {
|
||||
Ok(self.tx.get::<tables::Transactions>(id)?.map(Into::into))
|
||||
}
|
||||
|
||||
fn transaction_by_hash(&self, hash: TxHash) -> Result<Option<TransactionSigned>> {
|
||||
if let Some(id) = self.transaction_id(hash)? {
|
||||
Ok(self.transaction_by_id(id)?)
|
||||
|
||||
@@ -271,6 +271,10 @@ where
|
||||
self.database.provider()?.transaction_by_id(id)
|
||||
}
|
||||
|
||||
fn transaction_by_id_no_hash(&self, id: TxNumber) -> Result<Option<TransactionSignedNoHash>> {
|
||||
self.database.provider()?.transaction_by_id_no_hash(id)
|
||||
}
|
||||
|
||||
fn transaction_by_hash(&self, hash: TxHash) -> Result<Option<TransactionSigned>> {
|
||||
self.database.provider()?.transaction_by_hash(hash)
|
||||
}
|
||||
|
||||
@@ -11,7 +11,8 @@ use reth_interfaces::{provider::ProviderError, Result};
|
||||
use reth_primitives::{
|
||||
keccak256, Account, Address, Block, BlockHash, BlockHashOrNumber, BlockId, BlockNumber,
|
||||
BlockWithSenders, Bytecode, Bytes, ChainInfo, Header, Receipt, SealedBlock, SealedHeader,
|
||||
StorageKey, StorageValue, TransactionMeta, TransactionSigned, TxHash, TxNumber, H256, U256,
|
||||
StorageKey, StorageValue, TransactionMeta, TransactionSigned, TransactionSignedNoHash, TxHash,
|
||||
TxNumber, H256, U256,
|
||||
};
|
||||
use reth_revm_primitives::primitives::{BlockEnv, CfgEnv};
|
||||
use std::{
|
||||
@@ -168,6 +169,10 @@ impl TransactionsProvider for MockEthProvider {
|
||||
Ok(None)
|
||||
}
|
||||
|
||||
fn transaction_by_id_no_hash(&self, _id: TxNumber) -> Result<Option<TransactionSignedNoHash>> {
|
||||
Ok(None)
|
||||
}
|
||||
|
||||
fn transaction_by_hash(&self, hash: TxHash) -> Result<Option<TransactionSigned>> {
|
||||
Ok(self
|
||||
.blocks
|
||||
|
||||
@@ -11,7 +11,8 @@ use reth_primitives::{
|
||||
stage::{StageCheckpoint, StageId},
|
||||
Account, Address, Block, BlockHash, BlockHashOrNumber, BlockId, BlockNumber, Bytecode, Bytes,
|
||||
ChainInfo, ChainSpec, Header, Receipt, SealedBlock, SealedHeader, StorageKey, StorageValue,
|
||||
TransactionMeta, TransactionSigned, TxHash, TxNumber, H256, KECCAK_EMPTY, MAINNET, U256,
|
||||
TransactionMeta, TransactionSigned, TransactionSignedNoHash, TxHash, TxNumber, H256,
|
||||
KECCAK_EMPTY, MAINNET, U256,
|
||||
};
|
||||
use reth_revm_primitives::primitives::{BlockEnv, CfgEnv};
|
||||
use std::{ops::RangeBounds, sync::Arc};
|
||||
@@ -130,6 +131,10 @@ impl TransactionsProvider for NoopProvider {
|
||||
Ok(None)
|
||||
}
|
||||
|
||||
fn transaction_by_id_no_hash(&self, _id: TxNumber) -> Result<Option<TransactionSignedNoHash>> {
|
||||
Ok(None)
|
||||
}
|
||||
|
||||
fn transaction_by_hash(&self, _hash: TxHash) -> Result<Option<TransactionSigned>> {
|
||||
Ok(None)
|
||||
}
|
||||
|
||||
@@ -15,9 +15,12 @@ pub trait TransactionsProvider: BlockNumReader + Send + Sync {
|
||||
/// Returns None if the transaction is not found.
|
||||
fn transaction_id(&self, tx_hash: TxHash) -> Result<Option<TxNumber>>;
|
||||
|
||||
/// Get transaction by id.
|
||||
/// Get transaction by id, computes hash everytime so more expensive.
|
||||
fn transaction_by_id(&self, id: TxNumber) -> Result<Option<TransactionSigned>>;
|
||||
|
||||
/// Get transaction by id without computing the hash.
|
||||
fn transaction_by_id_no_hash(&self, id: TxNumber) -> Result<Option<TransactionSignedNoHash>>;
|
||||
|
||||
/// Get transaction by transaction hash.
|
||||
fn transaction_by_hash(&self, hash: TxHash) -> Result<Option<TransactionSigned>>;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user