From 50a2a567b8c04e537a79caa6e0e2744205f365e5 Mon Sep 17 00:00:00 2001 From: bdchatham Date: Tue, 17 Mar 2026 10:38:34 -0700 Subject: [PATCH] feat: add well-known port constants and NodePorts() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Exposes canonical Sei node port numbers (RPC, P2P, gRPC, EVM, metrics, sidecar) as typed int32 constants so consumers like sei-k8s-controller don't need to maintain their own copies. Also adds NodePorts() which returns the name→port pairs for container/service port generation. The EVM defaults in baseDefaults() now reference PortEVMHTTP/PortEVMWS instead of bare literals. --- config.go | 30 ++++++++++++++++++++++++++++++ defaults.go | 4 ++-- 2 files changed, 32 insertions(+), 2 deletions(-) diff --git a/config.go b/config.go index fb56a67..f460332 100644 --- a/config.go +++ b/config.go @@ -14,6 +14,36 @@ const CurrentVersion = 1 // 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 + 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}, + {"p2p", PortP2P}, + {"rpc", PortRPC}, + {"metrics", PortMetrics}, + } +} + // Pruning strategy constants. const ( PruningDefault = "default" diff --git a/defaults.go b/defaults.go index 0bf1f9b..9262328 100644 --- a/defaults.go +++ b/defaults.go @@ -139,9 +139,9 @@ func baseDefaults() *SeiConfig { EVM: EVMConfig{ HTTPEnabled: true, - HTTPPort: 8545, + HTTPPort: int(PortEVMHTTP), WSEnabled: true, - WSPort: 8546, + WSPort: int(PortEVMWS), ReadTimeout: Dur(30 * time.Second), ReadHeaderTimeout: Dur(30 * time.Second), WriteTimeout: Dur(30 * time.Second),