From e83d3aa704f87825ca8cab6f593ab4d4adbf6792 Mon Sep 17 00:00:00 2001 From: Dan Cline <6798349+Rjected@users.noreply.github.com> Date: Thu, 21 Sep 2023 21:05:10 -0400 Subject: [PATCH] chore: bump revm (#4723) --- Cargo.lock | 8 +++--- Cargo.toml | 4 +-- crates/payload/builder/src/payload.rs | 29 ++++++++++++---------- crates/primitives/src/eip4844.rs | 2 +- crates/primitives/src/header.rs | 6 ++--- crates/revm/revm-primitives/src/env.rs | 4 ++- crates/rpc/rpc/src/eth/api/transactions.rs | 4 +-- crates/rpc/rpc/src/eth/error.rs | 7 ++++-- 8 files changed, 36 insertions(+), 28 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 76e4038b54e9..e05b51210b2c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -6323,7 +6323,7 @@ dependencies = [ [[package]] name = "revm" version = "3.3.0" -source = "git+https://github.com/bluealloy/revm?rev=6e65230a#6e65230a4e6f4fb18b377cbf0929308795728841" +source = "git+https://github.com/bluealloy/revm?rev=516f62cc#516f62ccc1c5f2a62e5fc58115213fe04c7f7a8c" dependencies = [ "auto_impl", "revm-interpreter", @@ -6333,7 +6333,7 @@ dependencies = [ [[package]] name = "revm-interpreter" version = "1.1.2" -source = "git+https://github.com/bluealloy/revm?rev=6e65230a#6e65230a4e6f4fb18b377cbf0929308795728841" +source = "git+https://github.com/bluealloy/revm?rev=516f62cc#516f62ccc1c5f2a62e5fc58115213fe04c7f7a8c" dependencies = [ "derive_more", "enumn", @@ -6344,7 +6344,7 @@ dependencies = [ [[package]] name = "revm-precompile" version = "2.0.3" -source = "git+https://github.com/bluealloy/revm?rev=6e65230a#6e65230a4e6f4fb18b377cbf0929308795728841" +source = "git+https://github.com/bluealloy/revm?rev=516f62cc#516f62ccc1c5f2a62e5fc58115213fe04c7f7a8c" dependencies = [ "c-kzg 0.1.0 (git+https://github.com/ethereum/c-kzg-4844)", "hex", @@ -6362,7 +6362,7 @@ dependencies = [ [[package]] name = "revm-primitives" version = "1.1.2" -source = "git+https://github.com/bluealloy/revm?rev=6e65230a#6e65230a4e6f4fb18b377cbf0929308795728841" +source = "git+https://github.com/bluealloy/revm?rev=516f62cc#516f62ccc1c5f2a62e5fc58115213fe04c7f7a8c" dependencies = [ "arbitrary", "auto_impl", diff --git a/Cargo.toml b/Cargo.toml index 64b7cb49e806..0e3f72f62c9f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -99,8 +99,8 @@ reth-network-api = { path = "./crates/net/network-api" } reth-rpc-types-compat = { path = "./crates/rpc/rpc-types-compat" } # revm -revm = { git = "https://github.com/bluealloy/revm", rev = "6e65230a" } -revm-primitives = { git = "https://github.com/bluealloy/revm", rev = "6e65230a" } +revm = { git = "https://github.com/bluealloy/revm", rev = "516f62cc" } +revm-primitives = { git = "https://github.com/bluealloy/revm", rev = "516f62cc" } ## eth ethers-core = { version = "2.0", default-features = false } diff --git a/crates/payload/builder/src/payload.rs b/crates/payload/builder/src/payload.rs index 222af177b97a..b7573588d779 100644 --- a/crates/payload/builder/src/payload.rs +++ b/crates/payload/builder/src/payload.rs @@ -13,7 +13,7 @@ use reth_rpc_types_compat::engine::payload::{ convert_block_to_payload_field_v2, convert_standalonewithdraw_to_withdrawal, try_block_to_payload_v1, try_block_to_payload_v3, }; -use revm_primitives::{BlockEnv, CfgEnv, SpecId}; +use revm_primitives::{BlobExcessGasAndPrice, BlockEnv, CfgEnv, SpecId}; /// Contains the built payload. /// /// According to the [engine API specification](https://github.com/ethereum/execution-apis/blob/main/src/engine/README.md) the execution layer should build the initial version of the payload with an empty transaction set and then keep update it in order to maximize the revenue. @@ -183,17 +183,20 @@ impl PayloadBuilderAttributes { // if the parent block did not have excess blob gas (i.e. it was pre-cancun), but it is // cancun now, we need to set the excess blob gas to the default value - let excess_blob_gas = parent.next_block_blob_fee().map_or_else( - || { - if cfg.spec_id == SpecId::CANCUN { - // default excess blob gas is zero - Some(0) - } else { - None - } - }, - Some, - ); + let blob_excess_gas_and_price = parent + .next_block_blob_fee() + .map_or_else( + || { + if cfg.spec_id == SpecId::CANCUN { + // default excess blob gas is zero + Some(0) + } else { + None + } + }, + Some, + ) + .map(BlobExcessGasAndPrice::new); let block_env = BlockEnv { number: U256::from(parent.number + 1), @@ -207,7 +210,7 @@ impl PayloadBuilderAttributes { parent.next_block_base_fee(chain_spec.base_fee_params).unwrap_or_default(), ), // calculate excess gas based on parent block's blob gas usage - excess_blob_gas, + blob_excess_gas_and_price, }; (cfg, block_env) diff --git a/crates/primitives/src/eip4844.rs b/crates/primitives/src/eip4844.rs index f7d136d6ac66..ea91d4f11e82 100644 --- a/crates/primitives/src/eip4844.rs +++ b/crates/primitives/src/eip4844.rs @@ -7,7 +7,7 @@ use crate::{ use sha2::{Digest, Sha256}; // re-exports from revm for calculating blob fee -pub use revm_primitives::calc_blob_fee; +pub use revm_primitives::calc_blob_gasprice; /// Calculates the versioned hash for a KzgCommitment /// diff --git a/crates/primitives/src/header.rs b/crates/primitives/src/header.rs index 0a409787bb38..d02d26c07fea 100644 --- a/crates/primitives/src/header.rs +++ b/crates/primitives/src/header.rs @@ -1,6 +1,6 @@ use crate::{ basefee::calculate_next_block_base_fee, - eip4844::{calc_blob_fee, calculate_excess_blob_gas}, + eip4844::{calc_blob_gasprice, calculate_excess_blob_gas}, keccak256, proofs::{EMPTY_LIST_HASH, EMPTY_ROOT}, BaseFeeParams, BlockBodyRoots, BlockHash, BlockNumHash, BlockNumber, Bloom, Bytes, H160, H256, @@ -186,7 +186,7 @@ impl Header { /// /// Returns `None` if `excess_blob_gas` is None pub fn blob_fee(&self) -> Option { - self.excess_blob_gas.map(calc_blob_fee) + self.excess_blob_gas.map(calc_blob_gasprice) } /// Returns the blob fee for the next block according to the EIP-4844 spec. @@ -195,7 +195,7 @@ impl Header { /// /// See also [Self::next_block_excess_blob_gas] pub fn next_block_blob_fee(&self) -> Option { - self.next_block_excess_blob_gas().map(calc_blob_fee) + self.next_block_excess_blob_gas().map(calc_blob_gasprice) } /// Calculate base fee for next block according to the EIP-1559 spec. diff --git a/crates/revm/revm-primitives/src/env.rs b/crates/revm/revm-primitives/src/env.rs index 9257d0450223..b2e546790930 100644 --- a/crates/revm/revm-primitives/src/env.rs +++ b/crates/revm/revm-primitives/src/env.rs @@ -75,7 +75,9 @@ pub fn fill_block_env_with_coinbase( block_env.gas_limit = U256::from(header.gas_limit); // EIP-4844 excess blob gas of this block, introduced in Cancun - block_env.excess_blob_gas = header.excess_blob_gas; + if let Some(excess_blob_gas) = header.excess_blob_gas { + block_env.set_blob_excess_gas_and_price(excess_blob_gas); + } } /// Return the coinbase address for the given header and chain spec. diff --git a/crates/rpc/rpc/src/eth/api/transactions.rs b/crates/rpc/rpc/src/eth/api/transactions.rs index 3479ce59bc11..b5be6fbd83e4 100644 --- a/crates/rpc/rpc/src/eth/api/transactions.rs +++ b/crates/rpc/rpc/src/eth/api/transactions.rs @@ -14,7 +14,7 @@ use crate::{ use async_trait::async_trait; use reth_network_api::NetworkInfo; use reth_primitives::{ - eip4844::calc_blob_fee, + eip4844::calc_blob_gasprice, Address, BlockId, BlockNumberOrTag, Bytes, FromRecoveredPooledTransaction, Header, IntoRecoveredTransaction, Receipt, SealedBlock, TransactionKind::{Call, Create}, @@ -888,7 +888,7 @@ pub(crate) fn build_transaction_receipt_with_block_receipts( status_code: if receipt.success { Some(U64::from(1)) } else { Some(U64::from(0)) }, // EIP-4844 fields - blob_gas_price: meta.excess_blob_gas.map(calc_blob_fee).map(U128::from), + blob_gas_price: meta.excess_blob_gas.map(calc_blob_gasprice).map(U128::from), blob_gas_used: transaction.transaction.blob_gas_used().map(U128::from), }; diff --git a/crates/rpc/rpc/src/eth/error.rs b/crates/rpc/rpc/src/eth/error.rs index 58728b0ee644..92d0b9525613 100644 --- a/crates/rpc/rpc/src/eth/error.rs +++ b/crates/rpc/rpc/src/eth/error.rs @@ -13,6 +13,7 @@ use reth_transaction_pool::error::{ Eip4844PoolTransactionError, InvalidPoolTransactionError, PoolError, PoolTransactionError, }; use revm::primitives::{EVMError, ExecutionResult, Halt, OutOfGasError}; +use revm_primitives::InvalidHeader; use std::time::Duration; /// Result alias @@ -188,8 +189,10 @@ where fn from(err: EVMError) -> Self { match err { EVMError::Transaction(err) => RpcInvalidTransactionError::from(err).into(), - EVMError::PrevrandaoNotSet => EthApiError::PrevrandaoNotSet, - EVMError::ExcessBlobGasNotSet => EthApiError::ExcessBlobGasNotSet, + EVMError::Header(InvalidHeader::PrevrandaoNotSet) => EthApiError::PrevrandaoNotSet, + EVMError::Header(InvalidHeader::ExcessBlobGasNotSet) => { + EthApiError::ExcessBlobGasNotSet + } EVMError::Database(err) => err.into(), } }