diff --git a/aggregator/service.go b/aggregator/service.go index 09662ee..cf31cf5 100644 --- a/aggregator/service.go +++ b/aggregator/service.go @@ -261,6 +261,15 @@ func (agg *AggregatorService) sendNewTask(alertHash message.Bytes32, taskIndex t agg.logger.Error("GetQuorumCountByBlockNumber failed", "err", err) return nil, err } + agg.logger.Info("get quorumNumbers from layer1", "quorumNumbers", fmt.Sprintf("%v", quorumNumbers)) + + if len(quorumNumbers) < len(agg.cfg.QuorumNums) { + agg.logger.Error("the cfg quorum numbers is larger to the layer1, it will commit failed") + return nil, fmt.Errorf("the quorum numbers is larger to the layer1 %v, expected %v", agg.cfg.QuorumNums, quorumNumbers) + } + + // just use config value + quorumNumbers = agg.cfg.QuorumNums quorumThresholdPercentages, err := agg.avsReader.GetQuorumThresholdPercentages(context.Background(), uint32(referenceBlockNumber), quorumNumbers) if err != nil { diff --git a/config-files/aggregator.yaml b/config-files/aggregator.yaml index d33f81c..0ba1ef4 100644 --- a/config-files/aggregator.yaml +++ b/config-files/aggregator.yaml @@ -14,3 +14,6 @@ layer1_chain_id: 31337 # the layer2 chain id layer2_chain_id: 0 + +# the QuorumNums we use, just no change +quorum_nums: [0] \ No newline at end of file diff --git a/core/config/config.go b/core/config/config.go index afb16ba..c634230 100644 --- a/core/config/config.go +++ b/core/config/config.go @@ -41,6 +41,7 @@ type Config struct { AggregatorGRPCServerIpPortAddr string Layer1ChainId uint32 Layer2ChainId uint32 + QuorumNums types.QuorumNums // json:"-" skips this field when marshaling (only used for logging to stdout), since SignerFn doesnt implement marshalJson SignerFn signerv2.SignerFn `json:"-"` PrivateKey *ecdsa.PrivateKey `json:"-"` @@ -57,6 +58,7 @@ type ConfigRaw struct { AggregatorGRPCServerIpPortAddr string `yaml:"aggregator_grpc_server_ip_port_address"` Layer1ChainId uint32 `yaml:"layer1_chain_id"` Layer2ChainId uint32 `yaml:"layer2_chain_id"` + QuorumNums []uint8 `yaml:"quorum_nums"` } // These are read from DeploymentFileFlag @@ -182,6 +184,22 @@ func NewConfig(ctx *cli.Context) (*Config, error) { } txMgr := txmgr.NewSimpleTxManager(txSender, ethRpcClient, logger, aggregatorAddr) + quorumNums := make([]types.QuorumNum, len(configRaw.QuorumNums)) + for i, quorumNum := range configRaw.QuorumNums { + quorumNums[i] = types.QuorumNum(quorumNum) + } + + if len(quorumNums) == 0 { + // default use zero + logger.Warn("not quorumNums, just use [0]") + quorumNums = []types.QuorumNum{types.QuorumNum(0)} + } + logger.Info( + "the quorumNums", + "quorumNums", fmt.Sprintf("%#v", quorumNums), + "raw", fmt.Sprintf("%#v", configRaw.QuorumNums), + ) + config := &Config{ Logger: logger, EthWsRpcUrl: configRaw.EthWsUrl, @@ -198,6 +216,7 @@ func NewConfig(ctx *cli.Context) (*Config, error) { AggregatorAddress: aggregatorAddr, Layer1ChainId: configRaw.Layer1ChainId, Layer2ChainId: configRaw.Layer2ChainId, + QuorumNums: quorumNums, } config.validate() return config, nil