Skip to content

Commit 6873cbe

Browse files
committed
fix: exiting tx receipt wait when context times out
1 parent 61a64df commit 6873cbe

File tree

2 files changed

+8
-9
lines changed

2 files changed

+8
-9
lines changed

core/chainio/avs_writer.go

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ import (
1111
"github.com/Layr-Labs/eigensdk-go/chainio/clients/eth"
1212
"github.com/Layr-Labs/eigensdk-go/logging"
1313
"github.com/Layr-Labs/eigensdk-go/signer"
14-
"github.com/ethereum/go-ethereum"
1514
"github.com/ethereum/go-ethereum/accounts/abi/bind"
1615
"github.com/ethereum/go-ethereum/common"
1716
"github.com/ethereum/go-ethereum/core/types"
@@ -120,7 +119,7 @@ func (w *AvsWriter) SendAggregatedResponse(batchIdentifierHash [32]byte, batchMe
120119
return nil, err
121120
}
122121
}
123-
ctx, cancel := context.WithTimeout(context.Background(), time.Millisecond*10)
122+
ctx, cancel := context.WithTimeout(context.Background(), time.Second*36)
124123
defer cancel()
125124
receipt, err := utils.WaitForTransactionReceipt(w.Client, ctx, tx.Hash())
126125

@@ -133,14 +132,10 @@ func (w *AvsWriter) SendAggregatedResponse(batchIdentifierHash [32]byte, batchMe
133132
}
134133
}
135134

136-
// transaction not included in block, try again
137-
if err == ethereum.NotFound {
138-
w.logger.Infof("Transaction not included in block will try again bumping the fee")
139-
continue
140-
} else if err == context.DeadlineExceeded {
135+
// this means we have reached the timeout (after three blocks it hasn't been included)
136+
// so we try again by bumping the fee to make sure its included
137+
if err != nil {
141138
continue
142-
} else {
143-
return receipt, err
144139
}
145140

146141
}

core/utils/eth_client_utils.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@ const sleepTime = 5 * time.Second
1818
func WaitForTransactionReceipt(client eth.InstrumentedClient, ctx context.Context, txHash gethcommon.Hash) (*types.Receipt, error) {
1919
for i := 0; i < maxRetries; i++ {
2020
receipt, err := client.TransactionReceipt(ctx, txHash)
21+
// if context has timed out, return
22+
if ctx.Err() != nil {
23+
return nil, ctx.Err()
24+
}
2125
if err != nil {
2226
time.Sleep(sleepTime)
2327
} else {

0 commit comments

Comments
 (0)