Skip to content

Commit

Permalink
Merge branch 'rc/v1.6.0' into topic_request_fallback
Browse files Browse the repository at this point in the history
  • Loading branch information
sstanculeanu committed Oct 3, 2023
2 parents 7dd7c23 + ae2d7db commit e190b68
Show file tree
Hide file tree
Showing 54 changed files with 1,457 additions and 369 deletions.
4 changes: 2 additions & 2 deletions cmd/node/CLI.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ GLOBAL OPTIONS:
--round-config [path] The [path] for the round configuration file. This TOML file contains activation round configurations (default: "./config/enableRounds.toml")
--gas-costs-config [path] The [path] for the gas costs configuration directory. (default: "./config/gasSchedules")
--sk-index value The index in the PEM file of the private key to be used by the node. (default: 0)
--validator-key-pem-file filepath The filepath for the PEM file which contains the secret keys for the validator key. (default: "./config/validatorKey.pem")
--validator-key-pem-file filepath The filepath for the PEM file which contains the secret keys to be used by this node. If the file does not exists or can not be loaded, the node will autogenerate and use a random key. The key may or may not be registered to be a consensus validator. (default: "./config/validatorKey.pem")
--all-validator-keys-pem-file filepath The filepath for the PEM file which contains all the secret keys managed by the current node. (default: "./config/allValidatorsKeys.pem")
--port [p2p port] The [p2p port] number on which the application will start. Can use single values such as `0, 10230, 15670` or range of ports such as `5000-10000` (default: "0")
--full-archive-port [p2p port] The [p2p port] number on which the application will start the second network when running in full archive mode. Can use single values such as `0, 10230, 15670` or range of ports such as `5000-10000` (default: "0")
Expand Down Expand Up @@ -66,7 +66,7 @@ GLOBAL OPTIONS:
--force-start-from-network Flag that will force the start from network bootstrap process
--disable-consensus-watchdog Flag that will disable the consensus watchdog
--serialize-snapshots state snapshotting Flag that will serialize state snapshotting and `processing`
--no-key Boolean flag for enabling the node to generate a signing key when it starts (if the validatorKey.pem file is present, setting this flag to true will overwrite the BLS key used by the node)
--no-key DEPRECATED option, it will be removed in the next releases. To start a node without a key, simply omit to provide a validatorKey.pem file
--p2p-key-pem-file filepath The filepath for the PEM file which contains the secret keys for the p2p key. If this is not specified a new key will be generated (internally) by default. (default: "./config/p2pKey.pem")
--snapshots-enabled Boolean option for enabling state snapshots. If it is not set it defaults to true, it will be set to false if it is set specifically as --snapshots-enabled=false
--db-path directory This flag specifies the directory where the node will store databases.
Expand Down
5 changes: 5 additions & 0 deletions cmd/node/config/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -955,3 +955,8 @@
Capacity = 50000
Type = "SizeLRU"
SizeInBytes = 314572800 #300MB

[Redundancy]
# MaxRoundsOfInactivityAccepted defines the number of rounds missed by a main or higher level backup machine before
# the current machine will take over and propose/sign blocks. Used in both single-key and multi-key modes.
MaxRoundsOfInactivityAccepted = 3
17 changes: 12 additions & 5 deletions cmd/node/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -218,8 +218,10 @@ var (

// validatorKeyPemFile defines a flag for the path to the validator key used in block signing
validatorKeyPemFile = cli.StringFlag{
Name: "validator-key-pem-file",
Usage: "The `filepath` for the PEM file which contains the secret keys for the validator key.",
Name: "validator-key-pem-file",
Usage: "The `filepath` for the PEM file which contains the secret keys to be used by this node. If the file " +
"does not exists or can not be loaded, the node will autogenerate and use a random key. The key may or may not " +
"be registered to be a consensus validator.",
Value: "./config/validatorKey.pem",
}
// allValidatorKeysPemFile defines a flag for the path to the file that hold all validator keys used in block signing
Expand Down Expand Up @@ -373,10 +375,11 @@ var (
}

// noKey defines a flag that, if set, will generate every time when node starts a new signing key
// TODO: remove this in the next releases
noKey = cli.BoolFlag{
Name: "no-key",
Usage: "Boolean flag for enabling the node to generate a signing key when it starts (if the validatorKey.pem" +
" file is present, setting this flag to true will overwrite the BLS key used by the node)",
Usage: "DEPRECATED option, it will be removed in the next releases. To start a node without a key, " +
"simply omit to provide a validatorKey.pem file",
}

// p2pKeyPemFile defines the flag for the path to the key pem file used for p2p signing
Expand Down Expand Up @@ -492,10 +495,14 @@ func getFlagsConfig(ctx *cli.Context, log logger.Logger) *config.ContextFlagsCon
flagsConfig.ForceStartFromNetwork = ctx.GlobalBool(forceStartFromNetwork.Name)
flagsConfig.DisableConsensusWatchdog = ctx.GlobalBool(disableConsensusWatchdog.Name)
flagsConfig.SerializeSnapshots = ctx.GlobalBool(serializeSnapshots.Name)
flagsConfig.NoKeyProvided = ctx.GlobalBool(noKey.Name)
flagsConfig.OperationMode = ctx.GlobalString(operationMode.Name)
flagsConfig.RepopulateTokensSupplies = ctx.GlobalBool(repopulateTokensSupplies.Name)

if ctx.GlobalBool(noKey.Name) {
log.Warn("the provided -no-key option is deprecated and will soon be removed. To start a node without " +
"a key, simply omit to provide the validatorKey.pem file to the node binary")
}

return flagsConfig
}

