Skip to content

Commit

Permalink
feat: support start/stop block number for querying operator info
Browse files Browse the repository at this point in the history
  • Loading branch information
renlulu committed Sep 4, 2024
1 parent 8757e81 commit 9374824
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 7 deletions.
2 changes: 2 additions & 0 deletions services/bls_aggregation/blsagg_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1150,6 +1150,8 @@ func TestIntegrationBlsAgg(t *testing.T) {
avsClients.AvsRegistryChainSubscriber,
avsClients.AvsRegistryChainReader,
nil,
nil,
nil,
logger,
)
avsRegistryService := avsregistry.NewAvsRegistryServiceChainCaller(
Expand Down
22 changes: 15 additions & 7 deletions services/operatorsinfo/operatorsinfo_inmemory.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,8 @@ func NewOperatorsInfoServiceInMemory(
avsRegistrySubscriber avsRegistrySubscriber,
avsRegistryReader avsRegistryReader,
logFilterQueryBlockRange *big.Int,
startBlock *big.Int,
stopBlock *big.Int,
logger logging.Logger,
) *OperatorsInfoServiceInMemory {
queryC := make(chan query)
Expand All @@ -112,7 +114,7 @@ func NewOperatorsInfoServiceInMemory(
// which requires querying the past events of the pubkey registration contract
wg := sync.WaitGroup{}
wg.Add(1)
pkcs.startServiceInGoroutine(ctx, queryC, &wg)
pkcs.startServiceInGoroutine(ctx, queryC, &wg, startBlock, stopBlock)
wg.Wait()
return pkcs
}
Expand All @@ -121,6 +123,8 @@ func (ops *OperatorsInfoServiceInMemory) startServiceInGoroutine(
ctx context.Context,
queryC <-chan query,
wg *sync.WaitGroup,
startBlock *big.Int,
stopBlock *big.Int,
) {
go func() {

Expand Down Expand Up @@ -153,7 +157,7 @@ func (ops *OperatorsInfoServiceInMemory) startServiceInGoroutine(
)
panic(err)
}
err = ops.queryPastRegisteredOperatorEventsAndFillDb(ctx)
err = ops.queryPastRegisteredOperatorEventsAndFillDb(ctx, startBlock, stopBlock)
if err != nil {
ops.logger.Error(
"Fatal error querying past registered operator events and filling db",
Expand Down Expand Up @@ -275,7 +279,11 @@ func (ops *OperatorsInfoServiceInMemory) startServiceInGoroutine(
}()
}

func (ops *OperatorsInfoServiceInMemory) queryPastRegisteredOperatorEventsAndFillDb(ctx context.Context) error {
func (ops *OperatorsInfoServiceInMemory) queryPastRegisteredOperatorEventsAndFillDb(
ctx context.Context,
startBlock *big.Int,
stopBlock *big.Int,
) error {
// Querying with nil startBlock and stopBlock will return all events. It doesn't matter if we query some events that
// we will receive again in the websocket,
// since we will just overwrite the pubkey dict with the same values.
Expand All @@ -290,8 +298,8 @@ func (ops *OperatorsInfoServiceInMemory) queryPastRegisteredOperatorEventsAndFil
go func() {
alreadyRegisteredOperatorAddrs, alreadyRegisteredOperatorPubkeys, pubkeysErr = ops.avsRegistryReader.QueryExistingRegisteredOperatorPubKeys(
ctx,
nil,
nil,
startBlock,
stopBlock,
ops.logFilterQueryBlockRange,
)
wg.Done()
Expand All @@ -301,8 +309,8 @@ func (ops *OperatorsInfoServiceInMemory) queryPastRegisteredOperatorEventsAndFil
go func() {
socketsMap, socketsErr = ops.avsRegistryReader.QueryExistingRegisteredOperatorSockets(
ctx,
nil,
nil,
startBlock,
stopBlock,
ops.logFilterQueryBlockRange,
)
wg.Done()
Expand Down
2 changes: 2 additions & 0 deletions services/operatorsinfo/operatorsinfo_inmemory_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,8 @@ func TestGetOperatorInfo(t *testing.T) {
mockAvsRegistrySubscriber,
mockAvsReader,
nil,
nil,
nil,
logger,
)
time.Sleep(
Expand Down

0 comments on commit 9374824

Please sign in to comment.