Skip to content

Commit 3345d4a

Browse files
authored
fix: use exponential backoff parameters correctly (#1409)
1 parent 2c45fb2 commit 3345d4a

File tree

3 files changed

+38
-10
lines changed

3 files changed

+38
-10
lines changed

aggregator/pkg/aggregator.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -393,15 +393,17 @@ func (agg *Aggregator) AddNewTask(batchMerkleRoot [32]byte, senderAddress [20]by
393393
// |---RETRYABLE---|
394394

395395
/*
396+
InitializeNewTask
397+
Initialize a new task in the BLS Aggregation service
396398
- Errors:
397399
Permanent:
398400
- TaskAlreadyInitializedError (Permanent): Task is already intialized in the BLS Aggregation service (https://github.com/Layr-Labs/eigensdk-go/blob/dev/services/bls_aggregation/blsagg.go#L27).
399401
Transient:
400402
- All others.
401-
- Retry times (3 retries): 12 sec (1 Blocks), 24 sec (2 Blocks), 48 sec (4 Blocks)
403+
- Retry times (3 retries): 1 sec, 2 sec, 4 sec
402404
*/
403405
func (agg *Aggregator) InitializeNewTask(batchIndex uint32, taskCreatedBlock uint32, quorumNums eigentypes.QuorumNums, quorumThresholdPercentages eigentypes.QuorumThresholdPercentages, timeToExpiry time.Duration) error {
404-
initilizeNewTask_func := func() error {
406+
initializeNewTask_func := func() error {
405407
err := agg.blsAggregationService.InitializeNewTask(batchIndex, taskCreatedBlock, quorumNums, quorumThresholdPercentages, timeToExpiry)
406408
if err != nil {
407409
// Task is already initialized
@@ -411,7 +413,7 @@ func (agg *Aggregator) InitializeNewTask(batchIndex uint32, taskCreatedBlock uin
411413
}
412414
return err
413415
}
414-
return retry.Retry(initilizeNewTask_func, retry.MinDelayChain, retry.RetryFactor, retry.NumRetries, retry.MaxIntervalChain, retry.MaxElapsedTime)
416+
return retry.Retry(initializeNewTask_func, retry.MinDelay, retry.RetryFactor, retry.NumRetries, retry.MaxInterval, retry.MaxElapsedTime)
415417
}
416418

417419
// Long-lived goroutine that periodically checks and removes old Tasks from stored Maps

core/chainio/retryable.go

Lines changed: 30 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ import (
1616
// |---AVS_WRITER---|
1717

1818
/*
19+
RespondToTaskV2Retryable
20+
Send a transaction to the AVS contract to respond to a task.
1921
- All errors are considered Transient Errors
2022
- Retry times (3 retries): 12 sec (1 Blocks), 24 sec (2 Blocks), 48 sec (4 Blocks)
2123
- NOTE: Contract call reverts are not considered `PermanentError`'s as block reorg's may lead to contract call revert in which case the aggregator should retry.
@@ -34,8 +36,10 @@ func (w *AvsWriter) RespondToTaskV2Retryable(opts *bind.TransactOpts, batchMerkl
3436
}
3537

3638
/*
39+
BatchesStateRetryable
40+
Get the state of a batch from the AVS contract.
3741
- All errors are considered Transient Errors
38-
- Retry times (3 retries): 12 sec (1 Blocks), 24 sec (2 Blocks), 48 sec (4 Blocks)
42+
- Retry times (3 retries): 1 sec, 2 sec, 4 sec
3943
*/
4044
func (w *AvsWriter) BatchesStateRetryable(opts *bind.CallOpts, arg0 [32]byte) (struct {
4145
TaskCreatedBlock uint32
@@ -56,12 +60,14 @@ func (w *AvsWriter) BatchesStateRetryable(opts *bind.CallOpts, arg0 [32]byte) (s
5660
}
5761
return state, err
5862
}
59-
return retry.RetryWithData(batchesState_func, retry.MinDelayChain, retry.RetryFactor, retry.NumRetries, retry.MaxIntervalChain, retry.MaxElapsedTime)
63+
return retry.RetryWithData(batchesState_func, retry.MinDelay, retry.RetryFactor, retry.NumRetries, retry.MaxInterval, retry.MaxElapsedTime)
6064
}
6165

6266
/*
67+
BatcherBalancesRetryable
68+
Get the balance of a batcher from the AVS contract.
6369
- All errors are considered Transient Errors
64-
- Retry times (3 retries): 12 sec (1 Blocks), 24 sec (2 Blocks), 48 sec (4 Blocks)
70+
- Retry times (3 retries): 1 sec, 2 sec, 4 sec
6571
*/
6672
func (w *AvsWriter) BatcherBalancesRetryable(opts *bind.CallOpts, senderAddress common.Address) (*big.Int, error) {
6773
batcherBalances_func := func() (*big.Int, error) {
@@ -73,10 +79,14 @@ func (w *AvsWriter) BatcherBalancesRetryable(opts *bind.CallOpts, senderAddress
7379
}
7480
return batcherBalance, err
7581
}
76-
return retry.RetryWithData(batcherBalances_func, retry.MinDelayChain, retry.RetryFactor, retry.NumRetries, retry.MaxIntervalChain, retry.MaxElapsedTime)
82+
return retry.RetryWithData(batcherBalances_func, retry.MinDelay, retry.RetryFactor, retry.NumRetries, retry.MaxInterval, retry.MaxElapsedTime)
7783
}
7884

7985
/*
86+
BalanceAtRetryable
87+
Get the balance of aggregatorAddress at blockNumber.
88+
If blockNumber is nil, it gets the latest balance.
89+
TODO: it gets the balance from an Address, not necessarily an aggregator. The name of the parameter should be changed.
8090
- All errors are considered Transient Errors
8191
- Retry times (3 retries): 1 sec, 2 sec, 4 sec.
8292
*/
@@ -96,6 +106,8 @@ func (w *AvsWriter) BalanceAtRetryable(ctx context.Context, aggregatorAddress co
96106
// |---AVS_SUBSCRIBER---|
97107

98108
/*
109+
BlockNumberRetryable
110+
Get the latest block number from Ethereum
99111
- All errors are considered Transient Errors
100112
- Retry times (3 retries): 1 sec, 2 sec, 4 sec.
101113
*/
@@ -113,6 +125,8 @@ func (s *AvsSubscriber) BlockNumberRetryable(ctx context.Context) (uint64, error
113125
}
114126

115127
/*
128+
FilterBatchV2Retryable
129+
Get NewBatchV2 logs from the AVS contract.
116130
- All errors are considered Transient Errors
117131
- Retry times (3 retries): 1 sec, 2 sec, 4 sec.
118132
*/
@@ -124,6 +138,8 @@ func (s *AvsSubscriber) FilterBatchV2Retryable(opts *bind.FilterOpts, batchMerkl
124138
}
125139

126140
/*
141+
FilterBatchV3Retryable
142+
Get NewBatchV3 logs from the AVS contract.
127143
- All errors are considered Transient Errors
128144
- Retry times (3 retries): 1 sec, 2 sec, 4 sec.
129145
*/
@@ -135,8 +151,10 @@ func (s *AvsSubscriber) FilterBatchV3Retryable(opts *bind.FilterOpts, batchMerkl
135151
}
136152

137153
/*
154+
BatchesStateRetryable
155+
Get the state of a batch from the AVS contract.
138156
- All errors are considered Transient Errors
139-
- Retry times (3 retries): 12 sec (1 Blocks), 24 sec (2 Blocks), 48 sec (4 Blocks)
157+
- Retry times (3 retries): 1 sec, 2 sec, 4 sec
140158
*/
141159
func (s *AvsSubscriber) BatchesStateRetryable(opts *bind.CallOpts, arg0 [32]byte) (struct {
142160
TaskCreatedBlock uint32
@@ -151,10 +169,12 @@ func (s *AvsSubscriber) BatchesStateRetryable(opts *bind.CallOpts, arg0 [32]byte
151169
return s.AvsContractBindings.ServiceManager.ContractAlignedLayerServiceManagerCaller.BatchesState(opts, arg0)
152170
}
153171

154-
return retry.RetryWithData(batchState_func, retry.MinDelayChain, retry.RetryFactor, retry.NumRetries, retry.MaxIntervalChain, retry.MaxElapsedTime)
172+
return retry.RetryWithData(batchState_func, retry.MinDelay, retry.RetryFactor, retry.NumRetries, retry.MaxInterval, retry.MaxElapsedTime)
155173
}
156174

157175
/*
176+
SubscribeNewHeadRetryable
177+
Subscribe to new heads from the Ethereum node.
158178
- All errors are considered Transient Errors
159179
- Retry times (3 retries): 1 sec, 2 sec, 4 sec.
160180
*/
@@ -172,6 +192,8 @@ func (s *AvsSubscriber) SubscribeNewHeadRetryable(ctx context.Context, c chan<-
172192
}
173193

174194
/*
195+
SubscribeToNewTasksV2Retryable
196+
Subscribe to NewBatchV2 logs from the AVS contract.
175197
- All errors are considered Transient Errors
176198
- Retry times (3 retries): 1 sec, 2 sec, 4 sec.
177199
*/
@@ -188,6 +210,8 @@ func SubscribeToNewTasksV2Retryable(
188210
}
189211

190212
/*
213+
SubscribeToNewTasksV3Retryable
214+
Subscribe to NewBatchV3 logs from the AVS contract.
191215
- All errors are considered Transient Errors
192216
- Retry times (3 retries): 1 sec, 2 sec, 4 sec.
193217
*/

core/utils/eth_client_utils.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,9 @@ import (
1717
// If the receipt is still unavailable after `waitTimeout`, it will return an error.
1818
//
1919
// Note: The `time.Second * 2` is set as the max interval in the retry mechanism because we can't reliably measure the specific time the tx will be included in a block.
20-
// Setting a higher value will imply doing less retries across the waitTimeout and so we might lose the receipt
20+
// Setting a higher value will imply doing less retries across the waitTimeout, and so we might lose the receipt
21+
// All errors are considered Transient Errors
22+
// - Retry times: 0.5s, 1s, 2s, 2s, 2s, ... until it reaches waitTimeout
2123
func WaitForTransactionReceiptRetryable(client eth.InstrumentedClient, fallbackClient eth.InstrumentedClient, txHash gethcommon.Hash, waitTimeout time.Duration) (*types.Receipt, error) {
2224
receipt_func := func() (*types.Receipt, error) {
2325
receipt, err := client.TransactionReceipt(context.Background(), txHash)

0 commit comments

Comments
 (0)