Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion cmd/node/config/enableEpochs.toml
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,11 @@
# GovernanceEnableEpoch represents the epoch when governance is enabled
GovernanceEnableEpoch = 5

# GovernanceDisableProposalEnableEpoch represents the epoch when governance disable proposal is enabled
GovernanceDisableProposalEnableEpoch = 6

# GovernanceFixesEnableEpoch represents the epoch when governance fixes are enabled
GovernanceFixesEnableEpoch = 6
GovernanceFixesEnableEpoch = 7

# DelegationManagerEnableEpoch represents the epoch when the delegation manager is enabled
# epoch should not be 0
Expand Down
1 change: 1 addition & 0 deletions common/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -913,6 +913,7 @@ const (
ESDTFlag core.EnableEpochFlag = "ESDTFlag"
ESDTFlagInSpecificEpochOnly core.EnableEpochFlag = "ESDTFlagInSpecificEpochOnly"
GovernanceFlag core.EnableEpochFlag = "GovernanceFlag"
GovernanceDisableProposeFlag core.EnableEpochFlag = "GovernanceDisableProposeFlag"
GovernanceFixesFlag core.EnableEpochFlag = "GovernanceFixesFlag"
GovernanceFlagInSpecificEpochOnly core.EnableEpochFlag = "GovernanceFlagInSpecificEpochOnly"
DelegationManagerFlag core.EnableEpochFlag = "DelegationManagerFlag"
Expand Down
6 changes: 6 additions & 0 deletions common/enablers/enableEpochsHandler.go
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,12 @@ func (handler *enableEpochsHandler) createAllFlagsMap() {
},
activationEpoch: handler.enableEpochsConfig.GovernanceEnableEpoch,
},
common.GovernanceDisableProposeFlag: {
isActiveInEpoch: func(epoch uint32) bool {
return epoch >= handler.enableEpochsConfig.GovernanceDisableProposeEnableEpoch
},
activationEpoch: handler.enableEpochsConfig.GovernanceDisableProposeEnableEpoch,
},
common.GovernanceFixesFlag: {
isActiveInEpoch: func(epoch uint32) bool {
return epoch >= handler.enableEpochsConfig.GovernanceFixesEnableEpoch
Expand Down
1 change: 1 addition & 0 deletions common/enablers/enableEpochsHandler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,7 @@ func TestEnableEpochsHandler_GetActivationEpoch(t *testing.T) {
require.Equal(t, cfg.DoubleKeyProtectionEnableEpoch, handler.GetActivationEpoch(common.DoubleKeyProtectionFlag))
require.Equal(t, cfg.ESDTEnableEpoch, handler.GetActivationEpoch(common.ESDTFlag))
require.Equal(t, cfg.GovernanceEnableEpoch, handler.GetActivationEpoch(common.GovernanceFlag))
require.Equal(t, cfg.GovernanceDisableProposeEnableEpoch, handler.GetActivationEpoch(common.GovernanceDisableProposeFlag))
require.Equal(t, cfg.GovernanceFixesEnableEpoch, handler.GetActivationEpoch(common.GovernanceFixesFlag))
require.Equal(t, cfg.DelegationManagerEnableEpoch, handler.GetActivationEpoch(common.DelegationManagerFlag))
require.Equal(t, cfg.DelegationSmartContractEnableEpoch, handler.GetActivationEpoch(common.DelegationSmartContractFlag))
Expand Down
1 change: 1 addition & 0 deletions config/epochConfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ type EnableEpochs struct {
DoubleKeyProtectionEnableEpoch uint32
ESDTEnableEpoch uint32
GovernanceEnableEpoch uint32
GovernanceDisableProposeEnableEpoch uint32
GovernanceFixesEnableEpoch uint32
DelegationManagerEnableEpoch uint32
DelegationSmartContractEnableEpoch uint32
Expand Down
1 change: 1 addition & 0 deletions genesis/process/shardGenesisBlockCreator.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ func createGenesisConfig() config.EnableEpochs {
DoubleKeyProtectionEnableEpoch: 0,
ESDTEnableEpoch: unreachableEpoch,
GovernanceEnableEpoch: unreachableEpoch,
GovernanceDisableProposeEnableEpoch: unreachableEpoch,
GovernanceFixesEnableEpoch: unreachableEpoch,
DelegationManagerEnableEpoch: unreachableEpoch,
DelegationSmartContractEnableEpoch: unreachableEpoch,
Expand Down
2 changes: 2 additions & 0 deletions integrationTests/testProcessorNode.go
Original file line number Diff line number Diff line change
Expand Up @@ -3172,6 +3172,8 @@ func CreateEnableEpochsConfig() config.EnableEpochs {
DoubleKeyProtectionEnableEpoch: 0,
ESDTEnableEpoch: UnreachableEpoch,
GovernanceEnableEpoch: UnreachableEpoch,
GovernanceDisableProposeEnableEpoch: UnreachableEpoch,
GovernanceFixesEnableEpoch: UnreachableEpoch,
DelegationManagerEnableEpoch: UnreachableEpoch,
DelegationSmartContractEnableEpoch: UnreachableEpoch,
CorrectLastUnjailedEnableEpoch: UnreachableEpoch,
Expand Down
1 change: 1 addition & 0 deletions node/nodeRunner.go
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,7 @@ func printEnableEpochs(configs *config.Configs) {
log.Debug(readEpochFor("double key protection"), "epoch", enableEpochs.DoubleKeyProtectionEnableEpoch)
log.Debug(readEpochFor("esdt"), "epoch", enableEpochs.ESDTEnableEpoch)
log.Debug(readEpochFor("governance"), "epoch", enableEpochs.GovernanceEnableEpoch)
log.Debug(readEpochFor("governance disable proposal"), "epoch", enableEpochs.GovernanceDisableProposeEnableEpoch)
log.Debug(readEpochFor("governance fixes"), "epoch", enableEpochs.GovernanceFixesEnableEpoch)
log.Debug(readEpochFor("delegation manager"), "epoch", enableEpochs.DelegationManagerEnableEpoch)
log.Debug(readEpochFor("delegation smart contract"), "epoch", enableEpochs.DelegationSmartContractEnableEpoch)
Expand Down
4 changes: 4 additions & 0 deletions vm/systemSmartContracts/governance.go
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,10 @@ func (g *governanceContract) changeConfig(args *vmcommon.ContractCallInput) vmco

// proposal creates a new proposal from passed arguments
func (g *governanceContract) proposal(args *vmcommon.ContractCallInput) vmcommon.ReturnCode {
if g.enableEpochsHandler.IsFlagEnabled(common.GovernanceDisableProposeFlag) && !g.enableEpochsHandler.IsFlagEnabled(common.GovernanceFixesFlag) {
g.eei.AddReturnMessage("proposing is disabled")
return vmcommon.UserError
}
err := g.eei.UseGas(g.gasCost.MetaChainSystemSCsCost.Proposal)
if err != nil {
g.eei.AddReturnMessage("not enough gas")
Expand Down
23 changes: 23 additions & 0 deletions vm/systemSmartContracts/governance_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -942,6 +942,29 @@ func TestGovernanceContract_DelegateVoteMoreErrors(t *testing.T) {
require.True(t, strings.Contains(eei.GetReturnMessage(), "double vote is not allowed"))
}

func TestGovernanceContract_ProposalDuringDisableFlag(t *testing.T) {
t.Parallel()

gsc, _, eei := createGovernanceBlockChainHookStubContextHandler()
gsc.enableEpochsHandler = enableEpochsHandlerMock.NewEnableEpochsHandlerStub(common.GovernanceFlag, common.GovernanceDisableProposeFlag)
proposalIdentifier := bytes.Repeat([]byte("a"), commitHashLength)

callInputArgs := [][]byte{
proposalIdentifier,
[]byte("50"),
[]byte("55"),
}
callInput := createVMInput(big.NewInt(500), "proposal", vm.GovernanceSCAddress, []byte("addr1"), callInputArgs)
retCode := gsc.Execute(callInput)

require.True(t, strings.Contains(eei.GetReturnMessage(), "proposing is disabled"))
require.Equal(t, vmcommon.UserError, retCode)

gsc.enableEpochsHandler = enableEpochsHandlerMock.NewEnableEpochsHandlerStub(common.GovernanceFlag, common.GovernanceDisableProposeFlag, common.GovernanceFixesFlag)
retCode = gsc.Execute(callInput)
require.Equal(t, vmcommon.Ok, retCode)
}

func TestGovernanceContract_DelegateVoteMultiple(t *testing.T) {
t.Parallel()

Expand Down