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

feat(Rundler): Handle standardized eth_sendRawTransactionConditional error codes #931

Merged
merged 5 commits into from
Dec 11, 2024
Merged
Show file tree
Hide file tree
Changes from 3 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
4 changes: 3 additions & 1 deletion crates/builder/src/sender/bloxroute.rs
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,9 @@ struct BloxrouteResponse {
impl From<jsonrpsee::core::ClientError> for TxSenderError {
fn from(value: jsonrpsee::core::ClientError) -> Self {
if let jsonrpsee::core::ClientError::Call(e) = &value {
if let Some(e) = super::parse_known_call_execution_failed(e.message()) {
if let Some(e) =
super::parse_known_call_execution_failed(e.message(), &(e.code() as i64))
{
return e;
}
}
Expand Down
16 changes: 9 additions & 7 deletions crates/builder/src/sender/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ impl From<ProviderError> for TxSenderError {
ProviderError::RPC(e) => {
niveda-krish marked this conversation as resolved.
Show resolved Hide resolved
if let Some(e) = e.as_error_resp() {
// Client impls use different error codes, just match on the message
if let Some(e) = parse_known_call_execution_failed(&e.message) {
if let Some(e) = parse_known_call_execution_failed(&e.message, &e.code) {
e
} else {
TxSenderError::Other(value.into())
Expand All @@ -257,9 +257,15 @@ impl From<ProviderError> for TxSenderError {
// Geth: https://github.com/ethereum/go-ethereum/blob/23800122b37695be50565f8221858a16ce1763db/core/txpool/errors.go#L31
// Reth: https://github.com/paradigmxyz/reth/blob/8e4a917ec1aa70b3779083454ff2d5ecf6b44168/crates/rpc/rpc-eth-types/src/error/mod.rs#L624
// Erigon: https://github.com/erigontech/erigon/blob/96fabf3fd1a4ddce26b845ffe2b6cfb50d5b4b2d/txnprovider/txpool/txpoolcfg/txpoolcfg.go#L124
fn parse_known_call_execution_failed(e: &str) -> Option<TxSenderError> {
fn parse_known_call_execution_failed(message: &str, code: &i64) -> Option<TxSenderError> {
niveda-krish marked this conversation as resolved.
Show resolved Hide resolved
// The error code is -32003 or -32005 when condition is not met, we check error codes before checking the message
// https://eips.ethereum.org/EIPS/eip-7796
if *code == -32003 || *code == -32005 {
return Some(TxSenderError::ConditionNotMet);
}
// String match on the error message when an error code is not available
// DEVELOPER NOTE: ensure to put the most specific matches first
match &e.to_lowercase() {
match &message.to_lowercase() {
// geth. Reth & erigon don't have similar
x if x.contains("future transaction tries to replace pending") => {
Some(TxSenderError::Rejected)
Expand All @@ -274,10 +280,6 @@ fn parse_known_call_execution_failed(e: &str) -> Option<TxSenderError> {
}
// geth, erigon, reth
x if x.contains("nonce too low") => Some(TxSenderError::NonceTooLow),
// Arbitrum conditional sender error message
x if x.contains("storage slot value condition not met") => {
Some(TxSenderError::ConditionNotMet)
}
// geth
x if x.contains("transaction underpriced") => Some(TxSenderError::Underpriced),
// reth
Expand Down
Loading