Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions aggregator/pkg/aggregator.go
Original file line number Diff line number Diff line change
Expand Up @@ -393,15 +393,17 @@ func (agg *Aggregator) AddNewTask(batchMerkleRoot [32]byte, senderAddress [20]by
// |---RETRYABLE---|

/*
InitializeNewTask
Initialize a new task in the BLS Aggregation service
- Errors:
Permanent:
- 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).
Transient:
- All others.
- Retry times (3 retries): 12 sec (1 Blocks), 24 sec (2 Blocks), 48 sec (4 Blocks)
- Retry times (3 retries): 1 sec, 2 sec, 4 sec
*/
func (agg *Aggregator) InitializeNewTask(batchIndex uint32, taskCreatedBlock uint32, quorumNums eigentypes.QuorumNums, quorumThresholdPercentages eigentypes.QuorumThresholdPercentages, timeToExpiry time.Duration) error {
initilizeNewTask_func := func() error {
initializeNewTask_func := func() error {
err := agg.blsAggregationService.InitializeNewTask(batchIndex, taskCreatedBlock, quorumNums, quorumThresholdPercentages, timeToExpiry)
if err != nil {
// Task is already initialized
Expand All @@ -411,7 +413,7 @@ func (agg *Aggregator) InitializeNewTask(batchIndex uint32, taskCreatedBlock uin
}
return err
}
return retry.Retry(initilizeNewTask_func, retry.MinDelayChain, retry.RetryFactor, retry.NumRetries, retry.MaxIntervalChain, retry.MaxElapsedTime)
return retry.Retry(initializeNewTask_func, retry.MinDelay, retry.RetryFactor, retry.NumRetries, retry.MaxInterval, retry.MaxElapsedTime)
}

// Long-lived goroutine that periodically checks and removes old Tasks from stored Maps
Expand Down
36 changes: 30 additions & 6 deletions core/chainio/retryable.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ import (
// |---AVS_WRITER---|

/*
RespondToTaskV2Retryable
Send a transaction to the AVS contract to respond to a task.
- All errors are considered Transient Errors
- Retry times (3 retries): 12 sec (1 Blocks), 24 sec (2 Blocks), 48 sec (4 Blocks)
- 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.
Expand All @@ -34,8 +36,10 @@ func (w *AvsWriter) RespondToTaskV2Retryable(opts *bind.TransactOpts, batchMerkl
}

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

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

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

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

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

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

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

return retry.RetryWithData(batchState_func, retry.MinDelayChain, retry.RetryFactor, retry.NumRetries, retry.MaxIntervalChain, retry.MaxElapsedTime)
return retry.RetryWithData(batchState_func, retry.MinDelay, retry.RetryFactor, retry.NumRetries, retry.MaxInterval, retry.MaxElapsedTime)
}

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

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

/*
SubscribeToNewTasksV3Retryable
Subscribe to NewBatchV3 logs from the AVS contract.
- All errors are considered Transient Errors
- Retry times (3 retries): 1 sec, 2 sec, 4 sec.
*/
Expand Down
4 changes: 3 additions & 1 deletion core/utils/eth_client_utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@ import (
// If the receipt is still unavailable after `waitTimeout`, it will return an error.
//
// 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.
// Setting a higher value will imply doing less retries across the waitTimeout and so we might lose the receipt
// Setting a higher value will imply doing less retries across the waitTimeout, and so we might lose the receipt
// All errors are considered Transient Errors
// - Retry times: 0.5s, 1s, 2s, 2s, 2s, ... until it reaches waitTimeout
func WaitForTransactionReceiptRetryable(client eth.InstrumentedClient, fallbackClient eth.InstrumentedClient, txHash gethcommon.Hash, waitTimeout time.Duration) (*types.Receipt, error) {
receipt_func := func() (*types.Receipt, error) {
receipt, err := client.TransactionReceipt(context.Background(), txHash)
Expand Down