Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/feat/esdt-improvements' into esd…
Browse files Browse the repository at this point in the history
…t-improvements-integration

# Conflicts:
#	common/constants.go
#	go.mod
#	go.sum
  • Loading branch information
BeniaminDrasovean committed Jan 30, 2024
2 parents 36b868d + d24b625 commit 9e61187
Show file tree
Hide file tree
Showing 125 changed files with 1,954 additions and 984 deletions.
2 changes: 1 addition & 1 deletion cmd/assessment/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (
"github.com/multiversx/mx-chain-core-go/core"
"github.com/multiversx/mx-chain-go/cmd/assessment/benchmarks"
"github.com/multiversx/mx-chain-go/cmd/assessment/benchmarks/factory"
"github.com/multiversx/mx-chain-go/cmd/assessment/hostParameters"
"github.com/multiversx/mx-chain-go/common/hostParameters"
logger "github.com/multiversx/mx-chain-logger-go"
"github.com/urfave/cli"
)
Expand Down
Binary file modified cmd/assessment/testdata/cpucalculate.wasm
100644 → 100755
Binary file not shown.
Binary file modified cmd/assessment/testdata/storage100.wasm
100644 → 100755
Binary file not shown.
1 change: 0 additions & 1 deletion cmd/node/CLI.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ GLOBAL OPTIONS:
--import-db value This flag, if set, will make the node start the import process using the provided data path. Will re-checkand re-process everything
--import-db-no-sig-check This flag, if set, will cause the signature checks on headers to be skipped. Can be used only if the import-db was previously set
--import-db-save-epoch-root-hash This flag, if set, will export the trie snapshots at every new epoch
--import-db-start-epoch value This flag will specify the start in epoch value in import-db process (default: 0)
--redundancy-level value This flag specifies the level of redundancy used by the current instance for the node (-1 = disabled, 0 = main instance (default), 1 = first backup, 2 = second backup, etc.) (default: 0)
--full-archive Boolean option for settings an observer as full archive, which will sync the entire database of its shard
--mem-ballast value Flag that specifies the number of MegaBytes to be used as a memory ballast for Garbage Collector optimization. If set to 0 (or not set at all), the feature will be disabled. This flag should be used only for well-monitored nodes and by advanced users, as a too high memory ballast could lead to Out Of Memory panics. The memory ballast should not be higher than 20-25% of the machine's available RAM (default: 0)
Expand Down
21 changes: 11 additions & 10 deletions cmd/node/config/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,13 @@
# SyncProcessTimeInMillis is the value in milliseconds used when processing blocks while synchronizing blocks
SyncProcessTimeInMillis = 12000

# SetGuardianEpochsDelay represents the delay in epochs between the execution time of the SetGuardian transaction and
# the activation of the configured guardian.
# Make sure that this is greater than the unbonding period!
SetGuardianEpochsDelay = 2 # TODO: for mainnet should be 20, 2 is just for testing
# SetGuardianEpochsDelay represents the delay in epochs between the execution time of the SetGuardian transaction and
# the activation of the configured guardian.
# Make sure that this is greater than the unbonding period!
SetGuardianEpochsDelay = 2 # TODO: for mainnet should be 20, 2 is just for testing

[HardwareRequirements]
CPUFlags = ["SSE4", "SSE42"]

[Versions]
DefaultVersion = "default"
Expand Down Expand Up @@ -665,19 +668,17 @@
TimeOutForSCExecutionInMilliseconds = 10000 # 10 seconds = 10000 milliseconds
WasmerSIGSEGVPassthrough = false # must be false for release
WasmVMVersions = [
{ StartEpoch = 0, Version = "v1.3" },
{ StartEpoch = 1, Version = "v1.4" },
{ StartEpoch = 3, Version = "v1.5" }, # TODO: set also the RoundActivations.DisableAsyncCallV1 accordingly
{ StartEpoch = 0, Version = "v1.4" },
{ StartEpoch = 1, Version = "v1.5" }, # TODO: set also the RoundActivations.DisableAsyncCallV1 accordingly
]

