Skip to content

Commit 94b99ed

Browse files
authored
Merge branch 'main' into claude/issue-2532-20250808-1039
2 parents 327aefe + a7dbf77 commit 94b99ed

File tree

3 files changed

+60
-45
lines changed

3 files changed

+60
-45
lines changed

pkg/cmd/p2p_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ func TestNetInfoCmd_Success(t *testing.T) {
105105
NetInfoCmd.SetContext(context.WithValue(context.Background(), viperKey, v))
106106
rootCmd.AddCommand(NetInfoCmd)
107107

108-
output, err := executeCommandC(rootCmd, "net-info", "--rollkit.rpc.address="+rpcAddr)
108+
output, err := executeCommandC(rootCmd, "net-info", "--evnode.rpc.address="+rpcAddr)
109109

110110
require.NoError(err, "Command execution failed: %s", output)
111111
t.Log("Command Output:\n", output)
@@ -183,7 +183,7 @@ func TestNetInfoCmd_NoPeers(t *testing.T) {
183183
NetInfoCmd.SetContext(context.WithValue(context.Background(), viperKey, v))
184184
rootCmd.AddCommand(NetInfoCmd)
185185

186-
output, err := executeCommandC(rootCmd, "net-info", "--rollkit.rpc.address="+rpcAddr)
186+
output, err := executeCommandC(rootCmd, "net-info", "--evnode.rpc.address="+rpcAddr)
187187

188188
require.NoError(err, "Command execution failed: %s", output)
189189
t.Log("Command Output:\n", output)

pkg/config/config.go

Lines changed: 57 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -17,107 +17,110 @@ import (
1717
)
1818

1919
const (
20+
FlagPrefixRollkit = "rollkit."
21+
FlagPrefixEvnode = "evnode."
22+
2023
// Base configuration flags
2124

2225
// FlagRootDir is a flag for specifying the root directory
2326
FlagRootDir = "home"
2427
// FlagDBPath is a flag for specifying the database path
25-
FlagDBPath = "rollkit.db_path"
28+
FlagDBPath = FlagPrefixEvnode + "db_path"
2629

2730
// Node configuration flags
2831

2932
// FlagAggregator is a flag for running node in aggregator mode
30-
FlagAggregator = "rollkit.node.aggregator"
33+
FlagAggregator = FlagPrefixEvnode + "node.aggregator"
3134
// FlagLight is a flag for running the node in light mode
32-
FlagLight = "rollkit.node.light"
35+
FlagLight = FlagPrefixEvnode + "node.light"
3336
// FlagBlockTime is a flag for specifying the block time
34-
FlagBlockTime = "rollkit.node.block_time"
37+
FlagBlockTime = FlagPrefixEvnode + "node.block_time"
3538
// FlagTrustedHash is a flag for specifying the trusted hash
36-
FlagTrustedHash = "rollkit.node.trusted_hash"
39+
FlagTrustedHash = FlagPrefixEvnode + "node.trusted_hash"
3740
// FlagLazyAggregator is a flag for enabling lazy aggregation mode that only produces blocks when transactions are available
38-
FlagLazyAggregator = "rollkit.node.lazy_mode"
41+
FlagLazyAggregator = FlagPrefixEvnode + "node.lazy_mode"
3942
// FlagMaxPendingHeadersAndData is a flag to limit and pause block production when too many headers or data are waiting for DA confirmation
40-
FlagMaxPendingHeadersAndData = "rollkit.node.max_pending_headers_and_data"
43+
FlagMaxPendingHeadersAndData = FlagPrefixEvnode + "node.max_pending_headers_and_data"
4144
// FlagLazyBlockTime is a flag for specifying the maximum interval between blocks in lazy aggregation mode
42-
FlagLazyBlockTime = "rollkit.node.lazy_block_interval"
45+
FlagLazyBlockTime = FlagPrefixEvnode + "node.lazy_block_interval"
4346

4447
// Data Availability configuration flags
4548

4649
// FlagDAAddress is a flag for specifying the data availability layer address
47-
FlagDAAddress = "rollkit.da.address"
50+
FlagDAAddress = FlagPrefixEvnode + "da.address"
4851
// FlagDAAuthToken is a flag for specifying the data availability layer auth token
49-
FlagDAAuthToken = "rollkit.da.auth_token" // #nosec G101
52+
FlagDAAuthToken = FlagPrefixEvnode + "da.auth_token" // #nosec G101
5053
// FlagDABlockTime is a flag for specifying the data availability layer block time
51-
FlagDABlockTime = "rollkit.da.block_time"
54+
FlagDABlockTime = FlagPrefixEvnode + "da.block_time"
5255
// FlagDAGasPrice is a flag for specifying the data availability layer gas price
53-
FlagDAGasPrice = "rollkit.da.gas_price"
56+
FlagDAGasPrice = FlagPrefixEvnode + "da.gas_price"
5457
// FlagDAGasMultiplier is a flag for specifying the data availability layer gas price retry multiplier
55-
FlagDAGasMultiplier = "rollkit.da.gas_multiplier"
58+
FlagDAGasMultiplier = FlagPrefixEvnode + "da.gas_multiplier"
5659
// FlagDAStartHeight is a flag for specifying the data availability layer start height
57-
FlagDAStartHeight = "rollkit.da.start_height"
60+
FlagDAStartHeight = FlagPrefixEvnode + "da.start_height"
5861
// FlagDANamespace is a flag for specifying the DA namespace ID
59-
FlagDANamespace = "rollkit.da.namespace"
62+
FlagDANamespace = FlagPrefixEvnode + "da.namespace"
6063
// FlagDAHeaderNamespace is a flag for specifying the DA header namespace ID
61-
FlagDAHeaderNamespace = "rollkit.da.header_namespace"
64+
FlagDAHeaderNamespace = FlagPrefixEvnode + "da.header_namespace"
6265
// FlagDADataNamespace is a flag for specifying the DA data namespace ID
63-
FlagDADataNamespace = "rollkit.da.data_namespace"
66+
FlagDADataNamespace = FlagPrefixEvnode + "da.data_namespace"
6467
// FlagDASubmitOptions is a flag for data availability submit options
65-
FlagDASubmitOptions = "rollkit.da.submit_options"
68+
FlagDASubmitOptions = FlagPrefixEvnode + "da.submit_options"
6669
// FlagDAMempoolTTL is a flag for specifying the DA mempool TTL
67-
FlagDAMempoolTTL = "rollkit.da.mempool_ttl"
70+
FlagDAMempoolTTL = FlagPrefixEvnode + "da.mempool_ttl"
6871
// FlagDAMaxSubmitAttempts is a flag for specifying the maximum DA submit attempts
69-
FlagDAMaxSubmitAttempts = "rollkit.da.max_submit_attempts"
72+
FlagDAMaxSubmitAttempts = FlagPrefixEvnode + "da.max_submit_attempts"
7073

7174
// P2P configuration flags
7275

7376
// FlagP2PListenAddress is a flag for specifying the P2P listen address
74-
FlagP2PListenAddress = "rollkit.p2p.listen_address"
77+
FlagP2PListenAddress = FlagPrefixEvnode + "p2p.listen_address"
7578
// FlagP2PPeers is a flag for specifying the P2P peers
76-
FlagP2PPeers = "rollkit.p2p.peers"
79+
FlagP2PPeers = FlagPrefixEvnode + "p2p.peers"
7780
// FlagP2PBlockedPeers is a flag for specifying the P2P blocked peers
78-
FlagP2PBlockedPeers = "rollkit.p2p.blocked_peers"
81+
FlagP2PBlockedPeers = FlagPrefixEvnode + "p2p.blocked_peers"
7982
// FlagP2PAllowedPeers is a flag for specifying the P2P allowed peers
80-
FlagP2PAllowedPeers = "rollkit.p2p.allowed_peers"
83+
FlagP2PAllowedPeers = FlagPrefixEvnode + "p2p.allowed_peers"
8184

8285
// Instrumentation configuration flags
8386

8487
// FlagPrometheus is a flag for enabling Prometheus metrics
85-
FlagPrometheus = "rollkit.instrumentation.prometheus"
88+
FlagPrometheus = FlagPrefixEvnode + "instrumentation.prometheus"
8689
// FlagPrometheusListenAddr is a flag for specifying the Prometheus listen address
87-
FlagPrometheusListenAddr = "rollkit.instrumentation.prometheus_listen_addr"
90+
FlagPrometheusListenAddr = FlagPrefixEvnode + "instrumentation.prometheus_listen_addr"
8891
// FlagMaxOpenConnections is a flag for specifying the maximum number of open connections
89-
FlagMaxOpenConnections = "rollkit.instrumentation.max_open_connections"
92+
FlagMaxOpenConnections = FlagPrefixEvnode + "instrumentation.max_open_connections"
9093
// FlagPprof is a flag for enabling pprof profiling endpoints for runtime debugging
91-
FlagPprof = "rollkit.instrumentation.pprof"
94+
FlagPprof = FlagPrefixEvnode + "instrumentation.pprof"
9295
// FlagPprofListenAddr is a flag for specifying the pprof listen address
93-
FlagPprofListenAddr = "rollkit.instrumentation.pprof_listen_addr"
96+
FlagPprofListenAddr = FlagPrefixEvnode + "instrumentation.pprof_listen_addr"
9497

9598
// Logging configuration flags
9699

97100
// FlagLogLevel is a flag for specifying the log level
98-
FlagLogLevel = "rollkit.log.level"
101+
FlagLogLevel = FlagPrefixEvnode + "log.level"
99102
// FlagLogFormat is a flag for specifying the log format
100-
FlagLogFormat = "rollkit.log.format"
103+
FlagLogFormat = FlagPrefixEvnode + "log.format"
101104
// FlagLogTrace is a flag for enabling stack traces in error logs
102-
FlagLogTrace = "rollkit.log.trace"
105+
FlagLogTrace = FlagPrefixEvnode + "log.trace"
103106

104107
// Signer configuration flags
105108

106109
// FlagSignerType is a flag for specifying the signer type
107-
FlagSignerType = "rollkit.signer.type"
110+
FlagSignerType = FlagPrefixEvnode + "signer.type"
108111
// FlagSignerPath is a flag for specifying the signer path
109-
FlagSignerPath = "rollkit.signer.path"
112+
FlagSignerPath = FlagPrefixEvnode + "signer.path"
110113

111114
// FlagSignerPassphrase is a flag for specifying the signer passphrase
112115
//nolint:gosec
113-
FlagSignerPassphrase = "rollkit.signer.passphrase"
116+
FlagSignerPassphrase = FlagPrefixEvnode + "signer.passphrase"
114117

115118
// RPC configuration flags
116119

117120
// FlagRPCAddress is a flag for specifying the RPC server address
118-
FlagRPCAddress = "rollkit.rpc.address"
121+
FlagRPCAddress = FlagPrefixEvnode + "rpc.address"
119122
// FlagRPCEnableDAVisualization is a flag for enabling DA visualization endpoints
120-
FlagRPCEnableDAVisualization = "rollkit.rpc.enable_da_visualization"
123+
FlagRPCEnableDAVisualization = FlagPrefixEvnode + "rpc.enable_da_visualization"
121124
)
122125

123126
// Config stores Rollkit configuration.
@@ -262,6 +265,15 @@ func AddGlobalFlags(cmd *cobra.Command, defaultHome string) {
262265
func AddFlags(cmd *cobra.Command) {
263266
def := DefaultConfig
264267

268+
// Set normalization function to support both flag prefixes
269+
cmd.Flags().SetNormalizeFunc(func(f *pflag.FlagSet, name string) pflag.NormalizedName {
270+
if strings.HasPrefix(name, FlagPrefixRollkit) {
271+
return pflag.NormalizedName(strings.Replace(name, FlagPrefixRollkit, FlagPrefixEvnode, 1))
272+
}
273+
274+
return pflag.NormalizedName(name)
275+
})
276+
265277
// Add base flags
266278
cmd.Flags().String(FlagDBPath, def.DBPath, "path for the node database")
267279

@@ -400,7 +412,11 @@ func LoadFromViper(inputViper *viper.Viper) (Config, error) {
400412
// then override with settings from input viper (higher precedence)
401413
for _, key := range inputViper.AllKeys() {
402414
// Handle special case for prefixed keys
403-
if after, ok := strings.CutPrefix(key, "rollkit."); ok {
415+
if after, ok := strings.CutPrefix(key, FlagPrefixEvnode); ok {
416+
// Strip the prefix for the merged viper
417+
strippedKey := after
418+
mergedViper.Set(strippedKey, inputViper.Get(key))
419+
} else if after, ok := strings.CutPrefix(key, FlagPrefixRollkit); ok {
404420
// Strip the prefix for the merged viper
405421
strippedKey := after
406422
mergedViper.Set(strippedKey, inputViper.Get(key))
@@ -457,7 +473,9 @@ func bindFlags(basename string, cmd *cobra.Command, v *viper.Viper) (err error)
457473
}()
458474

459475
cmd.Flags().VisitAll(func(f *pflag.Flag) {
460-
flagName := strings.TrimPrefix(f.Name, "rollkit.") // trimm the prefix from the flag name
476+
// trimm possible prefixes from the flag name
477+
flagName := strings.TrimPrefix(f.Name, FlagPrefixEvnode)
478+
flagName = strings.TrimPrefix(flagName, FlagPrefixRollkit)
461479

462480
// Environment variables can't have dashes in them, so bind them to their equivalent
463481
// keys with underscores, e.g. --favorite-color to STING_FAVORITE_COLOR

pkg/rpc/server/da_visualization.go

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -321,10 +321,7 @@ func (s *DAVisualizationServer) handleDAHealth(w http.ResponseWriter, r *http.Re
321321
)
322322

323323
// Look at recent submissions (last 10 or all if less)
324-
recentCount := 10
325-
if len(s.submissions) < recentCount {
326-
recentCount = len(s.submissions)
327-
}
324+
recentCount := min(len(s.submissions), 10)
328325

329326
// Analyze recent submissions
330327
for i := len(s.submissions) - recentCount; i < len(s.submissions); i++ {

0 commit comments

Comments
 (0)