From 6d4b5ea935e4cff90a2ae6af2e35d843c6523e48 Mon Sep 17 00:00:00 2001 From: colindickson Date: Mon, 15 Jul 2024 13:40:43 -0400 Subject: [PATCH 1/2] block fetcher: FetchReceipts retries if result is nil, and returns error if retries are exhausted --- blockfetcher/rpc.go | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/blockfetcher/rpc.go b/blockfetcher/rpc.go index bc6acb3b..0f279920 100644 --- a/blockfetcher/rpc.go +++ b/blockfetcher/rpc.go @@ -9,6 +9,7 @@ import ( "github.com/abourget/llerrgroup" "github.com/streamingfast/bstream" pbbstream "github.com/streamingfast/bstream/pb/sf/bstream/v1" + "github.com/streamingfast/derr" "github.com/streamingfast/eth-go/rpc" pbeth "github.com/streamingfast/firehose-ethereum/types/pb/sf/ethereum/type/v2" "go.uber.org/zap" @@ -110,10 +111,19 @@ func FetchReceipts(ctx context.Context, block *rpc.Block, client *rpc.Client) (o } hash := tx.Hash eg.Go(func() error { - receipt, err := client.TransactionReceipt(ctx, hash) + var receipt *rpc.TransactionReceipt + err := derr.RetryContext(ctx, 25, func(ctx context.Context) error { + r, err := client.TransactionReceipt(ctx, hash) + if err != nil { + return err + } + receipt = r + return nil + }) if err != nil { - return fmt.Errorf("fetching receipt for tx %q: %w", hash.Pretty(), err) + return fmt.Errorf("fetching receipt for tx %s: %w", hash.Pretty(), err) } + lock.Lock() out[hash.Pretty()] = receipt lock.Unlock() From 2b83bbd0805c0bac4e7df400219e098a159500bc Mon Sep 17 00:00:00 2001 From: colindickson Date: Tue, 16 Jul 2024 09:25:31 -0400 Subject: [PATCH 2/2] block fetcher: check if receipt is nil --- blockfetcher/rpc.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/blockfetcher/rpc.go b/blockfetcher/rpc.go index 0f279920..dc3ac588 100644 --- a/blockfetcher/rpc.go +++ b/blockfetcher/rpc.go @@ -112,11 +112,15 @@ func FetchReceipts(ctx context.Context, block *rpc.Block, client *rpc.Client) (o hash := tx.Hash eg.Go(func() error { var receipt *rpc.TransactionReceipt - err := derr.RetryContext(ctx, 25, func(ctx context.Context) error { + err := derr.RetryContext(ctx, 10, func(ctx context.Context) error { r, err := client.TransactionReceipt(ctx, hash) if err != nil { return err } + if r == nil { + return fmt.Errorf("receipt is nil") + } + receipt = r return nil })