Skip to content

Commit 4e1dc6d

Browse files
PatStilesuri-99
andauthored
feat(sdk): Add msg to batcher errors telling a users their funds have not been spent (#1725)
Co-authored-by: Uriel Mihura <[email protected]>
1 parent 6845473 commit 4e1dc6d

File tree

1 file changed

+33
-18
lines changed

1 file changed

+33
-18
lines changed

batcher/aligned-sdk/src/communication/messaging.rs

Lines changed: 33 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -175,49 +175,52 @@ async fn handle_batcher_response(msg: Message) -> Result<BatchInclusionData, Sub
175175
Ok(batch_inclusion_data)
176176
}
177177
Ok(SubmitProofResponseMessage::InvalidNonce) => {
178-
error!("Batcher responded with invalid nonce");
178+
error!("Batcher responded with invalid nonce. Funds have not been spent.");
179179
Err(SubmitError::InvalidNonce)
180180
}
181181
Ok(SubmitProofResponseMessage::InvalidSignature) => {
182-
error!("Batcher responded with invalid signature");
182+
error!("Batcher responded with invalid signature. Funds have not been spent.");
183183
Err(SubmitError::InvalidSignature)
184184
}
185185
Ok(SubmitProofResponseMessage::ProofTooLarge) => {
186-
error!("Batcher responded with proof too large");
186+
error!("Batcher responded with proof too large. Funds have not been spent.");
187187
Err(SubmitError::ProofTooLarge)
188188
}
189189
Ok(SubmitProofResponseMessage::InvalidMaxFee) => {
190-
error!("Batcher responded with invalid max fee");
190+
error!("Batcher responded with invalid max fee. Funds have not been spent.");
191191
Err(SubmitError::InvalidMaxFee)
192192
}
193193
Ok(SubmitProofResponseMessage::InsufficientBalance(addr)) => {
194-
error!("Batcher responded with insufficient balance");
194+
error!("Batcher responded with insufficient balance. Funds have not been spent for submittions which had insufficient balance.");
195195
Err(SubmitError::InsufficientBalance(addr))
196196
}
197197
Ok(SubmitProofResponseMessage::InvalidChainId) => {
198-
error!("Batcher responded with invalid chain id");
198+
error!("Batcher responded with invalid chain id. Funds have not been spent.");
199199
Err(SubmitError::InvalidChainId)
200200
}
201201
Ok(SubmitProofResponseMessage::InvalidReplacementMessage) => {
202-
error!("Batcher responded with invalid replacement message");
202+
error!(
203+
"Batcher responded with invalid replacement message. Funds have not been spent."
204+
);
203205
Err(SubmitError::InvalidReplacementMessage)
204206
}
205207
Ok(SubmitProofResponseMessage::AddToBatchError) => {
206-
error!("Batcher responded with add to batch error");
208+
error!("Batcher responded with add to batch error. Funds have not been spent.");
207209
Err(SubmitError::AddToBatchError)
208210
}
209211
Ok(SubmitProofResponseMessage::EthRpcError) => {
210-
error!("Batcher experienced Eth RPC connection error");
212+
error!("Batcher experienced Eth RPC connection error. Funds have not been spent.");
211213
Err(SubmitError::EthereumProviderError(
212-
"Batcher experienced Eth RPC connection error".to_string(),
214+
"Batcher experienced Eth RPC connection error. Funds have not been spent."
215+
.to_string(),
213216
))
214217
}
215218
Ok(SubmitProofResponseMessage::InvalidPaymentServiceAddress(
216219
received_addr,
217220
expected_addr,
218221
)) => {
219222
error!(
220-
"Batcher responded with invalid payment service address: {:?}, expected: {:?}",
223+
"Batcher responded with invalid payment service address: {:?}, expected: {:?}. Funds have not been spent.",
221224
received_addr, expected_addr
222225
);
223226
Err(SubmitError::InvalidPaymentServiceAddress(
@@ -226,11 +229,17 @@ async fn handle_batcher_response(msg: Message) -> Result<BatchInclusionData, Sub
226229
))
227230
}
228231
Ok(SubmitProofResponseMessage::InvalidProof(reason)) => {
229-
error!("Batcher responded with invalid proof: {}", reason);
232+
error!(
233+
"Batcher responded with invalid proof: {}. Funds have not been spent.",
234+
reason
235+
);
230236
Err(SubmitError::InvalidProof(reason))
231237
}
232238
Ok(SubmitProofResponseMessage::CreateNewTaskError(merkle_root, error)) => {
233-
error!("Batcher responded with create new task error: {}", error);
239+
error!(
240+
"Batcher responded with create new task error: {}. Funds have not been spent.",
241+
error
242+
);
234243
Err(SubmitError::BatchSubmissionFailed(
235244
"Could not create task with merkle root ".to_owned()
236245
+ &merkle_root
@@ -239,22 +248,28 @@ async fn handle_batcher_response(msg: Message) -> Result<BatchInclusionData, Sub
239248
))
240249
}
241250
Ok(SubmitProofResponseMessage::ProtocolVersion(_)) => {
242-
error!("Batcher responded with protocol version instead of batch inclusion data");
251+
error!("Batcher responded with protocol version instead of batch inclusion data. Funds have not been spent.");
243252
Err(SubmitError::UnexpectedBatcherResponse(
244-
"Batcher responded with protocol version instead of batch inclusion data"
253+
"Batcher responded with protocol version instead of batch inclusion data. Funds have not been spent."
245254
.to_string(),
246255
))
247256
}
248257
Ok(SubmitProofResponseMessage::BatchReset) => {
249-
error!("Batcher responded with batch reset");
258+
error!("Batcher responded with batch reset. Funds have not been spent.");
250259
Err(SubmitError::ProofQueueFlushed)
251260
}
252261
Ok(SubmitProofResponseMessage::Error(e)) => {
253-
error!("Batcher responded with error: {}", e);
262+
error!(
263+
"Batcher responded with error: {}. Funds have not been spent.",
264+
e
265+
);
254266
Err(SubmitError::GenericError(e))
255267
}
256268
Err(e) => {
257-
error!("Error while deserializing batch inclusion data: {}", e);
269+
error!(
270+
"Error while deserializing batch inclusion data: {}. Funds have not been spent.",
271+
e
272+
);
258273
Err(SubmitError::SerializationError(e))
259274
}
260275
}

0 commit comments

Comments
 (0)