Skip to content

Commit ad756a2

Browse files
committed
missed fucntions outside chainio
1 parent 261aa1c commit ad756a2

3 files changed

Lines changed: 57 additions & 38 deletions

File tree

aggregator/pkg/aggregator.go

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -398,17 +398,7 @@ func (agg *Aggregator) AddNewTask(batchMerkleRoot [32]byte, senderAddress [20]by
398398

399399
// |---RETRYABLE---|
400400

401-
/*
402-
InitializeNewTask
403-
Initialize a new task in the BLS Aggregation service
404-
- Errors:
405-
Permanent:
406-
- 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).
407-
Transient:
408-
- All others.
409-
- Retry times (3 retries): 1 sec, 2 sec, 4 sec
410-
*/
411-
func (agg *Aggregator) InitializeNewTask(batchIndex uint32, taskCreatedBlock uint32, quorumNums eigentypes.QuorumNums, quorumThresholdPercentages eigentypes.QuorumThresholdPercentages, timeToExpiry time.Duration) error {
401+
func InitializeNewTask(agg *Aggregator, batchIndex uint32, taskCreatedBlock uint32, quorumNums eigentypes.QuorumNums, quorumThresholdPercentages eigentypes.QuorumThresholdPercentages, timeToExpiry time.Duration) func() error {
412402
initializeNewTask_func := func() error {
413403
err := agg.blsAggregationService.InitializeNewTask(batchIndex, taskCreatedBlock, quorumNums, quorumThresholdPercentages, timeToExpiry)
414404
if err != nil {
@@ -419,7 +409,21 @@ func (agg *Aggregator) InitializeNewTask(batchIndex uint32, taskCreatedBlock uin
419409
}
420410
return err
421411
}
422-
return retry.Retry(initializeNewTask_func, retry.EthCallRetryConfig())
412+
return initializeNewTask_func
413+
}
414+
415+
/*
416+
InitializeNewTask
417+
Initialize a new task in the BLS Aggregation service
418+
- Errors:
419+
Permanent:
420+
- 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).
421+
Transient:
422+
- All others.
423+
- Retry times (3 retries): 1 sec, 2 sec, 4 sec
424+
*/
425+
func (agg *Aggregator) InitializeNewTaskRetryable(batchIndex uint32, taskCreatedBlock uint32, quorumNums eigentypes.QuorumNums, quorumThresholdPercentages eigentypes.QuorumThresholdPercentages, timeToExpiry time.Duration) error {
426+
return retry.Retry(InitializeNewTask(agg, batchIndex, taskCreatedBlock, quorumNums, quorumThresholdPercentages, timeToExpiry), retry.EthCallRetryConfig())
423427
}
424428

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

aggregator/pkg/server.go

Lines changed: 27 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -114,16 +114,8 @@ func (agg *Aggregator) ServerRunning(_ *struct{}, reply *int64) error {
114114

115115
// |---RETRYABLE---|
116116

117-
/*
118-
- Errors:
119-
Permanent:
120-
- SignatureVerificationError: Verification of the sigature within the BLS Aggregation Service failed. (https://github.com/Layr-Labs/eigensdk-go/blob/dev/services/bls_aggregation/blsagg.go#L42).
121-
Transient:
122-
- All others.
123-
- Retry times (3 retries): 12 sec (1 Blocks), 24 sec (2 Blocks), 48 sec (4 Blocks)
124-
- NOTE: TaskNotFound errors from the BLS Aggregation service are Transient errors as block reorg's may lead to these errors being thrown.
125-
*/
126-
func (agg *Aggregator) ProcessNewSignatureRetryable(ctx context.Context, taskIndex uint32, taskResponse interface{}, blsSignature *bls.Signature, operatorId eigentypes.Bytes32) error {
117+
func ProcessNewSignature(agg *Aggregator, ctx context.Context, taskIndex uint32, taskResponse interface{}, blsSignature *bls.Signature, operatorId eigentypes.Bytes32) func() error {
118+
127119
processNewSignature_func := func() error {
128120
err := agg.blsAggregationService.ProcessNewSignature(
129121
ctx, taskIndex, taskResponse,
@@ -136,16 +128,25 @@ func (agg *Aggregator) ProcessNewSignatureRetryable(ctx context.Context, taskInd
136128
}
137129
return err
138130
}
139-
140-
return retry.Retry(processNewSignature_func, retry.ChainRetryConfig())
131+
return processNewSignature_func
141132
}
142133

143-
// Checks Internal mapping for Signed Task Response, returns its TaskIndex.
144134
/*
145-
- All errors are considered Transient Errors
146-
- Retry times (3 retries): 1 sec, 2 sec, 4 sec
135+
- Errors:
136+
Permanent:
137+
- SignatureVerificationError: Verification of the sigature within the BLS Aggregation Service failed. (https://github.com/Layr-Labs/eigensdk-go/blob/dev/services/bls_aggregation/blsagg.go#L42).
138+
Transient:
139+
- All others.
140+
- Retry times (3 retries): 12 sec (1 Blocks), 24 sec (2 Blocks), 48 sec (4 Blocks)
141+
- NOTE: TaskNotFound errors from the BLS Aggregation service are Transient errors as block reorg's may lead to these errors being thrown.
147142
*/
148-
func (agg *Aggregator) GetTaskIndexRetryable(batchIdentifierHash [32]byte) (uint32, error) {
143+
func (agg *Aggregator) ProcessNewSignatureRetryable(ctx context.Context, taskIndex uint32, taskResponse interface{}, blsSignature *bls.Signature, operatorId eigentypes.Bytes32) error {
144+
145+
return retry.Retry(ProcessNewSignature(agg, ctx, taskIndex, taskResponse, blsSignature, operatorId), retry.ChainRetryConfig())
146+
}
147+
148+
func GetTaskIndex(agg *Aggregator, batchIdentifierHash [32]byte) func() (uint32, error) {
149+
149150
getTaskIndex_func := func() (uint32, error) {
150151
agg.taskMutex.Lock()
151152
agg.AggregatorConfig.BaseConfig.Logger.Info("- Locked Resources: Starting processing of Response")
@@ -158,5 +159,14 @@ func (agg *Aggregator) GetTaskIndexRetryable(batchIdentifierHash [32]byte) (uint
158159
return taskIndex, nil
159160
}
160161
}
161-
return retry.RetryWithData(getTaskIndex_func, retry.EthCallRetryConfig())
162+
return getTaskIndex_func
163+
}
164+
165+
// Checks Internal mapping for Signed Task Response, returns its TaskIndex.
166+
/*
167+
- All errors are considered Transient Errors
168+
- Retry times (3 retries): 1 sec, 2 sec, 4 sec
169+
*/
170+
func (agg *Aggregator) GetTaskIndexRetryable(batchIdentifierHash [32]byte) (uint32, error) {
171+
return retry.RetryWithData(GetTaskIndex(agg, batchIdentifierHash), retry.EthCallRetryConfig())
162172
}

core/utils/eth_client_utils.go

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -84,14 +84,9 @@ func CalculateGasPriceBumpBasedOnRetry(currentGasPrice *big.Int, baseBumpPercent
8484
return bumpedGasPrice
8585
}
8686

87-
/*
88-
GetGasPriceRetryable
89-
Get the gas price from the client with retry logic.
90-
- All errors are considered Transient Errors
91-
- Retry times: 1 sec, 2 sec, 4 sec
92-
*/
93-
func GetGasPriceRetryable(client eth.InstrumentedClient, fallbackClient eth.InstrumentedClient) (*big.Int, error) {
94-
respondToTaskV2_func := func() (*big.Int, error) {
87+
func GetGasPrice(client eth.InstrumentedClient, fallbackClient eth.InstrumentedClient) func() (*big.Int, error) {
88+
89+
getGasPrice_func := func() (*big.Int, error) {
9590
gasPrice, err := client.SuggestGasPrice(context.Background())
9691
if err != nil {
9792
gasPrice, err = fallbackClient.SuggestGasPrice(context.Background())
@@ -102,5 +97,15 @@ func GetGasPriceRetryable(client eth.InstrumentedClient, fallbackClient eth.Inst
10297

10398
return gasPrice, nil
10499
}
105-
return retry.RetryWithData(respondToTaskV2_func, retry.EthCallRetryConfig())
100+
return getGasPrice_func
101+
}
102+
103+
/*
104+
GetGasPriceRetryable
105+
Get the gas price from the client with retry logic.
106+
- All errors are considered Transient Errors
107+
- Retry times: 1 sec, 2 sec, 4 sec
108+
*/
109+
func GetGasPriceRetryable(client eth.InstrumentedClient, fallbackClient eth.InstrumentedClient) (*big.Int, error) {
110+
return retry.RetryWithData(GetGasPrice(client, fallbackClient), retry.EthCallRetryConfig())
106111
}

0 commit comments

Comments
 (0)