Skip to content
This repository has been archived by the owner on Nov 5, 2023. It is now read-only.

Commit

Permalink
More rebasing
Browse files Browse the repository at this point in the history
  • Loading branch information
clabby committed Oct 14, 2023
1 parent f431c14 commit 5b09808
Show file tree
Hide file tree
Showing 12 changed files with 35 additions and 108 deletions.
27 changes: 14 additions & 13 deletions Cargo.lock

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

1 change: 1 addition & 0 deletions bin/reth/src/cli/ext.rs
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ pub trait RethNodeCommandConfig: fmt::Debug {
.extradata(conf.extradata_rlp_bytes())
.max_gas_limit(conf.max_gas_limit()),
components.chain_spec(),
payload_builder,
);
let (payload_service, payload_builder) = PayloadBuilderService::new(payload_generator);

Expand Down
2 changes: 1 addition & 1 deletion bin/reth/src/debug_cmd/build_block.rs
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ impl Command {
let payload_config = PayloadConfig::new(
Arc::clone(&best_block),
Bytes::default(),
PayloadBuilderAttributes::new(best_block.hash, payload_attrs),
PayloadBuilderAttributes::try_new(best_block.hash, payload_attrs)?,
self.chain.clone(),
);
let args = BuildArguments::new(
Expand Down
5 changes: 1 addition & 4 deletions bin/reth/src/node/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -784,10 +784,7 @@ impl<Ext: RethCliExt> NodeCommand<Ext> {
.discovery_addr(SocketAddr::V4(SocketAddrV4::new(
self.network.addr,
// set discovery port based on instance number
match self.network.port {
Some(port) => port + self.instance - 1,
None => DEFAULT_DISCOVERY_PORT + self.instance - 1,
},
self.network.port + self.instance - 1,
)));

#[cfg(feature = "optimism")]
Expand Down
11 changes: 5 additions & 6 deletions crates/payload/basic/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ mod metrics;

/// The [`PayloadJobGenerator`] that creates [`BasicPayloadJob`]s.
#[derive(Debug)]
pub struct BasicPayloadJobGenerator<Client, Pool, Tasks, Builder> {
pub struct BasicPayloadJobGenerator<Client, Pool, Tasks, Builder = ()> {
/// The client that can interact with the chain.
client: Client,
/// txpool
Expand Down Expand Up @@ -158,10 +158,10 @@ where
Arc::new(parent_block),
self.config.extradata.clone(),
attributes,
chain_spec: Arc::clone(&self.chain_spec),
Arc::clone(&self.chain_spec),
#[cfg(feature = "optimism")]
compute_pending_block: self.config.compute_pending_block,
};
self.config.compute_pending_block,
);

let until = tokio::time::Instant::now() + self.config.deadline;
let deadline = Box::pin(tokio::time::sleep_until(until));
Expand Down Expand Up @@ -604,7 +604,7 @@ impl PayloadConfig {
if self.chain_spec.optimism {
return Default::default()
}
reth_primitives::Bytes(self.extra_data.clone())
self.extra_data.clone()
}
}

Expand Down Expand Up @@ -1041,7 +1041,6 @@ where
extra_data,
blob_gas_used: None,
excess_blob_gas: None,
extra_data,
parent_beacon_block_root: attributes.parent_beacon_block_root,
};

Expand Down
3 changes: 2 additions & 1 deletion crates/payload/builder/src/payload.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//! Contains types required for building a payload.

use alloy_rlp::Encodable;
use alloy_rlp::{DecodeError, Encodable};
use reth_primitives::{
Address, BlobTransactionSidecar, ChainSpec, Header, SealedBlock, Withdrawal, B256, U256,
};
Expand Down Expand Up @@ -196,6 +196,7 @@ impl PayloadBuilderAttributes {
gas_limit: attributes.gas_limit,
})
}

/// Returns the configured [CfgEnv] and [BlockEnv] for the targeted payload (that has the
/// `parent` as its parent).
///
Expand Down
59 changes: 1 addition & 58 deletions crates/primitives/src/receipt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,8 @@ use std::{
ops::{Deref, DerefMut},
};

#[cfg(any(test, feature = "arbitrary"))]
use proptest::strategy::Strategy;

/// Receipt containing result of transaction execution.
#[main_codec(no_arbitrary, zstd)]
#[add_arbitrary_tests]
#[main_codec(zstd)]
#[derive(Clone, Debug, PartialEq, Eq, Default)]
pub struct Receipt {
/// Receipt type.
Expand Down Expand Up @@ -289,59 +285,6 @@ impl Decodable for ReceiptWithBloom {
}
}

#[cfg(any(test, feature = "arbitrary"))]
impl proptest::arbitrary::Arbitrary for Receipt {
type Parameters = ();

fn arbitrary_with(_: Self::Parameters) -> Self::Strategy {
use proptest::prelude::{any, prop_compose};

prop_compose! {
fn arbitrary_receipt()(tx_type in any::<TxType>(),
success in any::<bool>(),
cumulative_gas_used in any::<u64>(),
logs in proptest::collection::vec(proptest::arbitrary::any::<Log>(), 0..=20),
_deposit_nonce in any::<Option<u64>>()) -> Receipt
{
Receipt { tx_type,
success,
cumulative_gas_used,
logs,
// Only reecipts for deposit transactions may contain a deposit nonce
#[cfg(feature = "optimism")]
deposit_nonce: (tx_type == TxType::DEPOSIT).then_some(_deposit_nonce).flatten()
}
}
};
arbitrary_receipt().boxed()
}

type Strategy = proptest::strategy::BoxedStrategy<Receipt>;
}

