Skip to content
Merged
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
14 changes: 12 additions & 2 deletions crates/rpc/rpc-eth-types/src/simulate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,16 @@ use revm::{
Database,
};

/// Error code for execution reverted in `eth_simulateV1`.
///
/// <https://github.com/ethereum/execution-apis>
pub const SIMULATE_REVERT_CODE: i32 = -32000;

/// Error code for VM execution errors (e.g., out of gas) in `eth_simulateV1`.
///
/// <https://github.com/ethereum/execution-apis>
pub const SIMULATE_VM_ERROR_CODE: i32 = -32015;

/// Errors which may occur during `eth_simulateV1` execution.
#[derive(Debug, thiserror::Error)]
pub enum EthSimulateError {
Expand Down Expand Up @@ -263,7 +273,7 @@ where
return_data: Bytes::new(),
error: Some(SimulateError {
message: error.to_string(),
code: error.into().code(),
code: SIMULATE_VM_ERROR_CODE,
..SimulateError::invalid_params()
}),
gas_used,
Expand All @@ -278,7 +288,7 @@ where
return_data: output,
error: Some(SimulateError {
message: error.to_string(),
code: error.into().code(),
code: SIMULATE_REVERT_CODE,
..SimulateError::invalid_params()
}),
gas_used,
Expand Down
Loading