|
|
|
@ -285,14 +285,30 @@ func (vc *viewChange) ProcessViewChangeMsg( |
|
|
|
|
vc.getLogger().Info().Uint64("viewID", recvMsg.ViewID). |
|
|
|
|
Str("validatorPubKey", senderKeyStr). |
|
|
|
|
Msg("[ProcessViewChangeMsg] Add M1 (prepared) type message") |
|
|
|
|
|
|
|
|
|
if _, ok := vc.bhpSigs[recvMsg.ViewID]; !ok { |
|
|
|
|
vc.bhpSigs[recvMsg.ViewID] = map[string]*bls_core.Sign{} |
|
|
|
|
} |
|
|
|
|
vc.bhpSigs[recvMsg.ViewID][senderKeyStr] = recvMsg.ViewchangeSig |
|
|
|
|
if _, ok := vc.bhpBitmap[recvMsg.ViewID]; !ok { |
|
|
|
|
bhpBitmap, _ := bls_cosi.NewMask(decider.Participants(), nil) |
|
|
|
|
vc.bhpBitmap[recvMsg.ViewID] = bhpBitmap |
|
|
|
|
} |
|
|
|
|
vc.bhpBitmap[recvMsg.ViewID].SetKey(senderKey.Bytes, true) // Set the bitmap indicating that this validator signed.
|
|
|
|
|
|
|
|
|
|
vc.getLogger().Info().Uint64("viewID", recvMsg.ViewID). |
|
|
|
|
Str("validatorPubKey", senderKeyStr). |
|
|
|
|
Msg("[ProcessViewChangeMsg] Add M3 (ViewID) type message") |
|
|
|
|
|
|
|
|
|
if _, ok := vc.viewIDSigs[recvMsg.ViewID]; !ok { |
|
|
|
|
vc.viewIDSigs[recvMsg.ViewID] = map[string]*bls_core.Sign{} |
|
|
|
|
} |
|
|
|
|
vc.viewIDSigs[recvMsg.ViewID][senderKeyStr] = recvMsg.ViewidSig |
|
|
|
|
|
|
|
|
|
if _, ok := vc.viewIDBitmap[recvMsg.ViewID]; !ok { |
|
|
|
|
viewIDBitmap, _ := bls_cosi.NewMask(decider.Participants(), nil) |
|
|
|
|
vc.viewIDBitmap[recvMsg.ViewID] = viewIDBitmap |
|
|
|
|
} |
|
|
|
|
// Set the bitmap indicating that this validator signed.
|
|
|
|
|
vc.viewIDBitmap[recvMsg.ViewID].SetKey(senderKey.Bytes, true) |
|
|
|
|
|
|
|
|
@ -328,15 +344,32 @@ func (vc *viewChange) ProcessViewChangeMsg( |
|
|
|
|
vc.getLogger().Info().Uint64("viewID", recvMsg.ViewID). |
|
|
|
|
Str("validatorPubKey", senderKeyStr). |
|
|
|
|
Msg("[ProcessViewChangeMsg] Add M2 (NIL) type message") |
|
|
|
|
|
|
|
|
|
if _, ok := vc.nilSigs[recvMsg.ViewID]; !ok { |
|
|
|
|
vc.nilSigs[recvMsg.ViewID] = map[string]*bls_core.Sign{} |
|
|
|
|
} |
|
|
|
|
vc.nilSigs[recvMsg.ViewID][senderKeyStr] = recvMsg.ViewchangeSig |
|
|
|
|
|
|
|
|
|
if _, ok := vc.nilBitmap[recvMsg.ViewID]; !ok { |
|
|
|
|
nilBitmap, _ := bls_cosi.NewMask(decider.Participants(), nil) |
|
|
|
|
vc.nilBitmap[recvMsg.ViewID] = nilBitmap |
|
|
|
|
} |
|
|
|
|
vc.nilBitmap[recvMsg.ViewID].SetKey(senderKey.Bytes, true) // Set the bitmap indicating that this validator signed.
|
|
|
|
|
|
|
|
|
|
vc.getLogger().Info().Uint64("viewID", recvMsg.ViewID). |
|
|
|
|
Str("validatorPubKey", senderKeyStr). |
|
|
|
|
Msg("[ProcessViewChangeMsg] Add M3 (ViewID) type message") |
|
|
|
|
|
|
|
|
|
if _, ok := vc.viewIDSigs[recvMsg.ViewID]; !ok { |
|
|
|
|
vc.viewIDSigs[recvMsg.ViewID] = map[string]*bls_core.Sign{} |
|
|
|
|
} |
|
|
|
|
vc.viewIDSigs[recvMsg.ViewID][senderKeyStr] = recvMsg.ViewidSig |
|
|
|
|
|
|
|
|
|
// Set the bitmap indicating that this validator signed.
|
|
|
|
|
if _, ok := vc.viewIDBitmap[recvMsg.ViewID]; !ok { |
|
|
|
|
viewIDBitmap, _ := bls_cosi.NewMask(decider.Participants(), nil) |
|
|
|
|
vc.viewIDBitmap[recvMsg.ViewID] = viewIDBitmap |
|
|
|
|
} |
|
|
|
|
vc.viewIDBitmap[recvMsg.ViewID].SetKey(senderKey.Bytes, true) |
|
|
|
|
|
|
|
|
|
return nil |
|
|
|
@ -348,6 +381,7 @@ func (vc *viewChange) InitPayload( |
|
|
|
|
viewID uint64, |
|
|
|
|
blockNum uint64, |
|
|
|
|
privKeys multibls.PrivateKeys, |
|
|
|
|
members multibls.PublicKeys, |
|
|
|
|
) error { |
|
|
|
|
// m1 or m2 init once per viewID/key.
|
|
|
|
|
// m1 and m2 are mutually exclusive.
|
|
|
|
@ -376,10 +410,18 @@ func (vc *viewChange) InitPayload( |
|
|
|
|
vc.getLogger().Info().Uint64("viewID", viewID).Uint64("blockNum", blockNum).Msg("[InitPayload] add my M1 (prepared) type messaage") |
|
|
|
|
msgToSign := append(preparedMsg.BlockHash[:], preparedMsg.Payload...) |
|
|
|
|
for _, key := range privKeys { |
|
|
|
|
// update the dictionary key if the viewID is first time received
|
|
|
|
|
if _, ok := vc.bhpBitmap[viewID]; !ok { |
|
|
|
|
bhpBitmap, _ := bls_cosi.NewMask(members, nil) |
|
|
|
|
vc.bhpBitmap[viewID] = bhpBitmap |
|
|
|
|
} |
|
|
|
|
if err := vc.bhpBitmap[viewID].SetKey(key.Pub.Bytes, true); err != nil { |
|
|
|
|
vc.getLogger().Warn().Str("key", key.Pub.Bytes.Hex()).Msg("[InitPayload] bhpBitmap setkey failed") |
|
|
|
|
continue |
|
|
|
|
} |
|
|
|
|
if _, ok := vc.bhpSigs[viewID]; !ok { |
|
|
|
|
vc.bhpSigs[viewID] = map[string]*bls_core.Sign{} |
|
|
|
|
} |
|
|
|
|
vc.bhpSigs[viewID][key.Pub.Bytes.Hex()] = key.Pri.SignHash(msgToSign) |
|
|
|
|
} |
|
|
|
|
hasBlock = true |
|
|
|
@ -393,6 +435,10 @@ func (vc *viewChange) InitPayload( |
|
|
|
|
if !hasBlock { |
|
|
|
|
vc.getLogger().Info().Uint64("viewID", viewID).Uint64("blockNum", blockNum).Msg("[InitPayload] add my M2 (NIL) type messaage") |
|
|
|
|
for _, key := range privKeys { |
|
|
|
|
if _, ok := vc.nilBitmap[viewID]; !ok { |
|
|
|
|
nilBitmap, _ := bls_cosi.NewMask(members, nil) |
|
|
|
|
vc.nilBitmap[viewID] = nilBitmap |
|
|
|
|
} |
|
|
|
|
if err := vc.nilBitmap[viewID].SetKey(key.Pub.Bytes, true); err != nil { |
|
|
|
|
vc.getLogger().Warn().Str("key", key.Pub.Bytes.Hex()).Msg("[InitPayload] nilBitmap setkey failed") |
|
|
|
|
continue |
|
|
|
@ -420,6 +466,10 @@ func (vc *viewChange) InitPayload( |
|
|
|
|
binary.LittleEndian.PutUint64(viewIDBytes, viewID) |
|
|
|
|
vc.getLogger().Info().Uint64("viewID", viewID).Uint64("blockNum", blockNum).Msg("[InitPayload] add my M3 (ViewID) type messaage") |
|
|
|
|
for _, key := range privKeys { |
|
|
|
|
if _, ok := vc.viewIDBitmap[viewID]; !ok { |
|
|
|
|
viewIDBitmap, _ := bls_cosi.NewMask(members, nil) |
|
|
|
|
vc.viewIDBitmap[viewID] = viewIDBitmap |
|
|
|
|
} |
|
|
|
|
if err := vc.viewIDBitmap[viewID].SetKey(key.Pub.Bytes, true); err != nil { |
|
|
|
|
vc.getLogger().Warn().Str("key", key.Pub.Bytes.Hex()).Msg("[InitPayload] viewIDBitmap setkey failed") |
|
|
|
|
continue |
|
|
|
|