#[cfg(any(test, feature = "arbitrary"))]
impl<'a> arbitrary::Arbitrary<'a> for Receipt {
fn arbitrary(u: &mut arbitrary::Unstructured<'a>) -> arbitrary::Result<Self> {
let tx_type = TxType::arbitrary(u)?;
let success = bool::arbitrary(u)?;
let cumulative_gas_used = u64::arbitrary(u)?;
let logs = Vec::<Log>::arbitrary(u)?;

#[cfg(feature = "optimism")]
let deposit_nonce =
if tx_type == TxType::DEPOSIT { Option::<u64>::arbitrary(u)? } else { None };

Ok(Self {
tx_type,
success,
cumulative_gas_used,
logs,
#[cfg(feature = "optimism")]
deposit_nonce,
})
}
}

/// [`Receipt`] reference type with calculated bloom filter.
#[derive(Clone, Debug, PartialEq, Eq)]
pub struct ReceiptWithBloomRef<'a> {
Expand Down
4 changes: 3 additions & 1 deletion crates/primitives/src/serde_helper/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,14 @@ pub mod option_u64_hex {
where
D: Deserializer<'de>,
{
Ok(U64::deserialize(deserializer).map_or(None, |v| Some(v.as_u64())))
Ok(U64::deserialize(deserializer)
.map_or(None, |v| Some(u64::from_be_bytes(v.to_be_bytes()))))
}
}

/// serde functions for handling bytes as hex strings, such as [bytes::Bytes]
pub mod hex_bytes {
use alloy_primitives::hex;
use serde::{Deserialize, Deserializer, Serializer};

/// Serialize a byte vec as a hex string with 0x prefix
Expand Down
3 changes: 2 additions & 1 deletion crates/transaction-pool/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,8 @@ test-utils = ["rand", "paste", "serde"]
arbitrary = ["proptest", "reth-primitives/arbitrary"]
optimism = [
"reth-primitives/optimism",
"reth-revm/optimism",
"revm/optimism",
"reth-revm-primitives/optimism",
"reth-provider/test-utils",
"reth-provider/optimism",
]
Expand Down
15 changes: 2 additions & 13 deletions crates/transaction-pool/src/test_utils/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -482,10 +482,6 @@ impl PoolTransaction for MockTransaction {
}
}

fn input(&self) -> &Bytes {
panic!("not implemented")
}

fn cost(&self) -> U256 {
match self {
MockTransaction::Legacy { gas_price, value, gas_limit, .. } => {
Expand Down Expand Up @@ -590,15 +586,8 @@ impl PoolTransaction for MockTransaction {
}
}

fn input(&self) -> &[u8] {
match self {
MockTransaction::Legacy { .. } => &[],
MockTransaction::Eip1559 { input, .. } => input,
MockTransaction::Eip4844 { input, .. } => input,
MockTransaction::Eip2930 { input, .. } => input,
#[cfg(feature = "optimism")]
MockTransaction::Deposit { .. } => &[],
}
fn input(&self) -> &Bytes {
unimplemented!()
}

fn size(&self) -> usize {
Expand Down
9 changes: 1 addition & 8 deletions crates/transaction-pool/src/traits.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use crate::{
};
use futures_util::{ready, Stream};
use reth_primitives::{
AccessList, Address, BlobTransactionSidecar, BlobTransactionValidationError,
AccessList, Address, BlobTransactionSidecar, BlobTransactionValidationError, Bytes,
FromRecoveredPooledTransaction, FromRecoveredTransaction, IntoRecoveredTransaction, PeerId,
PooledTransactionsElement, PooledTransactionsElementEcRecovered, SealedBlock, Transaction,
TransactionKind, TransactionSignedEcRecovered, TxEip4844, TxHash, B256, EIP1559_TX_TYPE_ID,
Expand Down Expand Up @@ -726,9 +726,6 @@ pub trait PoolTransaction:
/// [`TransactionKind::Create`] if the transaction is a contract creation.
fn kind(&self) -> &TransactionKind;

/// Returns the input data of this transaction.
fn input(&self) -> &[u8];

/// Returns a measurement of the heap usage of this type and all its internals.
fn size(&self) -> usize;

Expand Down Expand Up @@ -965,10 +962,6 @@ impl PoolTransaction for EthPooledTransaction {
self.transaction.kind()
}

fn input(&self) -> &[u8] {
self.transaction.input().as_ref()
}

/// Returns a measurement of the heap usage of this type and all its internals.
fn size(&self) -> usize {
self.transaction.transaction.input().len()
Expand Down
4 changes: 2 additions & 2 deletions crates/transaction-pool/src/validate/eth.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ use reth_primitives::{
ChainSpec, InvalidTransactionError, SealedBlock, EIP1559_TX_TYPE_ID, EIP2930_TX_TYPE_ID,
EIP4844_TX_TYPE_ID, LEGACY_TX_TYPE_ID,
};
use reth_provider::{AccountReader, StateProviderFactory};
use reth_provider::{AccountReader, BlockReaderIdExt, StateProviderFactory};
use reth_revm_primitives::calculate_intrinsic_gas_after_merge;
use reth_tasks::TaskSpawner;
use std::{
Expand Down Expand Up @@ -45,7 +45,7 @@ where

impl<Client, Tx> EthTransactionValidator<Client, Tx>
where
Client: StateProviderFactory,
Client: StateProviderFactory + BlockReaderIdExt,
Tx: EthPoolTransaction,
{
/// Validates a single transaction.
Expand Down

0 comments on commit 5b09808

Please sign in to comment.