Skip to content

Commit

Permalink
Merge branch 'rc/v1.6.0' into fix-shard-header-construction-epoch
Browse files Browse the repository at this point in the history
  • Loading branch information
iulianpascalau authored Feb 24, 2023
2 parents b6d5a60 + 5fcba4f commit ececb73
Show file tree
Hide file tree
Showing 44 changed files with 963 additions and 264 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
[![](https://img.shields.io/badge/project-MultiversX%20Mainnet-blue.svg)](https://explorer.multiversx.com/)
[![Go Report Card](https://goreportcard.com/badge/github.com/multiversx/mx-chain-go)](https://goreportcard.com/report/github.com/multiversx/mx-chain-go)
[![codecov](https://codecov.io/gh/multiversx/mx-chain-go/branch/master/graph/badge.svg?token=MYS5EDASOJ)](https://codecov.io/gh/multiversx/mx-chain-go)
[![Contributors](https://img.shields.io/github/contributors/multiversx/mx-chain-go)](https://github.com/multiversx/mx-chain-go/graphs/contributors)

# mx-chain-go

Expand Down
3 changes: 3 additions & 0 deletions cmd/node/config/enableEpochs.toml
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,9 @@
# AlwaysSaveTokenMetaDataEnableEpoch represents the epoch when the token metadata is always saved
AlwaysSaveTokenMetaDataEnableEpoch = 1

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

# 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/enablers/enableEpochsHandler.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ func (handler *enableEpochsHandler) EpochConfirmed(epoch uint32, _ uint64) {
handler.setFlagValue(epoch >= handler.enableEpochsConfig.FixAsyncCallBackArgsListEnableEpoch, handler.fixAsyncCallBackArgsList, "fixAsyncCallBackArgsList")
handler.setFlagValue(epoch >= handler.enableEpochsConfig.FixOldTokenLiquidityEnableEpoch, handler.fixOldTokenLiquidity, "fixOldTokenLiquidity")
handler.setFlagValue(epoch >= handler.enableEpochsConfig.RuntimeMemStoreLimitEnableEpoch, handler.runtimeMemStoreLimitFlag, "runtimeMemStoreLimitFlag")
handler.setFlagValue(epoch >= handler.enableEpochsConfig.RuntimeCodeSizeFixEnableEpoch, handler.runtimeCodeSizeFixFlag, "runtimeCodeSizeFixFlag")
handler.setFlagValue(epoch >= handler.enableEpochsConfig.MaxBlockchainHookCountersEnableEpoch, handler.maxBlockchainHookCountersFlag, "maxBlockchainHookCountersFlag")
handler.setFlagValue(epoch >= handler.enableEpochsConfig.WipeSingleNFTLiquidityDecreaseEnableEpoch, handler.wipeSingleNFTLiquidityDecreaseFlag, "wipeSingleNFTLiquidityDecreaseFlag")
handler.setFlagValue(epoch >= handler.enableEpochsConfig.AlwaysSaveTokenMetaDataEnableEpoch, handler.alwaysSaveTokenMetaDataFlag, "alwaysSaveTokenMetaDataFlag")
Expand Down
8 changes: 6 additions & 2 deletions common/enablers/enableEpochsHandler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ func createEnableEpochsConfig() config.EnableEpochs {
MaxBlockchainHookCountersEnableEpoch: 74,
WipeSingleNFTLiquidityDecreaseEnableEpoch: 75,
AlwaysSaveTokenMetaDataEnableEpoch: 76,
RuntimeCodeSizeFixEnableEpoch: 77,
}
}

Expand Down Expand Up @@ -128,7 +129,7 @@ func TestNewEnableEpochsHandler_EpochConfirmed(t *testing.T) {
handler, _ := NewEnableEpochsHandler(cfg, &epochNotifier.EpochNotifierStub{})
require.False(t, check.IfNil(handler))

handler.EpochConfirmed(76, 0)
handler.EpochConfirmed(77, 0)

assert.Equal(t, cfg.BlockGasAndFeesReCheckEnableEpoch, handler.BlockGasAndFeesReCheckEnableEpoch())
assert.True(t, handler.IsSCDeployFlagEnabled())
Expand Down Expand Up @@ -211,11 +212,12 @@ func TestNewEnableEpochsHandler_EpochConfirmed(t *testing.T) {
assert.True(t, handler.IsRuntimeMemStoreLimitEnabled())
assert.True(t, handler.IsMaxBlockchainHookCountersFlagEnabled())
assert.True(t, handler.IsAlwaysSaveTokenMetaDataEnabled())
assert.True(t, handler.IsRuntimeCodeSizeFixEnabled())
})
t.Run("flags with == condition should be set, along with all >=", func(t *testing.T) {
t.Parallel()

epoch := uint32(77)
epoch := uint32(78)
cfg := createEnableEpochsConfig()
cfg.StakingV2EnableEpoch = epoch
cfg.ESDTEnableEpoch = epoch
Expand Down Expand Up @@ -310,6 +312,7 @@ func TestNewEnableEpochsHandler_EpochConfirmed(t *testing.T) {
assert.True(t, handler.IsMaxBlockchainHookCountersFlagEnabled())
assert.True(t, handler.IsWipeSingleNFTLiquidityDecreaseEnabled())
assert.True(t, handler.IsAlwaysSaveTokenMetaDataEnabled())
assert.True(t, handler.IsRuntimeCodeSizeFixEnabled())
})
t.Run("flags with < should be set", func(t *testing.T) {
t.Parallel()
Expand Down Expand Up @@ -404,5 +407,6 @@ func TestNewEnableEpochsHandler_EpochConfirmed(t *testing.T) {
assert.False(t, handler.IsMaxBlockchainHookCountersFlagEnabled())
assert.False(t, handler.IsWipeSingleNFTLiquidityDecreaseEnabled())
assert.False(t, handler.IsAlwaysSaveTokenMetaDataEnabled())
assert.False(t, handler.IsRuntimeCodeSizeFixEnabled())
})
}
7 changes: 7 additions & 0 deletions common/enablers/epochFlags.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ type epochFlagsHolder struct {
fixAsyncCallBackArgsList *atomic.Flag
fixOldTokenLiquidity *atomic.Flag
runtimeMemStoreLimitFlag *atomic.Flag
runtimeCodeSizeFixFlag *atomic.Flag
maxBlockchainHookCountersFlag *atomic.Flag
wipeSingleNFTLiquidityDecreaseFlag *atomic.Flag
alwaysSaveTokenMetaDataFlag *atomic.Flag
Expand Down Expand Up @@ -174,6 +175,7 @@ func newEpochFlagsHolder() *epochFlagsHolder {
fixAsyncCallBackArgsList: &atomic.Flag{},
fixOldTokenLiquidity: &atomic.Flag{},
runtimeMemStoreLimitFlag: &atomic.Flag{},
runtimeCodeSizeFixFlag: &atomic.Flag{},
maxBlockchainHookCountersFlag: &atomic.Flag{},
wipeSingleNFTLiquidityDecreaseFlag: &atomic.Flag{},
alwaysSaveTokenMetaDataFlag: &atomic.Flag{},
Expand Down Expand Up @@ -638,6 +640,11 @@ func (holder *epochFlagsHolder) IsRuntimeMemStoreLimitEnabled() bool {
return holder.runtimeMemStoreLimitFlag.IsSet()
}

// IsRuntimeCodeSizeFixEnabled returns true if runtimeCodeSizeFixFlag is enabled
func (holder *epochFlagsHolder) IsRuntimeCodeSizeFixEnabled() bool {
return holder.runtimeCodeSizeFixFlag.IsSet()
}

// IsMaxBlockchainHookCountersFlagEnabled returns true if maxBlockchainHookCountersFlagEnabled is enabled
func (holder *epochFlagsHolder) IsMaxBlockchainHookCountersFlagEnabled() bool {
return holder.maxBlockchainHookCountersFlag.IsSet()
Expand Down
1 change: 1 addition & 0 deletions common/interface.go
Original file line number Diff line number Diff line change
Expand Up @@ -333,6 +333,7 @@ type EnableEpochsHandler interface {
IsFixAsyncCallBackArgsListFlagEnabled() bool
IsFixOldTokenLiquidityEnabled() bool
IsRuntimeMemStoreLimitEnabled() bool
IsRuntimeCodeSizeFixEnabled() bool
IsMaxBlockchainHookCountersFlagEnabled() bool
IsWipeSingleNFTLiquidityDecreaseEnabled() bool
IsAlwaysSaveTokenMetaDataEnabled() bool
Expand Down
1 change: 1 addition & 0 deletions config/epochConfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ type EnableEpochs struct {
FixAsyncCallBackArgsListEnableEpoch uint32
FixOldTokenLiquidityEnableEpoch uint32
RuntimeMemStoreLimitEnableEpoch uint32
RuntimeCodeSizeFixEnableEpoch uint32
SetSenderInEeiOutputTransferEnableEpoch uint32
RefactorPeersMiniBlocksEnableEpoch uint32
MaxBlockchainHookCountersEnableEpoch uint32
Expand Down
104 changes: 56 additions & 48 deletions config/tomlConfig_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ func TestTomlParser(t *testing.T) {
[MiniBlocksStorage.Cache]
Capacity = ` + strconv.Itoa(txBlockBodyStorageSize) + `
Type = "` + txBlockBodyStorageType + `"
Shards = ` + strconv.Itoa(txBlockBodyStorageShards) + `
Shards = ` + strconv.Itoa(txBlockBodyStorageShards) + `
[MiniBlocksStorage.DB]
FilePath = "` + txBlockBodyStorageFile + `"
Type = "` + txBlockBodyStorageTypeDB + `"
Expand Down Expand Up @@ -173,13 +173,13 @@ func TestTomlParser(t *testing.T) {
Type = "` + accountsStorageTypeDB + `"
[Hasher]
Type = "` + hasherType + `"
Type = "` + hasherType + `"
[MultisigHasher]
Type = "` + multiSigHasherType + `"
Type = "` + multiSigHasherType + `"
[Consensus]
Type = "` + consensusType + `"
Type = "` + consensusType + `"
[VirtualMachine]
[VirtualMachine.Execution]
Expand All @@ -197,15 +197,15 @@ func TestTomlParser(t *testing.T) {
{ StartEpoch = 88, Version = "v1.2" },
]
[VirtualMachine.GasConfig]
ShardMaxGasPerVmQuery = 1500000000
MetaMaxGasPerVmQuery = 0
[VirtualMachine.GasConfig]
ShardMaxGasPerVmQuery = 1500000000
MetaMaxGasPerVmQuery = 0
[Debug]
[Debug.InterceptorResolver]
Enabled = true
CacheSize = 10000
EnablePrint = true
EnablePrint = true
IntervalAutoPrintInSeconds = 20
NumRequestsThreshold = 9
NumResolveFailureThreshold = 3
Expand Down Expand Up @@ -277,22 +277,22 @@ func TestTomlEconomicsParser(t *testing.T) {
[GlobalSettings]
Denomination = ` + fmt.Sprintf("%d", denomination) + `
[RewardsSettings]
[[RewardsSettings.RewardsConfigByEpoch]]
EpochEnable = ` + fmt.Sprintf("%d", epoch0) + `
LeaderPercentage = ` + fmt.Sprintf("%.6f", leaderPercentage1) + `
DeveloperPercentage = ` + fmt.Sprintf("%.6f", developerPercentage) + `
ProtocolSustainabilityPercentage = ` + fmt.Sprintf("%.6f", protocolSustainabilityPercentage) + ` #fraction of value 0.1 - 10%
ProtocolSustainabilityAddress = "` + protocolSustainabilityAddress + `"
[[RewardsSettings.RewardsConfigByEpoch]]
EpochEnable = ` + fmt.Sprintf("%d", epoch1) + `
LeaderPercentage = ` + fmt.Sprintf("%.6f", leaderPercentage2) + `
[[RewardsSettings.RewardsConfigByEpoch]]
EpochEnable = ` + fmt.Sprintf("%d", epoch0) + `
LeaderPercentage = ` + fmt.Sprintf("%.6f", leaderPercentage1) + `
DeveloperPercentage = ` + fmt.Sprintf("%.6f", developerPercentage) + `
ProtocolSustainabilityPercentage = ` + fmt.Sprintf("%.6f", protocolSustainabilityPercentage) + ` #fraction of value 0.1 - 10%
ProtocolSustainabilityAddress = "` + protocolSustainabilityAddress + `"
[[RewardsSettings.RewardsConfigByEpoch]]
EpochEnable = ` + fmt.Sprintf("%d", epoch1) + `
LeaderPercentage = ` + fmt.Sprintf("%.6f", leaderPercentage2) + `
DeveloperPercentage = ` + fmt.Sprintf("%.6f", developerPercentage) + `
ProtocolSustainabilityPercentage = ` + fmt.Sprintf("%.6f", protocolSustainabilityPercentage) + ` #fraction of value 0.1 - 10%
ProtocolSustainabilityAddress = "` + protocolSustainabilityAddress + `"
[FeeSettings]
GasLimitSettings = [{EnableEpoch = 0, MaxGasLimitPerBlock = "` + maxGasLimitPerBlock + `", MaxGasLimitPerMiniBlock = "", MaxGasLimitPerMetaBlock = "", MaxGasLimitPerMetaMiniBlock = "", MaxGasLimitPerTx = "", MinGasLimit = "` + minGasLimit + `"}]
GasLimitSettings = [{EnableEpoch = 0, MaxGasLimitPerBlock = "` + maxGasLimitPerBlock + `", MaxGasLimitPerMiniBlock = "", MaxGasLimitPerMetaBlock = "", MaxGasLimitPerMetaMiniBlock = "", MaxGasLimitPerTx = "", MinGasLimit = "` + minGasLimit + `"}]
MinGasPrice = "` + minGasPrice + `"
`
cfg := EconomicsConfig{}
Expand Down Expand Up @@ -323,14 +323,14 @@ func TestTomlPreferencesParser(t *testing.T) {

testString := `
[Preferences]
NodeDisplayName = "` + nodeDisplayName + `"
DestinationShardAsObserver = "` + destinationShardAsObs + `"
Identity = "` + identity + `"
RedundancyLevel = ` + fmt.Sprintf("%d", redundancyLevel) + `
PreferredConnections = [
"` + prefPubKey0 + `",
"` + prefPubKey1 + `"
]
NodeDisplayName = "` + nodeDisplayName + `"
DestinationShardAsObserver = "` + destinationShardAsObs + `"
Identity = "` + identity + `"
RedundancyLevel = ` + fmt.Sprintf("%d", redundancyLevel) + `
PreferredConnections = [
"` + prefPubKey0 + `",
"` + prefPubKey1 + `"
]
`
cfg := Preferences{}

Expand Down Expand Up @@ -408,16 +408,16 @@ func TestAPIRoutesToml(t *testing.T) {
[APIPackages]
[APIPackages.` + package0 + `]
Routes = [
Routes = [
# test comment
{ Name = "` + route0 + `", Open = true },
# test comment
{ Name = "` + route1 + `", Open = true },
]
]
[APIPackages.` + package1 + `]
Routes = [
Routes = [
# test comment
{ Name = "` + route2 + `", Open = false }
]
Expand Down Expand Up @@ -639,55 +639,61 @@ func TestEnableEpochConfig(t *testing.T) {
# IsPayableBySCEnableEpoch represents the epoch when a new flag isPayable by SC is enabled
IsPayableBySCEnableEpoch = 48
# CleanUpInformativeSCRsEnableEpoch represents the epoch when the scrs which contain only information are cleaned from miniblocks and logs are created from it
CleanUpInformativeSCRsEnableEpoch = 49
# CleanUpInformativeSCRsEnableEpoch represents the epoch when the scrs which contain only information are cleaned from miniblocks and logs are created from it
CleanUpInformativeSCRsEnableEpoch = 49
# StorageAPICostOptimizationEnableEpoch represents the epoch when new storage helper functions are enabled and cost is reduced in Wasm VM
StorageAPICostOptimizationEnableEpoch = 50
# TransformToMultiShardCreateEnableEpoch represents the epoch when the new function on esdt system sc is enabled to transfer create role into multishard
TransformToMultiShardCreateEnableEpoch = 51
TransformToMultiShardCreateEnableEpoch = 51
# ESDTRegisterAndSetAllRolesEnableEpoch represents the epoch when new function to register tickerID and set all roles is enabled
ESDTRegisterAndSetAllRolesEnableEpoch = 52
# FailExecutionOnEveryAPIErrorEnableEpoch represent the epoch when new protection in VM is enabled to fail all wrong API calls
FailExecutionOnEveryAPIErrorEnableEpoch = 53
# FailExecutionOnEveryAPIErrorEnableEpoch represent the epoch when new protection in VM is enabled to fail all wrong API calls
FailExecutionOnEveryAPIErrorEnableEpoch = 53
# ManagedCryptoAPIsEnableEpoch represents the epoch when the new managed crypto APIs are enabled
ManagedCryptoAPIsEnableEpoch = 54
# ManagedCryptoAPIsEnableEpoch represents the epoch when the new managed crypto APIs are enabled
ManagedCryptoAPIsEnableEpoch = 54
# ESDTMetadataContinuousCleanupEnableEpoch represents the epoch when esdt metadata is automatically deleted according to inshard liquidity
ESDTMetadataContinuousCleanupEnableEpoch = 55
# ESDTMetadataContinuousCleanupEnableEpoch represents the epoch when esdt metadata is automatically deleted according to inshard liquidity
ESDTMetadataContinuousCleanupEnableEpoch = 55
# FixAsyncCallBackArgsListEnableEpoch represents the epoch when the async callback arguments lists fix will be enabled
FixAsyncCallBackArgsListEnableEpoch = 56
# FixOldTokenLiquidityEnableEpoch represents the epoch when the fix for old token liquidity is enabled
FixOldTokenLiquidityEnableEpoch = 57
# FixOldTokenLiquidityEnableEpoch represents the epoch when the fix for old token liquidity is enabled
FixOldTokenLiquidityEnableEpoch = 57
# SetSenderInEeiOutputTransferEnableEpoch represents the epoch when setting the sender in eei output transfers will be enabled
# SetSenderInEeiOutputTransferEnableEpoch represents the epoch when setting the sender in eei output transfers will be enabled
SetSenderInEeiOutputTransferEnableEpoch = 58
# MaxBlockchainHookCountersEnableEpoch represents the epoch when the max blockchainhook counters are enabled
MaxBlockchainHookCountersEnableEpoch = 59
# MaxBlockchainHookCountersEnableEpoch represents the epoch when the max blockchainhook counters are enabled
MaxBlockchainHookCountersEnableEpoch = 59
# WipeSingleNFTLiquidityDecreaseEnableEpoch represents the epoch when the system account liquidity is decreased for wipeSingleNFT as well
WipeSingleNFTLiquidityDecreaseEnableEpoch = 60
# AlwaysSaveTokenMetaDataEnableEpoch represents the epoch when the token metadata is always saved
AlwaysSaveTokenMetaDataEnableEpoch = 61
# RuntimeCodeSizeFixEnableEpoch represents the epoch when the code size fix in the VM is enabled
RuntimeCodeSizeFixEnableEpoch = 62
# RuntimeMemStoreLimitEnableEpoch represents the epoch when the condition for Runtime MemStore is enabled
RuntimeMemStoreLimitEnableEpoch = 63
# MaxNodesChangeEnableEpoch holds configuration for changing the maximum number of nodes and the enabling epoch
MaxNodesChangeEnableEpoch = [
{ EpochEnable = 44, MaxNumNodes = 2169, NodesToShufflePerShard = 80 },
{ EpochEnable = 45, MaxNumNodes = 3200, NodesToShufflePerShard = 80 }
]
BLSMultiSignerEnableEpoch = [
{EnableEpoch = 0, Type = "no-KOSK"},
{EnableEpoch = 3, Type = "KOSK"}
]
BLSMultiSignerEnableEpoch = [
{EnableEpoch = 0, Type = "no-KOSK"},
{EnableEpoch = 3, Type = "KOSK"}
]
[GasSchedule]
GasScheduleByEpochs = [
Expand Down Expand Up @@ -771,6 +777,8 @@ func TestEnableEpochConfig(t *testing.T) {
MaxBlockchainHookCountersEnableEpoch: 59,
WipeSingleNFTLiquidityDecreaseEnableEpoch: 60,
AlwaysSaveTokenMetaDataEnableEpoch: 61,
RuntimeCodeSizeFixEnableEpoch: 62,
RuntimeMemStoreLimitEnableEpoch: 63,
BLSMultiSignerEnableEpoch: []MultiSignerConfig{
{
EnableEpoch: 0,
Expand Down
23 changes: 23 additions & 0 deletions dataRetriever/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,29 @@ func SetEpochHandlerToHdrResolver(
return nil
}

// SetEpochHandlerToHdrRequester sets the epoch handler to the metablock hdr requester
func SetEpochHandlerToHdrRequester(
requestersContainer RequestersContainer,
epochHandler EpochHandler,
) error {
requester, err := requestersContainer.Get(factory.MetachainBlocksTopic)
if err != nil {
return err
}

hdrRequester, ok := requester.(HeaderRequester)
if !ok {
return ErrWrongTypeInContainer
}

err = hdrRequester.SetEpochHandler(epochHandler)
if err != nil {
return err
}

return nil
}

// GetHdrNonceHashDataUnit gets the HdrNonceHashDataUnit by shard
func GetHdrNonceHashDataUnit(shard uint32) UnitType {
if shard == core.MetachainShardId {
Expand Down
Loading

0 comments on commit ececb73

Please sign in to comment.