Expand Down
2 changes: 1 addition & 1 deletion common/interface.go
Original file line number Diff line number Diff line change
Expand Up @@ -408,7 +408,7 @@ type ManagedPeersHolder interface {
GetMachineID(pkBytes []byte) (string, error)
GetNameAndIdentity(pkBytes []byte) (string, string, error)
IncrementRoundsWithoutReceivedMessages(pkBytes []byte)
ResetRoundsWithoutReceivedMessages(pkBytes []byte)
ResetRoundsWithoutReceivedMessages(pkBytes []byte, pid core.PeerID)
GetManagedKeysByCurrentNode() map[string]crypto.PrivateKey
IsKeyManagedByCurrentNode(pkBytes []byte) bool
IsKeyRegistered(pkBytes []byte) bool
Expand Down
6 changes: 6 additions & 0 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,7 @@ type Config struct {

PeersRatingConfig PeersRatingConfig
PoolsCleanersConfig PoolsCleanersConfig
Redundancy RedundancyConfig
}

// PeersRatingConfig will hold settings related to peers rating
Expand Down Expand Up @@ -621,3 +622,8 @@ type PoolsCleanersConfig struct {
MaxRoundsToKeepUnprocessedMiniBlocks int64
MaxRoundsToKeepUnprocessedTransactions int64
}

// RedundancyConfig represents the config options to be used when setting the redundancy configuration
type RedundancyConfig struct {
MaxRoundsOfInactivityAccepted int
}
1 change: 0 additions & 1 deletion config/contextFlagsConfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ type ContextFlagsConfig struct {
ForceStartFromNetwork bool
DisableConsensusWatchdog bool
SerializeSnapshots bool
NoKeyProvided bool
OperationMode string
RepopulateTokensSupplies bool
}
Expand Down
8 changes: 8 additions & 0 deletions config/tomlConfig_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,9 @@ func TestTomlParser(t *testing.T) {
MaxStateTrieLevelInMemory: 38,
MaxPeerTrieLevelInMemory: 39,
},
Redundancy: RedundancyConfig{
MaxRoundsOfInactivityAccepted: 3,
},
}
testString := `
[MiniBlocksStorage]
Expand Down Expand Up @@ -236,6 +239,11 @@ func TestTomlParser(t *testing.T) {
PeerStatePruningEnabled = true
MaxStateTrieLevelInMemory = 38
MaxPeerTrieLevelInMemory = 39
[Redundancy]
# MaxRoundsOfInactivityAccepted defines the number of rounds missed by a main or higher level backup machine before
# the current machine will take over and propose/sign blocks. Used in both single-key and multi-key modes.
MaxRoundsOfInactivityAccepted = 3
`
cfg := Config{}

Expand Down
2 changes: 1 addition & 1 deletion consensus/interface.go
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,6 @@ type KeysHandler interface {
IncrementRoundsWithoutReceivedMessages(pkBytes []byte)
GetAssociatedPid(pkBytes []byte) core.PeerID
IsOriginalPublicKeyOfTheNode(pkBytes []byte) bool
UpdatePublicKeyLiveness(pkBytes []byte, pid core.PeerID)
ResetRoundsWithoutReceivedMessages(pkBytes []byte, pid core.PeerID)
IsInterfaceNil() bool
}
34 changes: 34 additions & 0 deletions consensus/mock/sentSignatureTrackerStub.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package mock

