From f4d8b70dd2d9f94ed13a98046e5474c179e320ed Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Sun, 25 Jan 2026 16:27:46 +0100 Subject: [PATCH] fix(rpc): use correct error codes for eth_simulateV1 reverts and halts Defines constants for eth_simulateV1 specific error codes: - SIMULATE_REVERT_CODE (-32000) for execution reverts - SIMULATE_VM_ERROR_CODE (-32015) for VM execution errors (e.g., out of gas) These match geth's behavior per the execution-apis spec. Amp-Thread-ID: https://ampcode.com/threads/T-019bf5ac-dd59-76c0-8ba8-8739e84b6a33 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 98658a75b52..50f11674273 100644 --- a/crates/rpc/rpc-eth-types/src/simulate.rs +++ b/crates/rpc/rpc-eth-types/src/simulate.rs @@ -27,6 +27,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 { @@ -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, @@ -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,