Skip to content
This repository was archived by the owner on May 11, 2024. It is now read-only.

Commit d5c7775

Browse files
committed
feat: update ProposeTxLists
1 parent d7bab11 commit d5c7775

File tree

1 file changed

+24
-14
lines changed

1 file changed

+24
-14
lines changed

proposer/proposer.go

+24-14
Original file line numberDiff line numberDiff line change
@@ -320,23 +320,11 @@ func (p *Proposer) ProposeOp(ctx context.Context) error {
320320
}
321321

322322
for i, err := range p.ProposeTxLists(ctx, txListsBytes) {
323-
var errMsg = err
324323
if err != nil {
325-
// If a transaction is reverted on chain, the error string will like this:
326-
// fmt.Errorf("%w purpose: %v hash: %v", ErrTransactionReverted, txPurpose, rcpt.Receipt.TxHash)
327-
// Then we try parsing the custom error for more details in log.
328-
if strings.Contains("purpose: ", err.Error()) && strings.Contains("hash: ", err.Error()) {
329-
txHash := strings.Split(err.Error(), "hash: ")[1]
330-
receipt, err := p.rpc.L1.TransactionReceipt(ctx, common.HexToHash(txHash))
331-
if err != nil {
332-
return err
333-
}
334-
errMsg = encoding.TryParsingCustomErrorFromReceipt(ctx, p.rpc.L1, p.proposerAddress, receipt)
335-
}
336324
log.Error(
337325
"Failed to send TaikoL1.proposeBlock transaction",
338326
"index", i,
339-
"error", errMsg,
327+
"error", err,
340328
)
341329
continue
342330
}
@@ -376,7 +364,29 @@ func (p *Proposer) ProposeTxLists(ctx context.Context, txListsBytes [][]byte) []
376364
txCandidates[i] = *candidate
377365
}
378366

379-
return p.txSender.SendAndWaitDetailed("proposeBlock", txCandidates...)
367+
// Send the transactions to the TaikoL1 contract, and if any of them fails, try
368+
// to parse the custom error.
369+
errors := p.txSender.SendAndWaitDetailed("proposeBlock", txCandidates...)
370+
for i, err := range errors {
371+
if err == nil {
372+
continue
373+
}
374+
375+
// If a transaction is reverted on chain, the error string returned by txSender will like this:
376+
// fmt.Errorf("%w purpose: %v hash: %v", ErrTransactionReverted, txPurpose, rcpt.Receipt.TxHash)
377+
// Then we try parsing the custom error for more details in log.
378+
if strings.Contains("purpose: ", err.Error()) && strings.Contains("hash: ", err.Error()) {
379+
txHash := strings.Split(err.Error(), "hash: ")[1]
380+
receipt, err := p.rpc.L1.TransactionReceipt(ctx, common.HexToHash(txHash))
381+
if err != nil {
382+
log.Error("Failed to fetch receipt", "txHash", txHash, "error", err)
383+
continue
384+
}
385+
errors[i] = encoding.TryParsingCustomErrorFromReceipt(ctx, p.rpc.L1, p.proposerAddress, receipt)
386+
}
387+
}
388+
389+
return errors
380390
}
381391

382392
// updateProposingTicker updates the internal proposing timer.

0 commit comments

Comments
 (0)