Skip to content

Commit a0c22f3

Browse files
committed
refactor(tx-sender): check transient errors before terminal config errors
Transient transport errors (BackendGone, retry-eligible, KMS signer) should be classified before attempting to decode gateway config errors, since transport-level failures may lack a valid RPC error payload.
1 parent 297abe4 commit a0c22f3

File tree

3 files changed

+36
-36
lines changed

3 files changed

+36
-36
lines changed

coprocessor/fhevm-engine/transaction-sender/src/ops/add_ciphertext.rs

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -75,20 +75,6 @@ where
7575
return Ok(());
7676
}
7777
Err(e) => {
78-
if let Some(terminal_config_error) = try_extract_terminal_config_error(&e) {
79-
ADD_CIPHERTEXT_MATERIAL_FAIL_COUNTER.inc();
80-
error!(
81-
error = %terminal_config_error,
82-
handle = h,
83-
"Detected non-retryable gateway coprocessor config error while adding ciphertext"
84-
);
85-
self.mark_add_ciphertext_terminal_config_error(
86-
handle,
87-
&terminal_config_error.to_string(),
88-
)
89-
.await?;
90-
return Ok(());
91-
}
9278
// Consider transport retryable errors, BackendGone and local usage errors as something that must be retried infinitely.
9379
// Local usage are included as they might be transient due to external AWS KMS signers.
9480
if matches!(&e, RpcError::Transport(inner) if inner.is_retry_err() || matches!(inner, TransportErrorKind::BackendGone))
@@ -108,6 +94,20 @@ where
10894
.await?;
10995
bail!(e);
11096
}
97+
if let Some(terminal_config_error) = try_extract_terminal_config_error(&e) {
98+
ADD_CIPHERTEXT_MATERIAL_FAIL_COUNTER.inc();
99+
error!(
100+
error = %terminal_config_error,
101+
handle = h,
102+
"Detected non-retryable gateway coprocessor config error while adding ciphertext"
103+
);
104+
self.mark_add_ciphertext_terminal_config_error(
105+
handle,
106+
&terminal_config_error.to_string(),
107+
)
108+
.await?;
109+
return Ok(());
110+
}
111111
ADD_CIPHERTEXT_MATERIAL_FAIL_COUNTER.inc();
112112
warn!(
113113
error = %e,

coprocessor/fhevm-engine/transaction-sender/src/ops/allow_handle.rs

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -100,20 +100,6 @@ where
100100
return Ok(());
101101
}
102102
Err(e) => {
103-
if let Some(terminal_config_error) = try_extract_terminal_config_error(&e) {
104-
ALLOW_HANDLE_FAIL_COUNTER.inc();
105-
error!(
106-
error = %terminal_config_error,
107-
key = %key,
108-
"Detected non-retryable gateway coprocessor config error while allowing handle"
109-
);
110-
self.mark_allow_handle_terminal_config_error(
111-
key,
112-
&terminal_config_error.to_string(),
113-
)
114-
.await?;
115-
return Ok(());
116-
}
117103
// Consider transport retryable errors, BackendGone and local usage errors as something that must be retried infinitely.
118104
// Local usage are included as they might be transient due to external AWS KMS signers.
119105
if matches!(&e, RpcError::Transport(inner) if inner.is_retry_err() || matches!(inner, TransportErrorKind::BackendGone))
@@ -133,6 +119,20 @@ where
133119
.await?;
134120
bail!(e);
135121
}
122+
if let Some(terminal_config_error) = try_extract_terminal_config_error(&e) {
123+
ALLOW_HANDLE_FAIL_COUNTER.inc();
124+
error!(
125+
error = %terminal_config_error,
126+
key = %key,
127+
"Detected non-retryable gateway coprocessor config error while allowing handle"
128+
);
129+
self.mark_allow_handle_terminal_config_error(
130+
key,
131+
&terminal_config_error.to_string(),
132+
)
133+
.await?;
134+
return Ok(());
135+
}
136136
ALLOW_HANDLE_FAIL_COUNTER.inc();
137137
warn!(
138138
error = %e,

coprocessor/fhevm-engine/transaction-sender/src/ops/delegate_user_decrypt.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -150,14 +150,6 @@ impl<P: Provider<Ethereum> + Clone + 'static> DelegateUserDecryptOperation<P> {
150150
return TxResult::IdemPotentError;
151151
}
152152
Err(error) => {
153-
if let Some(terminal_config_error) = try_extract_terminal_config_error(&error) {
154-
error!(
155-
error = %terminal_config_error,
156-
?delegation,
157-
"{operation} failed with non-retryable gateway coprocessor config error"
158-
);
159-
return TxResult::NonRetryableConfigError(terminal_config_error);
160-
}
161153
if is_transient_error(&error) {
162154
warn!(
163155
%error,
@@ -166,6 +158,14 @@ impl<P: Provider<Ethereum> + Clone + 'static> DelegateUserDecryptOperation<P> {
166158
);
167159
return TxResult::TransientError;
168160
}
161+
if let Some(terminal_config_error) = try_extract_terminal_config_error(&error) {
162+
error!(
163+
error = %terminal_config_error,
164+
?delegation,
165+
"{operation} failed with non-retryable gateway coprocessor config error"
166+
);
167+
return TxResult::NonRetryableConfigError(terminal_config_error);
168+
}
169169
warn!(
170170
%error,
171171
?delegation,

0 commit comments

Comments
 (0)