Skip to content

Commit ea9affb

Browse files
committed
revert MaxNumRetries -> NumRetries, change default name to rpc
1 parent 55a197e commit ea9affb

8 files changed

Lines changed: 32 additions & 32 deletions

File tree

aggregator/pkg/aggregator.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -419,7 +419,7 @@ func (agg *Aggregator) InitializeNewTask(batchIndex uint32, taskCreatedBlock uin
419419
}
420420
return err
421421
}
422-
return retry.Retry(initializeNewTask_func, retry.DefaultRetryConfig())
422+
return retry.Retry(initializeNewTask_func, retry.RpcRetryConfig())
423423
}
424424

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

aggregator/pkg/server.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,5 +158,5 @@ func (agg *Aggregator) GetTaskIndexRetryable(batchIdentifierHash [32]byte) (uint
158158
return taskIndex, nil
159159
}
160160
}
161-
return retry.RetryWithData(getTaskIndex_func, retry.DefaultRetryConfig())
161+
return retry.RetryWithData(getTaskIndex_func, retry.RpcRetryConfig())
162162
}

core/chainio/avs_subscriber.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,13 +68,13 @@ func (s *AvsSubscriber) SubscribeToNewTasksV2(newTaskCreatedChan chan *servicema
6868
// Subscribe to new tasks
6969
sub, err := SubscribeToNewTasksV2Retryable(&bind.WatchOpts{}, s.AvsContractBindings.ServiceManager, internalChannel, nil)
7070
if err != nil {
71-
s.logger.Error("Primary failed to subscribe to new AlignedLayer V2 tasks after %d retries", retry.DefaultMaxNumRetries, "err", err)
71+
s.logger.Error("Primary failed to subscribe to new AlignedLayer V2 tasks after %d retries", retry.DefaultNumRetries, "err", err)
7272
return nil, err
7373
}
7474

7575
subFallback, err := SubscribeToNewTasksV2Retryable(&bind.WatchOpts{}, s.AvsContractBindings.ServiceManagerFallback, internalChannel, nil)
7676
if err != nil {
77-
s.logger.Error("Fallback failed to subscribe to new AlignedLayer V2 tasks after %d retries", retry.DefaultMaxNumRetries, "err", err)
77+
s.logger.Error("Fallback failed to subscribe to new AlignedLayer V2 tasks after %d retries", retry.DefaultNumRetries, "err", err)
7878
return nil, err
7979
}
8080
s.logger.Info("Subscribed to new AlignedLayer V2 tasks")

core/chainio/avs_writer.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -94,13 +94,13 @@ func (w *AvsWriter) SendAggregatedResponse(batchIdentifierHash [32]byte, batchMe
9494
i := 0
9595

9696
// Set Retry config for RespondToTaskV2
97-
respondToTaskV2Config := retry.DefaultRetryConfig()
97+
respondToTaskV2Config := retry.RpcRetryConfig()
9898
respondToTaskV2Config.MaxElapsedTime = 0
9999

100100
// Set Retry config for WaitForTxRetryable
101-
waitForTxConfig := retry.DefaultRetryConfig()
101+
waitForTxConfig := retry.RpcRetryConfig()
102102
waitForTxConfig.MaxInterval = 2 * time.Second
103-
waitForTxConfig.MaxNumRetries = 0
103+
waitForTxConfig.NumRetries = 0
104104
waitForTxConfig.MaxElapsedTime = timeToWaitBeforeBump
105105

106106
respondToTaskV2Func := func() (*types.Receipt, error) {

core/chainio/retryable.go

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ func (w *AvsWriter) BatchesStateRetryable(opts *bind.CallOpts, arg0 [32]byte) (s
7171
Responded bool
7272
RespondToTaskFeeLimit *big.Int
7373
}, error) {
74-
return retry.RetryWithData(BatchesState(w, opts, arg0), retry.DefaultRetryConfig())
74+
return retry.RetryWithData(BatchesState(w, opts, arg0), retry.RpcRetryConfig())
7575
}
7676

7777
func BatcherBalances(w *AvsWriter, opts *bind.CallOpts, senderAddress common.Address) func() (*big.Int, error) {
@@ -94,7 +94,7 @@ Get the balance of a batcher from the AVS contract.
9494
- Retry times (3 retries): 1 sec, 2 sec, 4 sec
9595
*/
9696
func (w *AvsWriter) BatcherBalancesRetryable(opts *bind.CallOpts, senderAddress common.Address) (*big.Int, error) {
97-
return retry.RetryWithData(BatcherBalances(w, opts, senderAddress), retry.DefaultRetryConfig())
97+
return retry.RetryWithData(BatcherBalances(w, opts, senderAddress), retry.RpcRetryConfig())
9898
}
9999

100100
func BalanceAt(w *AvsWriter, ctx context.Context, aggregatorAddress common.Address, blockNumber *big.Int) func() (*big.Int, error) {
@@ -119,7 +119,7 @@ TODO: it gets the balance from an Address, not necessarily an aggregator. The na
119119
- Retry times (3 retries): 1 sec, 2 sec, 4 sec.
120120
*/
121121
func (w *AvsWriter) BalanceAtRetryable(ctx context.Context, aggregatorAddress common.Address, blockNumber *big.Int) (*big.Int, error) {
122-
return retry.RetryWithData(BalanceAt(w, ctx, aggregatorAddress, blockNumber), retry.DefaultRetryConfig())
122+
return retry.RetryWithData(BalanceAt(w, ctx, aggregatorAddress, blockNumber), retry.RpcRetryConfig())
123123
}
124124

125125
// |---AVS_SUBSCRIBER---|
@@ -144,7 +144,7 @@ Get the latest block number from Ethereum
144144
- Retry times (3 retries): 1 sec, 2 sec, 4 sec.
145145
*/
146146
func (s *AvsSubscriber) BlockNumberRetryable(ctx context.Context) (uint64, error) {
147-
return retry.RetryWithData(BlockNumber(s, ctx), retry.DefaultRetryConfig())
147+
return retry.RetryWithData(BlockNumber(s, ctx), retry.RpcRetryConfig())
148148
}
149149

150150
func FilterBatchV2(s *AvsSubscriber, opts *bind.FilterOpts, batchMerkleRoot [][32]byte) func() (*servicemanager.ContractAlignedLayerServiceManagerNewBatchV2Iterator, error) {
@@ -165,7 +165,7 @@ Get NewBatchV2 logs from the AVS contract.
165165
- Retry times (3 retries): 1 sec, 2 sec, 4 sec.
166166
*/
167167
func (s *AvsSubscriber) FilterBatchV2Retryable(opts *bind.FilterOpts, batchMerkleRoot [][32]byte) (*servicemanager.ContractAlignedLayerServiceManagerNewBatchV2Iterator, error) {
168-
return retry.RetryWithData(FilterBatchV2(s, opts, batchMerkleRoot), retry.DefaultRetryConfig())
168+
return retry.RetryWithData(FilterBatchV2(s, opts, batchMerkleRoot), retry.RpcRetryConfig())
169169
}
170170

171171
func FilterBatchV3(s *AvsSubscriber, opts *bind.FilterOpts, batchMerkleRoot [][32]byte) func() (*servicemanager.ContractAlignedLayerServiceManagerNewBatchV3Iterator, error) {
@@ -186,7 +186,7 @@ Get NewBatchV3 logs from the AVS contract.
186186
- Retry times (3 retries): 1 sec, 2 sec, 4 sec.
187187
*/
188188
func (s *AvsSubscriber) FilterBatchV3Retryable(opts *bind.FilterOpts, batchMerkleRoot [][32]byte) (*servicemanager.ContractAlignedLayerServiceManagerNewBatchV3Iterator, error) {
189-
return retry.RetryWithData(FilterBatchV3(s, opts, batchMerkleRoot), retry.DefaultRetryConfig())
189+
return retry.RetryWithData(FilterBatchV3(s, opts, batchMerkleRoot), retry.RpcRetryConfig())
190190
}
191191

192192
func BatchState(s *AvsSubscriber, opts *bind.CallOpts, arg0 [32]byte) func() (struct {
@@ -220,7 +220,7 @@ func (s *AvsSubscriber) BatchesStateRetryable(opts *bind.CallOpts, arg0 [32]byte
220220
RespondToTaskFeeLimit *big.Int
221221
}, error) {
222222

223-
return retry.RetryWithData(BatchState(s, opts, arg0), retry.DefaultRetryConfig())
223+
return retry.RetryWithData(BatchState(s, opts, arg0), retry.RpcRetryConfig())
224224
}
225225

226226
func SubscribeNewHead(s *AvsSubscriber, ctx context.Context, c chan<- *types.Header) func() (ethereum.Subscription, error) {
@@ -243,7 +243,7 @@ Subscribe to new heads from the Ethereum node.
243243
- Retry times (3 retries): 1 sec, 2 sec, 4 sec.
244244
*/
245245
func (s *AvsSubscriber) SubscribeNewHeadRetryable(ctx context.Context, c chan<- *types.Header) (ethereum.Subscription, error) {
246-
return retry.RetryWithData(SubscribeNewHead(s, ctx, c), retry.DefaultRetryConfig())
246+
return retry.RetryWithData(SubscribeNewHead(s, ctx, c), retry.RpcRetryConfig())
247247
}
248248

249249
func SubscribeToNewTasksV2(
@@ -270,7 +270,7 @@ func SubscribeToNewTasksV2Retryable(
270270
newTaskCreatedChan chan *servicemanager.ContractAlignedLayerServiceManagerNewBatchV2,
271271
batchMerkleRoot [][32]byte,
272272
) (event.Subscription, error) {
273-
return retry.RetryWithData(SubscribeToNewTasksV2(opts, serviceManager, newTaskCreatedChan, batchMerkleRoot), retry.DefaultRetryConfig())
273+
return retry.RetryWithData(SubscribeToNewTasksV2(opts, serviceManager, newTaskCreatedChan, batchMerkleRoot), retry.RpcRetryConfig())
274274
}
275275

276276
func SubscribeToNewTasksV3(
@@ -297,5 +297,5 @@ func SubscribeToNewTasksV3Retryable(
297297
newTaskCreatedChan chan *servicemanager.ContractAlignedLayerServiceManagerNewBatchV3,
298298
batchMerkleRoot [][32]byte,
299299
) (event.Subscription, error) {
300-
return retry.RetryWithData(SubscribeToNewTasksV3(opts, serviceManager, newTaskCreatedChan, batchMerkleRoot), retry.DefaultRetryConfig())
300+
return retry.RetryWithData(SubscribeToNewTasksV3(opts, serviceManager, newTaskCreatedChan, batchMerkleRoot), retry.RpcRetryConfig())
301301
}

core/retry.go

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ const (
3030
DefaultMaxElapsedTime = 0 * time.Second // Maximum time all retries may take. `0` corresponds to no limit on the time of the retries.
3131
DefaultRandomizationFactor float64 = 0 // Randomization (Jitter) factor used to map retry interval to a range of values around the computed interval. In precise terms (random value in range [1 - randomizationfactor, 1 + randomizationfactor]). NOTE: This is set to 0 as we do not use jitter in Aligned.
3232
DefaultMultiplier float64 = 2 // Multiplier factor computed exponential retry interval is scaled by.
33-
DefaultMaxNumRetries uint64 = 3 // Total number of retries attempted.
33+
DefaultNumRetries uint64 = 3 // Total number of retries attempted.
3434
ChainInitialInterval = 12 * time.Second // Initial delay for retry interval for contract calls. Corresponds to 1 ethereum block.
3535
ChainMaxInterval = 2 * time.Minute // Maximum interval for an individual retry.
3636
)
@@ -41,17 +41,17 @@ type RetryConfig struct {
4141
MaxElapsedTime time.Duration // Maximum time all retries may take. `0` corresponds to no limit on the time of the retries.
4242
RandomizationFactor float64
4343
Multiplier float64
44-
MaxNumRetries uint64
44+
NumRetries uint64
4545
}
4646

47-
func DefaultRetryConfig() *RetryConfig {
47+
func RpcRetryConfig() *RetryConfig {
4848
return &RetryConfig{
4949
InitialInterval: DefaultInitialInterval,
5050
MaxInterval: DefaultMaxInterval,
5151
MaxElapsedTime: DefaultMaxElapsedTime,
5252
RandomizationFactor: DefaultRandomizationFactor,
5353
Multiplier: DefaultMultiplier,
54-
MaxNumRetries: DefaultMaxNumRetries,
54+
NumRetries: DefaultNumRetries,
5555
}
5656
}
5757

@@ -62,7 +62,7 @@ func ChainRetryConfig() *RetryConfig {
6262
MaxElapsedTime: DefaultMaxElapsedTime,
6363
RandomizationFactor: DefaultRandomizationFactor,
6464
Multiplier: DefaultMultiplier,
65-
MaxNumRetries: DefaultMaxNumRetries,
65+
NumRetries: DefaultNumRetries,
6666
}
6767
}
6868

@@ -160,8 +160,8 @@ func RetryWithData[T any](functionToRetry func() (T, error), config *RetryConfig
160160
expBackoff := backoff.NewExponentialBackOff(randomOption, multiplierOption, initialRetryOption, maxIntervalOption, maxElapsedTimeOption)
161161
var maxRetriesBackoff backoff.BackOff
162162

163-
if config.MaxNumRetries > 0 {
164-
maxRetriesBackoff = backoff.WithMaxRetries(expBackoff, config.MaxNumRetries)
163+
if config.NumRetries > 0 {
164+
maxRetriesBackoff = backoff.WithMaxRetries(expBackoff, config.NumRetries)
165165
} else {
166166
maxRetriesBackoff = expBackoff
167167
}
@@ -207,8 +207,8 @@ func Retry(functionToRetry func() error, config *RetryConfig) error {
207207
expBackoff := backoff.NewExponentialBackOff(randomOption, multiplierOption, initialRetryOption, maxIntervalOption, maxElapsedTimeOption)
208208
var maxRetriesBackoff backoff.BackOff
209209

210-
if config.MaxNumRetries > 0 {
211-
maxRetriesBackoff = backoff.WithMaxRetries(expBackoff, config.MaxNumRetries)
210+
if config.NumRetries > 0 {
211+
maxRetriesBackoff = backoff.WithMaxRetries(expBackoff, config.NumRetries)
212212
} else {
213213
maxRetriesBackoff = expBackoff
214214
}

core/retry_test.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ func TestRetryWithData(t *testing.T) {
4949
MaxElapsedTime: 3,
5050
RandomizationFactor: 0,
5151
Multiplier: retry.DefaultMultiplier,
52-
MaxNumRetries: retry.DefaultMaxNumRetries,
52+
NumRetries: retry.DefaultNumRetries,
5353
}
5454
_, err := retry.RetryWithData(function, config)
5555
if err != nil {
@@ -68,7 +68,7 @@ func TestRetry(t *testing.T) {
6868
MaxElapsedTime: 3,
6969
RandomizationFactor: 0,
7070
Multiplier: retry.DefaultMultiplier,
71-
MaxNumRetries: retry.DefaultMaxNumRetries,
71+
NumRetries: retry.DefaultNumRetries,
7272
}
7373
err := retry.Retry(function, config)
7474
if err != nil {
@@ -170,7 +170,7 @@ func TestWaitForTransactionReceipt(t *testing.T) {
170170
}
171171

172172
// Assert Call succeeds when Anvil running
173-
receipt_function := utils.WaitForTransactionReceipt(*client, *client, hash, retry.DefaultRetryConfig())
173+
receipt_function := utils.WaitForTransactionReceipt(*client, *client, hash, retry.RpcRetryConfig())
174174
_, err = receipt_function()
175175
assert.NotNil(t, err, "Error Waiting for Transaction with Anvil Running: %s\n", err)
176176
if !strings.Contains(err.Error(), "not found") {
@@ -183,7 +183,7 @@ func TestWaitForTransactionReceipt(t *testing.T) {
183183
return
184184
}
185185

186-
receipt_function = utils.WaitForTransactionReceipt(*client, *client, hash, retry.DefaultRetryConfig())
186+
receipt_function = utils.WaitForTransactionReceipt(*client, *client, hash, retry.RpcRetryConfig())
187187
_, err = receipt_function()
188188
assert.NotNil(t, err)
189189
if _, ok := err.(retry.PermanentError); ok {
@@ -200,7 +200,7 @@ func TestWaitForTransactionReceipt(t *testing.T) {
200200
t.Errorf("Error setting up Anvil: %s\n", err)
201201
}
202202

203-
receipt_function = utils.WaitForTransactionReceipt(*client, *client, hash, retry.DefaultRetryConfig())
203+
receipt_function = utils.WaitForTransactionReceipt(*client, *client, hash, retry.RpcRetryConfig())
204204
_, err = receipt_function()
205205
assert.NotNil(t, err)
206206
if !strings.Contains(err.Error(), "not found") {

core/utils/eth_client_utils.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,5 +103,5 @@ func GetGasPriceRetryable(client eth.InstrumentedClient, fallbackClient eth.Inst
103103

104104
return gasPrice, nil
105105
}
106-
return retry.RetryWithData(respondToTaskV2_func, retry.DefaultRetryConfig())
106+
return retry.RetryWithData(respondToTaskV2_func, retry.RpcRetryConfig())
107107
}

0 commit comments

Comments
 (0)