Skip to content

Commit

Permalink
chore: migrate revm changes
Browse files Browse the repository at this point in the history
  • Loading branch information
mattsse committed Sep 17, 2023
1 parent 0d4cb44 commit 0f4cb31
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 0 deletions.
27 changes: 27 additions & 0 deletions crates/rpc/rpc/src/eth/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ pub enum EthApiError {
/// An internal error where prevrandao is not set in the evm's environment
#[error("Prevrandao not in th EVM's environment after merge")]
PrevrandaoNotSet,
/// Excess_blob_gas is not set for Cancun and above.
#[error("Excess blob gas missing th EVM's environment after Cancun")]
ExcessBlobGasNotSet,
/// Thrown when a call or transaction request (`eth_call`, `eth_estimateGas`,
/// `eth_sendTransaction`) contains conflicting fields (legacy, EIP-1559)
#[error("both gasPrice and (maxFeePerGas or maxPriorityFeePerGas) specified")]
Expand Down Expand Up @@ -110,6 +113,7 @@ impl From<EthApiError> for ErrorObject<'static> {
EthApiError::InvalidTransaction(err) => err.into(),
EthApiError::PoolError(err) => err.into(),
EthApiError::PrevrandaoNotSet |
EthApiError::ExcessBlobGasNotSet |
EthApiError::InvalidBlockData(_) |
EthApiError::Internal(_) |
EthApiError::TransactionNotFound => internal_rpc_err(error.to_string()),
Expand Down Expand Up @@ -184,7 +188,11 @@ where
match err {
EVMError::Transaction(err) => RpcInvalidTransactionError::from(err).into(),
EVMError::PrevrandaoNotSet => EthApiError::PrevrandaoNotSet,
EVMError::ExcessBlobGasNotSet => EthApiError::ExcessBlobGasNotSet,
EVMError::Database(err) => err.into(),
_ => {
unreachable!()
}
}
}
}
Expand Down Expand Up @@ -281,6 +289,16 @@ pub enum RpcInvalidTransactionError {
/// The transitions is before Berlin and has access list
#[error("Transactions before Berlin should not have access list")]
AccessListNotSupported,
/// `max_fee_per_blob_gas` is not supported for blocks before the Cancun hardfork.
#[error("max_fee_per_blob_gas is not supported for blocks before the Cancun hardfork.")]
MaxFeePerBlobGasNotSupported,
/// `blob_hashes`/`blob_versioned_hashes` is not supported for blocks before the Cancun
/// hardfork.
#[error("blob_versioned_hashes is not supported for blocks before the Cancun hardfork.")]
BlobVersionedHashesNotSupported,
/// Block `blob_gas_price` is greater than tx-specified `max_fee_per_blob_gas` after Cancun.
#[error("max fee per blob gas less than block blob gas fee")]
BlobFeeCapTooLow,
}

impl RpcInvalidTransactionError {
Expand Down Expand Up @@ -370,6 +388,15 @@ impl From<revm::primitives::InvalidTransaction> for RpcInvalidTransactionError {
InvalidTransaction::AccessListNotSupported => {
RpcInvalidTransactionError::AccessListNotSupported
}
InvalidTransaction::MaxFeePerBlobGasNotSupported => {
RpcInvalidTransactionError::MaxFeePerBlobGasNotSupported
}
InvalidTransaction::BlobVersionedHashesNotSupported => {
RpcInvalidTransactionError::BlobVersionedHashesNotSupported
}
InvalidTransaction::BlobGasPriceGreaterThanMax => {
RpcInvalidTransactionError::BlobFeeCapTooLow
}
}
}
}
Expand Down
4 changes: 4 additions & 0 deletions crates/rpc/rpc/src/eth/revm_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,10 @@ pub(crate) fn create_txn_env(block_env: &BlockEnv, request: CallRequest) -> EthR
data: input.try_into_unique_input()?.map(|data| data.0).unwrap_or_default(),
chain_id: chain_id.map(|c| c.as_u64()),
access_list: access_list.map(AccessList::flattened).unwrap_or_default(),

// EIP-4844 fields
blob_hashes: Default::default(),
max_fee_per_blob_gas: None,
};

Ok(env)
Expand Down

0 comments on commit 0f4cb31

Please sign in to comment.