Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: bump revm #4723

Merged
merged 1 commit into from
Sep 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 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 @@ -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 }
Expand Down
29 changes: 16 additions & 13 deletions crates/payload/builder/src/payload.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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),
Expand All @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion crates/primitives/src/eip4844.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
///
Expand Down
6 changes: 3 additions & 3 deletions crates/primitives/src/header.rs
Original file line number Diff line number Diff line change
@@ -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,
Expand Down Expand Up @@ -186,7 +186,7 @@ impl Header {
///
/// Returns `None` if `excess_blob_gas` is None
pub fn blob_fee(&self) -> Option<u64> {
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.
Expand All @@ -195,7 +195,7 @@ impl Header {
///
/// See also [Self::next_block_excess_blob_gas]
pub fn next_block_blob_fee(&self) -> Option<u64> {
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.
Expand Down
4 changes: 3 additions & 1 deletion crates/revm/revm-primitives/src/env.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
4 changes: 2 additions & 2 deletions crates/rpc/rpc/src/eth/api/transactions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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},
Expand Down Expand Up @@ -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),
};

Expand Down
7 changes: 5 additions & 2 deletions crates/rpc/rpc/src/eth/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -188,8 +189,10 @@ where
fn from(err: EVMError<T>) -> 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(),
}
}
Expand Down
Loading