add aggregateSig flag (#3438)

* add aggregateSig flag

* add flag to valid

* revert import change

* enable agg sig at epoch 233 for shard 3 in mainnet

* fix consensus nil

* revert agg sig epoch logic

* fix test
pull/3440/head
Rongjian Lan 4 years ago committed by GitHub
parent 94ecc99e7b
commit bae5be68da
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 3
      cmd/harmony/config.go
  2. 3
      cmd/harmony/default.go
  3. 12
      cmd/harmony/flags.go
  4. 14
      cmd/harmony/flags_test.go
  5. 4
      cmd/harmony/main.go
  6. 6
      consensus/consensus_service.go

@ -60,7 +60,8 @@ type generalConfig struct {
}
type consensusConfig struct {
MinPeers int
MinPeers int
AggregateSig bool
}
type blsConfig struct {

@ -89,7 +89,8 @@ var defaultLogContext = logContext{
}
var defaultConsensusConfig = consensusConfig{
MinPeers: 6,
MinPeers: 6,
AggregateSig: true,
}
const (

@ -92,6 +92,7 @@ var (
// consensusValidFlags are flags that are effective
consensusValidFlags = []cli.Flag{
consensusMinPeersFlag,
consensusAggregateSigFlag,
legacyConsensusMinPeersFlag,
}
@ -746,6 +747,11 @@ var (
DefValue: defaultConsensusConfig.MinPeers,
Hidden: true,
}
consensusAggregateSigFlag = cli.BoolFlag{
Name: "consensus.aggregate-sig",
Usage: "(multi-key) aggregate bls signatures before sending",
DefValue: defaultConsensusConfig.AggregateSig,
}
legacyDelayCommitFlag = cli.StringFlag{
Name: "delay_commit",
Usage: "how long to delay sending commit messages in consensus, ex: 500ms, 1s",
@ -766,7 +772,7 @@ var (
)
func applyConsensusFlags(cmd *cobra.Command, config *harmonyConfig) {
if cli.HasFlagsChanged(cmd, consensusValidFlags) {
if config.Consensus == nil && cli.HasFlagsChanged(cmd, consensusValidFlags) {
cfg := getDefaultConsensusConfigCopy()
config.Consensus = &cfg
}
@ -776,6 +782,10 @@ func applyConsensusFlags(cmd *cobra.Command, config *harmonyConfig) {
} else if cli.IsFlagChanged(cmd, legacyConsensusMinPeersFlag) {
config.Consensus.MinPeers = cli.GetIntFlagValue(cmd, legacyConsensusMinPeersFlag)
}
if cli.IsFlagChanged(cmd, consensusAggregateSigFlag) {
config.Consensus.AggregateSig = cli.GetBoolFlagValue(cmd, consensusAggregateSigFlag)
}
}
// transaction pool flags

@ -67,7 +67,8 @@ func TestHarmonyFlags(t *testing.T) {
Port: 9800,
},
Consensus: &consensusConfig{
MinPeers: 6,
MinPeers: 6,
AggregateSig: true,
},
BLSKeys: blsConfig{
KeyDir: "./.hmy/blskeys",
@ -600,15 +601,18 @@ func TestConsensusFlags(t *testing.T) {
expConfig: nil,
},
{
args: []string{"--consensus.min-peers", "10"},
args: []string{"--consensus.min-peers", "10", "--consensus.aggregate-sig=false"},
expConfig: &consensusConfig{
MinPeers: 10,
MinPeers: 10,
AggregateSig: false,
},
},
{
args: []string{"--delay_commit", "10ms", "--block_period", "5", "--min_peers", "10"},
args: []string{"--delay_commit", "10ms", "--block_period", "5", "--min_peers", "10",
"--consensus.aggregate-sig=true"},
expConfig: &consensusConfig{
MinPeers: 10,
MinPeers: 10,
AggregateSig: true,
},
},
}

@ -575,12 +575,16 @@ func setupConsensusAndNode(hc harmonyConfig, nodeConfig *nodeconfig.ConfigType)
// Parse minPeers from harmonyConfig
var minPeers int
var aggregateSig bool
if hc.Consensus != nil {
minPeers = hc.Consensus.MinPeers
aggregateSig = hc.Consensus.AggregateSig
} else {
minPeers = defaultConsensusConfig.MinPeers
aggregateSig = defaultConsensusConfig.AggregateSig
}
currentConsensus.MinPeers = minPeers
currentConsensus.AggregateSig = aggregateSig
blacklist, err := setupBlacklist(hc)
if err != nil {

@ -313,10 +313,8 @@ func (consensus *Consensus) UpdateConsensusInformation() Mode {
consensus.BlockPeriod = 5 * time.Second
// Enable aggregate sig at epoch 1000 for mainnet, at epoch 53000 for testnet, and always for other nets.
if (consensus.Blockchain.Config().ChainID == params.MainnetChainID && curEpoch.Cmp(big.NewInt(1000)) > 0) ||
(consensus.Blockchain.Config().ChainID == params.TestnetChainID && curEpoch.Cmp(big.NewInt(54500)) > 0) ||
(consensus.Blockchain.Config().ChainID != params.MainnetChainID && consensus.Blockchain.Config().ChainID != params.TestChainID) {
// Disable aggregate sig at epoch TBD for mainnet (for other net, it's default to true)
if consensus.Blockchain.Config().ChainID == params.MainnetChainID && curEpoch.Cmp(big.NewInt(1000)) >= 0 {
consensus.AggregateSig = true
}

Loading…
Cancel
Save