Skip to content

Commit

Permalink
Merge pull request #5852 from multiversx/hardware-requirements-checks
Browse files Browse the repository at this point in the history
Hardware requirements checks
  • Loading branch information
ssd04 authored Jan 23, 2024
2 parents dbf6d2e + 728c22b commit c84a6e6
Show file tree
Hide file tree
Showing 8 changed files with 55 additions and 14 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
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", "SSE42"]

[Versions]
DefaultVersion = "default"
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
}
File renamed without changes.
File renamed without changes.
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

0 comments on commit c84a6e6

Please sign in to comment.