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

Hardware requirements checks #5852

Merged
merged 8 commits into from
Jan 23, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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
11 changes: 7 additions & 4 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_1", "sse4_2"]

[Versions]
DefaultVersion = "default"
Expand Down
28 changes: 28 additions & 0 deletions cmd/node/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"github.com/multiversx/mx-chain-core-go/core/check"
"github.com/multiversx/mx-chain-go/cmd/node/factory"
"github.com/multiversx/mx-chain-go/common"
"github.com/multiversx/mx-chain-go/common/hostParameters"
"github.com/multiversx/mx-chain-go/config"
"github.com/multiversx/mx-chain-go/config/overridableConfig"
"github.com/multiversx/mx-chain-go/node"
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,25 @@ func attachFileLogger(log logger.Logger, flagsConfig *config.ContextFlagsConfig)

return fileLogging, nil
}

func checkHardwareRequirements(cfg config.HardwareRequirementsConfig) error {
hpg := hostParameters.NewHostParameterGetter("")
hostInfo := hpg.GetHostInfo()

for _, cpuFlag := range cfg.CPUFlags {
if !contains(hostInfo.CPUFlags, cpuFlag) {
return fmt.Errorf("CPU Flag %s not available", cpuFlag)
}
}

return nil
}

func contains(list []string, s string) bool {
for _, item := range list {
if item == s {
return true
}
}
return false
}
24 changes: 15 additions & 9 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -190,15 +190,16 @@ type Config struct {
PublicKeyPIDSignature CacheConfig
PeerHonesty CacheConfig

Antiflood AntifloodConfig
WebServerAntiflood WebServerAntifloodConfig
ResourceStats ResourceStatsConfig
HeartbeatV2 HeartbeatV2Config
ValidatorStatistics ValidatorStatisticsConfig
GeneralSettings GeneralSettingsConfig
Consensus ConsensusConfig
StoragePruning StoragePruningConfig
LogsAndEvents LogsAndEventsConfig
Antiflood AntifloodConfig
WebServerAntiflood WebServerAntifloodConfig
ResourceStats ResourceStatsConfig
HeartbeatV2 HeartbeatV2Config
ValidatorStatistics ValidatorStatisticsConfig
GeneralSettings GeneralSettingsConfig
Consensus ConsensusConfig
StoragePruning StoragePruningConfig
LogsAndEvents LogsAndEventsConfig
HardwareRequirements HardwareRequirementsConfig

NTPConfig NTPConfig
HeadersPoolConfig HeadersPoolConfig
Expand Down Expand Up @@ -285,6 +286,11 @@ type GeneralSettingsConfig struct {
SetGuardianEpochsDelay uint32
}

// HardwareRequirementsConfig will hold the hardware requirements config
type HardwareRequirementsConfig struct {
CPUFlags []string
}

// FacadeConfig will hold different configuration option that will be passed to the node facade
type FacadeConfig struct {
RestApiInterface string
Expand Down