Skip to content

Commit

Permalink
page through pubkeys
Browse files Browse the repository at this point in the history
  • Loading branch information
vanderian committed Apr 9, 2024
1 parent 6056687 commit 6540737
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 18 deletions.
31 changes: 15 additions & 16 deletions avs-aggregator/aggregator.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
"errors"
"math/big"
"sync"
"time"

"github.com/ethereum/go-ethereum/accounts/abi/bind"

Expand All @@ -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.
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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
}
5 changes: 4 additions & 1 deletion avs-aggregator/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -98,6 +100,7 @@ var Flags = []cli.Flag{
config.AvsServerPortAddressFlag,
config.ChainIdFlag,
config.AvsRegistryCoordinatorFlag,
config.AvsDeploymentBlockFlag,
config.EcdsaKeyFileFlag,
config.EcdsaKeyJsonFlag,
config.EcdsaKeyPasswordFlag,
Expand Down
7 changes: 7 additions & 0 deletions avs-aggregator/core/config/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand Down
2 changes: 1 addition & 1 deletion avs-eigensdk-go

0 comments on commit 6540737

Please sign in to comment.