Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mx 15702 sovereign enable epochs handler #6626

Open
wants to merge 31 commits into
base: feat/chain-go-sdk
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 24 commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
06ec481
sovereign enable epochs handler components
axenteoctavian Nov 22, 2024
616fb58
enable epoch handler in run type core components
axenteoctavian Nov 22, 2024
cdf3af3
Revert "enable epoch handler in run type core components"
axenteoctavian Nov 22, 2024
25e723d
Merge branch 'refs/heads/feat/chain-go-sdk' into MX-15702-sovereign-e…
axenteoctavian Nov 25, 2024
1ecbf3a
sovereign enable epoch handler in components
axenteoctavian Nov 25, 2024
39dd138
fixes and unit test files
axenteoctavian Nov 25, 2024
ae8c842
Merge branch 'feat/chain-go-sdk' into MX-15702-sovereign-enable-epoch…
axenteoctavian Nov 25, 2024
24f419a
mocks and other changes
axenteoctavian Nov 26, 2024
a0726b2
unit test fixes
axenteoctavian Nov 26, 2024
dfd199d
Merge branch 'feat/chain-go-sdk' into MX-15702-sovereign-enable-epoch…
axenteoctavian Nov 26, 2024
35b4a1b
fixes after running long tests
axenteoctavian Nov 26, 2024
2987d1d
Merge remote-tracking branch 'origin/MX-15702-sovereign-enable-epochs…
axenteoctavian Nov 26, 2024
8277d45
fixes after running long tests
axenteoctavian Nov 26, 2024
08aaac2
unit test fix
axenteoctavian Nov 27, 2024
392e646
fixes after self review
axenteoctavian Nov 27, 2024
3ecac02
fixes after self review
axenteoctavian Nov 27, 2024
5c8327f
fixes after self review
axenteoctavian Nov 27, 2024
246363d
Merge branch 'feat/chain-go-sdk' into MX-15702-sovereign-enable-epoch…
axenteoctavian Nov 27, 2024
7a8922f
fix sovereign genesis block creator
axenteoctavian Nov 28, 2024
368e17a
nodes setup mock updated
axenteoctavian Nov 28, 2024
caba123
refactor the implementation
axenteoctavian Dec 6, 2024
5f9042c
Merge branch 'feat/chain-go-sdk' into MX-15702-sovereign-enable-epoch…
axenteoctavian Dec 9, 2024
b8fd2f8
fixes after review
axenteoctavian Dec 9, 2024
bcbce0e
fixes after review
axenteoctavian Dec 9, 2024
739d48e
added missing checks
axenteoctavian Dec 11, 2024
d2aac11
Merge branch 'feat/chain-go-sdk' into MX-15702-sovereign-enable-epoch…
axenteoctavian Dec 11, 2024
2cc653b
extra comment
axenteoctavian Dec 11, 2024
4a767eb
all flags with epoch 0
axenteoctavian Dec 11, 2024
2c0776e
sovereign epoch config unit test
axenteoctavian Dec 11, 2024
f5dc173
Merge branch 'feat/chain-go-sdk' into MX-15702-sovereign-enable-epoch…
axenteoctavian Dec 13, 2024
a3798d0
fix testing component
axenteoctavian Dec 13, 2024
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
12 changes: 9 additions & 3 deletions cmd/sovereignnode/chainSimulator/sovereignChainSimulator.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ func NewSovereignChainSimulator(args ArgsSovereignChainSimulator) (chainSimulato
}

