Skip to content

Commit

Permalink
Merge pull request #104 from mangata-finance/feature/update-sdk-014
Browse files Browse the repository at this point in the history
update to v0.1.4; expiration period as flag
  • Loading branch information
vanderian authored Apr 22, 2024
2 parents 1c1a988 + 933b01f commit 42c1e54
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 8 deletions.
10 changes: 6 additions & 4 deletions avs-aggregator/aggregator.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"errors"
"math/big"
"sync"
"time"

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

Expand Down Expand Up @@ -60,6 +61,7 @@ type Aggregator struct {
logger sdklogging.Logger
serverIpPortAddr string
blockPeriod uint32
expiration uint32
ethRpc *chainio.EthRpc
// aggregation related fields
blsAggregationService blsagg.BlsAggregationService
Expand Down Expand Up @@ -124,7 +126,7 @@ func NewAggregator(c *Config) (*Aggregator, error) {
logger,
)
avsRegistryService := avsregistry.NewAvsRegistryServiceChainCaller(ethRpc.Clients.AvsRegistryChainReader, pubkeyService, logger)
blsAggregationService := blsagg.NewBlsAggregatorService(avsRegistryService, ethRpc.Clients.EthWsClient, logger)
blsAggregationService := blsagg.NewBlsAggregatorService(avsRegistryService, logger)

substrateRpc, err := gsrpc.NewSubstrateAPI(c.SubstrateWsRpcUrl)
if err != nil {
Expand Down Expand Up @@ -155,6 +157,7 @@ func NewAggregator(c *Config) (*Aggregator, error) {
blockPeriod: uint32(c.BlockPeriod),
kicker: kicker,
updater: updater,
expiration: uint32(c.Expiration),
}, nil
}

Expand Down Expand Up @@ -266,9 +269,8 @@ func (agg *Aggregator) sendNewTask(blockNumber uint32) error {
for i, n := range newTask.QuorumNumbers {
quorumNums[i] = sdktypes.QuorumNum(n)
}
// should monitor the chain and only expire the task aggregation once the chain has reached that block number.
taskTimeToExpiry := agg.taskResponseWindowBlock / 2
agg.blsAggregationService.InitializeNewTask(taskIndex, newTask.TaskCreatedBlock, taskTimeToExpiry, quorumNums, quorumThresholdPercentages)
taskTimeToExpiry := time.Second * time.Duration(agg.expiration)
agg.blsAggregationService.InitializeNewTask(taskIndex, newTask.TaskCreatedBlock, quorumNums, quorumThresholdPercentages, taskTimeToExpiry)
agg.logger.Info("Aggregator initialized new task", "block number", blockNumber, "task index", taskIndex, "expiry", taskTimeToExpiry)
return nil
}
3 changes: 3 additions & 0 deletions avs-aggregator/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ type Config struct {

ServerAddressPort string
BlockPeriod int
Expiration int
UpdatePeriod int

AvsRegistryCoordinatorAddr common.Address
Expand Down Expand Up @@ -79,6 +80,7 @@ func NewConfig(ctx *cli.Context) (*Config, error) {
LogLevel: logLevel,
ServerAddressPort: ctx.GlobalString(config.AvsServerPortAddressFlag.Name),
BlockPeriod: ctx.GlobalInt(config.AvsBlockValidationPeriodFlag.Name),
Expiration: ctx.GlobalInt(config.AvsTaskExpirationFlag.Name),
KickPeriod: ctx.GlobalInt(config.AvsKickPeriodFlag.Name),
UpdatePeriod: ctx.GlobalInt(config.AvsUpdateStakePeriodFlag.Name),
EthRpcUrl: ctx.GlobalString(config.EthRpcFlag.Name),
Expand Down Expand Up @@ -107,4 +109,5 @@ var Flags = []cli.Flag{
config.AvsBlockValidationPeriodFlag,
config.AvsKickPeriodFlag,
config.AvsUpdateStakePeriodFlag,
config.AvsTaskExpirationFlag,
}
9 changes: 8 additions & 1 deletion avs-aggregator/core/config/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,18 @@ var (
}
AvsBlockValidationPeriodFlag = cli.IntFlag{
Name: "avs-block-validation-period",
Usage: "Period of block finalization per block produced on mangata",
Usage: "Period of block finalization per block produced on L2",
Required: false,
Value: 4,
EnvVar: "AVS_BLOCK_VALIDATION_PERIOD",
}
AvsTaskExpirationFlag = cli.IntFlag{
Name: "avs-task-expiration",
Usage: "Expiration of task in seconds",
Required: false,
Value: 30,
EnvVar: "AVS_TASK_EXPIRATION",
}
AvsKickPeriodFlag = cli.IntFlag{
Name: "avs-kick-period",
Usage: "Period of active OPs check per tasks created",
Expand Down
2 changes: 1 addition & 1 deletion avs-eigensdk-go
2 changes: 1 addition & 1 deletion contracts/script/config/17000/deploy.config.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,6 @@
],

"taskManagerParams": {
"taskResponseWindowBlocks": 20
"taskResponseWindowBlocks": 100
}
}
2 changes: 1 addition & 1 deletion contracts/script/output/17000/avs_deployment_output.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"serviceManagerImplementation": "0x3287D5077e05e0b0bcF7103C8340a5d6cc992fF1",
"stakeRegistry": "0x96A14F6eb10a67167249Adb64149F33f5D6e8f2b",
"stakeRegistryImplementation": "0xD2333E11ea617E30fb97900f6ac9782A85f233e7",
"taksManagerImplementation": "0x72fB284429F4088aD38E7Bc229A218FEefe62a3E",
"taksManagerImplementation": "0xF361D5EFb03E14F10f669ffE334f6A9394eb57f7",
"taskManager": "0x998AaF69F731009d4E2d470E974766F1EB8f5142"
},
"chainInfo": {
Expand Down
2 changes: 2 additions & 0 deletions ops/helmfiles/config/testnet.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ env:
AVS_SERVER_IP_PORT_ADDRESS: 0.0.0.0:8090
# every 100th block, ~ 10min
AVS_BLOCK_VALIDATION_PERIOD: '100'
# 5min
AVS_TASK_EXPIRATION: '300'
# every 25th task, ~ 4h
AVS_KICK_PERIOD: '25'
# every 150th task, ~ daily
Expand Down

0 comments on commit 42c1e54

Please sign in to comment.