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

Return a propoer error code for txpool is full error #13245

Merged
merged 1 commit into from
Dec 9, 2024

Conversation

angel-ding-cb
Copy link
Contributor

Currently, when reth's transaction pool is full, it returns an RPC error without a specific error code. This leads to two issues:

  1. Users receive ambiguous errors with code = None in the response
  2. Monitoring systems (like proxyd) cannot properly categorize and alert on pool overflow conditions since the error lacks a standard error code

Solution
Map the RpcPoolError::TxPoolOverflow error to a proper JSON-RPC error code by modifying the error conversion implementation:

impl From<RpcPoolError> for jsonrpsee_types::error::ErrorObject<'static> {
    fn from(error: RpcPoolError) -> Self {
        match error {
            RpcPoolError::Invalid(err) => err.into(),
            RpcPoolError::TxPoolOverflow => rpc_error_with_code(
                EthRpcErrorCode::TransactionRejected.code(),
                error.to_string()
            ),
            error => internal_rpc_err(error.to_string()),
        }
    }
}

This change:

  1. Maps pool overflow errors to the standard TransactionRejected error code (-32003)
  2. Maintains the descriptive error message "txpool is full"
  3. Keeps other error handling behavior unchanged

Benefits

  1. Users receive clear error responses with proper error codes
  2. Monitoring systems can properly track and alert on pool overflow conditions
  3. Better alignment with Ethereum JSON-RPC error code standards

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.

cool, ty.

that makes sense

@mattsse mattsse added the A-rpc Related to the RPC implementation label Dec 9, 2024
@mattsse mattsse enabled auto-merge December 9, 2024 20:32
@mattsse mattsse added this pull request to the merge queue Dec 9, 2024
Merged via the queue into paradigmxyz:main with commit af5dc60 Dec 9, 2024
43 checks passed
lean-apple pushed a commit to lean-apple/reth that referenced this pull request Dec 12, 2024
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
None yet
Development

Successfully merging this pull request may close these issues.

2 participants