Skip to content

Commit

Permalink
adjust suggestion pruning config
Browse files Browse the repository at this point in the history
  • Loading branch information
0xbcdev committed May 23, 2024
1 parent 7420f2b commit 77d8a9f
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 21 deletions.
53 changes: 35 additions & 18 deletions cmd/check_home_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,55 +110,68 @@ func checkHomeConfigAppToml(configPath string, nodeType types.NodeType) *types.A
}
}

const recommendPruningCustomKeepRecent = 362880

switch app.Pruning {
case constants.PruningDefault:
if isValidator {
warnRecord(
"pruning set to 'default' in app.toml file",
"set pruning to everything for validator",
fmt.Sprintf("set pruning to 'custom' %d/10", recommendPruningCustomKeepRecent),
)
} else if isSnapshotNode {
warnRecord(
"pruning set to 'default' in app.toml file, snapshot not should be configured properly for snapshot purpose",
"set pruning to custom 100/10",
fmt.Sprintf("set pruning to 'custom' 100/10"),
)
} else if isArchivalNode {
fatalRecord(
"pruning set to 'default' in app.toml file, archival node should be configured properly for archival purpose",
"set pruning to nothing",
"pruning set to 'default' in app.toml file, archival node must be configured properly for archival purpose",
"set pruning to 'nothing'",
)
}
case constants.PruningNothing:
if isValidator {
fatalRecord(
"pruning set to 'nothing' in app.toml file, validator should not use this option",
"set pruning to everything",
fmt.Sprintf("set pruning to 'custom' %d/10", recommendPruningCustomKeepRecent),
)
} else if isSnapshotNode {
fatalRecord(
"pruning set to 'nothing' in app.toml file, snapshot not should be configured properly for snapshot purpose",
"set pruning to custom 100/10",
"set pruning to 'custom' 100/10",
)
}
case constants.PruningEverything:
if isValidator {
warnRecord(
fmt.Sprintf(
"pruning set to 'everything', however to work properly with double_sign_check_height, it should be set to 'custom' %d/%d in app.toml file",
"pruning set to 'everything', however to work properly with double_sign_check_height, it should be set to 'custom' at least %d/10 in app.toml file",
constants.RecommendDoubleSignCheckHeight+10,
10,
),
"can be ignored, or change pruning = \"custom\", pruning-keep-recent = double_sign_check_height + 10, pruning-interval = 10",
fmt.Sprintf("set pruning = 'custom', pruning-keep-recent = at least double_sign_check_height + 10 or recommend %d, pruning-interval = 10", recommendPruningCustomKeepRecent),
)
warnRecord(
fmt.Sprintf(
"pruning set to 'everything', however to work properly with evident, it should be set to 'custom' %d/10 in app.toml file",
recommendPruningCustomKeepRecent,
),
fmt.Sprintf("set pruning to 'custom' %d/10", recommendPruningCustomKeepRecent),
)
} else if isArchivalNode {
fatalRecord(
"pruning set to 'everything' in app.toml file, archival node must not use this option",
"set pruning to nothing",
"set pruning to 'nothing'",
)
} else if isSnapshotNode {
fatalRecord(
"pruning set to 'everything' in app.toml file, snapshot node must not use this option",
"set pruning to 'custom' 100/10",
)
} else {
fatalRecord(
"pruning set to 'everything' in app.toml file, non-validator should not use this option",
"set pruning to default or custom",
fmt.Sprintf("set pruning to 'custom' %d/10", recommendPruningCustomKeepRecent),
)
}
case constants.PruningCustom:
Expand All @@ -167,20 +180,21 @@ func checkHomeConfigAppToml(configPath string, nodeType types.NodeType) *types.A
}
default:
msg := fmt.Sprintf("invalid pruning option '%s' in app.toml file", app.Pruning)
if isValidator {
fatalRecord(msg, "set pruning to everything")
} else if isArchivalNode {
if isArchivalNode {
fatalRecord(msg, "set pruning to nothing")
} else {
fatalRecord(msg, "set pruning to default or custom")
fatalRecord(msg, fmt.Sprintf("set pruning to custom %d/10", recommendPruningCustomKeepRecent))
}
exitWithErrorMsgf("ERR: invalid pruning option in app.toml file: %s\n", appTomlFilePath, app.Pruning)
return nil
}

if isSnapshotNode {
if app.Pruning != constants.PruningCustom || app.PruningKeepRecent != "100" || app.PruningInterval != "10" {
warnRecord("snapshot node should use pruning custom 100/10 in app.toml file", "set pruning to custom 100/10")
warnRecord(
"snapshot node should use pruning custom 100/10 in app.toml file",
"set pruning to 'custom' 100/10",
)
}
}

Expand All @@ -192,13 +206,16 @@ func checkHomeConfigAppToml(configPath string, nodeType types.NodeType) *types.A
return nil
}

if pruningKeepRecent > 400_000 {
if pruningKeepRecent > 500_000 {
warnRecord("pruning-keep-recent is too high in app.toml file", "")
} else if pruningKeepRecent < 2 {
fatalRecord("pruning-keep-recent is too low in app.toml file", "")
}
} else {
fatalRecord("pruning-keep-recent is empty in app.toml file", "set pruning-keep-recent to 100")
fatalRecord(
"pruning-keep-recent is empty in app.toml file",
fmt.Sprintf("set pruning-keep-recent to %d", recommendPruningCustomKeepRecent),
)
}

if app.PruningInterval != "" {
Expand Down
4 changes: 2 additions & 2 deletions constants/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ package constants

//goland:noinspection GoSnakeCaseUsage
const (
APP_NAME = "Validator Setup Check"
APP_DESC = "Checking validator setup"
APP_NAME = "Node Setup Check"
APP_DESC = "Checking node setup"
BINARY_NAME = "nodesc"
)
2 changes: 1 addition & 1 deletion constants/varcons.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ package constants

//goland:noinspection GoSnakeCaseUsage
var (
VERSION = "1.2.0"
VERSION = "1.2.1"
COMMIT_HASH = ""
BUILD_DATE = ""
)

0 comments on commit 77d8a9f

Please sign in to comment.