-
Notifications
You must be signed in to change notification settings - Fork 1.7k
/
Copy pathgeneral_config.go
213 lines (195 loc) · 5.74 KB
/
general_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
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
package config
import (
"math/big"
"net/url"
"strings"
"time"
"github.com/gin-contrib/sessions"
"github.com/pkg/errors"
uuid "github.com/satori/go.uuid"
"go.uber.org/zap/zapcore"
"github.com/smartcontractkit/chainlink/v2/core/logger/audit"
"github.com/smartcontractkit/chainlink/v2/core/store/dialects"
"github.com/smartcontractkit/chainlink/v2/core/store/models"
"github.com/smartcontractkit/chainlink/v2/core/utils"
)
// nolint
var (
ErrEnvUnset = errors.New("env var unset")
)
// FeatureFlags contains bools that toggle various features or chains
// TODO: document the new ones
type FeatureFlags interface {
FeatureExternalInitiators() bool
FeatureFeedsManager() bool
FeatureOffchainReporting() bool
FeatureOffchainReporting2() bool
FeatureUICSAKeys() bool
FeatureLogPoller() bool
AutoPprofEnabled() bool
EVMEnabled() bool
EVMRPCEnabled() bool
P2PEnabled() bool
CosmosEnabled() bool
SolanaEnabled() bool
StarkNetEnabled() bool
}
type LogFn func(...any)
type BasicConfig interface {
Validate() error
LogConfiguration(log LogFn)
SetLogLevel(lvl zapcore.Level) error
SetLogSQL(logSQL bool)
SetPasswords(keystore, vrf *string)
FeatureFlags
audit.Config
AllowOrigins() string
AppID() uuid.UUID
AuthenticatedRateLimit() int64
AuthenticatedRateLimitPeriod() models.Duration
AutoPprofBlockProfileRate() int
AutoPprofCPUProfileRate() int
AutoPprofGatherDuration() models.Duration
AutoPprofGatherTraceDuration() models.Duration
AutoPprofGoroutineThreshold() int
AutoPprofMaxProfileSize() utils.FileSize
AutoPprofMemProfileRate() int
AutoPprofMemThreshold() utils.FileSize
AutoPprofMutexProfileFraction() int
AutoPprofPollInterval() models.Duration
AutoPprofProfileRoot() string
BridgeResponseURL() *url.URL
BridgeCacheTTL() time.Duration
CertFile() string
DatabaseBackupDir() string
DatabaseBackupFrequency() time.Duration
DatabaseBackupMode() DatabaseBackupMode
DatabaseBackupOnVersionUpgrade() bool
DatabaseBackupURL() *url.URL
DatabaseDefaultIdleInTxSessionTimeout() time.Duration
DatabaseDefaultLockTimeout() time.Duration
DatabaseDefaultQueryTimeout() time.Duration
DatabaseListenerMaxReconnectDuration() time.Duration
DatabaseListenerMinReconnectInterval() time.Duration
DatabaseLockingMode() string
DatabaseURL() url.URL
DefaultChainID() *big.Int
DefaultHTTPLimit() int64
DefaultHTTPTimeout() models.Duration
DefaultLogLevel() zapcore.Level
Dev() bool
ShutdownGracePeriod() time.Duration
EthereumHTTPURL() *url.URL
EthereumSecondaryURLs() []url.URL
EthereumURL() string
ExplorerAccessKey() string
ExplorerSecret() string
ExplorerURL() *url.URL
FMDefaultTransactionQueueDepth() uint32
FMSimulateTransactions() bool
GetDatabaseDialectConfiguredOrDefault() dialects.DialectName
HTTPServerWriteTimeout() time.Duration
InsecureFastScrypt() bool
JSONConsole() bool
JobPipelineMaxRunDuration() time.Duration
JobPipelineMaxSuccessfulRuns() uint64
JobPipelineReaperInterval() time.Duration
JobPipelineReaperThreshold() time.Duration
JobPipelineResultWriteQueueDepth() uint64
KeeperDefaultTransactionQueueDepth() uint32
KeeperGasPriceBufferPercent() uint16
KeeperGasTipCapBufferPercent() uint16
KeeperBaseFeeBufferPercent() uint16
KeeperMaximumGracePeriod() int64
KeeperRegistryCheckGasOverhead() uint32
KeeperRegistryPerformGasOverhead() uint32
KeeperRegistryMaxPerformDataSize() uint32
KeeperRegistrySyncInterval() time.Duration
KeeperRegistrySyncUpkeepQueueSize() uint32
KeeperTurnLookBack() int64
KeyFile() string
KeystorePassword() string
LeaseLockDuration() time.Duration
LeaseLockRefreshInterval() time.Duration
LogFileDir() string
LogLevel() zapcore.Level
LogSQL() bool
LogFileMaxSize() utils.FileSize
LogFileMaxAge() int64
LogFileMaxBackups() int64
LogUnixTimestamps() bool
MigrateDatabase() bool
ORMMaxIdleConns() int
ORMMaxOpenConns() int
Port() uint16
PrometheusAuthToken() string
PyroscopeAuthToken() string
PyroscopeServerAddress() string
PyroscopeEnvironment() string
RPID() string
RPOrigin() string
ReaperExpiration() models.Duration
RootDir() string
SecureCookies() bool
SentryDSN() string
SentryDebug() bool
SentryEnvironment() string
SentryRelease() string
SessionOptions() sessions.Options
SessionTimeout() models.Duration
TLSCertPath() string
TLSDir() string
TLSHost() string
TLSKeyPath() string
TLSPort() uint16
TLSRedirect() bool
TelemetryIngressLogging() bool
TelemetryIngressUniConn() bool
TelemetryIngressServerPubKey() string
TelemetryIngressURL() *url.URL
TelemetryIngressBufferSize() uint
TelemetryIngressMaxBatchSize() uint
TelemetryIngressSendInterval() time.Duration
TelemetryIngressSendTimeout() time.Duration
TelemetryIngressUseBatchSend() bool
TriggerFallbackDBPollInterval() time.Duration
UnAuthenticatedRateLimit() int64
UnAuthenticatedRateLimitPeriod() models.Duration
VRFPassword() string
OCR1Config
OCR2Config
P2PNetworking
P2PV1Networking
P2PV2Networking
}
type GeneralConfig interface {
BasicConfig
}
func ValidateDBURL(dbURI url.URL) error {
if strings.Contains(dbURI.Redacted(), "_test") {
return nil
}
// url params take priority if present, multiple params are ignored by postgres (it picks the first)
q := dbURI.Query()
// careful, this is a raw database password
pw := q.Get("password")
if pw == "" {
// fallback to user info
userInfo := dbURI.User
if userInfo == nil {
return errors.Errorf("DB URL must be authenticated; plaintext URLs are not allowed")
}
var pwSet bool
pw, pwSet = userInfo.Password()
if !pwSet {
return errors.Errorf("DB URL must be authenticated; password is required")
}
}
return utils.VerifyPasswordComplexity(pw)
}
type DatabaseBackupMode string
var (
DatabaseBackupModeNone DatabaseBackupMode = "none"
DatabaseBackupModeLite DatabaseBackupMode = "lite"
DatabaseBackupModeFull DatabaseBackupMode = "full"
)