Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/breaking-changes' into alexey/re…
Browse files Browse the repository at this point in the history
…name-tables
  • Loading branch information
shekhirin committed Feb 26, 2024
2 parents 5154fc7 + e0128c7 commit f8dd4a1
Show file tree
Hide file tree
Showing 23 changed files with 64 additions and 22 deletions.
1 change: 0 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions crates/ethereum-forks/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
html_favicon_url = "https://avatars0.githubusercontent.com/u/97369466?s=256",
issue_tracker_base_url = "https://github.com/paradigmxyz/reth/issues/"
)]
// TODO: remove when https://github.com/proptest-rs/proptest/pull/427 is merged
#![allow(unknown_lints, non_local_definitions)]
#![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg))]

mod forkid;
Expand Down
2 changes: 2 additions & 0 deletions crates/net/eth-wire/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
html_favicon_url = "https://avatars0.githubusercontent.com/u/97369466?s=256",
issue_tracker_base_url = "https://github.com/paradigmxyz/reth/issues/"
)]
// TODO: remove when https://github.com/proptest-rs/proptest/pull/427 is merged
#![allow(unknown_lints, non_local_definitions)]
#![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg))]

pub mod builder;
Expand Down
3 changes: 3 additions & 0 deletions crates/net/eth-wire/tests/fuzz_roundtrip.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
//! Round-trip encoding fuzzing for the `eth-wire` crate.

// TODO: remove when https://github.com/proptest-rs/proptest/pull/427 is merged
#![allow(unknown_lints, non_local_definitions)]

use alloy_rlp::{Decodable, Encodable};
use serde::Serialize;
use std::fmt::Debug;
Expand Down
2 changes: 1 addition & 1 deletion crates/net/network/src/transactions/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -451,7 +451,7 @@ where
return propagated
}

// send full transactions to a fraction fo the connected peers (square root of the total
// send full transactions to a fraction of the connected peers (square root of the total
// number of connected peers)
let max_num_full = (self.peers.len() as f64).sqrt() as usize + 1;

Expand Down
2 changes: 2 additions & 0 deletions crates/primitives/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
html_favicon_url = "https://avatars0.githubusercontent.com/u/97369466?s=256",
issue_tracker_base_url = "https://github.com/paradigmxyz/reth/issues/"
)]
// TODO: remove when https://github.com/proptest-rs/proptest/pull/427 is merged
#![allow(unknown_lints, non_local_definitions)]
#![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg))]

mod account;
Expand Down
6 changes: 3 additions & 3 deletions crates/revm/src/processor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -591,9 +591,9 @@ mod tests {
Account, Bytecode, Bytes, ChainSpecBuilder, ForkCondition, Signature, StorageKey,
Transaction, TransactionKind, TxEip1559, MAINNET,
};
use reth_provider::{
AccountReader, BlockHashReader, BundleStateWithReceipts, StateRootProvider,
};
#[cfg(feature = "optimism")]
use reth_provider::BundleStateWithReceipts;
use reth_provider::{AccountReader, BlockHashReader, StateRootProvider};
use reth_trie::updates::TrieUpdates;
use revm::{Database, TransitionState};
use std::collections::HashMap;
Expand Down
1 change: 0 additions & 1 deletion crates/stages/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ revm.workspace = true
# async
tokio = { workspace = true, features = ["sync"] }
tokio-stream.workspace = true
async-trait.workspace = true
futures-util.workspace = true
pin-project.workspace = true

