/
types.go
246 lines (235 loc) · 7.73 KB
/
types.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
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
/*
Copyright 2022 Nethermind
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package generate
import (
"github.com/NethermindEth/sedge/internal/pkg/clients"
)
// EnvData : Struct Data object to be applied to the docker-compose script environment (.env) template
type EnvData struct {
Services []string
Mev bool
ElImage string
ElDataDir string
CcImage string
CcDataDir string
VlImage string
VlDataDir string
ExecutionApiURL string
ExecutionAuthURL string
ConsensusApiURL string
ConsensusAdditionalApiURL string
FeeRecipient string
JWTSecretPath string
ExecutionEngineName string
ConsensusClientName string
KeystoreDir string
Graffiti string
RelayURLs string
CheckpointSyncUrl string
}
// GenData : Struct Data object for script's generation
type GenData struct {
Services []string
ExecutionClient *clients.Client
ConsensusClient *clients.Client
ValidatorClient *clients.Client
Network string
CheckpointSyncUrl string
FeeRecipient string
JWTSecretPath string
FallbackELUrls []string
ElExtraFlags []string
ClExtraFlags []string
VlExtraFlags []string
MapAllPorts bool
Mev bool
RelayURLs []string
MevImage string
MevBoostService bool
MevBoostEndpoint string
MevBoostOnValidator bool
Ports map[string]uint16
Graffiti string
LoggingDriver string
ECBootnodes []string
CCBootnodes []string
CustomChainSpecPath string
CustomNetworkConfigPath string
CustomGenesisPath string
CustomDeployBlock string
CustomDeployBlockPath string
VLStartGracePeriod uint
ExecutionApiUrl string
ExecutionAuthUrl string
ConsensusApiUrl string
ContainerTag string
LatestVersion bool
}
// DockerComposeData : Struct Data object to be applied to docker-compose script
type DockerComposeData struct {
Services []string
Network string
XeeVersion bool
Mev bool
MevBoostOnValidator bool
MevPort uint16
MevImage string
MevBoostEndpoint string
CheckpointSyncUrl string
FeeRecipient string
ElDiscoveryPort uint16
ElMetricsPort uint16
ElApiPort uint16
ElAuthPort uint16
ElWsPort uint16
ClDiscoveryPort uint16
ClMetricsPort uint16
ClApiPort uint16
ClAdditionalApiPort uint16
VlMetricsPort uint16
FallbackELUrls []string
ElExtraFlags []string
ClExtraFlags []string
VlExtraFlags []string
ECBootnodes string
CCBootnodes string
CCBootnodesList []string
MapAllPorts bool
SplittedNetwork bool
ClCheckpointSyncUrl bool
LoggingDriver string
CustomConsensusConfigs bool
CustomNetwork bool
CustomChainSpecPath string
CustomNetworkConfigPath string
CustomGenesisPath string
CustomDeployBlock bool
CustomDeployBlockPath string // Needed for lighthouse
VLStartGracePeriod uint
UID int // Needed for teku
GID int // Needed for teku
ContainerTag string
}
// WithConsensusClient returns true if the consensus client is set
func (d DockerComposeData) WithConsensusClient() bool {
for _, service := range d.Services {
if service == consensus {
return true
}
}
return false
}
// WithValidatorClient returns true if the validator client is set
func (d DockerComposeData) WithValidatorClient() bool {
for _, service := range d.Services {
if service == validator {
return true
}
}
return false
}
// WithMevBoostClient returns true if the Mev-Boost client is set
func (d EnvData) WithMevBoostClient() bool {
for _, service := range d.Services {
if service == mevBoost {
return true
}
}
return false
}
type ComposeData struct {
Version string `yaml:"version,omitempty"`
Services *Services `yaml:"services"`
Networks *Networks `yaml:"networks,omitempty"`
}
type Options struct {
MaxSize string `yaml:"max-size"`
MaxFile string `yaml:"max-file"`
}
type Logging struct {
Driver string `yaml:"driver"`
Options *Options `yaml:"options"`
}
type Execution struct {
StopGracePeriod string `yaml:"stop_grace_period"`
ContainerName string `yaml:"container_name"`
Restart string `yaml:"restart"`
Image string `yaml:"image"`
Networks []string `yaml:"networks"`
Volumes []string `yaml:"volumes"`
Ports []string `yaml:"ports"`
Expose []int `yaml:"expose"`
Command []string `yaml:"command"`
Logging *Logging `yaml:"logging,omitempty"`
}
type Mevboost struct {
Image string `yaml:"image"`
Networks []string `yaml:"networks"`
ContainerName string `yaml:"container_name"`
Restart string `yaml:"restart"`
Entrypoint []string `yaml:"entrypoint"`
}
type Consensus struct {
StopGracePeriod string `yaml:"stop_grace_period"`
ContainerName string `yaml:"container_name"`
Restart string `yaml:"restart"`
Image string `yaml:"image"`
Networks []string `yaml:"networks"`
Volumes []string `yaml:"volumes"`
Ports []string `yaml:"ports"`
Expose []int `yaml:"expose"`
Command []string `yaml:"command"`
Logging *Logging `yaml:"logging,omitempty"`
}
type ValidatorBlocker struct {
Image string `yaml:"image"`
ContainerName string `yaml:"container_name"`
Command string `yaml:"command"`
}
type ValidatorImportDependsOn struct {
Condition string `yaml:"condition"`
}
type DependsOn struct {
ValidatorImport *ValidatorImportDependsOn `yaml:"validator-import"`
}
type Validator struct {
ContainerName string `yaml:"container_name"`
Image string `yaml:"image"`
DependsOn *DependsOn `yaml:"depends_on"`
Networks []string `yaml:"networks"`
Ports []string `yaml:"ports"`
Volumes []string `yaml:"volumes"`
Command []string `yaml:"command"`
Logging *Logging `yaml:"logging,omitempty"`
}
type ConfigConsensus struct {
ContainerName string `yaml:"container_name"`
Image string `yaml:"image"`
Volumes []string `yaml:"volumes"`
Command []string `yaml:"command"`
Logging *Logging `yaml:"logging,omitempty"`
}
type Services struct {
Execution *Execution `yaml:"execution,omitempty"`
Mevboost *Mevboost `yaml:"mev-boost,omitempty"`
Consensus *Consensus `yaml:"consensus,omitempty"`
ValidatorBlocker *ValidatorBlocker `yaml:"validator-blocker,omitempty"`
Validator *Validator `yaml:"validator,omitempty"`
ConfigConsensus *ConfigConsensus `yaml:"config_consensus,omitempty"`
}
type Sedge struct {
Name string `yaml:"name"`
}
type Networks struct {
Sedge *Sedge `yaml:"sedge"`
}