// SentSignatureTrackerStub -
type SentSignatureTrackerStub struct {
StartRoundCalled func()
SignatureSentCalled func(pkBytes []byte)
ReceivedActualSignersCalled func(signersPks []string)
}

// StartRound -
func (stub *SentSignatureTrackerStub) StartRound() {
if stub.StartRoundCalled != nil {
stub.StartRoundCalled()
}
}

// SignatureSent -
func (stub *SentSignatureTrackerStub) SignatureSent(pkBytes []byte) {
if stub.SignatureSentCalled != nil {
stub.SignatureSentCalled(pkBytes)
}
}

// ReceivedActualSigners -
func (stub *SentSignatureTrackerStub) ReceivedActualSigners(signersPks []string) {
if stub.ReceivedActualSignersCalled != nil {
stub.ReceivedActualSignersCalled(signersPks)
}
}

// IsInterfaceNil -
func (stub *SentSignatureTrackerStub) IsInterfaceNil() bool {
return stub == nil
}
31 changes: 21 additions & 10 deletions consensus/spos/bls/blsSubroundsFactory.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,11 @@ type factory struct {
consensusState *spos.ConsensusState
worker spos.WorkerHandler

appStatusHandler core.AppStatusHandler
outportHandler outport.OutportHandler
chainID []byte
currentPid core.PeerID
appStatusHandler core.AppStatusHandler
outportHandler outport.OutportHandler
sentSignaturesTracker spos.SentSignaturesTracker
chainID []byte
currentPid core.PeerID
}

// NewSubroundsFactory creates a new consensusState object
Expand All @@ -30,25 +31,28 @@ func NewSubroundsFactory(
chainID []byte,
currentPid core.PeerID,
appStatusHandler core.AppStatusHandler,
sentSignaturesTracker spos.SentSignaturesTracker,
) (*factory, error) {
err := checkNewFactoryParams(
consensusDataContainer,
consensusState,
worker,
chainID,
appStatusHandler,
sentSignaturesTracker,
)
if err != nil {
return nil, err
}

fct := factory{
consensusCore: consensusDataContainer,
consensusState: consensusState,
worker: worker,
appStatusHandler: appStatusHandler,
chainID: chainID,
currentPid: currentPid,
consensusCore: consensusDataContainer,
consensusState: consensusState,
worker: worker,
appStatusHandler: appStatusHandler,
chainID: chainID,
currentPid: currentPid,
sentSignaturesTracker: sentSignaturesTracker,
}

return &fct, nil
Expand All @@ -60,6 +64,7 @@ func checkNewFactoryParams(
worker spos.WorkerHandler,
chainID []byte,
appStatusHandler core.AppStatusHandler,
sentSignaturesTracker spos.SentSignaturesTracker,
) error {
err := spos.ValidateConsensusCore(container)
if err != nil {
Expand All @@ -74,6 +79,9 @@ func checkNewFactoryParams(
if check.IfNil(appStatusHandler) {
return spos.ErrNilAppStatusHandler
}
if check.IfNil(sentSignaturesTracker) {
return spos.ErrNilSentSignatureTracker
}
if len(chainID) == 0 {
return spos.ErrInvalidChainID
}
Expand Down Expand Up @@ -145,6 +153,7 @@ func (fct *factory) generateStartRoundSubround() error {
processingThresholdPercent,
fct.worker.ExecuteStoredMessages,
fct.worker.ResetConsensusMessages,
fct.sentSignaturesTracker,
)
if err != nil {
return err
Expand Down Expand Up @@ -221,6 +230,7 @@ func (fct *factory) generateSignatureSubround() error {
subround,
fct.worker.Extend,
fct.appStatusHandler,
fct.sentSignaturesTracker,
)
if err != nil {
return err
Expand Down Expand Up @@ -258,6 +268,7 @@ func (fct *factory) generateEndRoundSubround() error {
spos.MaxThresholdPercent,
fct.worker.DisplayStatistics,
fct.appStatusHandler,
fct.sentSignaturesTracker,
)
if err != nil {
return err
Expand Down

0 comments on commit e190b68

Please sign in to comment.