feat: use reth-ethereum-primitives (#13830)

This commit is contained in:
Arsenii Kulikov
2025-01-17 04:22:21 +04:00
committed by GitHub
parent 7e972ea23d
commit 8efe441cc0
67 changed files with 941 additions and 3025 deletions

View File

@ -1,6 +1,7 @@
use crate::BeaconSidecarConfig;
use alloy_consensus::{
transaction::PooledTransaction, BlockHeader, Signed, Transaction as _, TxEip4844WithSidecar,
Typed2718,
};
use alloy_primitives::B256;
use alloy_rpc_types_beacon::sidecar::{BeaconBlobBundle, SidecarIterator};
@ -8,6 +9,7 @@ use eyre::Result;
use futures_util::{stream::FuturesUnordered, Future, Stream, StreamExt};
use reqwest::{Error, StatusCode};
use reth::{
core::primitives::SignedTransaction,
primitives::RecoveredBlock,
providers::CanonStateNotification,
transaction_pool::{BlobStoreError, TransactionPoolExt},
@ -112,7 +114,7 @@ where
return
}
match self.pool.get_all_blobs_exact(txs.iter().map(|(tx, _)| tx.hash()).collect()) {
match self.pool.get_all_blobs_exact(txs.iter().map(|(tx, _)| *tx.tx_hash()).collect()) {
Ok(blobs) => {
actions_to_queue.reserve_exact(txs.len());
for ((tx, _), sidecar) in txs.iter().zip(blobs.into_iter()) {
@ -199,7 +201,7 @@ where
.transactions()
.filter(|tx| tx.is_eip4844())
.map(|tx| {
let transaction_hash = tx.hash();
let transaction_hash = *tx.tx_hash();
let block_metadata = BlockMetadata {
block_hash: new.tip().hash(),
block_number: new.tip().number(),

View File

@ -21,6 +21,4 @@ alloy-consensus.workspace = true
eyre.workspace = true
[features]
optimism = [
"reth-primitives/optimism"
]
optimism = []

View File

@ -15,7 +15,7 @@ use reth::{
tasks::TaskManager,
};
use reth_chainspec::ChainSpec;
use reth_node_core::{args::RpcServerArgs, node_config::NodeConfig};
use reth_node_core::{args::RpcServerArgs, node_config::NodeConfig, primitives::SignedTransaction};
use reth_node_ethereum::EthereumNode;
#[tokio::main]
@ -51,7 +51,7 @@ async fn main() -> eyre::Result<()> {
let head = notifications.next().await.unwrap();
let tx = &head.tip().body().transactions().next().unwrap();
assert_eq!(tx.hash(), hash);
assert_eq!(*tx.tx_hash(), hash);
println!("mined transaction: {hash}");
Ok(())
}

View File

@ -10,6 +10,7 @@ license.workspace = true
reth-chainspec.workspace = true
reth-db.workspace = true
reth-primitives.workspace = true
reth-primitives-traits.workspace = true
reth-provider.workspace = true
reth-node-ethereum.workspace = true
reth-node-types.workspace = true

View File

@ -6,6 +6,7 @@ use reth_db::{open_db_read_only, DatabaseEnv};
use reth_node_ethereum::EthereumNode;
use reth_node_types::NodeTypesWithDBAdapter;
use reth_primitives::{SealedBlock, SealedHeader, TransactionSigned};
use reth_primitives_traits::transaction::signed::SignedTransaction;
use reth_provider::{
providers::StaticFileProvider, AccountReader, BlockReader, BlockSource, HeaderProvider,
ProviderFactory, ReceiptProvider, StateProvider, TransactionsProvider,
@ -95,17 +96,17 @@ fn txs_provider_example<T: TransactionsProvider<Transaction = TransactionSigned>
// Can query the tx by hash
let tx_by_hash =
provider.transaction_by_hash(tx.hash())?.ok_or(eyre::eyre!("txhash not found"))?;
provider.transaction_by_hash(*tx.tx_hash())?.ok_or(eyre::eyre!("txhash not found"))?;
assert_eq!(tx, tx_by_hash);
// Can query the tx by hash with info about the block it was included in
let (tx, meta) = provider
.transaction_by_hash_with_meta(tx.hash())?
.transaction_by_hash_with_meta(*tx.tx_hash())?
.ok_or(eyre::eyre!("txhash not found"))?;
assert_eq!(tx.hash(), meta.tx_hash);
assert_eq!(*tx.tx_hash(), meta.tx_hash);
// Can reverse lookup the key too
let id = provider.transaction_id(tx.hash())?.ok_or(eyre::eyre!("txhash not found"))?;
let id = provider.transaction_id(*tx.tx_hash())?.ok_or(eyre::eyre!("txhash not found"))?;
assert_eq!(id, txid);
// Can find the block of a transaction given its key
@ -181,8 +182,9 @@ fn receipts_provider_example<
// Can query receipt by txhash too
let tx = provider.transaction_by_id(txid)?.unwrap();
let receipt_by_hash =
provider.receipt_by_hash(tx.hash())?.ok_or(eyre::eyre!("tx receipt by hash not found"))?;
let receipt_by_hash = provider
.receipt_by_hash(*tx.tx_hash())?
.ok_or(eyre::eyre!("tx receipt by hash not found"))?;
assert_eq!(receipt, receipt_by_hash);
// Can query all the receipts in a block