[VirtualMachine.Querying]
NumConcurrentVMs = 1
TimeOutForSCExecutionInMilliseconds = 10000 # 10 seconds = 10000 milliseconds
WasmerSIGSEGVPassthrough = false # must be false for release
WasmVMVersions = [
{ StartEpoch = 0, Version = "v1.3" },
{ StartEpoch = 1, Version = "v1.4" },
{ StartEpoch = 3, Version = "v1.5" }, # TODO: set also the RoundActivations.DisableAsyncCallV1 accordingly
{ StartEpoch = 0, Version = "v1.4" },
{ StartEpoch = 1, Version = "v1.5" }, # TODO: set also the RoundActivations.DisableAsyncCallV1 accordingly
]

[VirtualMachine.GasConfig]
Expand Down
35 changes: 20 additions & 15 deletions cmd/node/config/enableEpochs.toml
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
ESDTEnableEpoch = 1

# GovernanceEnableEpoch represents the epoch when governance is enabled
GovernanceEnableEpoch = 5
GovernanceEnableEpoch = 1

# DelegationManagerEnableEpoch represents the epoch when the delegation manager is enabled
# epoch should not be 0
Expand Down Expand Up @@ -252,40 +252,46 @@
DeterministicSortOnValidatorsInfoEnableEpoch = 1

# SCProcessorV2EnableEpoch represents the epoch when SC processor V2 will be used
SCProcessorV2EnableEpoch = 3
SCProcessorV2EnableEpoch = 1

# AutoBalanceDataTriesEnableEpoch represents the epoch when the data tries are automatically balanced by inserting at the hashed key instead of the normal key
AutoBalanceDataTriesEnableEpoch = 3
AutoBalanceDataTriesEnableEpoch = 1

# MigrateDataTrieEnableEpoch represents the epoch when the data tries migration is enabled
MigrateDataTrieEnableEpoch = 2

# KeepExecOrderOnCreatedSCRsEnableEpoch represents the epoch when the execution order of created SCRs is ensured
KeepExecOrderOnCreatedSCRsEnableEpoch = 3
KeepExecOrderOnCreatedSCRsEnableEpoch = 1

# MultiClaimOnDelegationEnableEpoch represents the epoch when the multi claim on delegation is enabled
MultiClaimOnDelegationEnableEpoch = 3
MultiClaimOnDelegationEnableEpoch = 1

# ChangeUsernameEnableEpoch represents the epoch when changing username is enabled
ChangeUsernameEnableEpoch = 3
ChangeUsernameEnableEpoch = 4

# ConsistentTokensValuesLengthCheckEnableEpoch represents the epoch when the consistent tokens values length check is enabled
ConsistentTokensValuesLengthCheckEnableEpoch = 3
ConsistentTokensValuesLengthCheckEnableEpoch = 1

# FixDelegationChangeOwnerOnAccountEnableEpoch represents the epoch when the fix for the delegation system smart contract is enabled
FixDelegationChangeOwnerOnAccountEnableEpoch = 3
FixDelegationChangeOwnerOnAccountEnableEpoch = 1

# DynamicGasCostForDataTrieStorageLoadEnableEpoch represents the epoch when dynamic gas cost for data trie storage load will be enabled
DynamicGasCostForDataTrieStorageLoadEnableEpoch = 3
DynamicGasCostForDataTrieStorageLoadEnableEpoch = 1

# ScToScLogEventEnableEpoch represents the epoch when the sc to sc log event feature is enabled
ScToScLogEventEnableEpoch = 3
ScToScLogEventEnableEpoch = 1

# NFTStopCreateEnableEpoch represents the epoch when NFT stop create feature is enabled
NFTStopCreateEnableEpoch = 3
NFTStopCreateEnableEpoch = 1

# ChangeOwnerAddressCrossShardThroughSCEnableEpoch represents the epoch when the change owner address built in function will work also through a smart contract call cross shard
ChangeOwnerAddressCrossShardThroughSCEnableEpoch = 3
ChangeOwnerAddressCrossShardThroughSCEnableEpoch = 1

# FixGasRemainingForSaveKeyValueBuiltinFunctionEnableEpoch represents the epoch when the fix for the remaining gas in the SaveKeyValue builtin function is enabled
FixGasRemainingForSaveKeyValueBuiltinFunctionEnableEpoch = 3
FixGasRemainingForSaveKeyValueBuiltinFunctionEnableEpoch = 1

# CurrentRandomnessOnSortingEnableEpoch represents the epoch when the current randomness on sorting is enabled
CurrentRandomnessOnSortingEnableEpoch = 4

