Skip to content

Commit

Permalink
Add receipt hash as a parameter for ProcessEvent
Browse files Browse the repository at this point in the history
  • Loading branch information
johnsaigle committed Dec 16, 2024
1 parent 3df7b65 commit 82ed1c1
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 7 deletions.
2 changes: 1 addition & 1 deletion node/cmd/transfer-verifier/transfer-verifier-evm.go
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ func runTransferVerifierEvm(cmd *cobra.Command, args []string) {

// Process observed LogMessagePublished events
case vLog := <-sub.Events():
transferVerifier.ProcessEvent(ctx, vLog)
transferVerifier.ProcessEvent(ctx, vLog, nil)
}
}
}
21 changes: 15 additions & 6 deletions node/pkg/transfer-verifier/transfer-verifier-evm.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,12 @@ const (
// the outbound transfers.
// If the return value is true, it implies that the event was processed successfully.
// If the return value is false, it implies that something serious has gone wrong.
func (tv *TransferVerifier[ethClient, Connector]) ProcessEvent(ctx context.Context, vLog *ethabi.AbiLogMessagePublished) bool {
func (tv *TransferVerifier[ethClient, Connector]) ProcessEvent(
ctx context.Context,
vLog *ethabi.AbiLogMessagePublished,
// If nil, this code will fetch the receipt using the TransferVerifier's connector.
receipt *types.Receipt,
) bool {

// Use this opportunity to prune old transaction information from the cache.
tv.pruneCache()
Expand All @@ -64,11 +69,15 @@ func (tv *TransferVerifier[ethClient, Connector]) ProcessEvent(ctx context.Conte
return true
}

// Get the full transaction receipt for this log.
receipt, txReceiptErr := tv.evmConnector.TransactionReceipt(ctx, vLog.Raw.TxHash)
if txReceiptErr != nil {
tv.logger.Warn("could not find core bridge receipt", zap.Error(txReceiptErr))
return true
if receipt == nil {
tv.logger.Debug("receipt was not passed as an argument. fetching it using the connector")
// Get the full transaction receipt for this log if it was not provided as an argument.
var txReceiptErr error
receipt, txReceiptErr = tv.evmConnector.TransactionReceipt(ctx, vLog.Raw.TxHash)
if txReceiptErr != nil {
tv.logger.Warn("could not find core bridge receipt", zap.Error(txReceiptErr))
return true
}
}

// Caching: record a new lastBlockNumber.
Expand Down

0 comments on commit 82ed1c1

Please sign in to comment.