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

Commit

Permalink
feat(proposer): improve proposer error messages (#756)
Browse files Browse the repository at this point in the history
  • Loading branch information
davidtaikocha committed Apr 24, 2024
1 parent 42af8ee commit e492321
Showing 1 changed file with 24 additions and 1 deletion.
25 changes: 24 additions & 1 deletion proposer/proposer.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"context"
"fmt"
"math/rand"
"strings"
"sync"
"time"

Expand Down Expand Up @@ -363,7 +364,29 @@ func (p *Proposer) ProposeTxLists(ctx context.Context, txListsBytes [][]byte) []
txCandidates[i] = *candidate
}

return p.txSender.SendAndWaitDetailed("proposeBlock", txCandidates...)
// Send the transactions to the TaikoL1 contract, and if any of them fails, try
// to parse the custom error.
errors := p.txSender.SendAndWaitDetailed("proposeBlock", txCandidates...)
for i, err := range errors {
if err == nil {
continue
}

// If a transaction is reverted on chain, the error string returned by txSender will like this:
// fmt.Errorf("%w purpose: %v hash: %v", ErrTransactionReverted, txPurpose, rcpt.Receipt.TxHash)
// Then we try parsing the custom error for more details in log.
if strings.Contains("purpose: ", err.Error()) && strings.Contains("hash: ", err.Error()) {
txHash := strings.Split(err.Error(), "hash: ")[1]
receipt, err := p.rpc.L1.TransactionReceipt(ctx, common.HexToHash(txHash))
if err != nil {
log.Error("Failed to fetch receipt", "txHash", txHash, "error", err)
continue
}
errors[i] = encoding.TryParsingCustomErrorFromReceipt(ctx, p.rpc.L1, p.proposerAddress, receipt)
}
}

return errors
}

// updateProposingTicker updates the internal proposing timer.
Expand Down

0 comments on commit e492321

Please sign in to comment.