Skip to content

Conversation

@figtracer
Copy link
Contributor

@figtracer figtracer commented Dec 3, 2025

solves #20054 by:

  • extending EthSimulateError following execution-apis and geth/ethapi/errors
  • extending the trait AsEthApiError with as_simulate_error() to match RpcInvalidTransactionError counterparts
  • small refactor at simulate_v1 using this new method

@github-project-automation github-project-automation bot moved this to Backlog in Reth Tracker Dec 3, 2025
@figtracer figtracer force-pushed the handle_dedicated_eth_simulate_rpc_errors branch from b851b3e to cf00024 Compare December 3, 2025 15:57
@figtracer figtracer force-pushed the handle_dedicated_eth_simulate_rpc_errors branch from 1f3f9e6 to 8c7312f Compare December 3, 2025 18:13
@figtracer figtracer marked this pull request as ready for review December 3, 2025 18:49
@mattsse mattsse requested a review from klkvr December 4, 2025 11:44
Copy link
Collaborator

@mattsse mattsse left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this should do it

wdyt @klkvr

Comment on lines +78 to +79
/// Returns [`EthSimulateError`] if this error maps to a simulate-specific error code.
fn as_simulate_error(&self) -> Option<EthSimulateError> {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

okay, this should actually work

Comment on lines +162 to +167
let map_err = |e: EthApiError| -> Self::Error {
match e.as_simulate_error() {
Some(sim_err) => Self::Error::from_eth_err(EthApiError::other(sim_err)),
None => Self::Error::from_eth_err(e),
}
};
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this isn't too bad either

@github-project-automation github-project-automation bot moved this from Backlog to In Progress in Reth Tracker Dec 4, 2025
Copy link
Member

@klkvr klkvr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this makes sense, though I think it's likely that there are some error code fixes that not only apply to simulateV1

Comment on lines +88 to +99
Self::NonceTooLow { .. } => -38010,
Self::NonceTooHigh => -38011,
Self::BaseFeePerGasTooLow => -38012,
Self::IntrinsicGasTooLow => -38013,
Self::InsufficientFunds { .. } => -38014,
Self::BlockGasLimitExceeded => -38015,
Self::BlockNumberInvalid => -38020,
Self::BlockTimestampInvalid => -38021,
Self::PrecompileSelfReference => -38022,
Self::PrecompileDuplicateAddress => -38023,
Self::SenderNotEOA => -38024,
Self::MaxInitCodeSizeExceeded => -38025,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

would be also great to check if any of those codes should apply here

/// Returns the rpc error code for this error.
pub const fn error_code(&self) -> i32 {
match self {
Self::InvalidChainId |
Self::GasTooLow |
Self::GasTooHigh |
Self::GasRequiredExceedsAllowance { .. } |
Self::NonceTooLow { .. } |
Self::NonceTooHigh { .. } |
Self::FeeCapTooLow |
Self::FeeCapVeryHigh => EthRpcErrorCode::InvalidInput.code(),
Self::Revert(_) => EthRpcErrorCode::ExecutionError.code(),
_ => EthRpcErrorCode::TransactionRejected.code(),
}
}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i agree, let me take a look at it

Copy link
Contributor Author

@figtracer figtracer Dec 4, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

actually i think we can leave it like this, there's nothing else to be added here

     pub const fn error_code(&self) -> i32 { 
         match self { 
             Self::InvalidChainId | 
             Self::GasTooLow | 
             Self::GasTooHigh | 
             Self::GasRequiredExceedsAllowance { .. } | 
             ...
        } 
     }

the generic json-rpc codes stay at RpcInvalidTransactionError and the conversion for (if needed) is handled by as_simulate_error(). the ones that don't match are specific

@mattsse mattsse added the A-rpc Related to the RPC implementation label Dec 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-rpc Related to the RPC implementation

Projects

Status: In Progress

Development

Successfully merging this pull request may close these issues.

3 participants