From 935a2cc056fcffb3c316b97a34c0329dab2395ac Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Mon, 26 Jan 2026 15:06:38 +0100 Subject: [PATCH] fix(rpc): use correct error codes for eth_simulateV1 reverts and halts (#21412) Co-authored-by: Amp --- crates/rpc/rpc-eth-types/src/simulate.rs | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/crates/rpc/rpc-eth-types/src/simulate.rs b/crates/rpc/rpc-eth-types/src/simulate.rs index d7f248f0e0..25b87bd1b2 100644 --- a/crates/rpc/rpc-eth-types/src/simulate.rs +++ b/crates/rpc/rpc-eth-types/src/simulate.rs @@ -29,6 +29,16 @@ use revm::{ Database, }; +/// Error code for execution reverted in `eth_simulateV1`. +/// +/// +pub const SIMULATE_REVERT_CODE: i32 = -32000; + +/// Error code for VM execution errors (e.g., out of gas) in `eth_simulateV1`. +/// +/// +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,