args.CreateRunTypeCoreComponents = func() (factory.RunTypeCoreComponentsHolder, error) {
return createSovereignRunTypeCoreComponents()
return createSovereignRunTypeCoreComponents(*configs.SovereignEpochConfig)
}
args.CreateIncomingHeaderSubscriber = func(config config.WebSocketConfig, dataPool dataRetriever.PoolsHolder, mainChainNotarizationStartRound uint64, runTypeComponents factory.RunTypeComponentsHolder) (process.IncomingHeaderSubscriber, error) {
return incomingHeader.CreateIncomingHeaderProcessor(config, dataPool, mainChainNotarizationStartRound, runTypeComponents)
Expand Down Expand Up @@ -85,17 +85,23 @@ func loadSovereignConfigs(configsPath string) (*sovereignConfig.SovereignConfig,
return nil, err
}

sovereignEpochConfig, err := sovereignConfig.LoadSovereignEpochConfig(path.Join(configsPath, "enableEpochs.toml"))
if err != nil {
return nil, err
}

return &sovereignConfig.SovereignConfig{
Configs: &config.Configs{
EpochConfig: epochConfig,
EconomicsConfig: economicsConfig,
},
SovereignExtraConfig: sovereignExtraConfig,
SovereignEpochConfig: sovereignEpochConfig,
}, nil
}

