chore: bump revm (#4723)

This commit is contained in:
Dan Cline
2023-09-21 21:05:10 -04:00
committed by GitHub
parent 7a5b631273
commit e83d3aa704
8 changed files with 36 additions and 28 deletions

View File

@ -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)

View File

@ -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
///

View File

@ -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<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.
@ -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.

View File

@ -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.

View File

@ -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),
};

View File

@ -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<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(),
}
}