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

Removed aggregate sig flag. #4657

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from
Open
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
3 changes: 1 addition & 2 deletions cmd/harmony/default.go
Original file line number Diff line number Diff line change
Expand Up @@ -165,8 +165,7 @@ var defaultLogContext = harmonyconfig.LogContext{
}

var defaultConsensusConfig = harmonyconfig.ConsensusConfig{
MinPeers: 6,
AggregateSig: true,
MinPeers: 6,
}

var defaultPrometheusConfig = harmonyconfig.PrometheusConfig{
Expand Down
10 changes: 0 additions & 10 deletions cmd/harmony/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,6 @@ var (
// consensusValidFlags are flags that are effective
consensusValidFlags = []cli.Flag{
consensusMinPeersFlag,
consensusAggregateSigFlag,
legacyConsensusMinPeersFlag,
}

Expand Down Expand Up @@ -1139,11 +1138,6 @@ 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",
Expand Down Expand Up @@ -1174,10 +1168,6 @@ func applyConsensusFlags(cmd *cobra.Command, config *harmonyconfig.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
Expand Down
14 changes: 5 additions & 9 deletions cmd/harmony/flags_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,7 @@ func TestHarmonyFlags(t *testing.T) {
AuthPort: 9801,
},
Consensus: &harmonyconfig.ConsensusConfig{
MinPeers: 6,
AggregateSig: true,
MinPeers: 6,
},
BLSKeys: harmonyconfig.BlsConfig{
KeyDir: "./.hmy/blskeys",
Expand Down Expand Up @@ -989,18 +988,15 @@ func TestConsensusFlags(t *testing.T) {
expConfig: nil,
},
{
args: []string{"--consensus.min-peers", "10", "--consensus.aggregate-sig=false"},
args: []string{"--consensus.min-peers", "10"},
expConfig: &harmonyconfig.ConsensusConfig{
MinPeers: 10,
AggregateSig: false,
MinPeers: 10,
},
},
{
args: []string{"--delay_commit", "10ms", "--block_period", "5", "--min_peers", "10",
"--consensus.aggregate-sig=true"},
args: []string{"--delay_commit", "10ms", "--block_period", "5", "--min_peers", "10"},
expConfig: &harmonyconfig.ConsensusConfig{
MinPeers: 10,
AggregateSig: true,
MinPeers: 10,
},
},
}
Expand Down
6 changes: 2 additions & 4 deletions cmd/harmony/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -788,13 +788,11 @@ func setupConsensusAndNode(hc harmonyconfig.HarmonyConfig, nodeConfig *nodeconfi

// Parse minPeers from harmonyconfig.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
}

blacklist, err := setupBlacklist(hc)
Expand All @@ -821,7 +819,7 @@ func setupConsensusAndNode(hc harmonyconfig.HarmonyConfig, nodeConfig *nodeconfi
// Consensus object.
registry.SetIsBackup(isBackup(hc))
currentConsensus, err := consensus.New(
myHost, nodeConfig.ShardID, nodeConfig.ConsensusPriKey, registry, decider, minPeers, aggregateSig)
myHost, nodeConfig.ShardID, nodeConfig.ConsensusPriKey, registry, decider, minPeers)

if err != nil {
_, _ = fmt.Fprintf(os.Stderr, "Error :%v \n", err)
Expand Down
25 changes: 11 additions & 14 deletions consensus/consensus.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,6 @@ type Consensus struct {
BlockPeriod time.Duration
// The time due for next block proposal
NextBlockDue time.Time
// Temporary flag to control whether aggregate signature signing is enabled
AggregateSig bool

// TODO (leo): an new metrics system to keep track of the consensus/viewchange
// finality of previous consensus in the unit of milliseconds
Expand Down Expand Up @@ -271,20 +269,19 @@ func (consensus *Consensus) getBlockNum() uint64 {
func New(
host p2p.Host, shard uint32, multiBLSPriKey multibls.PrivateKeys,
registry *registry.Registry,
Decider quorum.Decider, minPeers int, aggregateSig bool,
Decider quorum.Decider, minPeers int,
) (*Consensus, error) {
consensus := Consensus{
mutex: &sync.RWMutex{},
ShardID: shard,
fBFTLog: NewFBFTLog(),
phase: FBFTAnnounce,
current: State{mode: Normal},
decider: Decider,
registry: registry,
MinPeers: minPeers,
AggregateSig: aggregateSig,
host: host,
msgSender: NewMessageSender(host),
mutex: &sync.RWMutex{},
ShardID: shard,
fBFTLog: NewFBFTLog(),
phase: FBFTAnnounce,
current: State{mode: Normal},
decider: Decider,
registry: registry,
MinPeers: minPeers,
host: host,
msgSender: NewMessageSender(host),
// FBFT timeout
consensusTimeout: createTimeout(),
dHelper: downloadAsync{},
Expand Down
4 changes: 2 additions & 2 deletions consensus/consensus_service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ func TestSignAndMarshalConsensusMessage(t *testing.T) {
decider := quorum.NewDecider(quorum.SuperMajorityVote, shard.BeaconChainShardID)
blsPriKey := bls.RandPrivateKey()
reg := registry.New()
consensus, err := New(host, shard.BeaconChainShardID, multibls.GetPrivateKeys(blsPriKey), reg, decider, 3, false)
consensus, err := New(host, shard.BeaconChainShardID, multibls.GetPrivateKeys(blsPriKey), reg, decider, 3)
if err != nil {
t.Fatalf("Cannot craeate consensus: %v", err)
}
Expand Down Expand Up @@ -63,7 +63,7 @@ func TestSetViewID(t *testing.T) {
blsPriKey := bls.RandPrivateKey()
reg := registry.New()
consensus, err := New(
host, shard.BeaconChainShardID, multibls.GetPrivateKeys(blsPriKey), reg, decider, 3, false,
host, shard.BeaconChainShardID, multibls.GetPrivateKeys(blsPriKey), reg, decider, 3,
)
if err != nil {
t.Fatalf("Cannot craeate consensus: %v", err)
Expand Down
2 changes: 1 addition & 1 deletion consensus/consensus_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ func GenerateConsensusForTesting() (p2p.Host, multibls.PrivateKeys, *Consensus,
decider := quorum.NewDecider(quorum.SuperMajorityVote, shard.BeaconChainShardID)
multiBLSPrivateKey := multibls.GetPrivateKeys(bls.RandPrivateKey())

consensus, err := New(host, shard.BeaconChainShardID, multiBLSPrivateKey, registry.New(), decider, 3, false)
consensus, err := New(host, shard.BeaconChainShardID, multiBLSPrivateKey, registry.New(), decider, 3)
if err != nil {
return nil, nil, nil, nil, err
}
Expand Down
10 changes: 5 additions & 5 deletions consensus/construct_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ func TestConstructAnnounceMessage(test *testing.T) {
)
blsPriKey := bls.RandPrivateKey()
reg := registry.New()
consensus, err := New(host, shard.BeaconChainShardID, multibls.GetPrivateKeys(blsPriKey), reg, decider, 3, false)
consensus, err := New(host, shard.BeaconChainShardID, multibls.GetPrivateKeys(blsPriKey), reg, decider, 3)
if err != nil {
test.Fatalf("Cannot create consensus: %v", err)
}
Expand Down Expand Up @@ -66,7 +66,7 @@ func TestConstructPreparedMessage(test *testing.T) {
)
blsPriKey := bls.RandPrivateKey()
reg := registry.New()
consensus, err := New(host, shard.BeaconChainShardID, multibls.GetPrivateKeys(blsPriKey), reg, decider, 3, false)
consensus, err := New(host, shard.BeaconChainShardID, multibls.GetPrivateKeys(blsPriKey), reg, decider, 3)
if err != nil {
test.Fatalf("Cannot craeate consensus: %v", err)
}
Expand Down Expand Up @@ -146,7 +146,7 @@ func TestConstructPrepareMessage(test *testing.T) {
)

consensus, err := New(
host, shard.BeaconChainShardID, multibls.GetPrivateKeys(blsPriKey1), registry.New(), decider, 3, false,
host, shard.BeaconChainShardID, multibls.GetPrivateKeys(blsPriKey1), registry.New(), decider, 3,
)
if err != nil {
test.Fatalf("Cannot create consensus: %v", err)
Expand Down Expand Up @@ -237,7 +237,7 @@ func TestConstructCommitMessage(test *testing.T) {
quorum.SuperMajorityStake, shard.BeaconChainShardID,
)

consensus, err := New(host, shard.BeaconChainShardID, multibls.GetPrivateKeys(blsPriKey1), registry.New(), decider, 3, false)
consensus, err := New(host, shard.BeaconChainShardID, multibls.GetPrivateKeys(blsPriKey1), registry.New(), decider, 3)
if err != nil {
test.Fatalf("Cannot create consensus: %v", err)
}
Expand Down Expand Up @@ -319,7 +319,7 @@ func TestPopulateMessageFields(t *testing.T) {
quorum.SuperMajorityVote, shard.BeaconChainShardID,
)
consensus, err := New(
host, shard.BeaconChainShardID, multibls.GetPrivateKeys(blsPriKey), registry.New(), decider, 3, false,
host, shard.BeaconChainShardID, multibls.GetPrivateKeys(blsPriKey), registry.New(), decider, 3,
)
if err != nil {
t.Fatalf("Cannot craeate consensus: %v", err)
Expand Down
33 changes: 9 additions & 24 deletions consensus/validator.go
Original file line number Diff line number Diff line change
Expand Up @@ -405,33 +405,18 @@ func (consensus *Consensus) getPriKeysInCommittee() []*bls.PrivateKeyWrapper {

func (consensus *Consensus) constructP2pMessages(msgType msg_pb.MessageType, payloadForSign []byte, priKeys []*bls.PrivateKeyWrapper) []*NetworkMessage {
p2pMsgs := []*NetworkMessage{}
if consensus.AggregateSig {
networkMessage, err := consensus.construct(msgType, payloadForSign, priKeys)
if err != nil {
logger := consensus.getLogger().Err(err).
Str("message-type", msgType.String())
for _, key := range priKeys {
logger.Str("key", key.Pri.SerializeToHexStr())
}
logger.Msg("could not construct message")
} else {
p2pMsgs = append(p2pMsgs, networkMessage)
}

} else {
networkMessage, err := consensus.construct(msgType, payloadForSign, priKeys)
if err != nil {
logger := consensus.getLogger().Err(err).
Str("message-type", msgType.String())
for _, key := range priKeys {
networkMessage, err := consensus.construct(msgType, payloadForSign, []*bls.PrivateKeyWrapper{key})
if err != nil {
consensus.getLogger().Err(err).
Str("message-type", msgType.String()).
Str("key", key.Pri.SerializeToHexStr()).
Msg("could not construct message")
continue
}

p2pMsgs = append(p2pMsgs, networkMessage)
logger.Str("key", key.Pri.SerializeToHexStr())
}
logger.Msg("could not construct message")
} else {
p2pMsgs = append(p2pMsgs, networkMessage)
}

return p2pMsgs
}

Expand Down
2 changes: 1 addition & 1 deletion core_test/shardchain_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ func TestAddNewBlock(t *testing.T) {
SetEngine(engine).
SetShardChainCollection(collection)
consensus, err := consensus.New(
host, shard.BeaconChainShardID, multibls.GetPrivateKeys(blsKey), reg, decider, 3, false,
host, shard.BeaconChainShardID, multibls.GetPrivateKeys(blsKey), reg, decider, 3,
)
if err != nil {
t.Fatalf("Cannot craeate consensus: %v", err)
Expand Down
3 changes: 1 addition & 2 deletions internal/configs/harmony/harmony.go
Original file line number Diff line number Diff line change
Expand Up @@ -180,8 +180,7 @@ type GasPriceOracleConfig struct {
}

type ConsensusConfig struct {
MinPeers int
AggregateSig bool
MinPeers int
}

type BlsConfig struct {
Expand Down
6 changes: 3 additions & 3 deletions node/node_handler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ func TestAddNewBlock(t *testing.T) {
SetBlockchain(blockchain).
SetEngine(engine).
SetShardChainCollection(collection)
consensus, err := consensus.New(host, shard.BeaconChainShardID, multibls.GetPrivateKeys(blsKey), reg, decider, 3, false)
consensus, err := consensus.New(host, shard.BeaconChainShardID, multibls.GetPrivateKeys(blsKey), reg, decider, 3)
if err != nil {
t.Fatalf("Cannot craeate consensus: %v", err)
}
Expand Down Expand Up @@ -109,7 +109,7 @@ func TestVerifyNewBlock(t *testing.T) {
SetShardChainCollection(collection)

consensusObj, err := consensus.New(
host, shard.BeaconChainShardID, multibls.GetPrivateKeys(blsKey), reg, decider, 3, false,
host, shard.BeaconChainShardID, multibls.GetPrivateKeys(blsKey), reg, decider, 3,
)
if err != nil {
t.Fatalf("Cannot craeate consensus: %v", err)
Expand Down Expand Up @@ -168,7 +168,7 @@ func TestVerifyVRF(t *testing.T) {
SetEngine(engine).
SetShardChainCollection(collection)
consensus, err := consensus.New(
host, shard.BeaconChainShardID, multibls.GetPrivateKeys(blsKey), reg, decider, 3, false,
host, shard.BeaconChainShardID, multibls.GetPrivateKeys(blsKey), reg, decider, 3,
)
if err != nil {
t.Fatalf("Cannot craeate consensus: %v", err)
Expand Down
2 changes: 1 addition & 1 deletion node/node_newblock_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ func TestFinalizeNewBlockAsync(t *testing.T) {
SetEngine(engine).
SetShardChainCollection(collection)
consensusObj, err := consensus.New(
host, shard.BeaconChainShardID, multibls.GetPrivateKeys(blsKey), reg, decider, 3, false,
host, shard.BeaconChainShardID, multibls.GetPrivateKeys(blsKey), reg, decider, 3,
)
if err != nil {
t.Fatalf("Cannot craeate consensus: %v", err)
Expand Down
2 changes: 1 addition & 1 deletion node/node_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ func TestNewNode(t *testing.T) {
SetShardChainCollection(collection)

consensus, err := consensus.New(
host, shard.BeaconChainShardID, multibls.GetPrivateKeys(blsKey), reg, decider, 3, false,
host, shard.BeaconChainShardID, multibls.GetPrivateKeys(blsKey), reg, decider, 3,
)
if err != nil {
t.Fatalf("Cannot craeate consensus: %v", err)
Expand Down