Skip to content

Commit cb09539

Browse files
committed
use retry config for s3
1 parent a062ff3 commit cb09539

2 files changed

Lines changed: 12 additions & 10 deletions

File tree

operator/pkg/operator.go

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -66,10 +66,8 @@ type Operator struct {
6666
}
6767

6868
const (
69-
BatchDownloadTimeout = 1 * time.Minute
70-
BatchDownloadMaxRetries = 3
71-
BatchDownloadRetryDelay = 5 * time.Second
72-
UnverifiedBatchOffset = 100
69+
BatchDownloadTimeout = 1 * time.Minute
70+
UnverifiedBatchOffset = 100
7371
)
7472

7573
func NewOperatorFromConfig(configuration config.OperatorConfig) (*Operator, error) {
@@ -361,7 +359,7 @@ func (o *Operator) ProcessNewBatchLogV2(newBatchLog *servicemanager.ContractAlig
361359
ctx, cancel := context.WithTimeout(context.Background(), BatchDownloadTimeout)
362360
defer cancel()
363361

364-
verificationDataBatch, err := o.getBatchFromDataService(ctx, newBatchLog.BatchDataPointer, newBatchLog.BatchMerkleRoot, BatchDownloadMaxRetries, BatchDownloadRetryDelay)
362+
verificationDataBatch, err := o.getBatchFromDataService(ctx, newBatchLog.BatchDataPointer, newBatchLog.BatchMerkleRoot)
365363
if err != nil {
366364
o.Logger.Errorf("Could not get proofs from S3 bucket: %v", err)
367365
return err
@@ -442,7 +440,7 @@ func (o *Operator) ProcessNewBatchLogV3(newBatchLog *servicemanager.ContractAlig
442440
ctx, cancel := context.WithTimeout(context.Background(), BatchDownloadTimeout)
443441
defer cancel()
444442

445-
verificationDataBatch, err := o.getBatchFromDataService(ctx, newBatchLog.BatchDataPointer, newBatchLog.BatchMerkleRoot, BatchDownloadMaxRetries, BatchDownloadRetryDelay)
443+
verificationDataBatch, err := o.getBatchFromDataService(ctx, newBatchLog.BatchDataPointer, newBatchLog.BatchMerkleRoot)
446444
if err != nil {
447445
o.Logger.Errorf("Could not get proofs from S3 bucket: %v", err)
448446
return err

operator/pkg/s3.go

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ import (
1313
"github.com/yetanotherco/aligned_layer/operator/merkle_tree"
1414
)
1515

16+
const BatchDownloadRetryDelay = 5 * time.Second
17+
1618
func RequestBatch(req *http.Request, ctx context.Context) func() (*http.Response, error) {
1719

1820
req_func := func() (*http.Response, error) {
@@ -30,20 +32,22 @@ func RequestBatch(req *http.Request, ctx context.Context) func() (*http.Response
3032
return req_func
3133
}
3234

33-
func RequestBatchRetryable(ctx context.Context, logger logging.Logger, req *http.Request) (*http.Response, error) {
35+
func RequestBatchRetryable(ctx context.Context, logger logging.Logger, req *http.Request, config *retry.RetryConfig) (*http.Response, error) {
3436

35-
return retry.RetryWithData(RequestBatch(req, ctx), retry.EthCallRetryConfig())
37+
return retry.RetryWithData(RequestBatch(req, ctx), config)
3638
}
3739

38-
func (o *Operator) getBatchFromDataService(ctx context.Context, batchURL string, expectedMerkleRoot [32]byte, maxRetries int, retryDelay time.Duration) ([]VerificationData, error) {
40+
func (o *Operator) getBatchFromDataService(ctx context.Context, batchURL string, expectedMerkleRoot [32]byte) ([]VerificationData, error) {
3941
o.Logger.Infof("Getting batch from data service, batchURL: %s", batchURL)
4042

4143
req, err := http.NewRequestWithContext(ctx, "GET", batchURL, nil)
4244
if err != nil {
4345
return nil, err
4446
}
4547

46-
resp, err := RequestBatchRetryable(ctx, o.Logger, req)
48+
config := retry.EthCallRetryConfig()
49+
config.InitialInterval = BatchDownloadRetryDelay
50+
resp, err := RequestBatchRetryable(ctx, o.Logger, req, config)
4751
if err != nil {
4852
return nil, err
4953
}

0 commit comments

Comments
 (0)