Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add block expiration #87

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 3 additions & 14 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 @@ -123,7 +113,7 @@ func NewAggregator(c *Config) (*Aggregator, error) {

pubkeyService := operatorpubkeys.NewOperatorPubkeysServiceInMemory(context.Background(), ethRpc.Clients.AvsRegistryChainSubscriber, ethRpc.Clients.AvsRegistryChainReader, 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 @@ -257,8 +247,7 @@ func (agg *Aggregator) sendNewTask(blockNumber uint32) error {
}
// 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)
agg.logger.Info("Aggregator initialized new task", "block number", blockNumber, "task index", taskIndex, "expiry", taskTimeToExpiry)
agg.blsAggregationService.InitializeNewTask(taskIndex, newTask.TaskCreatedBlock, agg.taskResponseWindowBlock, quorumNums, quorumThresholdPercentages)
agg.logger.Info("Aggregator initialized new task", "block number", blockNumber, "task index", taskIndex, "expiry", newTask.TaskCreatedBlock + agg.taskResponseWindowBlock)
return nil
}
2 changes: 1 addition & 1 deletion avs-eigensdk-go
Loading