Skip to content

Commit c8cb8e7

Browse files
author
Julian Ventura
committed
Add block fetch range to config, fix related bug
1 parent 9c964bb commit c8cb8e7

File tree

4 files changed

+11
-11
lines changed

4 files changed

+11
-11
lines changed

aggregator/pkg/server.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,9 @@ func (agg *Aggregator) ProcessOperatorSignedTaskResponseV2(signedTaskResponse *t
5757

5858
if err != nil {
5959
agg.logger.Warn("Task not found in the internal map, might have been missed. Trying to fetch it from logs")
60-
batch, err := agg.avsReader.GetPendingBatchFromMerkleRoot(signedTaskResponse.BatchMerkleRoot)
61-
if err != nil {
62-
agg.logger.Warn("Pending task with merkle root 0x%x not found in logs")
60+
batch, err := agg.avsReader.GetPendingBatchFromMerkleRoot(signedTaskResponse.BatchMerkleRoot, agg.AggregatorConfig.Aggregator.PendingBatchFetchBlockRange)
61+
if err != nil || batch == nil {
62+
agg.logger.Warnf("Pending task with merkle root 0x%x not found in logs", signedTaskResponse.BatchMerkleRoot)
6363
*reply = 1
6464
return nil
6565
}

config-files/config-aggregator.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ aggregator:
3838
garbage_collector_tasks_age: 20 #The age of tasks that will be removed by the GC, in blocks. Suggested value for prod: '216000' (30 days)
3939
garbage_collector_tasks_interval: 10 #The interval of queried blocks to get an old batch. Suggested value for prod: '900' (3 hours)
4040
bls_service_task_timeout: 168h # The timeout of bls aggregation service tasks. Suggested value for prod '168h' (7 days)
41+
pending_batch_fetch_block_range: 1000 #The interval of queried blocks to get a pending batch by logs. Suggested valued for prod `1000`
4142

4243
## Operator Configurations
4344
# operator:

core/chainio/avs_reader.go

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,6 @@ import (
1717
"github.com/Layr-Labs/eigensdk-go/logging"
1818
)
1919

20-
const (
21-
BatchFetchBlocksRange uint64 = 1000
22-
)
23-
2420
type AvsReader struct {
2521
*sdkavsregistry.ChainReader
2622
AvsContractBindings *AvsServiceBindings
@@ -156,17 +152,17 @@ func (r *AvsReader) GetOldTaskHash(nBlocksOld uint64, interval uint64) (*[32]byt
156152
}
157153

158154
// Returns a pending batch from its merkle root or nil if it doesn't exist
159-
// Searches the last `BatchFetchBlocksRange` blocks at most
160-
func (r *AvsReader) GetPendingBatchFromMerkleRoot(merkleRoot [32]byte) (*servicemanager.ContractAlignedLayerServiceManagerNewBatchV3, error) {
155+
// Searches the last `blockRange` blocks at most
156+
func (r *AvsReader) GetPendingBatchFromMerkleRoot(merkleRoot [32]byte, blockRange uint64) (*servicemanager.ContractAlignedLayerServiceManagerNewBatchV3, error) {
161157
latestBlock, err := r.BlockNumberRetryable(context.Background())
162158
if err != nil {
163159
return nil, fmt.Errorf("Failed to get latest block number: %w", err)
164160
}
165161

166162
var fromBlock uint64 = 0
167163

168-
if latestBlock > BatchFetchBlocksRange {
169-
fromBlock = latestBlock - BatchFetchBlocksRange // TODO: Add this to config
164+
if latestBlock > blockRange {
165+
fromBlock = latestBlock - blockRange
170166
}
171167

172168
logs, err := r.FilterBatchV3Retryable(&bind.FilterOpts{Start: fromBlock, End: &latestBlock, Context: context.Background()}, [][32]byte{merkleRoot})

core/config/aggregator.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ type AggregatorConfig struct {
2525
GarbageCollectorTasksAge uint64
2626
GarbageCollectorTasksInterval uint64
2727
BlsServiceTaskTimeout time.Duration
28+
PendingBatchFetchBlockRange uint64
2829
}
2930
}
3031

@@ -40,6 +41,7 @@ type AggregatorConfigFromYaml struct {
4041
GarbageCollectorTasksAge uint64 `yaml:"garbage_collector_tasks_age"`
4142
GarbageCollectorTasksInterval uint64 `yaml:"garbage_collector_tasks_interval"`
4243
BlsServiceTaskTimeout time.Duration `yaml:"bls_service_task_timeout"`
44+
PendingBatchFetchBlockRange uint64 `yaml:"pending_batch_fetch_block_range"`
4345
} `yaml:"aggregator"`
4446
}
4547

@@ -85,6 +87,7 @@ func NewAggregatorConfig(configFilePath string) *AggregatorConfig {
8587
GarbageCollectorTasksAge uint64
8688
GarbageCollectorTasksInterval uint64
8789
BlsServiceTaskTimeout time.Duration
90+
PendingBatchFetchBlockRange uint64
8891
}(aggregatorConfigFromYaml.Aggregator),
8992
}
9093
}

0 commit comments

Comments
 (0)