Expand Down
12 changes: 7 additions & 5 deletions crates/stages/src/stage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use reth_primitives::{
use reth_provider::{BlockReader, DatabaseProviderRW, ProviderError, TransactionsProvider};
use std::{
cmp::{max, min},
future::poll_fn,
future::{poll_fn, Future},
ops::{Range, RangeInclusive},
task::{Context, Poll},
};
Expand Down Expand Up @@ -96,7 +96,7 @@ impl ExecInput {

if all_tx_cnt == 0 {
// if there is no more transaction return back.
return Ok((first_tx_num..first_tx_num, start_block..=target_block, true))
return Ok((first_tx_num..first_tx_num, start_block..=target_block, true));
}

// get block of this tx
Expand Down Expand Up @@ -247,12 +247,14 @@ pub trait Stage<DB: Database>: Send + Sync {
}

/// [Stage] trait extension.
#[async_trait::async_trait]
pub trait StageExt<DB: Database>: Stage<DB> {
/// Utility extension for the `Stage` trait that invokes `Stage::poll_execute_ready`
/// with [poll_fn] context. For more information see [Stage::poll_execute_ready].
async fn execute_ready(&mut self, input: ExecInput) -> Result<(), StageError> {
poll_fn(|cx| self.poll_execute_ready(cx, input)).await
fn execute_ready(
&mut self,
input: ExecInput,
) -> impl Future<Output = Result<(), StageError>> + Send {
poll_fn(move |cx| self.poll_execute_ready(cx, input))
}
}

Expand Down
1 change: 0 additions & 1 deletion crates/stages/src/stages/bodies.rs
Original file line number Diff line number Diff line change
Expand Up @@ -565,7 +565,6 @@ mod tests {
}
}

#[async_trait::async_trait]
impl ExecuteStageTestRunner for BodyTestRunner {
type Seed = Vec<SealedBlock>;

Expand Down
1 change: 0 additions & 1 deletion crates/stages/src/stages/hashing_account.rs
Original file line number Diff line number Diff line change
Expand Up @@ -520,7 +520,6 @@ mod tests {
}
}

#[async_trait::async_trait]
impl ExecuteStageTestRunner for AccountHashingTestRunner {
type Seed = Vec<(Address, Account)>;

Expand Down
1 change: 0 additions & 1 deletion crates/stages/src/stages/hashing_storage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -477,7 +477,6 @@ mod tests {
}
}

#[async_trait::async_trait]
impl ExecuteStageTestRunner for StorageHashingTestRunner {
type Seed = Vec<SealedBlock>;

Expand Down
1 change: 0 additions & 1 deletion crates/stages/src/stages/headers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,6 @@ mod tests {
}
}

#[async_trait::async_trait]
impl<D: HeaderDownloader + 'static> ExecuteStageTestRunner for HeadersTestRunner<D> {
type Seed = Vec<SealedHeader>;

Expand Down
1 change: 0 additions & 1 deletion crates/stages/src/stages/merkle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -457,7 +457,6 @@ mod tests {
}
}

#[async_trait::async_trait]
impl ExecuteStageTestRunner for MerkleTestRunner {
type Seed = Vec<SealedBlock>;

Expand Down
1 change: 0 additions & 1 deletion crates/stages/src/stages/total_difficulty.rs
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,6 @@ mod tests {
}
}

#[async_trait::async_trait]
impl ExecuteStageTestRunner for TotalDifficultyTestRunner {
type Seed = Vec<SealedHeader>;

Expand Down
4 changes: 1 addition & 3 deletions crates/stages/src/test_utils/runner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ pub(crate) trait StageTestRunner {
fn stage(&self) -> Self::S;
}

#[async_trait::async_trait]
pub(crate) trait ExecuteStageTestRunner: StageTestRunner {
type Seed: Send + Sync;

Expand Down Expand Up @@ -63,7 +62,6 @@ pub(crate) trait ExecuteStageTestRunner: StageTestRunner {
}
}

#[async_trait::async_trait]
pub(crate) trait UnwindStageTestRunner: StageTestRunner {
/// Validate the unwind
fn validate_unwind(&self, input: UnwindInput) -> Result<(), TestRunnerError>;
Expand All @@ -78,7 +76,7 @@ pub(crate) trait UnwindStageTestRunner: StageTestRunner {
provider.commit().expect("failed to commit");
tx.send(result).expect("failed to send result");
});
Box::pin(rx).await.unwrap()
rx.await.unwrap()
}

/// Run a hook before [Stage::unwind]. Required for MerkleStage.
Expand Down
2 changes: 2 additions & 0 deletions crates/storage/codecs/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
issue_tracker_base_url = "https://github.com/paradigmxyz/reth/issues/"
)]
#![warn(unused_crate_dependencies)]
// TODO: remove when https://github.com/proptest-rs/proptest/pull/427 is merged
#![allow(unknown_lints, non_local_definitions)]
#![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg))]
#![cfg_attr(not(feature = "std"), no_std)]

Expand Down
3 changes: 3 additions & 0 deletions crates/storage/db/src/tables/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@
//!
//! TODO(onbjerg): Find appropriate format for this...