# DynamicESDTEnableEpoch represents the epoch when dynamic NFT feature is enabled
DynamicESDTEnableEpoch = 4
Expand All @@ -305,6 +311,5 @@
[GasSchedule]
# GasScheduleByEpochs holds the configuration for the gas schedule that will be applied from specific epochs
GasScheduleByEpochs = [
{ StartEpoch = 0, FileName = "gasScheduleV1.toml" },
{ StartEpoch = 1, FileName = "gasScheduleV7.toml" },
{ StartEpoch = 0, FileName = "gasScheduleV7.toml" },
]
2 changes: 1 addition & 1 deletion cmd/node/config/enableRounds.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@
[RoundActivations]
[RoundActivations.DisableAsyncCallV1]
Options = []
Round = "500"
Round = "100"
Binary file modified cmd/node/config/genesisContracts/dns.wasm
Binary file not shown.
2 changes: 1 addition & 1 deletion cmd/node/config/genesisSmartContracts.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"owner": "erd188anxz35atlef7cucszypmvx88lhz4m7a7t7lhcwt6sfphpsqlkswfhcx2",
"filename": "./config/genesisContracts/dns.wasm",
"vm-type": "0500",
"init-parameters": "056bc75e2d63100000",
"init-parameters": "00",
"type": "dns",
"version": "0.2.*"
}
Expand Down
6 changes: 3 additions & 3 deletions cmd/node/config/prefs.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
# In multikey mode, all bls keys not mentioned in NamedIdentity section will use this one as default
NodeDisplayName = ""

# Identity represents the keybase/GitHub identity when the node does not run in multikey mode
# Identity represents the GitHub identity when the node does not run in multikey mode
# In multikey mode, all bls keys not mentioned in NamedIdentity section will use this one as default
Identity = ""

Expand All @@ -28,7 +28,7 @@
# ]
PreferredConnections = []

# ConnectionWatcherType represents the type of a connection watcher needed.
# ConnectionWatcherType represents the type of the connection watcher needed.
# possible options:
# - "disabled" - no connection watching should be made
# - "print" - new connection found will be printed in the log file
Expand Down Expand Up @@ -71,7 +71,7 @@
# NamedIdentity represents an identity that runs nodes on the multikey
# There can be multiple identities set on the same node, each one of them having different bls keys, just by duplicating the NamedIdentity
[[NamedIdentity]]
# Identity represents the keybase/GitHub identity for the current NamedIdentity
# Identity represents the GitHub identity for the current NamedIdentity
Identity = ""
# NodeName represents the name that will be given to the names of the current identity
NodeName = ""
Expand Down
13 changes: 1 addition & 12 deletions cmd/node/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -331,12 +331,6 @@ var (
Name: "import-db-save-epoch-root-hash",
Usage: "This flag, if set, will export the trie snapshots at every new epoch",
}
// importDbStartInEpoch defines a flag for an optional flag that can specify the start in epoch value when executing the import-db process
importDbStartInEpoch = cli.Uint64Flag{
Name: "import-db-start-epoch",
Value: 0,
Usage: "This flag will specify the start in epoch value in import-db process",
}
// redundancyLevel defines a flag that specifies the level of redundancy used by the current instance for the node (-1 = disabled, 0 = main instance (default), 1 = first backup, 2 = second backup, etc.)
redundancyLevel = cli.Int64Flag{
Name: "redundancy-level",
Expand Down Expand Up @@ -461,7 +455,6 @@ func getFlags() []cli.Flag {
importDbDirectory,
importDbNoSigCheck,
importDbSaveEpochRootHash,
importDbStartInEpoch,
redundancyLevel,
fullArchive,
memBallast,
Expand Down Expand Up @@ -557,7 +550,6 @@ func applyFlags(ctx *cli.Context, cfgs *config.Configs, flagsConfig *config.Cont
ImportDBWorkingDir: importDbDirectoryValue,
ImportDbNoSigCheckFlag: ctx.GlobalBool(importDbNoSigCheck.Name),
ImportDbSaveTrieEpochRootHash: ctx.GlobalBool(importDbSaveEpochRootHash.Name),
ImportDBStartInEpoch: uint32(ctx.GlobalUint64(importDbStartInEpoch.Name)),
}
cfgs.FlagsConfig = flagsConfig
cfgs.ImportDbConfig = importDBConfigs
Expand Down Expand Up @@ -715,9 +707,7 @@ func processConfigImportDBMode(log logger.Logger, configs *config.Configs) error
return err
}

if importDbFlags.ImportDBStartInEpoch == 0 {
generalConfigs.GeneralSettings.StartInEpochEnabled = false
}
generalConfigs.GeneralSettings.StartInEpochEnabled = false

// We need to increment "NumActivePersisters" in order to make the storage resolvers work (since they open 2 epochs in advance)
generalConfigs.StoragePruning.NumActivePersisters++
Expand All @@ -736,7 +726,6 @@ func processConfigImportDBMode(log logger.Logger, configs *config.Configs) error
"fullArchiveP2P.ThresholdMinConnectedPeers", fullArchiveP2PConfigs.Node.ThresholdMinConnectedPeers,
"no sig check", importDbFlags.ImportDbNoSigCheckFlag,
"import save trie epoch root hash", importDbFlags.ImportDbSaveTrieEpochRootHash,
"import DB start in epoch", importDbFlags.ImportDBStartInEpoch,
"import DB shard ID", importDbFlags.ImportDBTargetShardID,
"kad dht discoverer", "off",
)
Expand Down
32 changes: 32 additions & 0 deletions cmd/node/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"runtime"
"time"

