Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: add execution aborted error #3901

Merged
merged 1 commit into from
Jul 25, 2023
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
23 changes: 22 additions & 1 deletion crates/rpc/rpc/src/eth/error.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
//! Implementation specific Errors for the `eth_` namespace.

use crate::result::{internal_rpc_err, invalid_params_rpc_err, rpc_err, rpc_error_with_code};
use jsonrpsee::{core::Error as RpcError, types::ErrorObject};
use jsonrpsee::{
core::Error as RpcError,
types::{error::CALL_EXECUTION_FAILED_CODE, ErrorObject},
};
use reth_primitives::{abi::decode_revert_reason, Address, Bytes, U256};
use reth_revm::tracing::js::JsInspectorError;
use reth_rpc_types::{error::EthRpcErrorCode, BlockError};
use reth_transaction_pool::error::{InvalidPoolTransactionError, PoolError};
use revm::primitives::{EVMError, ExecutionResult, Halt, OutOfGasError};
use std::time::Duration;

/// Result alias
pub type EthResult<T> = Result<T, EthApiError>;
Expand Down Expand Up @@ -80,6 +84,9 @@ pub enum EthApiError {
/// Error thrown when a spawned blocking task failed to deliver an anticipated response.
#[error("internal eth error")]
InternalEthError,
/// Error thrown when a (tracing) call exceeded the configured timeout.
#[error("execution aborted (timeout = {0:?})")]
ExecutionTimedOut(Duration),
/// Internal Error thrown by the javascript tracer
#[error("{0}")]
InternalJsTracerError(String),
Expand Down Expand Up @@ -112,6 +119,9 @@ impl From<EthApiError> for ErrorObject<'static> {
EthApiError::InternalJsTracerError(msg) => internal_rpc_err(msg),
EthApiError::InvalidParams(msg) => invalid_params_rpc_err(msg),
EthApiError::InvalidRewardPercentiles => internal_rpc_err(error.to_string()),
err @ EthApiError::ExecutionTimedOut(_) => {
rpc_error_with_code(CALL_EXECUTION_FAILED_CODE, err.to_string())
}
err @ EthApiError::InternalTracingError => internal_rpc_err(err.to_string()),
err @ EthApiError::InternalEthError => internal_rpc_err(err.to_string()),
}
Expand Down Expand Up @@ -532,3 +542,14 @@ pub(crate) fn ensure_success(result: ExecutionResult) -> EthResult<Bytes> {
}
}
}

#[cfg(test)]
mod tests {
use super::*;

#[test]
fn timed_out_error() {
let err = EthApiError::ExecutionTimedOut(Duration::from_secs(10));
assert_eq!(err.to_string(), "execution aborted (timeout = 10s)");
}
}
Loading