/
nimbus-config.go
186 lines (159 loc) · 7.34 KB
/
nimbus-config.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
package config
import (
"runtime"
"github.com/Seb369888/smartnode/shared/types/config"
)
const (
// Prater
nimbusBnTagTest string = "statusim/nimbus-eth2:multiarch-v23.5.1"
nimbusVcTagTest string = "statusim/nimbus-validator-client:multiarch-v23.5.1"
// Mainnet
nimbusBnTagProd string = "statusim/nimbus-eth2:multiarch-v23.5.1"
nimbusVcTagProd string = "statusim/nimbus-validator-client:multiarch-v23.5.1"
defaultNimbusMaxPeersArm uint16 = 100
defaultNimbusMaxPeersAmd uint16 = 160
)
// Configuration for Nimbus
type NimbusConfig struct {
Title string `yaml:"-"`
// The max number of P2P peers to connect to
MaxPeers config.Parameter `yaml:"maxPeers,omitempty"`
// Common parameters that Nimbus doesn't support and should be hidden
UnsupportedCommonParams []string `yaml:"-"`
// The Docker Hub tag for the BN
BnContainerTag config.Parameter `yaml:"bnContainerTag,omitempty"`
// The Docker Hub tag for the VC
VcContainerTag config.Parameter `yaml:"vcContainerTag,omitempty"`
// The pruning mode to use in the BN
PruningMode config.Parameter `yaml:"pruningMode,omitempty"`
// Custom command line flags for the BN
AdditionalBnFlags config.Parameter `yaml:"additionalBnFlags,omitempty"`
// Custom command line flags for the VC
AdditionalVcFlags config.Parameter `yaml:"additionalVcFlags,omitempty"`
}
// Generates a new Nimbus configuration
func NewNimbusConfig(cfg *RocketPoolConfig) *NimbusConfig {
return &NimbusConfig{
Title: "Nimbus Settings",
MaxPeers: config.Parameter{
ID: "maxPeers",
Name: "Max Peers",
Description: "The maximum number of peers your client should try to maintain. You can try lowering this if you have a low-resource system or a constrained network.",
Type: config.ParameterType_Uint16,
Default: map[config.Network]interface{}{config.Network_All: getNimbusDefaultPeers()},
AffectsContainers: []config.ContainerID{config.ContainerID_Eth2},
EnvironmentVariables: []string{"BN_MAX_PEERS"},
CanBeBlank: false,
OverwriteOnUpgrade: false,
},
BnContainerTag: config.Parameter{
ID: "bnContainerTag",
Name: "Beacon Node Container Tag",
Description: "The tag name of the Nimbus Beacon Node container you want to use on Docker Hub.",
Type: config.ParameterType_String,
Default: map[config.Network]interface{}{
config.Network_Mainnet: nimbusBnTagProd,
config.Network_Prater: nimbusBnTagTest,
config.Network_Devnet: nimbusBnTagTest,
config.Network_PulseV4: nimbusBnTagTest,
config.Network_Pulsechain: nimbusBnTagTest,
},
AffectsContainers: []config.ContainerID{config.ContainerID_Eth2},
EnvironmentVariables: []string{"BN_CONTAINER_TAG"},
CanBeBlank: false,
OverwriteOnUpgrade: true,
},
VcContainerTag: config.Parameter{
ID: "containerTag",
Name: "Validator Client Container Tag",
Description: "The tag name of the Nimbus Validator Client container you want to use on Docker Hub.",
Type: config.ParameterType_String,
Default: map[config.Network]interface{}{
config.Network_Mainnet: nimbusVcTagProd,
config.Network_Prater: nimbusVcTagTest,
config.Network_Devnet: nimbusVcTagTest,
config.Network_PulseV4: nimbusVcTagTest,
config.Network_Pulsechain: nimbusVcTagTest,
},
AffectsContainers: []config.ContainerID{config.ContainerID_Validator},
EnvironmentVariables: []string{"VC_CONTAINER_TAG"},
CanBeBlank: false,
OverwriteOnUpgrade: true,
},
PruningMode: config.Parameter{
ID: "pruningMode",
Name: "Pruning Mode",
Description: "Choose how Nimbus will prune its database. Highlight each option to learn more about it.",
Type: config.ParameterType_Choice,
Default: map[config.Network]interface{}{config.Network_All: config.NimbusPruningMode_Archive},
AffectsContainers: []config.ContainerID{config.ContainerID_Eth2},
EnvironmentVariables: []string{"NIMBUS_PRUNING_MODE"},
CanBeBlank: false,
OverwriteOnUpgrade: false,
Options: []config.ParameterOption{{
Name: "Archive",
Description: "Nimbus will download the entire Beacon Chain history and store it forever. This is healthier for the overall network, since people will be able to sync the entire chain from scratch using your node.",
Value: config.NimbusPruningMode_Archive,
}, {
Name: "Pruned",
Description: "Nimbus will only keep the last 5 months of data available, and will delete everything older than that. This will make Nimbus use less disk space overall, but you won't be able to access state older than 5 months (such as regenerating old rewards trees).\n\n[orange]WARNING: Pruning an *existing* database will take a VERY long time when Nimbus first starts. If you change from Archive to Pruned, you should delete your old chain data and do a checkpoint sync using `poolseapool service resync-eth2`. Make sure you have a checkpoint sync provider specified first!",
Value: config.NimbusPruningMode_Prune,
}},
},
AdditionalBnFlags: config.Parameter{
ID: "additionalBnFlags",
Name: "Additional Beacon Client Flags",
Description: "Additional custom command line flags you want to pass Nimbus's Beacon Client, to take advantage of other settings that the Smartnode's configuration doesn't cover.",
Type: config.ParameterType_String,
Default: map[config.Network]interface{}{config.Network_All: ""},
AffectsContainers: []config.ContainerID{config.ContainerID_Eth2},
EnvironmentVariables: []string{"BN_ADDITIONAL_FLAGS"},
CanBeBlank: true,
OverwriteOnUpgrade: false,
},
AdditionalVcFlags: config.Parameter{
ID: "additionalVcFlags",
Name: "Additional Validator Client Flags",
Description: "Additional custom command line flags you want to pass Nimbus's Validator Client, to take advantage of other settings that the Smartnode's configuration doesn't cover.",
Type: config.ParameterType_String,
Default: map[config.Network]interface{}{config.Network_All: ""},
AffectsContainers: []config.ContainerID{config.ContainerID_Validator},
EnvironmentVariables: []string{"VC_ADDITIONAL_FLAGS"},
CanBeBlank: true,
OverwriteOnUpgrade: false,
},
}
}
// Get the parameters for this config
func (cfg *NimbusConfig) GetParameters() []*config.Parameter {
return []*config.Parameter{
&cfg.MaxPeers,
&cfg.PruningMode,
&cfg.BnContainerTag,
&cfg.VcContainerTag,
&cfg.AdditionalBnFlags,
&cfg.AdditionalVcFlags,
}
}
// Get the common params that this client doesn't support
func (cfg *NimbusConfig) GetUnsupportedCommonParams() []string {
return cfg.UnsupportedCommonParams
}
// Get the Docker container name of the validator client
func (cfg *NimbusConfig) GetValidatorImage() string {
return cfg.VcContainerTag.Value.(string)
}
// Get the name of the client
func (cfg *NimbusConfig) GetName() string {
return "Nimbus"
}
// The the title for the config
func (cfg *NimbusConfig) GetConfigTitle() string {
return cfg.Title
}
func getNimbusDefaultPeers() uint16 {
if runtime.GOARCH == "arm64" {
return defaultNimbusMaxPeersArm
}
return defaultNimbusMaxPeersAmd
}