Skip to content

Commit

Permalink
Merge branch 'main' into fix-no-std-compiler-errors-in-primitive-traits
Browse files Browse the repository at this point in the history
  • Loading branch information
mattsse committed Jul 17, 2024
2 parents c91ac0e + 269c649 commit 44d3e6e
Show file tree
Hide file tree
Showing 55 changed files with 323 additions and 309 deletions.
26 changes: 14 additions & 12 deletions Cargo.lock

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

4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -373,12 +373,12 @@ reth-trie-common = { path = "crates/trie/common" }
reth-trie-parallel = { path = "crates/trie/parallel" }

# revm
revm = { version = "12.0.0", features = [
revm = { version = "12.1.0", features = [
"std",
"secp256k1",
"blst",
], default-features = false }
revm-primitives = { version = "7.0.0", features = [
revm-primitives = { version = "7.1.0", features = [
"std",
], default-features = false }
revm-inspectors = "0.5"
Expand Down
13 changes: 5 additions & 8 deletions crates/evm/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,17 +42,14 @@ pub trait ConfigureEvm: ConfigureEvmEnv {
/// This does not automatically configure the EVM with [`ConfigureEvmEnv`] methods. It is up to
/// the caller to call an appropriate method to fill the transaction and block environment
/// before executing any transactions using the provided EVM.
fn evm<'a, DB: Database + 'a>(
&'a self,
db: DB,
) -> Evm<'a, Self::DefaultExternalContext<'a>, DB>;
fn evm<'a, DB: Database + 'a>(&self, db: DB) -> Evm<'a, Self::DefaultExternalContext<'a>, DB>;

/// Returns a new EVM with the given database configured with the given environment settings,
/// including the spec id.
///
/// This will preserve any handler modifications
fn evm_with_env<'a, DB: Database + 'a>(
&'a self,
&self,
db: DB,
env: EnvWithHandlerCfg,
) -> Evm<'a, Self::DefaultExternalContext<'a>, DB> {
Expand All @@ -69,13 +66,13 @@ pub trait ConfigureEvm: ConfigureEvmEnv {
///
/// This will preserve any handler modifications
fn evm_with_env_and_inspector<'a, DB, I>(
&'a self,
&self,
db: DB,
env: EnvWithHandlerCfg,
inspector: I,
) -> Evm<'a, I, DB>
where
DB: Database + 'a,
DB: Database,
I: GetInspector<DB>,
{
let mut evm = self.evm_with_inspector(db, inspector);
Expand All @@ -89,7 +86,7 @@ pub trait ConfigureEvm: ConfigureEvmEnv {
/// Caution: This does not automatically configure the EVM with [`ConfigureEvmEnv`] methods. It
/// is up to the caller to call an appropriate method to fill the transaction and block
/// environment before executing any transactions using the provided EVM.
fn evm_with_inspector<'a, DB, I>(&'a self, db: DB, inspector: I) -> Evm<'a, I, DB>
fn evm_with_inspector<'a, DB, I>(&self, db: DB, inspector: I) -> Evm<'a, I, DB>
where
DB: Database + 'a,
I: GetInspector<DB>,
Expand Down
10 changes: 10 additions & 0 deletions crates/optimism/rpc/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,18 @@ jsonrpsee.workspace = true

# misc
thiserror.workspace = true
serde = { workspace = true, features = ["derive"] }

[dev-dependencies]
serde_json.workspace = true

[features]
client = [
"jsonrpsee/client",
"jsonrpsee/async-client",
"reth-rpc-eth-api/client"
]

optimism = [
"reth-chainspec/optimism",
"reth-evm-optimism/optimism",
Expand Down
File renamed without changes.
2 changes: 2 additions & 0 deletions crates/optimism/rpc/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,10 @@
// The `optimism` feature must be enabled to use this crate.
#![cfg(feature = "optimism")]

pub mod api;
pub mod error;
pub mod eth;

pub use api::OpEthApiServer;
pub use error::OpEthApiError;
pub use eth::{receipt::op_receipt_fields, transaction::OptimismTxMeta, OpEthApi};
2 changes: 1 addition & 1 deletion crates/primitives-traits/src/account.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use serde::{Deserialize, Serialize};

/// An Ethereum account.
#[reth_codec]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Default)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Default, Serialize, Deserialize)]
pub struct Account {
/// Account nonce.
pub nonce: u64,
Expand Down
3 changes: 2 additions & 1 deletion crates/primitives-traits/src/header/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,12 @@ use bytes::BufMut;
use core::mem;
use reth_codecs::{add_arbitrary_tests, reth_codec, Compact};
use revm_primitives::{calc_blob_gasprice, calc_excess_blob_gas};
use serde::{Deserialize, Serialize};

/// Block header
#[reth_codec(no_arbitrary)]
#[add_arbitrary_tests(rlp, 25)]
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub struct Header {
/// The Keccak 256-bit hash of the parent
/// block’s header, in its entirety; formally Hp.
Expand Down
3 changes: 2 additions & 1 deletion crates/primitives-traits/src/header/sealed.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,13 @@ use bytes::BufMut;
use core::mem;
use derive_more::{AsRef, Deref};
use reth_codecs::{add_arbitrary_tests, reth_codec, Compact};
use serde::{Deserialize, Serialize};

/// A [`Header`] that is sealed at a precalculated hash, use [`SealedHeader::unseal()`] if you want
/// to modify header.
#[reth_codec(no_arbitrary)]
#[add_arbitrary_tests(rlp, compact)]
#[derive(Debug, Clone, PartialEq, Eq, Hash, AsRef, Deref)]
#[derive(Debug, Clone, PartialEq, Eq, Hash, AsRef, Deref, Serialize, Deserialize)]
pub struct SealedHeader {
/// Locked Header hash.
hash: BlockHash,
Expand Down
5 changes: 4 additions & 1 deletion crates/primitives-traits/src/log.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,14 @@ mod tests {
use proptest::proptest;
use proptest_arbitrary_interop::arb;
use reth_codecs::{reth_codec, Compact};
use serde::{Deserialize, Serialize};

/// This type is kept for compatibility tests after the codec support was added to
/// alloy-primitives Log type natively
#[reth_codec(rlp)]
#[derive(Clone, Debug, PartialEq, Eq, RlpDecodable, RlpEncodable, Default)]
#[derive(
Clone, Debug, PartialEq, Eq, RlpDecodable, RlpEncodable, Default, Serialize, Deserialize,
)]
struct Log {
/// Contract that emitted this log.
address: Address,
Expand Down
16 changes: 15 additions & 1 deletion crates/primitives-traits/src/request.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,27 @@ use alloy_rlp::{Decodable, Encodable};
use derive_more::{Deref, DerefMut, From, IntoIterator};
use reth_codecs::{reth_codec, Compact};
use revm_primitives::Bytes;
use serde::{Deserialize, Serialize};

#[cfg(not(feature = "std"))]
use alloc::vec::Vec;

/// A list of EIP-7685 requests.
#[reth_codec]
#[derive(Debug, Clone, PartialEq, Eq, Default, Hash, Deref, DerefMut, From, IntoIterator)]
#[derive(
Debug,
Clone,
PartialEq,
Eq,
Default,
Hash,
Deref,
DerefMut,
From,
IntoIterator,
Serialize,
Deserialize,
)]
pub struct Requests(pub Vec<Request>);

impl Encodable for Requests {
Expand Down
16 changes: 15 additions & 1 deletion crates/primitives-traits/src/withdrawal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ use alloc::vec::Vec;
/// Re-export from `alloy_eips`.
#[doc(inline)]
pub use alloy_eips::eip4895::Withdrawal;
use serde::{Deserialize, Serialize};

/// Represents a collection of Withdrawals.
#[reth_codec]
Expand All @@ -27,6 +28,8 @@ pub use alloy_eips::eip4895::Withdrawal;
IntoIterator,
RlpEncodableWrapper,
RlpDecodableWrapper,
Serialize,
Deserialize,
)]
#[as_ref(forward)]
pub struct Withdrawals(Vec<Withdrawal>);
Expand Down Expand Up @@ -93,7 +96,18 @@ mod tests {
/// This type is kept for compatibility tests after the codec support was added to alloy-eips
/// Withdrawal type natively
#[reth_codec]
#[derive(Debug, Clone, PartialEq, Eq, Default, Hash, RlpEncodable, RlpDecodable)]
#[derive(
Debug,
Clone,
PartialEq,
Eq,
Default,
Hash,
RlpEncodable,
RlpDecodable,
Serialize,
Deserialize,
)]
struct RethWithdrawal {
/// Monotonically increasing identifier issued by consensus layer.
index: u64,
Expand Down
6 changes: 4 additions & 2 deletions crates/primitives/src/receipt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@ use alloc::{vec, vec::Vec};
/// Receipt containing result of transaction execution.
#[cfg_attr(any(test, feature = "reth-codec"), reth_codecs::reth_codec(no_arbitrary, zstd))]
#[cfg_attr(any(test, feature = "reth-codec"), reth_codecs::add_arbitrary_tests)]
#[derive(Clone, Debug, PartialEq, Eq, Default, RlpEncodable, RlpDecodable)]
#[derive(
Clone, Debug, PartialEq, Eq, Default, RlpEncodable, RlpDecodable, Serialize, Deserialize,
)]
#[rlp(trailing)]
pub struct Receipt {
/// Receipt type.
Expand Down Expand Up @@ -141,7 +143,7 @@ impl From<Receipt> for ReceiptWithBloom {

/// [`Receipt`] with calculated bloom filter.
#[cfg_attr(any(test, feature = "reth-codec"), reth_codecs::reth_codec)]
#[derive(Clone, Debug, PartialEq, Eq, Default)]
#[derive(Clone, Debug, PartialEq, Eq, Default, Serialize, Deserialize)]
pub struct ReceiptWithBloom {
/// Bloom filter build from logs.
pub bloom: Bloom,
Expand Down
25 changes: 23 additions & 2 deletions crates/primitives/src/transaction/access_list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,22 @@ mod tests {
use proptest::proptest;
use proptest_arbitrary_interop::arb;
use reth_codecs::{reth_codec, Compact};
use serde::{Deserialize, Serialize};

/// This type is kept for compatibility tests after the codec support was added to alloy-eips
/// AccessList type natively
#[reth_codec(rlp)]
#[derive(
Clone, Debug, PartialEq, Eq, Hash, Default, RlpDecodableWrapper, RlpEncodableWrapper,
Clone,
Debug,
PartialEq,
Eq,
Hash,
Default,
RlpDecodableWrapper,
RlpEncodableWrapper,
Serialize,
Deserialize,
)]
struct RethAccessList(Vec<RethAccessListItem>);

Expand All @@ -29,7 +39,18 @@ mod tests {

// This
#[reth_codec(rlp)]
#[derive(Clone, Debug, PartialEq, Eq, Hash, Default, RlpDecodable, RlpEncodable)]
#[derive(
Clone,
Debug,
PartialEq,
Eq,
Hash,
Default,
RlpDecodable,
RlpEncodable,
Serialize,
Deserialize,
)]
#[serde(rename_all = "camelCase")]
struct RethAccessListItem {
/// Account address that would be loaded at the start of execution
Expand Down
3 changes: 2 additions & 1 deletion crates/primitives/src/transaction/eip1559.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,11 @@ use reth_codecs::Compact;

#[cfg(not(feature = "std"))]
use alloc::vec::Vec;
use serde::{Deserialize, Serialize};

/// A transaction with a priority fee ([EIP-1559](https://eips.ethereum.org/EIPS/eip-1559)).
#[cfg_attr(any(test, feature = "reth-codec"), reth_codecs::reth_codec)]
#[derive(Debug, Clone, PartialEq, Eq, Hash, Default)]
#[derive(Debug, Clone, PartialEq, Eq, Hash, Default, Serialize, Deserialize)]
pub struct TxEip1559 {
/// Added as EIP-155: Simple replay attack protection
pub chain_id: ChainId,
Expand Down
3 changes: 2 additions & 1 deletion crates/primitives/src/transaction/eip2930.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,11 @@ use reth_codecs::Compact;

#[cfg(not(feature = "std"))]
use alloc::vec::Vec;
use serde::{Deserialize, Serialize};

/// Transaction with an [`AccessList`] ([EIP-2930](https://eips.ethereum.org/EIPS/eip-2930)).
#[cfg_attr(any(test, feature = "reth-codec"), reth_codecs::reth_codec)]
#[derive(Debug, Clone, PartialEq, Eq, Hash, Default)]
#[derive(Debug, Clone, PartialEq, Eq, Hash, Default, Serialize, Deserialize)]
pub struct TxEip2930 {
/// Added as EIP-155: Simple replay attack protection
pub chain_id: ChainId,
Expand Down
Loading

0 comments on commit 44d3e6e

Please sign in to comment.