Skip to content

Commit

Permalink
Merge pull request #6161 from multiversx/unjail-cleanup
Browse files Browse the repository at this point in the history
cleanup proposal misses
  • Loading branch information
AdoAdoAdo authored Jul 18, 2024
2 parents aa19325 + 06c2254 commit 317f2f6
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 3 deletions.
3 changes: 3 additions & 0 deletions cmd/node/config/enableEpochs.toml
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,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 @@ -1220,5 +1220,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
)
6 changes: 6 additions & 0 deletions common/enablers/enableEpochsHandler.go
Original file line number Diff line number Diff line change
Expand Up @@ -750,6 +750,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 @@ -117,6 +117,7 @@ type EnableEpochs struct {
DynamicESDTEnableEpoch uint32
EGLDInMultiTransferEnableEpoch uint32
CryptoOpcodesV2EnableEpoch uint32
UnJailCleanupEnableEpoch uint32
BLSMultiSignerEnableEpoch []MultiSignerConfig
}

Expand Down
9 changes: 7 additions & 2 deletions process/scToProtocol/stakingToPeer.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,15 @@ import (
"github.com/multiversx/mx-chain-core-go/data/smartContractResult"
"github.com/multiversx/mx-chain-core-go/hashing"
"github.com/multiversx/mx-chain-core-go/marshal"
"github.com/multiversx/mx-chain-logger-go"
vmcommon "github.com/multiversx/mx-chain-vm-common-go"

"github.com/multiversx/mx-chain-go/common"
"github.com/multiversx/mx-chain-go/dataRetriever"
"github.com/multiversx/mx-chain-go/process"
"github.com/multiversx/mx-chain-go/state"
"github.com/multiversx/mx-chain-go/vm"
"github.com/multiversx/mx-chain-go/vm/systemSmartContracts"
"github.com/multiversx/mx-chain-logger-go"
vmcommon "github.com/multiversx/mx-chain-vm-common-go"
)

var _ process.SmartContractToProtocolHandler = (*stakingToPeer)(nil)
Expand Down Expand Up @@ -109,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 @@ -341,6 +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)
if stp.enableEpochsHandler.IsFlagEnabled(common.UnJailCleanupFlag) {
account.SetConsecutiveProposerMisses(0)
}
}

isNewValidator := !isValidator && stakingData.Staked
Expand Down
2 changes: 1 addition & 1 deletion state/interface.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ type PeerAccountHandler interface {
GetTempRating() uint32
SetTempRating(uint32)
GetConsecutiveProposerMisses() uint32
SetConsecutiveProposerMisses(uint322 uint32)
SetConsecutiveProposerMisses(consecutiveMisses uint32)
ResetAtNewEpoch()
SetPreviousList(list string)
vmcommon.AccountHandler
Expand Down

0 comments on commit 317f2f6

Please sign in to comment.