|
1 |
| -use crate::receipts::{TxStatus, check_tx_status, format_receipt}; |
| 1 | +use crate::receipts::{PendingReceiptError, TxStatus, check_tx_status, format_receipt}; |
2 | 2 | use alloy_chains::Chain;
|
3 | 3 | use alloy_primitives::{
|
4 | 4 | B256,
|
@@ -207,20 +207,37 @@ impl ScriptProgress {
|
207 | 207 | let mut tasks = futures::stream::iter(futs).buffer_unordered(10);
|
208 | 208 |
|
209 | 209 | let mut errors: Vec<String> = vec![];
|
| 210 | + let mut discarded_transactions = false; |
210 | 211 |
|
211 | 212 | while let Some((tx_hash, result)) = tasks.next().await {
|
212 | 213 | match result {
|
213 | 214 | Err(err) => {
|
214 |
| - errors.push(format!("Failure on receiving a receipt for {tx_hash:?}:\n{err}")); |
215 |
| - |
216 |
| - seq_progress.inner.write().finish_tx_spinner(tx_hash); |
| 215 | + // Check if this is a retry error for pending receipts |
| 216 | + if err.downcast_ref::<PendingReceiptError>().is_some() { |
| 217 | + // We've already retried several times with sleep, but the receipt is still |
| 218 | + // pending |
| 219 | + discarded_transactions = true; |
| 220 | + deployment_sequence.remove_pending(tx_hash); |
| 221 | + seq_progress |
| 222 | + .inner |
| 223 | + .write() |
| 224 | + .finish_tx_spinner_with_msg(tx_hash, &err.to_string())?; |
| 225 | + } else { |
| 226 | + errors.push(format!( |
| 227 | + "Failure on receiving a receipt for {tx_hash:?}:\n{err}" |
| 228 | + )); |
| 229 | + seq_progress.inner.write().finish_tx_spinner(tx_hash); |
| 230 | + } |
217 | 231 | }
|
218 | 232 | Ok(TxStatus::Dropped) => {
|
219 | 233 | // We want to remove it from pending so it will be re-broadcast.
|
220 | 234 | deployment_sequence.remove_pending(tx_hash);
|
221 |
| - errors.push(format!("Transaction dropped from the mempool: {tx_hash:?}")); |
| 235 | + discarded_transactions = true; |
222 | 236 |
|
223 |
| - seq_progress.inner.write().finish_tx_spinner(tx_hash); |
| 237 | + let msg = format!( |
| 238 | + "Transaction {tx_hash:?} dropped from the mempool. It will be retried when using --resume." |
| 239 | + ); |
| 240 | + seq_progress.inner.write().finish_tx_spinner_with_msg(tx_hash, &msg)?; |
224 | 241 | }
|
225 | 242 | Ok(TxStatus::Success(receipt)) => {
|
226 | 243 | trace!(tx_hash=?tx_hash, "received tx receipt");
|
@@ -249,11 +266,20 @@ impl ScriptProgress {
|
249 | 266 | // print any errors
|
250 | 267 | if !errors.is_empty() {
|
251 | 268 | let mut error_msg = errors.join("\n");
|
252 |
| - if !deployment_sequence.pending.is_empty() { |
253 |
| - error_msg += "\n\n Add `--resume` to your command to try and continue broadcasting |
254 |
| - the transactions." |
| 269 | + |
| 270 | + // Add information about using --resume if necessary |
| 271 | + if !deployment_sequence.pending.is_empty() || discarded_transactions { |
| 272 | + error_msg += r#" |
| 273 | +
|
| 274 | +Add `--resume` to your command to try and continue broadcasting the transactions. This will attempt to resend transactions that were discarded by the RPC."#; |
255 | 275 | }
|
| 276 | + |
256 | 277 | eyre::bail!(error_msg);
|
| 278 | + } else if discarded_transactions { |
| 279 | + // If we have discarded transactions but no errors, still inform the user |
| 280 | + sh_warn!( |
| 281 | + "Some transactions were discarded by the RPC node. Use `--resume` to retry these transactions." |
| 282 | + )?; |
257 | 283 | }
|
258 | 284 |
|
259 | 285 | Ok(())
|
|
0 commit comments