"github.com/klauspost/cpuid/v2"
"github.com/multiversx/mx-chain-core-go/core"
"github.com/multiversx/mx-chain-core-go/core/check"
"github.com/multiversx/mx-chain-go/cmd/node/factory"
Expand Down Expand Up @@ -129,6 +130,11 @@ func startNodeRunner(c *cli.Context, log logger.Logger, baseVersion string, vers
cfgs.FlagsConfig.BaseVersion = baseVersion
cfgs.FlagsConfig.Version = version

err = checkHardwareRequirements(cfgs.GeneralConfig.HardwareRequirements)
if err != nil {
return fmt.Errorf("Hardware Requirements checks failed: %s", err.Error())
}

nodeRunner, errRunner := node.NewNodeRunner(cfgs)
if errRunner != nil {
return errRunner
Expand Down Expand Up @@ -301,3 +307,29 @@ func attachFileLogger(log logger.Logger, flagsConfig *config.ContextFlagsConfig)

return fileLogging, nil
}

func checkHardwareRequirements(cfg config.HardwareRequirementsConfig) error {
cpuFlags, err := parseFeatures(cfg.CPUFlags)
if err != nil {
return err
}

if !cpuid.CPU.Supports(cpuFlags...) {
return fmt.Errorf("CPU Flags: Streaming SIMD Extensions 4 required")
}

return nil
}

func parseFeatures(features []string) ([]cpuid.FeatureID, error) {
flags := make([]cpuid.FeatureID, 0)

for _, cpuFlag := range features {
featureID := cpuid.ParseFeature(cpuFlag)
if featureID == cpuid.UNKNOWN {
return nil, fmt.Errorf("CPU Flags: cpu flag %s not found", cpuFlag)
}
}

return flags, nil
}
15 changes: 12 additions & 3 deletions cmd/seednode/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -309,12 +309,21 @@ func displayMessengerInfo(messenger p2p.Messenger) {
return strings.Compare(mesConnectedAddrs[i], mesConnectedAddrs[j]) < 0
})

log.Info("known peers", "num peers", len(messenger.Peers()))
headerConnectedAddresses := []string{fmt.Sprintf("Seednode is connected to %d peers:", len(mesConnectedAddrs))}
protocolIDString := "Valid protocol ID?"
log.Info("peers info", "num known peers", len(messenger.Peers()), "num connected peers", len(mesConnectedAddrs))
headerConnectedAddresses := []string{"Connected peers", protocolIDString}
connAddresses := make([]*display.LineData, len(mesConnectedAddrs))

yesMarker := "yes"
yesMarker = strings.Repeat(" ", (len(protocolIDString)-len(yesMarker))/2) + yesMarker // add padding
noMarker := "!!! no !!!"
noMarker = strings.Repeat(" ", (len(protocolIDString)-len(noMarker))/2) + noMarker // add padding
for idx, address := range mesConnectedAddrs {
connAddresses[idx] = display.NewLineData(false, []string{address})
marker := noMarker
if messenger.HasCompatibleProtocolID(address) {
marker = yesMarker
}
connAddresses[idx] = display.NewLineData(false, []string{address, marker})
}

tbl2, _ := display.CreateTableString(headerConnectedAddresses, connAddresses)
Expand Down
6 changes: 6 additions & 0 deletions common/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,9 @@ const MetricRedundancyLevel = "erd_redundancy_level"
// MetricRedundancyIsMainActive is the metric that specifies data about the redundancy main machine
const MetricRedundancyIsMainActive = "erd_redundancy_is_main_active"

