Skip to content

Commit

Permalink
Minimum changes for fixing 1.4.0 follow capabilities. (#980)
Browse files Browse the repository at this point in the history
  • Loading branch information
AnomalRoil committed May 4, 2022
1 parent f289edf commit 19b94a5
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 8 deletions.
6 changes: 4 additions & 2 deletions chain/info.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import (
"encoding/hex"
"time"

"github.com/drand/drand/common"

"github.com/drand/drand/common/scheme"

"github.com/drand/drand/key"
Expand Down Expand Up @@ -53,8 +55,8 @@ func (c *Info) Hash() []byte {
_, _ = h.Write(buff)
_, _ = h.Write(c.GroupHash)

// Use it only if ID is not empty. Keep backward compatibility
if c.ID != "" {
// To keep backward compatibility
if !common.IsDefaultBeaconID(c.ID) {
_, _ = h.Write([]byte(c.ID))
}

Expand Down
4 changes: 2 additions & 2 deletions core/drand_beacon_control.go
Original file line number Diff line number Diff line change
Expand Up @@ -770,7 +770,7 @@ func (bp *BeaconProcess) validateGroupTransition(oldGroup, newGroup *key.Group)
return errors.New("control: old and new group have different period - unsupported feature at the moment")
}

if oldGroup.ID != newGroup.ID {
if !commonutils.CompareBeaconIDs(oldGroup.ID, newGroup.ID) {
bp.log.Errorw("", "setup_reshare", "invalid ID in received group")
return errors.New("control: old and new group have different ID - unsupported feature at the moment")
}
Expand Down Expand Up @@ -1145,7 +1145,7 @@ func (bp *BeaconProcess) StartFollowChain(req *drand.StartFollowRequest, stream
if !bytes.Equal(info.Hash(), hash) {
return errors.New("invalid chain info hash")
}
if beaconID != info.ID {
if !commonutils.CompareBeaconIDs(beaconID, info.ID) {
return errors.New("invalid beacon id on chain info")
}

Expand Down
2 changes: 1 addition & 1 deletion core/drand_daemon_helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ func (dd *DrandDaemon) readBeaconID(metadata *protoCommon.Metadata) (string, err

if isChainHashFound {
// check if rcv beacon id on request points to a different id obtained from chain hash
if rcvBeaconID != "" && rcvBeaconID != beaconIDByHash {
if !common.CompareBeaconIDs(rcvBeaconID, beaconIDByHash) {
return "", fmt.Errorf("invalid chain hash")
}

Expand Down
6 changes: 3 additions & 3 deletions key/group.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,8 @@ func (g *Group) Hash() []byte {
_, _ = h.Write(g.PublicKey.Hash())
}

// Use it only if ID is not empty. Keep backward compatibility
if g.ID != "" {
// To keep backward compatibility
if !commonutils.IsDefaultBeaconID(g.ID) {
_, _ = h.Write([]byte(g.ID))
}

Expand Down Expand Up @@ -146,7 +146,7 @@ func (g *Group) String() string {

// Equal indicates if two groups are equal
func (g *Group) Equal(g2 *Group) bool {
if g.ID != g2.ID {
if !commonutils.CompareBeaconIDs(g.ID, g2.ID) {
return false
}
if g.Threshold != g2.Threshold {
Expand Down

0 comments on commit 19b94a5

Please sign in to comment.