mirror of
https://github.com/paradigmxyz/reth.git
synced 2026-02-19 03:04:27 -05:00
fix(rpc): use correct error codes for eth_simulateV1 reverts and halts (#21412)
Co-authored-by: Amp <amp@ampcode.com>
This commit is contained in:
@@ -29,6 +29,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 {
|
||||
@@ -344,7 +354,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,
|
||||
@@ -359,7 +369,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,
|
||||
|
||||
Reference in New Issue
Block a user