-
Notifications
You must be signed in to change notification settings - Fork 1.7k
feat: extract rpc<>revm specifc code #1818
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change | ||
---|---|---|---|---|
@@ -1,5 +1,11 @@ | ||||
//! Commonly used errors for the `eth_` namespace. | ||||
|
||||
use reth_primitives::{InvalidTransactionError, U256}; | ||||
use revm::primitives::EVMError; | ||||
|
||||
/// Result alias | ||||
pub type RevmResult<T> = Result<T, RevmError>; | ||||
|
||||
/// List of JSON-RPC error codes | ||||
#[derive(Debug, Copy, PartialEq, Eq, Clone)] | ||||
pub enum EthRpcErrorCode { | ||||
|
@@ -21,3 +27,51 @@ impl EthRpcErrorCode { | |||
} | ||||
} | ||||
} | ||||
|
||||
#[derive(Debug, thiserror::Error, Clone, PartialEq, Eq)] | ||||
#[allow(missing_docs)] | ||||
pub enum RevmError { | ||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This should rly be using the executor error enum instead of writing its own: reth/crates/interfaces/src/db.rs Line 3 in d774d91
And the functions like There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
RPC does not write to Disk and needs to configure the env directly depending on the RPC call. The EvmEnvProvider trait is used by RPC to get block and cfg of the env and |
||||
/// When a raw transaction is empty | ||||
#[error("Empty transaction data")] | ||||
EmptyRawTransactionData, | ||||
#[error("Failed to decode signed transaction")] | ||||
FailedToDecodeSignedTransaction, | ||||
#[error("Invalid transaction signature")] | ||||
InvalidTransactionSignature, | ||||
#[error("PoolError")] | ||||
PoolError, | ||||
#[error("Unknown block number")] | ||||
UnknownBlockNumber, | ||||
#[error("Invalid block range")] | ||||
InvalidBlockRange, | ||||
/// An internal error where prevrandao is not set in the evm's environment | ||||
#[error("Prevrandao not in th EVM's environment after merge")] | ||||
PrevrandaoNotSet, | ||||
#[error("Invalid transaction")] | ||||
InvalidTransaction(#[from] InvalidTransactionError), | ||||
#[error("Conflicting fee values in request. Both legacy gasPrice {gas_price} and maxFeePerGas {max_fee_per_gas} set")] | ||||
ConflictingRequestGasPrice { gas_price: U256, max_fee_per_gas: U256 }, | ||||
#[error("Conflicting fee values in request. Both legacy gasPrice {gas_price} maxFeePerGas {max_fee_per_gas} and maxPriorityFeePerGas {max_priority_fee_per_gas} set")] | ||||
ConflictingRequestGasPriceAndTipSet { | ||||
gas_price: U256, | ||||
max_fee_per_gas: U256, | ||||
max_priority_fee_per_gas: U256, | ||||
}, | ||||
#[error("Conflicting fee values in request. Legacy gasPrice {gas_price} and maxPriorityFeePerGas {max_priority_fee_per_gas} set")] | ||||
RequestLegacyGasPriceAndTipSet { gas_price: U256, max_priority_fee_per_gas: U256 }, | ||||
#[error("Unknown error")] | ||||
Internal, | ||||
} | ||||
|
||||
impl<T> From<EVMError<T>> for RevmError | ||||
where | ||||
T: Into<RevmError>, | ||||
{ | ||||
fn from(err: EVMError<T>) -> Self { | ||||
match err { | ||||
EVMError::Transaction(err) => InvalidTransactionError::from(err).into(), | ||||
EVMError::PrevrandaoNotSet => RevmError::PrevrandaoNotSet, | ||||
EVMError::Database(err) => err.into(), | ||||
} | ||||
} | ||||
} |
Uh oh!
There was an error while loading. Please reload this page.