func createSovereignRunTypeCoreComponents() (factory.RunTypeCoreComponentsHolder, error) {
sovereignRunTypeCoreComponentsFactory := runType.NewSovereignRunTypeCoreComponentsFactory()
func createSovereignRunTypeCoreComponents(sovereignEpochConfig config.SovereignEpochConfig) (factory.RunTypeCoreComponentsHolder, error) {
sovereignRunTypeCoreComponentsFactory := runType.NewSovereignRunTypeCoreComponentsFactory(sovereignEpochConfig)
managedRunTypeCoreComponents, err := runType.NewManagedRunTypeCoreComponents(sovereignRunTypeCoreComponentsFactory)
if err != nil {
return nil, err
Expand Down
15 changes: 9 additions & 6 deletions cmd/sovereignnode/chainSimulator/sovereignChainSimulator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ import (
"testing"
"time"

"github.com/multiversx/mx-chain-core-go/core"
"github.com/stretchr/testify/require"

chainSimulatorCommon "github.com/multiversx/mx-chain-go/integrationTests/chainSimulator"
chainSim "github.com/multiversx/mx-chain-go/node/chainSimulator"
"github.com/multiversx/mx-chain-go/node/chainSimulator/components/api"
"github.com/multiversx/mx-chain-go/node/chainSimulator/dtos"

"github.com/multiversx/mx-chain-core-go/core"
"github.com/stretchr/testify/require"
)

const (
Expand Down Expand Up @@ -57,9 +57,12 @@ func TestChainSimulator_GenerateBlocksShouldWork(t *testing.T) {
PathToInitialConfig: defaultPathToInitialConfig,
GenesisTimestamp: time.Now().Unix(),
RoundDurationInMillis: uint64(6000),
RoundsPerEpoch: core.OptionalUint64{},
ApiInterface: api.NewNoApiInterface(),
MinNodesPerShard: 2,
RoundsPerEpoch: core.OptionalUint64{
HasValue: true,
Value: 20,
},
ApiInterface: api.NewNoApiInterface(),
MinNodesPerShard: 2,
},
})
require.Nil(t, err)
Expand Down
12 changes: 12 additions & 0 deletions cmd/sovereignnode/config/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package config

import (
"github.com/multiversx/mx-chain-core-go/core"

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

Expand All @@ -15,3 +16,14 @@ func LoadSovereignGeneralConfig(filepath string) (*config.SovereignConfig, error

return cfg, nil
}

// LoadSovereignEpochConfig returns the epoch config necessary by sovereign by reading it from the provided file
func LoadSovereignEpochConfig(filepath string) (*config.SovereignEpochConfig, error) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You don't need this. These flags are already in an existing file that is being loaded anyway.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is loading the SovereignEpochConfig struct

cfg := &config.SovereignEpochConfig{}
err := core.LoadTomlFile(cfg, filepath)
if err != nil {
return nil, err
}

return cfg, nil
}
1 change: 1 addition & 0 deletions cmd/sovereignnode/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@ import "github.com/multiversx/mx-chain-go/config"
type SovereignConfig struct {
*config.Configs
SovereignExtraConfig *config.SovereignConfig
SovereignEpochConfig *config.SovereignEpochConfig
}
106 changes: 55 additions & 51 deletions cmd/sovereignnode/config/enableEpochs.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
BuiltInFunctionsEnableEpoch = 0

# RelayedTransactionsEnableEpoch represents the epoch when the relayed transactions will be enabled
RelayedTransactionsEnableEpoch = 1
RelayedTransactionsEnableEpoch = 0

# PenalizedTooMuchGasEnableEpoch represents the epoch when the penalization for using too much gas will be enabled
PenalizedTooMuchGasEnableEpoch = 0
Expand All @@ -19,35 +19,35 @@

# SwitchHysteresisForMinNodesEnableEpoch represents the epoch when the system smart contract changes its config to consider
# also (minimum) hysteresis nodes for the minimum number of nodes
SwitchHysteresisForMinNodesEnableEpoch = 1
SwitchHysteresisForMinNodesEnableEpoch = 0

# TransactionSignedWithTxHashEnableEpoch represents the epoch when the node will also accept transactions that are
# signed with the hash of transaction
TransactionSignedWithTxHashEnableEpoch = 0

# MetaProtectionEnableEpoch represents the epoch when the transactions to the metachain are checked to have enough gas
MetaProtectionEnableEpoch = 1
MetaProtectionEnableEpoch = 0

# AheadOfTimeGasUsageEnableEpoch represents the epoch when the cost of smart contract prepare changes from compiler per byte to ahead of time prepare per byte
AheadOfTimeGasUsageEnableEpoch = 1
AheadOfTimeGasUsageEnableEpoch = 0

# GasPriceModifierEnableEpoch represents the epoch when the gas price modifier in fee computation is enabled
GasPriceModifierEnableEpoch = 1
GasPriceModifierEnableEpoch = 0

# RepairCallbackEnableEpoch represents the epoch when the callback repair is activated for scrs
RepairCallbackEnableEpoch = 1
RepairCallbackEnableEpoch = 0

# BlockGasAndFeesReCheckEnableEpoch represents the epoch when gas and fees used in each created or processed block are re-checked
BlockGasAndFeesReCheckEnableEpoch = 1
BlockGasAndFeesReCheckEnableEpoch = 0

# BalanceWaitingListsEnableEpoch represents the epoch when the shard waiting lists are balanced at the start of an epoch
BalanceWaitingListsEnableEpoch = 1
BalanceWaitingListsEnableEpoch = 0

# ReturnDataToLastTransferEnableEpoch represents the epoch when returned data is added to last output transfer for callbacks
ReturnDataToLastTransferEnableEpoch = 1
ReturnDataToLastTransferEnableEpoch = 0

# SenderInOutTransferEnableEpoch represents the epoch when the feature of having different senders in output transfer is enabled
SenderInOutTransferEnableEpoch = 1
SenderInOutTransferEnableEpoch = 0

# StakeEnableEpoch represents the epoch when staking is enabled
StakeEnableEpoch = 0
Expand All @@ -56,7 +56,7 @@
StakingV2EnableEpoch = 0

# DoubleKeyProtectionEnableEpoch represents the epoch when the double key protection will be enabled
DoubleKeyProtectionEnableEpoch = 1
DoubleKeyProtectionEnableEpoch = 0

# ESDTEnableEpoch represents the epoch when ESDT is enabled
ESDTEnableEpoch = 0
Expand All @@ -70,33 +70,33 @@

# DelegationSmartContractEnableEpoch represents the epoch when delegation smart contract is enabled
# epoch should not be 0
DelegationSmartContractEnableEpoch = 1
DelegationSmartContractEnableEpoch = 0

# TODO: MX-15702: Sovereign enable epoch handler should have all these type of flags always disabled
# CorrectLastUnjailedEnableEpoch represents the epoch when the fix regaring the last unjailed node should apply
CorrectLastUnjailedEnableEpoch = 1000000

# RelayedTransactionsV2EnableEpoch represents the epoch when the relayed transactions V2 will be enabled
RelayedTransactionsV2EnableEpoch = 1
RelayedTransactionsV2EnableEpoch = 0

# UnbondTokensV2EnableEpoch represents the epoch when the new implementation of the unbond tokens function is available
UnbondTokensV2EnableEpoch = 1
UnbondTokensV2EnableEpoch = 0

# SaveJailedAlwaysEnableEpoch represents the epoch when saving jailed status at end of epoch will happen in all cases
SaveJailedAlwaysEnableEpoch = 1
SaveJailedAlwaysEnableEpoch = 0

# ReDelegateBelowMinCheckEnableEpoch represents the epoch when the check for the re-delegated value will be enabled
ReDelegateBelowMinCheckEnableEpoch = 1
ReDelegateBelowMinCheckEnableEpoch = 0

# ValidatorToDelegationEnableEpoch represents the epoch when the validator-to-delegation feature will be enabled
ValidatorToDelegationEnableEpoch = 1
ValidatorToDelegationEnableEpoch = 0

# WaitingListFixEnableEpoch represents the epoch when the 6 epoch waiting list fix is enabled
WaitingListFixEnableEpoch = 1000000

# IncrementSCRNonceInMultiTransferEnableEpoch represents the epoch when the fix for preventing the generation of the same SCRs
# is enabled. The fix is done by adding an extra increment.
IncrementSCRNonceInMultiTransferEnableEpoch = 1
IncrementSCRNonceInMultiTransferEnableEpoch = 0

# ESDTMultiTransferEnableEpoch represents the epoch when esdt multitransfer built in function is enabled
ESDTMultiTransferEnableEpoch = 0
Expand All @@ -111,13 +111,13 @@
BuiltInFunctionOnMetaEnableEpoch = 1000000

# ComputeRewardCheckpointEnableEpoch represents the epoch when compute rewards checkpoint epoch is enabled
ComputeRewardCheckpointEnableEpoch = 1
ComputeRewardCheckpointEnableEpoch = 0

# SCRSizeInvariantCheckEnableEpoch represents the epoch when the scr size invariant check is enabled
SCRSizeInvariantCheckEnableEpoch = 1
SCRSizeInvariantCheckEnableEpoch = 0

# BackwardCompSaveKeyValueEnableEpoch represents the epoch when the backward compatibility for save key value error is enabled
BackwardCompSaveKeyValueEnableEpoch = 1
BackwardCompSaveKeyValueEnableEpoch = 0

# ESDTNFTCreateOnMultiShardEnableEpoch represents the epoch when esdt nft creation is enabled on multiple shards
ESDTNFTCreateOnMultiShardEnableEpoch = 0
Expand All @@ -126,37 +126,37 @@
MetaESDTSetEnableEpoch = 0

# AddTokensToDelegationEnableEpoch represents the epoch when adding tokens to delegation is enabled for whitelisted address
AddTokensToDelegationEnableEpoch = 1
AddTokensToDelegationEnableEpoch = 0

# MultiESDTTransferFixOnCallBackOnEnableEpoch represents the epoch when multi esdt transfer on callback fix is enabled
MultiESDTTransferFixOnCallBackOnEnableEpoch = 0

# OptimizeGasUsedInCrossMiniBlocksEnableEpoch represents the epoch when gas used in cross shard mini blocks will be optimized
OptimizeGasUsedInCrossMiniBlocksEnableEpoch = 1
OptimizeGasUsedInCrossMiniBlocksEnableEpoch = 0

# CorrectFirstQueuedEpoch represents the epoch when the backward compatibility for setting the first queued node is enabled
CorrectFirstQueuedEpoch = 1
CorrectFirstQueuedEpoch = 0

# DeleteDelegatorAfterClaimRewardsEnableEpoch represents the epoch when the delegators data is deleted for delegators that have to claim rewards after they withdraw all funds
DeleteDelegatorAfterClaimRewardsEnableEpoch = 1
DeleteDelegatorAfterClaimRewardsEnableEpoch = 0

# FixOOGReturnCodeEnableEpoch represents the epoch when the backward compatibility returning out of gas error is enabled
FixOOGReturnCodeEnableEpoch = 1
FixOOGReturnCodeEnableEpoch = 0

# RemoveNonUpdatedStorageEnableEpoch represents the epoch when the backward compatibility for removing non updated storage is enabled
RemoveNonUpdatedStorageEnableEpoch = 1
RemoveNonUpdatedStorageEnableEpoch = 0

# OptimizeNFTStoreEnableEpoch represents the epoch when optimizations on NFT metadata store and send are enabled
OptimizeNFTStoreEnableEpoch = 0

# CreateNFTThroughExecByCallerEnableEpoch represents the epoch when nft creation through execution on destination by caller is enabled
CreateNFTThroughExecByCallerEnableEpoch = 1
CreateNFTThroughExecByCallerEnableEpoch = 0

# StopDecreasingValidatorRatingWhenStuckEnableEpoch represents the epoch when we should stop decreasing validator's rating if, for instance, a shard gets stuck
StopDecreasingValidatorRatingWhenStuckEnableEpoch = 1
StopDecreasingValidatorRatingWhenStuckEnableEpoch = 0

# FrontRunningProtectionEnableEpoch represents the epoch when the first version of protection against front running is enabled
FrontRunningProtectionEnableEpoch = 1
FrontRunningProtectionEnableEpoch = 0

# IsPayableBySCEnableEpoch represents the epoch when a new flag isPayable by SC is enabled
IsPayableBySCEnableEpoch = 0
Expand All @@ -168,7 +168,7 @@
StorageAPICostOptimizationEnableEpoch = 0

# TransformToMultiShardCreateEnableEpoch represents the epoch when the new function on esdt system sc is enabled to transfer create role into multishard
TransformToMultiShardCreateEnableEpoch = 1
TransformToMultiShardCreateEnableEpoch = 0

# ESDTRegisterAndSetAllRolesEnableEpoch represents the epoch when new function to register tickerID and set all roles is enabled
ESDTRegisterAndSetAllRolesEnableEpoch = 0
Expand All @@ -177,71 +177,71 @@
ScheduledMiniBlocksEnableEpoch = 0

# CorrectJailedNotUnstakedEpoch represents the epoch when the jailed validators will also be unstaked if the queue is empty
CorrectJailedNotUnstakedEmptyQueueEpoch = 1
CorrectJailedNotUnstakedEmptyQueueEpoch = 0

# DoNotReturnOldBlockInBlockchainHookEnableEpoch represents the epoch when the fetch old block operation is
# disabled in the blockchain hook component
DoNotReturnOldBlockInBlockchainHookEnableEpoch = 1
DoNotReturnOldBlockInBlockchainHookEnableEpoch = 0

# AddFailedRelayedTxToInvalidMBsDisableEpoch represents the epoch when adding the failed relayed txs to invalid miniblocks is disabled
AddFailedRelayedTxToInvalidMBsDisableEpoch = 1
AddFailedRelayedTxToInvalidMBsDisableEpoch = 0

# SCRSizeInvariantOnBuiltInResultEnableEpoch represents the epoch when scr size invariant on built in result is enabled
SCRSizeInvariantOnBuiltInResultEnableEpoch = 1
SCRSizeInvariantOnBuiltInResultEnableEpoch = 0

# CheckCorrectTokenIDForTransferRoleEnableEpoch represents the epoch when the correct token ID check is applied for transfer role verification
CheckCorrectTokenIDForTransferRoleEnableEpoch = 1
CheckCorrectTokenIDForTransferRoleEnableEpoch = 0

# DisableExecByCallerEnableEpoch represents the epoch when the check on value is disabled on exec by caller
DisableExecByCallerEnableEpoch = 1
DisableExecByCallerEnableEpoch = 0

# RefactorContextEnableEpoch represents the epoch when refactoring/simplifying is enabled in contexts
RefactorContextEnableEpoch = 1
RefactorContextEnableEpoch = 0

# FailExecutionOnEveryAPIErrorEnableEpoch represent the epoch when new protection in VM is enabled to fail all wrong API calls
FailExecutionOnEveryAPIErrorEnableEpoch = 1
FailExecutionOnEveryAPIErrorEnableEpoch = 0

# ManagedCryptoAPIsEnableEpoch represents the epoch when new managed crypto APIs are enabled in the wasm VM
ManagedCryptoAPIsEnableEpoch = 1
ManagedCryptoAPIsEnableEpoch = 0

# CheckFunctionArgumentEnableEpoch represents the epoch when the extra argument check is enabled in vm-common
CheckFunctionArgumentEnableEpoch = 1
CheckFunctionArgumentEnableEpoch = 0

# CheckExecuteOnReadOnlyEnableEpoch represents the epoch when the extra checks are enabled for execution on read only
CheckExecuteOnReadOnlyEnableEpoch = 1
CheckExecuteOnReadOnlyEnableEpoch = 0

# ESDTMetadataContinuousCleanupEnableEpoch represents the epoch when esdt metadata is automatically deleted according to inshard liquidity
ESDTMetadataContinuousCleanupEnableEpoch = 0

# MiniBlockPartialExecutionEnableEpoch represents the epoch when mini block partial execution will be enabled
MiniBlockPartialExecutionEnableEpoch = 1
MiniBlockPartialExecutionEnableEpoch = 0

# FixAsyncCallBackArgsListEnableEpoch represents the epoch when the async callback arguments lists fix will be enabled
FixAsyncCallBackArgsListEnableEpoch = 1
FixAsyncCallBackArgsListEnableEpoch = 0

# FixOldTokenLiquidityEnableEpoch represents the epoch when the fix for old token liquidity is enabled
FixOldTokenLiquidityEnableEpoch = 0

# RuntimeMemStoreLimitEnableEpoch represents the epoch when the condition for Runtime MemStore is enabled
RuntimeMemStoreLimitEnableEpoch = 1
RuntimeMemStoreLimitEnableEpoch = 0

# SetSenderInEeiOutputTransferEnableEpoch represents the epoch when setting the sender in eei output transfers will be enabled
SetSenderInEeiOutputTransferEnableEpoch = 1
SetSenderInEeiOutputTransferEnableEpoch = 0

# RefactorPeersMiniBlocksEnableEpoch represents the epoch when refactor of the peers mini blocks will be enabled
RefactorPeersMiniBlocksEnableEpoch = 1
RefactorPeersMiniBlocksEnableEpoch = 0

# MaxBlockchainHookCountersEnableEpoch represents the epoch when the max blockchainhook counters are enabled
MaxBlockchainHookCountersEnableEpoch = 1
MaxBlockchainHookCountersEnableEpoch = 0

# WipeSingleNFTLiquidityDecreaseEnableEpoch represents the epoch when the system account liquidity is decreased for wipeSingleNFT as well
WipeSingleNFTLiquidityDecreaseEnableEpoch = 1
WipeSingleNFTLiquidityDecreaseEnableEpoch = 0

# AlwaysSaveTokenMetaDataEnableEpoch represents the epoch when the token metadata is always saved
AlwaysSaveTokenMetaDataEnableEpoch = 0

# RuntimeCodeSizeFixEnableEpoch represents the epoch when the code size fix in the VM is enabled
RuntimeCodeSizeFixEnableEpoch = 2
RuntimeCodeSizeFixEnableEpoch = 0

# BLSMultiSignerEnableEpoch represents the activation epoch for different types of BLS multi-signers
BLSMultiSignerEnableEpoch = [
Expand All @@ -256,5 +256,9 @@
[GasSchedule]
# GasScheduleByEpochs holds the configuration for the gas schedule that will be applied from specific epochs
GasScheduleByEpochs = [
{ StartEpoch = 0, FileName = "gasScheduleV7.toml" },
{ StartEpoch = 0, FileName = "gasScheduleV8.toml" },
]

[SovereignEnableEpochs]

[SovereignChainSpecificEnableEpochs]
Loading
Loading