// TODO: remove when https://github.com/proptest-rs/proptest/pull/427 is merged
#![allow(unknown_lints, non_local_definitions)]

pub mod codecs;
pub mod models;

Expand Down
4 changes: 4 additions & 0 deletions crates/transaction-pool/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -417,6 +417,10 @@ where
self.pool.get_pooled_transaction_elements(tx_hashes, limit)
}

fn get_pooled_transaction_element(&self, tx_hash: TxHash) -> Option<PooledTransactionsElement> {
self.pool.get_pooled_transaction_element(tx_hash)
}

fn best_transactions(
&self,
) -> Box<dyn BestTransactions<Item = Arc<ValidPoolTransaction<Self::Transaction>>>> {
Expand Down
7 changes: 7 additions & 0 deletions crates/transaction-pool/src/noop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,13 @@ impl TransactionPool for NoopTransactionPool {
vec![]
}

fn get_pooled_transaction_element(
&self,
_tx_hash: TxHash,
) -> Option<PooledTransactionsElement> {
None
}

fn best_transactions(
&self,
) -> Box<dyn BestTransactions<Item = Arc<ValidPoolTransaction<Self::Transaction>>>> {
Expand Down
15 changes: 15 additions & 0 deletions crates/transaction-pool/src/pool/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -341,6 +341,21 @@ where
elements
}

/// Returns converted [PooledTransactionsElement] for the given transaction hash.
pub(crate) fn get_pooled_transaction_element(
&self,
tx_hash: TxHash,
) -> Option<PooledTransactionsElement> {
self.get(&tx_hash).and_then(|transaction| {
let tx = transaction.to_recovered_transaction().into_signed();
if tx.is_eip4844() {
self.get_blob_transaction(tx).map(PooledTransactionsElement::BlobTransaction)
} else {
Some(PooledTransactionsElement::from(tx))
}
})
}

/// Updates the entire pool after a new block was executed.
pub(crate) fn on_canonical_state_change(&self, update: CanonicalStateUpdate<'_>) {
trace!(target: "txpool", ?update, "updating pool on canonical state change");
Expand Down
10 changes: 10 additions & 0 deletions crates/transaction-pool/src/traits.rs
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,16 @@ pub trait TransactionPool: Send + Sync + Clone {
limit: GetPooledTransactionLimit,
) -> Vec<PooledTransactionsElement>;

/// Returns converted [PooledTransactionsElement] for the given transaction hash.
///
/// This adheres to the expected behavior of
/// [`GetPooledTransactions`](https://github.com/ethereum/devp2p/blob/master/caps/eth.md#getpooledtransactions-0x09):
///
/// If the transaction is a blob transaction, the sidecar will be included.
///
/// Consumer: P2P
fn get_pooled_transaction_element(&self, tx_hash: TxHash) -> Option<PooledTransactionsElement>;

/// Returns an iterator that yields transactions that are ready for block production.
///
/// Consumer: Block production
Expand Down
4 changes: 2 additions & 2 deletions docs/crates/network.md
Original file line number Diff line number Diff line change
Expand Up @@ -834,7 +834,7 @@ struct Peer {

Note that the `Peer` struct contains a field `transactions`, which is an [LRU cache](https://en.wikipedia.org/wiki/Cache_replacement_policies#Least_recently_used_(LRU)) of the transactions this peer is aware of.

The `request_tx` field on the `Peer` is used at the sender end of a channel to send requests to the session with the peer.
The `request_tx` field on the `Peer` is used as the sender end of a channel to send requests to the session with the peer.

After the `Peer` is added to `TransactionsManager.peers`, the hashes of all of the transactions in the node's transaction pool are sent to the peer in a [`NewPooledTransactionHashes` message](https://github.com/ethereum/devp2p/blob/master/caps/eth.md#newpooledtransactionhashes-0x08).

Expand Down Expand Up @@ -911,7 +911,7 @@ fn propagate_transactions(
) -> PropagatedTransactions {
let mut propagated = PropagatedTransactions::default();
// send full transactions to a fraction fo the connected peers (square root of the total
// send full transactions to a fraction of the connected peers (square root of the total
// number of connected peers)
let max_num_full = (self.peers.len() as f64).sqrt() as usize + 1;
Expand Down

0 comments on commit f8dd4a1

Please sign in to comment.