-
Notifications
You must be signed in to change notification settings - Fork 1.6k
/
types.go
344 lines (284 loc) · 9.03 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
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
package v2
import (
"fmt"
"net"
"net/url"
ocrcommontypes "github.com/smartcontractkit/libocr/commontypes"
ocrnetworking "github.com/smartcontractkit/libocr/networking"
"go.uber.org/multierr"
"github.com/smartcontractkit/chainlink/core/config"
"github.com/smartcontractkit/chainlink/core/services/keystore/keys/ethkey"
"github.com/smartcontractkit/chainlink/core/services/keystore/keys/p2pkey"
"github.com/smartcontractkit/chainlink/core/store/models"
"github.com/smartcontractkit/chainlink/core/utils"
)
// Core holds the core configuration. See chainlink.Config for more information.
type Core struct {
// General/misc
ExplorerURL *models.URL
InsecureFastScrypt *bool
RootDir *string
ShutdownGracePeriod *models.Duration
Feature *Feature
Database *Database
TelemetryIngress *TelemetryIngress
Log *Log
WebServer *WebServer
JobPipeline *JobPipeline
FluxMonitor *FluxMonitor
OCR2 *OCR2
OCR *OCR
P2P *P2P
Keeper *Keeper
AutoPprof *AutoPprof
Pyroscope *Pyroscope
Sentry *Sentry
}
type Secrets struct {
DatabaseURL *models.URL
DatabaseBackupURL *models.URL
ExplorerAccessKey *string
ExplorerSecret *string
KeystorePassword *string
VRFPassword *string
}
func (s *Secrets) ValidateConfig() (err error) {
if s.DatabaseURL == nil || (*url.URL)(s.DatabaseURL).String() == "" {
err = multierr.Append(err, ErrEmpty{Name: "DatabaseURL", Msg: "must be provided and non-empty"})
} else {
if verr := config.ValidateDBURL((url.URL)(*s.DatabaseURL)); verr != nil {
err = multierr.Append(err, ErrInvalid{Name: "DatabaseURL", Value: "*****", Msg: dbURLPasswordComplexity(verr)})
}
}
if s.DatabaseBackupURL != nil {
if verr := config.ValidateDBURL((url.URL)(*s.DatabaseBackupURL)); verr != nil {
err = multierr.Append(err, ErrInvalid{Name: "DatabaseBackupURL", Value: "*****", Msg: dbURLPasswordComplexity(verr)})
}
}
if s.KeystorePassword == nil || *s.KeystorePassword == "" {
err = multierr.Append(err, ErrEmpty{Name: "KeystorePassword", Msg: "must be provided and non-empty"})
}
return err
}
func dbURLPasswordComplexity(err error) string {
return fmt.Sprintf("missing or insufficiently complex password: %s. Database should be secured by a password matching the following complexity requirements: "+utils.PasswordComplexityRequirements, err)
}
func (s *Secrets) String() string {
return "<hidden>"
}
func (s *Secrets) GoString() string {
return "<hidden>"
}
func (s *Secrets) MarshalJSON() ([]byte, error) {
return []byte("{}"), nil
}
func (s *Secrets) MarshalText() ([]byte, error) {
return []byte("<hidden>"), nil
}
type Feature struct {
FeedsManager *bool
LogPoller *bool
UICSAKeys *bool
}
type Database struct {
DefaultIdleInTxSessionTimeout *models.Duration
DefaultLockTimeout *models.Duration
DefaultQueryTimeout *models.Duration
MigrateOnStartup *bool
ORMMaxIdleConns *int64
ORMMaxOpenConns *int64
Backup *DatabaseBackup
Listener *DatabaseListener
Lock *DatabaseLock
}
type DatabaseListener struct {
MaxReconnectDuration *models.Duration
MinReconnectInterval *models.Duration
FallbackPollInterval *models.Duration
}
type DatabaseLock struct {
LeaseDuration *models.Duration
LeaseRefreshInterval *models.Duration
}
func (l *DatabaseLock) ValidateConfig() (err error) {
if l.LeaseRefreshInterval.Duration() > l.LeaseDuration.Duration()/2 {
err = multierr.Append(err, fmt.Errorf("LeaseRefreshInterval (%s) must be less than or equal to half of LeaseDuration (%s)", l.LeaseRefreshInterval.String(), l.LeaseDuration.String()))
}
return
}
type DatabaseBackup struct {
Dir *string
Frequency *models.Duration
Mode *config.DatabaseBackupMode
OnVersionUpgrade *bool
// DatabaseBackupURL stored in Secrets
}
type TelemetryIngress struct {
UniConn *bool
Logging *bool
ServerPubKey *string
URL *models.URL
BufferSize *uint16
MaxBatchSize *uint16
SendInterval *models.Duration
SendTimeout *models.Duration
UseBatchSend *bool
}
type Log struct {
DatabaseQueries *bool
FileDir *string
FileMaxSize *utils.FileSize
FileMaxAgeDays *int64
FileMaxBackups *int64
JSONConsole *bool
UnixTS *bool
}
type WebServer struct {
AllowOrigins *string
BridgeResponseURL *models.URL
HTTPWriteTimeout *models.Duration
HTTPPort *uint16
SecureCookies *bool
SessionTimeout *models.Duration
SessionReaperExpiration *models.Duration
MFA *WebServerMFA
RateLimit *WebServerRateLimit
TLS *WebServerTLS
}
type WebServerMFA struct {
RPID *string
RPOrigin *string
}
type WebServerRateLimit struct {
Authenticated *int64
AuthenticatedPeriod *models.Duration
Unauthenticated *int64
UnauthenticatedPeriod *models.Duration
}
type WebServerTLS struct {
CertPath *string
ForceRedirect *bool
Host *string
HTTPSPort *uint16
KeyPath *string
}
type JobPipeline struct {
DefaultHTTPRequestTimeout *models.Duration
ExternalInitiatorsEnabled *bool
HTTPRequestMaxSize *utils.FileSize
MaxRunDuration *models.Duration
ReaperInterval *models.Duration
ReaperThreshold *models.Duration
ResultWriteQueueDepth *uint32
}
type FluxMonitor struct {
DefaultTransactionQueueDepth *uint32
SimulateTransactions *bool
}
type OCR2 struct {
Enabled *bool //TODO disabled https://app.shortcut.com/chainlinklabs/story/33615/
ContractConfirmations *uint32
BlockchainTimeout *models.Duration
ContractPollInterval *models.Duration
ContractSubscribeInterval *models.Duration
ContractTransmitterTransmitTimeout *models.Duration
DatabaseTimeout *models.Duration
KeyBundleID *models.Sha256Hash
}
type OCR struct {
Enabled *bool //TODO disabled https://app.shortcut.com/chainlinklabs/story/33615/
ObservationTimeout *models.Duration
BlockchainTimeout *models.Duration
ContractPollInterval *models.Duration
ContractSubscribeInterval *models.Duration
DefaultTransactionQueueDepth *uint32
// Optional
KeyBundleID *models.Sha256Hash
SimulateTransactions *bool
TransmitterAddress *ethkey.EIP55Address
}
type P2P struct {
// V1 and V2
IncomingMessageBufferSize *int64
OutgoingMessageBufferSize *int64
TraceLogging *bool
V1 *P2PV1
V2 *P2PV2
}
func (p *P2P) NetworkStack() ocrnetworking.NetworkingStack {
switch {
case p.V1 != nil && p.V2 != nil:
return ocrnetworking.NetworkingStackV1V2
case p.V2 != nil:
return ocrnetworking.NetworkingStackV2
case p.V1 != nil:
return ocrnetworking.NetworkingStackV1
}
return ocrnetworking.NetworkingStack(0)
}
type P2PV1 struct {
AnnounceIP *net.IP
AnnouncePort *uint16
BootstrapCheckInterval *models.Duration
DefaultBootstrapPeers *[]string
DHTAnnouncementCounterUserPrefix *uint32
DHTLookupInterval *int64
ListenIP *net.IP
ListenPort *uint16
NewStreamTimeout *models.Duration
PeerID *p2pkey.PeerID
PeerstoreWriteInterval *models.Duration
}
func (p *P2PV1) ValidateConfig() (err error) {
if p.AnnouncePort != nil && p.AnnounceIP == nil {
err = multierr.Append(err, ErrMissing{Name: "AnnounceIP", Msg: fmt.Sprintf("required when AnnouncePort is set: %d", *p.AnnouncePort)})
}
return
}
type P2PV2 struct {
AnnounceAddresses *[]string
DefaultBootstrappers *[]ocrcommontypes.BootstrapperLocator
DeltaDial *models.Duration
DeltaReconcile *models.Duration
ListenAddresses *[]string
}
type Keeper struct {
DefaultTransactionQueueDepth *uint32
GasPriceBufferPercent *uint32
GasTipCapBufferPercent *uint32
BaseFeeBufferPercent *uint32
MaximumGracePeriod *int64
RegistryCheckGasOverhead *uint32
RegistryPerformGasOverhead *uint32
RegistryMaxPerformDataSize *uint32
RegistrySyncInterval *models.Duration
RegistrySyncUpkeepQueueSize *uint32
TurnLookBack *int64
TurnFlagEnabled *bool
UpkeepCheckGasPriceEnabled *bool
}
type AutoPprof struct {
Enabled *bool //TODO Disabled https://app.shortcut.com/chainlinklabs/story/33615/
ProfileRoot *string
PollInterval *models.Duration
GatherDuration *models.Duration
GatherTraceDuration *models.Duration
MaxProfileSize *utils.FileSize
CPUProfileRate *int64 // runtime.SetCPUProfileRate
MemProfileRate *int64 // runtime.MemProfileRate
BlockProfileRate *int64 // runtime.SetBlockProfileRate
MutexProfileFraction *int64 // runtime.SetMutexProfileFraction
MemThreshold *utils.FileSize
GoroutineThreshold *int64
}
type Pyroscope struct {
AuthToken *string
ServerAddress *string
Environment *string
}
type Sentry struct {
Debug *bool
DSN *string
Environment *string
Release *string
}