Skip to content
This repository has been archived by the owner on Aug 24, 2022. It is now read-only.

Commit

Permalink
Bug fix setting of initial entropy for sentries (#108)
Browse files Browse the repository at this point in the history
* Bug fix for sentry nodes

* Style
  • Loading branch information
jinmannwong authored Jul 7, 2020
1 parent 6dea79a commit 76f851a
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 14 deletions.
15 changes: 8 additions & 7 deletions beacon/entropy_generator.go
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,14 @@ func (entropyGenerator *EntropyGenerator) changeKeys() (didChangeKeys bool) {
"start", entropyGenerator.aeon.Start)
didChangeKeys = true
}

// If lastComputedEntropyHeight is not set then set it is equal to group public key (should
// only be the case one for first DKG after genesis)
if entropyGenerator.lastComputedEntropyHeight == -1 && entropyGenerator.aeon.aeonExecUnit != nil {
entropyGenerator.lastComputedEntropyHeight = entropyGenerator.lastBlockHeight
entropyGenerator.entropyComputed[entropyGenerator.lastComputedEntropyHeight] =
tmhash.Sum([]byte(entropyGenerator.aeon.aeonExecUnit.GroupPublicKey()))
}
return
}

Expand Down Expand Up @@ -383,13 +391,6 @@ func (entropyGenerator *EntropyGenerator) sign() {
entropyGenerator.Logger.Debug("sign: no dkg private key", "height", entropyGenerator.lastBlockHeight+1)
return
}
if entropyGenerator.lastComputedEntropyHeight == -1 {
// If lastComputedEntropyHeight is not set then set it is equal to group public key (should
// only be the case one for first DKG after genesis)
entropyGenerator.lastComputedEntropyHeight = entropyGenerator.lastBlockHeight
entropyGenerator.entropyComputed[entropyGenerator.lastComputedEntropyHeight] =
tmhash.Sum([]byte(entropyGenerator.aeon.aeonExecUnit.GroupPublicKey()))
}

index, _ := entropyGenerator.aeon.validators.GetByAddress(entropyGenerator.aeon.privValidator.GetPubKey().Address())
blockHeight := entropyGenerator.lastBlockHeight + 1
Expand Down
4 changes: 2 additions & 2 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ var (
defaultPrivValKeyName = "priv_validator_key.json"
defaultPrivValStateName = "priv_validator_state.json"

defaultOldEntropyKeyName = "old_entropy_key.json"
defaultOldEntropyKeyName = "old_entropy_key.json"
defaultEntropyKeyName = "entropy_key.json"
defaultNextEntropyKeyName = "next_entropy_key.json"
defaultNoiseKeyName = "noise_key.json"
Expand All @@ -51,7 +51,7 @@ var (
defaultGenesisJSONPath = filepath.Join(defaultConfigDir, defaultGenesisJSONName)
defaultPrivValKeyPath = filepath.Join(defaultConfigDir, defaultPrivValKeyName)
defaultPrivValStatePath = filepath.Join(defaultDataDir, defaultPrivValStateName)
defaultOldEntropyKeyPath = filepath.Join(defaultDataDir, defaultOldEntropyKeyName)
defaultOldEntropyKeyPath = filepath.Join(defaultDataDir, defaultOldEntropyKeyName)
defaultEntropyKeyPath = filepath.Join(defaultDataDir, defaultEntropyKeyName)
defaultNextEntropyKeyPath = filepath.Join(defaultDataDir, defaultNextEntropyKeyName)
defaultNoiseKeyPath = filepath.Join(defaultDataDir, defaultNoiseKeyName)
Expand Down
2 changes: 1 addition & 1 deletion consensus/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ func NopMetrics() *Metrics {
BlockParts: discard.NewCounter(),

NumFailuresAsBlockProducer: discard.NewCounter(),
NumBlockProducer: discard.NewCounter(),
NumBlockProducer: discard.NewCounter(),
BlockWithEntropy: discard.NewGauge(),
}
}
2 changes: 1 addition & 1 deletion consensus/state.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ import (
"fmt"
"github.com/tendermint/tendermint/tx_extensions"
"math/rand"
"os"
"reflect"
"runtime/debug"
"sync"
"time"
"os"

"github.com/pkg/errors"

Expand Down
6 changes: 3 additions & 3 deletions node/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -592,15 +592,15 @@ func createBeaconReactor(
for _, fileToLoad := range keyFiles {
if cmn.FileExists(fileToLoad) {
// Load the aeon from file
if aeonFile, err := beacon.LoadAeonDetailsFile(fileToLoad);err == nil {
if aeonFile, err := beacon.LoadAeonDetailsFile(fileToLoad); err == nil {
// Get the validators for that aeon
if vals, err1 := sm.LoadValidators(db, aeonFile.PublicInfo.ValidatorHeight);err1 == nil {
if vals, err1 := sm.LoadValidators(db, aeonFile.PublicInfo.ValidatorHeight); err1 == nil {

// Push the complete aeon into the entropy generator
aeonDetails := beacon.LoadAeonDetails(aeonFile, vals, privValidator)
entropyGenerator.SetNextAeonDetails(aeonDetails)

// Set dkg runner to most recent aeon which we generated keys for
// Set dkg runner to most recent aeon which we generated keys for
if dkgRunner != nil {
dkgRunner.SetCurrentAeon(aeonDetails.Start, aeonDetails.End)
}
Expand Down

0 comments on commit 76f851a

Please sign in to comment.