From 5b09808b1eb9bed439c92270b09ccb9f4af30389 Mon Sep 17 00:00:00 2001 From: clabby Date: Sat, 14 Oct 2023 13:16:52 -0400 Subject: [PATCH] More rebasing --- Cargo.lock | 27 +++++---- bin/reth/src/cli/ext.rs | 1 + bin/reth/src/debug_cmd/build_block.rs | 2 +- bin/reth/src/node/mod.rs | 5 +- crates/payload/basic/src/lib.rs | 11 ++-- crates/payload/builder/src/payload.rs | 3 +- crates/primitives/src/receipt.rs | 59 +------------------ crates/primitives/src/serde_helper/mod.rs | 4 +- crates/transaction-pool/Cargo.toml | 3 +- .../transaction-pool/src/test_utils/mock.rs | 15 +---- crates/transaction-pool/src/traits.rs | 9 +-- crates/transaction-pool/src/validate/eth.rs | 4 +- 12 files changed, 35 insertions(+), 108 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 27203945a898..c63ead446111 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4607,7 +4607,7 @@ checksum = "a948666b637a0f465e8564c73e89d4dde00d72d4d473cc972f390fc3dcee7d9c" dependencies = [ "proc-macro2", "quote", - "syn 2.0.36", + "syn 2.0.38", ] [[package]] @@ -5560,7 +5560,6 @@ dependencies = [ "secp256k1", "serde", "serde_json", - "sha2", "shellexpand", "tempfile", "thiserror", @@ -6245,7 +6244,6 @@ name = "reth-revm-primitives" version = "0.1.0-alpha.10" dependencies = [ "reth-primitives", - "reth-rlp", "revm", ] @@ -6509,8 +6507,7 @@ dependencies = [ "reth-metrics", "reth-primitives", "reth-provider", - "reth-revm", - "reth-rlp", + "reth-revm-primitives", "reth-tasks", "revm", "serde", @@ -6542,8 +6539,9 @@ dependencies = [ [[package]] name = "revm" -version = "3.3.0" -source = "git+https://github.com/bluealloy/revm#ded673c0ca1c0308cefec6f8fb853225742cfc8c" +version = "3.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "68f4ca8ae0345104523b4af1a8a7ea97cfa1865cdb7a7c25d23c1a18d9b48598" dependencies = [ "auto_impl", "revm-interpreter", @@ -6552,16 +6550,18 @@ dependencies = [ [[package]] name = "revm-interpreter" -version = "1.1.2" -source = "git+https://github.com/bluealloy/revm#ded673c0ca1c0308cefec6f8fb853225742cfc8c" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f959cafdf64a7f89b014fa73dc2325001cf654b3d9400260b212d19a2ebe3da0" dependencies = [ "revm-primitives", ] [[package]] name = "revm-precompile" -version = "2.0.3" -source = "git+https://github.com/bluealloy/revm#ded673c0ca1c0308cefec6f8fb853225742cfc8c" +version = "2.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4d360a88223d85709d2e95d4609eb1e19c649c47e28954bfabae5e92bb37e83e" dependencies = [ "c-kzg", "k256", @@ -6576,8 +6576,9 @@ dependencies = [ [[package]] name = "revm-primitives" -version = "1.1.2" -source = "git+https://github.com/bluealloy/revm#ded673c0ca1c0308cefec6f8fb853225742cfc8c" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "51187b852d9e458816a2e19c81f1dd6c924077e1a8fccd16e4f044f865f299d7" dependencies = [ "alloy-primitives", "alloy-rlp", diff --git a/bin/reth/src/cli/ext.rs b/bin/reth/src/cli/ext.rs index ee8577913c4e..4fcfab6d5378 100644 --- a/bin/reth/src/cli/ext.rs +++ b/bin/reth/src/cli/ext.rs @@ -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); diff --git a/bin/reth/src/debug_cmd/build_block.rs b/bin/reth/src/debug_cmd/build_block.rs index fe8ff0bd3149..76a716e214e2 100644 --- a/bin/reth/src/debug_cmd/build_block.rs +++ b/bin/reth/src/debug_cmd/build_block.rs @@ -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( diff --git a/bin/reth/src/node/mod.rs b/bin/reth/src/node/mod.rs index ae8b1315592a..870dd0b38b23 100644 --- a/bin/reth/src/node/mod.rs +++ b/bin/reth/src/node/mod.rs @@ -784,10 +784,7 @@ impl NodeCommand { .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")] diff --git a/crates/payload/basic/src/lib.rs b/crates/payload/basic/src/lib.rs index a31408833a26..0718dbb5ddf8 100644 --- a/crates/payload/basic/src/lib.rs +++ b/crates/payload/basic/src/lib.rs @@ -65,7 +65,7 @@ mod metrics; /// The [`PayloadJobGenerator`] that creates [`BasicPayloadJob`]s. #[derive(Debug)] -pub struct BasicPayloadJobGenerator { +pub struct BasicPayloadJobGenerator { /// The client that can interact with the chain. client: Client, /// txpool @@ -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)); @@ -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() } } @@ -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, }; diff --git a/crates/payload/builder/src/payload.rs b/crates/payload/builder/src/payload.rs index 21df6353078f..18293fce5a3e 100644 --- a/crates/payload/builder/src/payload.rs +++ b/crates/payload/builder/src/payload.rs @@ -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, }; @@ -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). /// diff --git a/crates/primitives/src/receipt.rs b/crates/primitives/src/receipt.rs index 2b744d0502d4..d85fb7d1a686 100644 --- a/crates/primitives/src/receipt.rs +++ b/crates/primitives/src/receipt.rs @@ -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. @@ -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::(), - success in any::(), - cumulative_gas_used in any::(), - logs in proptest::collection::vec(proptest::arbitrary::any::(), 0..=20), - _deposit_nonce in any::>()) -> 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; -} - -#[cfg(any(test, feature = "arbitrary"))] -impl<'a> arbitrary::Arbitrary<'a> for Receipt { - fn arbitrary(u: &mut arbitrary::Unstructured<'a>) -> arbitrary::Result { - let tx_type = TxType::arbitrary(u)?; - let success = bool::arbitrary(u)?; - let cumulative_gas_used = u64::arbitrary(u)?; - let logs = Vec::::arbitrary(u)?; - - #[cfg(feature = "optimism")] - let deposit_nonce = - if tx_type == TxType::DEPOSIT { Option::::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> { diff --git a/crates/primitives/src/serde_helper/mod.rs b/crates/primitives/src/serde_helper/mod.rs index 9c1d792b3305..0b9894a228ad 100644 --- a/crates/primitives/src/serde_helper/mod.rs +++ b/crates/primitives/src/serde_helper/mod.rs @@ -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 diff --git a/crates/transaction-pool/Cargo.toml b/crates/transaction-pool/Cargo.toml index 6ebc4d2277eb..1c4386df5c68 100644 --- a/crates/transaction-pool/Cargo.toml +++ b/crates/transaction-pool/Cargo.toml @@ -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", ] diff --git a/crates/transaction-pool/src/test_utils/mock.rs b/crates/transaction-pool/src/test_utils/mock.rs index 16e1be239923..40f644d98afd 100644 --- a/crates/transaction-pool/src/test_utils/mock.rs +++ b/crates/transaction-pool/src/test_utils/mock.rs @@ -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, .. } => { @@ -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 { diff --git a/crates/transaction-pool/src/traits.rs b/crates/transaction-pool/src/traits.rs index 8c51283fa5ec..5fadf3d578a6 100644 --- a/crates/transaction-pool/src/traits.rs +++ b/crates/transaction-pool/src/traits.rs @@ -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, @@ -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; @@ -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() diff --git a/crates/transaction-pool/src/validate/eth.rs b/crates/transaction-pool/src/validate/eth.rs index 4070803d5c19..12035702f065 100644 --- a/crates/transaction-pool/src/validate/eth.rs +++ b/crates/transaction-pool/src/validate/eth.rs @@ -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::{ @@ -45,7 +45,7 @@ where impl EthTransactionValidator where - Client: StateProviderFactory, + Client: StateProviderFactory + BlockReaderIdExt, Tx: EthPoolTransaction, { /// Validates a single transaction.