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