From 65407371b5ef6dce325cfe4d10fb8fde735a5f18 Mon Sep 17 00:00:00 2001 From: Marian Vanderka Date: Tue, 9 Apr 2024 19:52:35 +0200 Subject: [PATCH] page through pubkeys --- avs-aggregator/aggregator.go | 31 ++++++++++++++--------------- avs-aggregator/config.go | 5 ++++- avs-aggregator/core/config/flags.go | 7 +++++++ avs-eigensdk-go | 2 +- 4 files changed, 27 insertions(+), 18 deletions(-) diff --git a/avs-aggregator/aggregator.go b/avs-aggregator/aggregator.go index 3d56535d2..4e56a5b57 100644 --- a/avs-aggregator/aggregator.go +++ b/avs-aggregator/aggregator.go @@ -5,7 +5,6 @@ import ( "errors" "math/big" "sync" - "time" "github.com/ethereum/go-ethereum/accounts/abi/bind" @@ -23,15 +22,6 @@ import ( gsrpc "github.com/centrifuge/go-substrate-rpc-client/v4" ) -const ( - // number of blocks after which a task is considered expired - // this hardcoded here because it's also hardcoded in the contracts, but should - // ideally be fetched from the contracts - // taskChallengeWindowBlock = 100 - // 6s block time on rollup nodes - blockTimeSeconds = 6 * time.Second -) - // Aggregator sends tasks (numbers to square) onchain, then listens for operator signed TaskResponses. // It aggregates responses signatures, and if any of the TaskResponses reaches the QuorumThresholdPercentage for each quorum // (currently we only use a single quorum of the ERC20Mock token), it sends the aggregated TaskResponse and signature onchain. @@ -90,6 +80,8 @@ func NewAggregator(c *Config) (*Aggregator, error) { return nil, err } + logger.Debug("creating new aggregator", "config", c) + ethRpc, err := chainio.NewEthRpc( c.AvsRegistryCoordinatorAddr, c.EthRpcUrl, @@ -121,9 +113,17 @@ func NewAggregator(c *Config) (*Aggregator, error) { return nil, err } - pubkeyService := operatorpubkeys.NewOperatorPubkeysServiceInMemory(context.Background(), ethRpc.Clients.AvsRegistryChainSubscriber, ethRpc.Clients.AvsRegistryChainReader, logger) + pubkeyService := operatorpubkeys.NewOperatorPubkeysServiceInMemory( + context.Background(), + ethRpc.Clients.AvsRegistryChainSubscriber, + ethRpc.Clients.AvsRegistryChainReader, + ethRpc.Clients.EthHttpClient, + c.AvsDeploymentBlock, + 50_000, + logger, + ) avsRegistryService := avsregistry.NewAvsRegistryServiceChainCaller(ethRpc.Clients.AvsRegistryChainReader, pubkeyService, logger) - blsAggregationService := blsagg.NewBlsAggregatorService(avsRegistryService, logger) + blsAggregationService := blsagg.NewBlsAggregatorService(avsRegistryService, ethRpc.Clients.EthWsClient, logger) substrateRpc, err := gsrpc.NewSubstrateAPI(c.SubstrateWsRpcUrl) if err != nil { @@ -255,10 +255,9 @@ func (agg *Aggregator) sendNewTask(blockNumber uint32) error { for i, n := range newTask.QuorumNumbers { quorumNums[i] = sdktypes.QuorumNum(n) } - // TODO(samlaf): we use seconds for now, but we should ideally pass a blocknumber to the blsAggregationService - // and it should monitor the chain and only expire the task aggregation once the chain has reached that block number. - taskTimeToExpiry := time.Duration(agg.taskResponseWindowBlock) * blockTimeSeconds - agg.blsAggregationService.InitializeNewTask(taskIndex, newTask.TaskCreatedBlock, quorumNums, quorumThresholdPercentages, taskTimeToExpiry) + // should monitor the chain and only expire the task aggregation once the chain has reached that block number. + taskTimeToExpiry := agg.taskResponseWindowBlock + agg.blsAggregationService.InitializeNewTask(taskIndex, newTask.TaskCreatedBlock, taskTimeToExpiry, quorumNums, quorumThresholdPercentages) agg.logger.Info("Aggregator initialized new task", "block number", blockNumber, "task index", taskIndex, "expiry", taskTimeToExpiry) return nil } diff --git a/avs-aggregator/config.go b/avs-aggregator/config.go index 319943cc7..d67a20d26 100644 --- a/avs-aggregator/config.go +++ b/avs-aggregator/config.go @@ -24,8 +24,9 @@ type Config struct { UpdatePeriod int AvsRegistryCoordinatorAddr common.Address + AvsDeploymentBlock uint64 - SignerFn signerv2.SignerFn + SignerFn signerv2.SignerFn `json:"-"` Address common.Address KickPeriod int @@ -85,6 +86,7 @@ func NewConfig(ctx *cli.Context) (*Config, error) { ChainId: chainId, SubstrateWsRpcUrl: ctx.GlobalString(config.SubstrateRpcFlag.Name), AvsRegistryCoordinatorAddr: common.HexToAddress(ctx.GlobalString(config.AvsRegistryCoordinatorFlag.Name)), + AvsDeploymentBlock: uint64(ctx.GlobalInt(config.AvsDeploymentBlockFlag.Name)), SignerFn: signer, Address: address, }, nil @@ -98,6 +100,7 @@ var Flags = []cli.Flag{ config.AvsServerPortAddressFlag, config.ChainIdFlag, config.AvsRegistryCoordinatorFlag, + config.AvsDeploymentBlockFlag, config.EcdsaKeyFileFlag, config.EcdsaKeyJsonFlag, config.EcdsaKeyPasswordFlag, diff --git a/avs-aggregator/core/config/flags.go b/avs-aggregator/core/config/flags.go index a0f88a60c..66d74b255 100644 --- a/avs-aggregator/core/config/flags.go +++ b/avs-aggregator/core/config/flags.go @@ -73,6 +73,13 @@ var ( Required: true, EnvVar: "AVS_REGISTRY_COORDINATOR_ADDR", } + AvsDeploymentBlockFlag = cli.IntFlag{ + Name: "avs-deployment-block", + Usage: "block number at which AVS contracts were deployed, used for startBlock event filtering", + Required: false, + Value: 0, + EnvVar: "AVS_DEPLOYMENT_BLOCK", + } // The files for encrypted private keys. EcdsaKeyFileFlag = cli.StringFlag{ diff --git a/avs-eigensdk-go b/avs-eigensdk-go index b85321519..aebeaa0b7 160000 --- a/avs-eigensdk-go +++ b/avs-eigensdk-go @@ -1 +1 @@ -Subproject commit b85321519be9e9f21c59bfa69c7a4765a57c713f +Subproject commit aebeaa0b783561645f76faf16a81b54987f0778f