Skip to content

Commit

Permalink
add activation flag for unjail cleanup backwards compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
AdoAdoAdo committed May 21, 2024
1 parent dea63b1 commit 288012b
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 2 deletions.
3 changes: 3 additions & 0 deletions cmd/node/config/enableEpochs.toml
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,9 @@
# CryptoOpcodesV2EnableEpoch represents the epoch when BLSMultiSig, Secp256r1 and other opcodes are enabled
CryptoOpcodesV2EnableEpoch = 4

# UnjailCleanupEnableEpoch represents the epoch when the cleanup of the unjailed nodes is enabled
UnJailCleanupEnableEpoch = 4

# BLSMultiSignerEnableEpoch represents the activation epoch for different types of BLS multi-signers
BLSMultiSignerEnableEpoch = [
{ EnableEpoch = 0, Type = "no-KOSK" },
Expand Down
1 change: 1 addition & 0 deletions common/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -1016,5 +1016,6 @@ const (
DynamicESDTFlag core.EnableEpochFlag = "DynamicEsdtFlag"
EGLDInESDTMultiTransferFlag core.EnableEpochFlag = "EGLDInESDTMultiTransferFlag"
CryptoOpcodesV2Flag core.EnableEpochFlag = "CryptoOpcodesV2Flag"
UnJailCleanupFlag core.EnableEpochFlag = "UnJailCleanupFlag"
// all new flags must be added to createAllFlagsMap method, as part of enableEpochsHandler allFlagsDefined
)
9 changes: 8 additions & 1 deletion common/enablers/enableEpochsHandler.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,11 @@ import (

"github.com/multiversx/mx-chain-core-go/core"
"github.com/multiversx/mx-chain-core-go/core/check"
logger "github.com/multiversx/mx-chain-logger-go"

"github.com/multiversx/mx-chain-go/common"
"github.com/multiversx/mx-chain-go/config"
"github.com/multiversx/mx-chain-go/process"
logger "github.com/multiversx/mx-chain-logger-go"
)

var log = logger.GetOrCreate("common/enablers")
Expand Down Expand Up @@ -743,6 +744,12 @@ func (handler *enableEpochsHandler) createAllFlagsMap() {
},
activationEpoch: handler.enableEpochsConfig.CryptoOpcodesV2EnableEpoch,
},
common.UnJailCleanupFlag: {
isActiveInEpoch: func(epoch uint32) bool {
return epoch >= handler.enableEpochsConfig.UnJailCleanupEnableEpoch
},
activationEpoch: handler.enableEpochsConfig.UnJailCleanupEnableEpoch,
},
}
}

Expand Down
1 change: 1 addition & 0 deletions config/epochConfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ type EnableEpochs struct {
DynamicESDTEnableEpoch uint32
EGLDInMultiTransferEnableEpoch uint32
CryptoOpcodesV2EnableEpoch uint32
UnJailCleanupEnableEpoch uint32
BLSMultiSignerEnableEpoch []MultiSignerConfig
}

Expand Down
5 changes: 4 additions & 1 deletion process/scToProtocol/stakingToPeer.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ func checkIfNil(args ArgStakingToPeer) error {
return core.CheckHandlerCompatibility(args.EnableEpochsHandler, []core.EnableEpochFlag{
common.StakeFlag,
common.ValidatorToDelegationFlag,
common.UnJailCleanupFlag,
})
}

Expand Down Expand Up @@ -342,7 +343,9 @@ func (stp *stakingToPeer) updatePeerState(
if account.GetTempRating() < stp.unJailRating {
log.Debug("node is unJailed, setting temp rating to start rating", "blsKey", blsPubKey)
account.SetTempRating(stp.unJailRating)
account.SetConsecutiveProposerMisses(0)
if stp.enableEpochsHandler.IsFlagEnabled(common.UnJailCleanupFlag) {
account.SetConsecutiveProposerMisses(0)
}
}

isNewValidator := !isValidator && stakingData.Staked
Expand Down

0 comments on commit 288012b

Please sign in to comment.