-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathconfig.go
More file actions
546 lines (450 loc) · 20.2 KB
/
config.go
File metadata and controls
546 lines (450 loc) · 20.2 KB
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
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
// Package seiconfig provides unified configuration types, mode-aware defaults,
// validation, and serialization for Sei blockchain nodes.
//
// It serves as the single source of truth for configuration across all Sei
// components: seid, seictl (CLI and sidecar), and the Kubernetes controller.
package seiconfig
import "runtime"
// CurrentVersion is the config schema version produced by this library.
const CurrentVersion = 1
// DefaultSnapshotInterval is the default Tendermint state-sync snapshot
// creation interval (in blocks) used when snapshot generation is enabled.
const DefaultSnapshotInterval = 2000
// Well-known default ports for Sei node services and the sidecar.
const (
PortEVMHTTP int32 = 8545
PortEVMWS int32 = 8546
PortGRPC int32 = 9090
PortREST int32 = 1317
PortP2P int32 = 26656
PortRPC int32 = 26657
PortMetrics int32 = 26660
PortSidecar int32 = 7777
)
// NodePort pairs a human-readable service name with its default port number.
type NodePort struct {
Name string
Port int32
}
// NodePorts returns the canonical set of ports exposed by a Sei node (seid).
// The sidecar port is excluded; use PortSidecar directly.
func NodePorts() []NodePort {
return []NodePort{
{"evm-rpc", PortEVMHTTP},
{"evm-ws", PortEVMWS},
{"grpc", PortGRPC},
{"rest", PortREST},
{"p2p", PortP2P},
{"rpc", PortRPC},
{"metrics", PortMetrics},
}
}
// NodePortsForMode returns the ports that are actually served by a node
// running in the given mode.
func NodePortsForMode(mode NodeMode) []NodePort {
switch mode {
case ModeValidator:
return []NodePort{
{"p2p", PortP2P},
{"metrics", PortMetrics},
}
case ModeFull, ModeArchive:
return []NodePort{
{"evm-rpc", PortEVMHTTP},
{"evm-ws", PortEVMWS},
{"grpc", PortGRPC},
{"rest", PortREST},
{"p2p", PortP2P},
{"rpc", PortRPC},
{"metrics", PortMetrics},
}
default:
return nil
}
}
// Override key constants for the unified config schema.
const (
KeyPruningKeepRecent = "storage.pruning_keep_recent"
KeyPruningKeepEvery = "storage.pruning_keep_every"
KeySnapshotInterval = "storage.snapshot_interval"
KeySnapshotKeepRecent = "storage.snapshot_keep_recent"
KeyMinRetainBlocks = "chain.min_retain_blocks"
KeyP2PExternalAddress = "network.p2p.external_address"
KeyP2PMaxConnections = "network.p2p.max_connections"
KeyP2PSendRate = "network.p2p.send_rate"
KeyP2PRecvRate = "network.p2p.recv_rate"
)
// Pruning strategy constants.
const (
PruningDefault = "default"
PruningNothing = "nothing"
PruningEverything = "everything"
PruningCustom = "custom"
)
// SeiConfig is the unified configuration for a Sei node, encompassing all
// settings previously split across config.toml (Tendermint) and app.toml
// (Cosmos SDK + Sei extensions).
type SeiConfig struct {
Version int `toml:"version"`
Mode NodeMode `toml:"mode"`
Chain ChainConfig `toml:"chain"`
Network NetworkConfig `toml:"network"`
Consensus ConsensusConfig `toml:"consensus"`
Mempool MempoolConfig `toml:"mempool"`
StateSync StateSyncConfig `toml:"state_sync"`
Storage StorageConfig `toml:"storage"`
TxIndex TxIndexConfig `toml:"tx_index"`
EVM EVMConfig `toml:"evm"`
API APIConfig `toml:"api"`
Metrics MetricsConfig `toml:"metrics"`
Logging LogConfig `toml:"logging"`
WASM WASMConfig `toml:"wasm"`
GigaExecutor GigaExecutorConfig `toml:"giga_executor"`
LightInvariance LightInvarianceConfig `toml:"light_invariance"`
PrivValidator PrivValidatorConfig `toml:"priv_validator"`
SelfRemediation SelfRemediationConfig `toml:"self_remediation"`
Genesis GenesisConfig `toml:"genesis"`
}
// ---------------------------------------------------------------------------
// Chain — node identity and core chain parameters
// ---------------------------------------------------------------------------
type ChainConfig struct {
ChainID string `toml:"chain_id"`
Moniker string `toml:"moniker"`
ProxyApp string `toml:"proxy_app"`
ABCI string `toml:"abci"`
FilterPeers bool `toml:"filter_peers"`
MinGasPrices string `toml:"min_gas_prices"`
HaltHeight uint64 `toml:"halt_height"`
HaltTime uint64 `toml:"halt_time"`
MinRetainBlocks uint64 `toml:"min_retain_blocks"`
InterBlockCache bool `toml:"inter_block_cache"`
IndexEvents []string `toml:"index_events"`
ConcurrencyWorkers int `toml:"concurrency_workers"`
OccEnabled bool `toml:"occ_enabled"`
}
// ---------------------------------------------------------------------------
// Network — RPC and P2P
// ---------------------------------------------------------------------------
type NetworkConfig struct {
RPC RPCConfig `toml:"rpc"`
P2P P2PConfig `toml:"p2p"`
}
type RPCConfig struct {
ListenAddress string `toml:"listen_address"`
CORSOrigins []string `toml:"cors_allowed_origins"`
CORSMethods []string `toml:"cors_allowed_methods"`
CORSHeaders []string `toml:"cors_allowed_headers"`
Unsafe bool `toml:"unsafe"`
MaxOpenConnections int `toml:"max_open_connections"`
MaxSubscriptionClients int `toml:"max_subscription_clients"`
MaxSubscriptionsPerClient int `toml:"max_subscriptions_per_client"`
ExperimentalDisableWebsocket bool `toml:"experimental_disable_websocket"`
EventLogWindowSize Duration `toml:"event_log_window_size"`
EventLogMaxItems int `toml:"event_log_max_items"`
TimeoutBroadcastTxCommit Duration `toml:"timeout_broadcast_tx_commit"`
MaxBodyBytes int64 `toml:"max_body_bytes"`
MaxHeaderBytes int `toml:"max_header_bytes"`
TLSCertFile string `toml:"tls_cert_file"`
TLSKeyFile string `toml:"tls_key_file"`
PprofListenAddress string `toml:"pprof_listen_address"`
LagThreshold int64 `toml:"lag_threshold"`
TimeoutRead Duration `toml:"timeout_read"`
}
type P2PConfig struct {
ListenAddress string `toml:"listen_address"`
ExternalAddress string `toml:"external_address"`
BootstrapPeers string `toml:"bootstrap_peers"`
PersistentPeers string `toml:"persistent_peers"`
BlockSyncPeers string `toml:"blocksync_peers"`
UPNP bool `toml:"upnp"`
MaxConnections uint16 `toml:"max_connections"`
MaxIncomingConnectionAttempts uint `toml:"max_incoming_connection_attempts"`
PexReactor bool `toml:"pex"`
PrivatePeerIDs string `toml:"private_peer_ids"`
AllowDuplicateIP bool `toml:"allow_duplicate_ip"`
UnconditionalPeerIDs string `toml:"unconditional_peer_ids"`
FlushThrottleTimeout Duration `toml:"flush_throttle_timeout"`
MaxPacketMsgPayloadSize int `toml:"max_packet_msg_payload_size"`
SendRate int64 `toml:"send_rate"`
RecvRate int64 `toml:"recv_rate"`
HandshakeTimeout Duration `toml:"handshake_timeout"`
DialTimeout Duration `toml:"dial_timeout"`
DialInterval Duration `toml:"dial_interval"`
QueueType string `toml:"queue_type"`
}
// ---------------------------------------------------------------------------
// Consensus
// ---------------------------------------------------------------------------
type ConsensusConfig struct {
WALPath string `toml:"wal_path"`
CreateEmptyBlocks bool `toml:"create_empty_blocks"`
CreateEmptyBlocksInterval Duration `toml:"create_empty_blocks_interval"`
GossipTransactionKeyOnly bool `toml:"gossip_transaction_key_only"`
PeerGossipSleepDuration Duration `toml:"peer_gossip_sleep_duration"`
PeerQueryMaj23SleepDuration Duration `toml:"peer_query_maj23_sleep_duration"`
DoubleSignCheckHeight int64 `toml:"double_sign_check_height"`
UnsafeProposeTimeoutOverride Duration `toml:"unsafe_propose_timeout_override"`
UnsafeProposeTimeoutDeltaOverride Duration `toml:"unsafe_propose_timeout_delta_override"`
UnsafeVoteTimeoutOverride Duration `toml:"unsafe_vote_timeout_override"`
UnsafeVoteTimeoutDeltaOverride Duration `toml:"unsafe_vote_timeout_delta_override"`
UnsafeCommitTimeoutOverride Duration `toml:"unsafe_commit_timeout_override"`
UnsafeBypassCommitTimeoutOverride *bool `toml:"unsafe_bypass_commit_timeout_override"`
}
// ---------------------------------------------------------------------------
// Mempool
// ---------------------------------------------------------------------------
type MempoolConfig struct {
Broadcast bool `toml:"broadcast"`
Size int `toml:"size"`
MaxTxsBytes int64 `toml:"max_txs_bytes"`
CacheSize int `toml:"cache_size"`
DuplicateTxsCacheSize int `toml:"duplicate_txs_cache_size"`
KeepInvalidTxsInCache bool `toml:"keep_invalid_txs_in_cache"`
MaxTxBytes int `toml:"max_tx_bytes"`
MaxBatchBytes int `toml:"max_batch_bytes"`
TTLDuration Duration `toml:"ttl_duration"`
TTLNumBlocks int64 `toml:"ttl_num_blocks"`
TxNotifyThreshold uint64 `toml:"tx_notify_threshold"`
CheckTxErrorBlacklistEnabled bool `toml:"check_tx_error_blacklist_enabled"`
CheckTxErrorThreshold int `toml:"check_tx_error_threshold"`
PendingSize int `toml:"pending_size"`
MaxPendingTxsBytes int64 `toml:"max_pending_txs_bytes"`
PendingTTLDuration Duration `toml:"pending_ttl_duration"`
PendingTTLNumBlocks int64 `toml:"pending_ttl_num_blocks"`
RemoveExpiredTxsFromQueue bool `toml:"remove_expired_txs_from_queue"`
DropPriorityThreshold float64 `toml:"drop_priority_threshold"`
DropUtilisationThreshold float64 `toml:"drop_utilisation_threshold"`
DropPriorityReservoirSize int `toml:"drop_priority_reservoir_size"`
}
// ---------------------------------------------------------------------------
// StateSync
// ---------------------------------------------------------------------------
type StateSyncConfig struct {
Enable bool `toml:"enable"`
UseP2P bool `toml:"use_p2p"`
RPCServers []string `toml:"rpc_servers"`
TrustHeight int64 `toml:"trust_height"`
TrustHash string `toml:"trust_hash"`
TrustPeriod Duration `toml:"trust_period"`
BackfillBlocks int64 `toml:"backfill_blocks"`
BackfillDuration Duration `toml:"backfill_duration"`
DiscoveryTime Duration `toml:"discovery_time"`
TempDir string `toml:"temp_dir"`
ChunkRequestTimeout Duration `toml:"chunk_request_timeout"`
Fetchers int32 `toml:"fetchers"`
VerifyLightBlockTimeout Duration `toml:"verify_light_block_timeout"`
BlacklistTTL Duration `toml:"blacklist_ttl"`
UseLocalSnapshot bool `toml:"use_local_snapshot"`
LightBlockResponseTimeout Duration `toml:"light_block_response_timeout"`
}
// ---------------------------------------------------------------------------
// Storage — DB, pruning, snapshots, SeiDB (state-commit + state-store)
// ---------------------------------------------------------------------------
type StorageConfig struct {
DBBackend string `toml:"db_backend"`
DBPath string `toml:"db_path"`
PruningStrategy string `toml:"pruning"`
PruningKeepRecent string `toml:"pruning_keep_recent"`
PruningKeepEvery string `toml:"pruning_keep_every"`
PruningInterval string `toml:"pruning_interval"`
SnapshotInterval uint64 `toml:"snapshot_interval"`
SnapshotKeepRecent uint32 `toml:"snapshot_keep_recent"`
SnapshotDirectory string `toml:"snapshot_directory"`
CompactionInterval uint64 `toml:"compaction_interval"`
IAVLDisableFastNode bool `toml:"iavl_disable_fast_node"`
StateCommit StateCommitConfig `toml:"state_commit"`
StateStore StateStoreConfig `toml:"state_store"`
}
type StateCommitConfig struct {
Enable bool `toml:"enable"`
Directory string `toml:"directory"`
AsyncCommitBuffer int `toml:"async_commit_buffer"`
WriteMode WriteMode `toml:"write_mode"`
ReadMode ReadMode `toml:"read_mode"`
MemIAVL MemIAVLConfig `toml:"memiavl"`
}
type MemIAVLConfig struct {
SnapshotKeepRecent uint32 `toml:"snapshot_keep_recent"`
SnapshotInterval uint32 `toml:"snapshot_interval"`
SnapshotMinTimeInterval uint32 `toml:"snapshot_min_time_interval"`
SnapshotWriterLimit int `toml:"snapshot_writer_limit"`
SnapshotPrefetchThreshold float64 `toml:"snapshot_prefetch_threshold"`
}
type StateStoreConfig struct {
Enable bool `toml:"enable"`
DBDirectory string `toml:"db_directory"`
Backend string `toml:"backend"`
AsyncWriteBuffer int `toml:"async_write_buffer"`
KeepRecent int `toml:"keep_recent"`
PruneIntervalSeconds int `toml:"prune_interval_seconds"`
ImportNumWorkers int `toml:"import_num_workers"`
KeepLastVersion bool `toml:"keep_last_version"`
UseDefaultComparer bool `toml:"use_default_comparer"`
WriteMode WriteMode `toml:"write_mode"`
ReadMode ReadMode `toml:"read_mode"`
EVMDBDirectory string `toml:"evm_db_directory"`
}
// ---------------------------------------------------------------------------
// TxIndex
// ---------------------------------------------------------------------------
type TxIndexConfig struct {
Indexer []string `toml:"indexer"`
PsqlConn string `toml:"psql_conn"`
}
// ---------------------------------------------------------------------------
// EVM — RPC server, tracing, query, replay, block test
// ---------------------------------------------------------------------------
type EVMConfig struct {
HTTPEnabled bool `toml:"http_enabled"`
HTTPPort int `toml:"http_port"`
WSEnabled bool `toml:"ws_enabled"`
WSPort int `toml:"ws_port"`
ReadTimeout Duration `toml:"read_timeout"`
ReadHeaderTimeout Duration `toml:"read_header_timeout"`
WriteTimeout Duration `toml:"write_timeout"`
IdleTimeout Duration `toml:"idle_timeout"`
SimulationGasLimit uint64 `toml:"simulation_gas_limit"`
SimulationEVMTimeout Duration `toml:"simulation_evm_timeout"`
CORSOrigins string `toml:"cors_origins"`
WSOrigins string `toml:"ws_origins"`
FilterTimeout Duration `toml:"filter_timeout"`
CheckTxTimeout Duration `toml:"checktx_timeout"`
MaxTxPoolTxs uint64 `toml:"max_tx_pool_txs"`
Slow bool `toml:"slow"`
DenyList []string `toml:"deny_list"`
MaxLogNoBlock int64 `toml:"max_log_no_block"`
MaxBlocksForLog int64 `toml:"max_blocks_for_log"`
MaxSubscriptionsNewHead uint64 `toml:"max_subscriptions_new_head"`
EnableTestAPI bool `toml:"enable_test_api"`
MaxConcurrentTraceCalls uint64 `toml:"max_concurrent_trace_calls"`
MaxConcurrentSimulationCalls int `toml:"max_concurrent_simulation_calls"`
MaxTraceLookbackBlocks int64 `toml:"max_trace_lookback_blocks"`
TraceTimeout Duration `toml:"trace_timeout"`
RPCStatsInterval Duration `toml:"rpc_stats_interval"`
WorkerPoolSize int `toml:"worker_pool_size"`
WorkerQueueSize int `toml:"worker_queue_size"`
Query EVMQueryConfig `toml:"query"`
Replay EVMReplayConfig `toml:"replay"`
BlockTest EVMBlockTestConfig `toml:"block_test"`
}
type EVMQueryConfig struct {
GasLimit uint64 `toml:"gas_limit"`
}
type EVMReplayConfig struct {
Enabled bool `toml:"enabled"`
EthRPC string `toml:"eth_rpc"`
EthDataDir string `toml:"eth_data_dir"`
ContractStateChecks bool `toml:"contract_state_checks"`
}
type EVMBlockTestConfig struct {
Enabled bool `toml:"enabled"`
TestDataPath string `toml:"test_data_path"`
}
// ---------------------------------------------------------------------------
// API — REST, gRPC, gRPC-Web
// ---------------------------------------------------------------------------
type APIConfig struct {
REST RESTAPIConfig `toml:"rest"`
GRPC GRPCConfig `toml:"grpc"`
GRPCWeb GRPCWebConfig `toml:"grpc_web"`
}
type RESTAPIConfig struct {
Enable bool `toml:"enable"`
Swagger bool `toml:"swagger"`
Address string `toml:"address"`
MaxOpenConnections uint `toml:"max_open_connections"`
RPCReadTimeout uint `toml:"rpc_read_timeout"`
RPCWriteTimeout uint `toml:"rpc_write_timeout"`
RPCMaxBodyBytes uint `toml:"rpc_max_body_bytes"`
EnableUnsafeCORS bool `toml:"enable_unsafe_cors"`
}
type GRPCConfig struct {
Enable bool `toml:"enable"`
Address string `toml:"address"`
}
type GRPCWebConfig struct {
Enable bool `toml:"enable"`
Address string `toml:"address"`
EnableUnsafeCORS bool `toml:"enable_unsafe_cors"`
}
// ---------------------------------------------------------------------------
// Metrics — merges Tendermint instrumentation + Cosmos telemetry
// ---------------------------------------------------------------------------
type MetricsConfig struct {
Enabled bool `toml:"enabled"`
PrometheusListenAddr string `toml:"prometheus_listen_addr"`
MaxOpenConnections int `toml:"max_open_connections"`
Namespace string `toml:"namespace"`
ServiceName string `toml:"service_name"`
EnableHostname bool `toml:"enable_hostname"`
EnableHostnameLabel bool `toml:"enable_hostname_label"`
EnableServiceLabel bool `toml:"enable_service_label"`
PrometheusRetentionTime int64 `toml:"prometheus_retention_time"`
GlobalLabels [][]string `toml:"global_labels"`
}
// ---------------------------------------------------------------------------
// Logging
// ---------------------------------------------------------------------------
type LogConfig struct {
Level string `toml:"level"`
Format string `toml:"format"`
}
// ---------------------------------------------------------------------------
// WASM
// ---------------------------------------------------------------------------
type WASMConfig struct {
QueryGasLimit uint64 `toml:"query_gas_limit"`
LruSize uint64 `toml:"lru_size"`
}
// ---------------------------------------------------------------------------
// GigaExecutor
// ---------------------------------------------------------------------------
type GigaExecutorConfig struct {
Enabled bool `toml:"enabled"`
OccEnabled bool `toml:"occ_enabled"`
}
// ---------------------------------------------------------------------------
// LightInvariance
// ---------------------------------------------------------------------------
type LightInvarianceConfig struct {
SupplyEnabled bool `toml:"supply_enabled"`
}
// ---------------------------------------------------------------------------
// PrivValidator
// ---------------------------------------------------------------------------
type PrivValidatorConfig struct {
KeyFile string `toml:"key_file"`
StateFile string `toml:"state_file"`
ListenAddr string `toml:"listen_addr"`
ClientCertificate string `toml:"client_certificate_file"`
ClientKey string `toml:"client_key_file"`
RootCA string `toml:"root_ca_file"`
}
// ---------------------------------------------------------------------------
// SelfRemediation
// ---------------------------------------------------------------------------
type SelfRemediationConfig struct {
P2PNoPeersRestartWindowSeconds uint64 `toml:"p2p_no_peers_restart_window_seconds"`
StatesyncNoPeersRestartWindowSeconds uint64 `toml:"statesync_no_peers_restart_window_seconds"`
BlocksBehindThreshold uint64 `toml:"blocks_behind_threshold"`
BlocksBehindCheckIntervalSeconds uint64 `toml:"blocks_behind_check_interval_seconds"`
RestartCooldownSeconds uint64 `toml:"restart_cooldown_seconds"`
}
// ---------------------------------------------------------------------------
// Genesis (stream import)
// ---------------------------------------------------------------------------
type GenesisConfig struct {
StreamImport bool `toml:"stream_import"`
GenesisStreamFile string `toml:"genesis_stream_file"`
}
// ---------------------------------------------------------------------------
// Helpers
// ---------------------------------------------------------------------------
func defaultConcurrencyWorkers() int {
workers := runtime.NumCPU() * 2
return max(10, min(workers, 128))
}
func defaultEVMWorkerPoolSize() int {
return min(64, runtime.NumCPU()*2)
}