// MetricRedundancyStepInReason is the metric that specifies why the back-up machine stepped in
const MetricRedundancyStepInReason = "erd_redundancy_step_in_reason"

// MetricValueNA represents the value to be used when a metric is not available/applicable
const MetricValueNA = "N/A"

Expand Down Expand Up @@ -890,6 +893,7 @@ const MetricTrieSyncNumProcessedNodes = "erd_trie_sync_num_nodes_processed"
// FullArchiveMetricSuffix is the suffix added to metrics specific for full archive network
const FullArchiveMetricSuffix = "_full_archive"

// Enable epoch flags definitions
const (
SCDeployFlag core.EnableEpochFlag = "SCDeployFlag"
BuiltInFunctionsFlag core.EnableEpochFlag = "BuiltInFunctionsFlag"
Expand Down Expand Up @@ -988,6 +992,7 @@ const (
MultiClaimOnDelegationFlag core.EnableEpochFlag = "MultiClaimOnDelegationFlag"
ChangeUsernameFlag core.EnableEpochFlag = "ChangeUsernameFlag"
AutoBalanceDataTriesFlag core.EnableEpochFlag = "AutoBalanceDataTriesFlag"
MigrateDataTrieFlag core.EnableEpochFlag = "MigrateDataTrieFlag"
FixDelegationChangeOwnerOnAccountFlag core.EnableEpochFlag = "FixDelegationChangeOwnerOnAccountFlag"
FixOOGReturnCodeFlag core.EnableEpochFlag = "FixOOGReturnCodeFlag"
DeterministicSortOnValidatorsInfoFixFlag core.EnableEpochFlag = "DeterministicSortOnValidatorsInfoFixFlag"
Expand All @@ -999,6 +1004,7 @@ const (
NFTStopCreateFlag core.EnableEpochFlag = "NFTStopCreateFlag"
FixGasRemainingForSaveKeyValueFlag core.EnableEpochFlag = "FixGasRemainingForSaveKeyValueFlag"
IsChangeOwnerAddressCrossShardThroughSCFlag core.EnableEpochFlag = "IsChangeOwnerAddressCrossShardThroughSCFlag"
CurrentRandomnessOnSortingFlag core.EnableEpochFlag = "CurrentRandomnessOnSortingFlag"
DynamicESDTFlag core.EnableEpochFlag = "DynamicEsdtFlag"
// all new flags must be added to createAllFlagsMap method, as part of enableEpochsHandler allFlagsDefined
)
12 changes: 12 additions & 0 deletions common/enablers/enableEpochsHandler.go
Original file line number Diff line number Diff line change
Expand Up @@ -629,6 +629,12 @@ func (handler *enableEpochsHandler) createAllFlagsMap() {
},
activationEpoch: handler.enableEpochsConfig.AutoBalanceDataTriesEnableEpoch,
},
common.MigrateDataTrieFlag: {
isActiveInEpoch: func(epoch uint32) bool {
return epoch >= handler.enableEpochsConfig.MigrateDataTrieEnableEpoch
},
activationEpoch: handler.enableEpochsConfig.MigrateDataTrieEnableEpoch,
},
common.FixDelegationChangeOwnerOnAccountFlag: {
isActiveInEpoch: func(epoch uint32) bool {
return epoch >= handler.enableEpochsConfig.FixDelegationChangeOwnerOnAccountEnableEpoch
Expand Down Expand Up @@ -695,6 +701,12 @@ func (handler *enableEpochsHandler) createAllFlagsMap() {
},
activationEpoch: handler.enableEpochsConfig.ChangeOwnerAddressCrossShardThroughSCEnableEpoch,
},
common.CurrentRandomnessOnSortingFlag: {
isActiveInEpoch: func(epoch uint32) bool {
return epoch >= handler.enableEpochsConfig.CurrentRandomnessOnSortingEnableEpoch
},
activationEpoch: handler.enableEpochsConfig.CurrentRandomnessOnSortingEnableEpoch,
},
common.DynamicESDTFlag: {
isActiveInEpoch: func(epoch uint32) bool {
return epoch >= handler.enableEpochsConfig.DynamicESDTEnableEpoch
Expand Down
Loading

0 comments on commit 9e61187

Please sign in to comment.