From d41e92464b3606a78a3df3f3829a0cff25bb2c2a Mon Sep 17 00:00:00 2001 From: Tudor Malene Date: Wed, 20 Mar 2024 10:52:21 +0000 Subject: [PATCH] fix --- tools/faucet/faucet/faucet.go | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/tools/faucet/faucet/faucet.go b/tools/faucet/faucet/faucet.go index 32508550fa..c45dd4727f 100644 --- a/tools/faucet/faucet/faucet.go +++ b/tools/faucet/faucet/faucet.go @@ -3,12 +3,15 @@ package faucet import ( "context" "encoding/json" + "errors" "fmt" "math/big" "os" "sync" "time" + "github.com/ethereum/go-ethereum" + "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/log" @@ -82,14 +85,16 @@ func (f *Faucet) Fund(address *common.Address, token string, amount *big.Int) (s func (f *Faucet) validateTx(tx *types.Transaction) error { for now := time.Now(); time.Since(now) < _timeout; time.Sleep(time.Second) { receipt, err := f.client.TransactionReceipt(context.Background(), tx.Hash()) - if err != nil { - if receipt == nil { - // tx receipt is not available yet - continue - } + // end eagerly for unexpected errors + if err != nil && !errors.Is(err, ethereum.NotFound) { return fmt.Errorf("could not retrieve transaction receipt in eth_getTransactionReceipt request. Cause: %w", err) } + // try again until timeout + if receipt == nil { + continue + } + txReceiptBytes, err := receipt.MarshalJSON() if err != nil { return fmt.Errorf("could not marshal transaction receipt to JSON in eth_getTransactionReceipt request. Cause: %w", err)