Skip to content

Commit 5ad3b28

Browse files
committed
Merge remote-tracking branch 'origin/main' into feat/no-overservicing
2 parents cd45da6 + bae452a commit 5ad3b28

31 files changed

+3729
-149
lines changed

Tiltfile

+25-4
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ load("ext://deployment", "deployment_create")
66
load("ext://execute_in_pod", "execute_in_pod")
77

88
# A list of directories where changes trigger a hot-reload of the validator
9-
hot_reload_dirs = ["app", "cmd", "tools", "x", "pkg"]
9+
hot_reload_dirs = ["app", "cmd", "tools", "x", "pkg", "telemetry"]
1010

1111

1212
def merge_dicts(base, updates):
@@ -38,14 +38,26 @@ localnet_config_defaults = {
3838
"enabled": True,
3939
"grafana": {"defaultDashboardsEnabled": False},
4040
},
41-
"relayminers": {"count": 1, "delve": {"enabled": False}},
41+
"relayminers": {
42+
"count": 1,
43+
"delve": {"enabled": False},
44+
"logs": {
45+
"level": "debug",
46+
},
47+
},
4248
"gateways": {
4349
"count": 1,
4450
"delve": {"enabled": False},
51+
"logs": {
52+
"level": "debug",
53+
},
4554
},
4655
"appgateservers": {
4756
"count": 1,
4857
"delve": {"enabled": False},
58+
"logs": {
59+
"level": "debug",
60+
},
4961
},
5062
"ollama": {
5163
"enabled": False,
@@ -100,8 +112,10 @@ if localnet_config["observability"]["enabled"]:
100112
helm_repo("prometheus-community", "https://prometheus-community.github.io/helm-charts")
101113
helm_repo("grafana-helm-repo", "https://grafana.github.io/helm-charts")
102114

103-
# Increase timeout for building the image
104-
update_settings(k8s_upsert_timeout_secs=60)
115+
# Timeout is increased to 120 seconds (default is 30) because a slow internet connection
116+
# could timeout pulling the image.
117+
# container images.
118+
update_settings(k8s_upsert_timeout_secs=120)
105119

106120
helm_resource(
107121
"observability",
@@ -226,6 +240,7 @@ helm_resource(
226240
"--set=logs.format=" + str(localnet_config["validator"]["logs"]["format"]),
227241
"--set=serviceMonitor.enabled=" + str(localnet_config["observability"]["enabled"]),
228242
"--set=development.delve.enabled=" + str(localnet_config["validator"]["delve"]["enabled"]),
243+
"--set=image.repository=poktrolld",
229244
],
230245
image_deps=["poktrolld"],
231246
image_keys=[("image.repository", "image.tag")],
@@ -244,6 +259,8 @@ for x in range(localnet_config["relayminers"]["count"]):
244259
"--values=./localnet/kubernetes/values-relayminer-" + str(actor_number) + ".yaml",
245260
"--set=metrics.serviceMonitor.enabled=" + str(localnet_config["observability"]["enabled"]),
246261
"--set=development.delve.enabled=" + str(localnet_config["relayminers"]["delve"]["enabled"]),
262+
"--set=logLevel=" + str(localnet_config["relayminers"]["logs"]["level"]),
263+
"--set=image.repository=poktrolld",
247264
],
248265
image_deps=["poktrolld"],
249266
image_keys=[("image.repository", "image.tag")],
@@ -284,6 +301,8 @@ for x in range(localnet_config["appgateservers"]["count"]):
284301
"--set=config.signing_key=app" + str(actor_number),
285302
"--set=metrics.serviceMonitor.enabled=" + str(localnet_config["observability"]["enabled"]),
286303
"--set=development.delve.enabled=" + str(localnet_config["appgateservers"]["delve"]["enabled"]),
304+
"--set=logLevel=" + str(localnet_config["appgateservers"]["logs"]["level"]),
305+
"--set=image.repository=poktrolld",
287306
],
288307
image_deps=["poktrolld"],
289308
image_keys=[("image.repository", "image.tag")],
@@ -325,6 +344,8 @@ for x in range(localnet_config["gateways"]["count"]):
325344
"--set=config.signing_key=gateway" + str(actor_number),
326345
"--set=metrics.serviceMonitor.enabled=" + str(localnet_config["observability"]["enabled"]),
327346
"--set=development.delve.enabled=" + str(localnet_config["gateways"]["delve"]["enabled"]),
347+
"--set=logLevel=" + str(localnet_config["gateways"]["logs"]["level"]),
348+
"--set=image.repository=poktrolld",
328349
],
329350
image_deps=["poktrolld"],
330351
image_keys=[("image.repository", "image.tag")],

app/app.go

+5
Original file line numberDiff line numberDiff line change
@@ -302,6 +302,11 @@ func New(
302302
return nil, err
303303
}
304304

305+
// Set up poktroll telemetry using `app.toml` configuration options (in addition to cosmos-sdk telemetry config).
306+
if err := telemetry.New(appOpts); err != nil {
307+
return nil, err
308+
}
309+
305310
return app, nil
306311
}
307312

cmd/poktrolld/cmd/config.go

+53-14
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,27 @@ import (
99
sdk "github.com/cosmos/cosmos-sdk/types"
1010

1111
"github.com/pokt-network/poktroll/app"
12+
"github.com/pokt-network/poktroll/telemetry"
1213
)
1314

1415
var once sync.Once
1516

17+
// PoktrollAppConfig represents a poktroll-specific part of `app.toml` file.
18+
// Checkout `customAppConfigTemplate()` for additional information about each setting.
19+
type PoktrollAppConfig struct {
20+
Telemetry telemetry.PoktrollTelemetryConfig `mapstructure:"telemetry"`
21+
}
22+
23+
// poktrollAppConfigDefaults sets default values to render in `app.toml`.
24+
// Checkout `customAppConfigTemplate()` for additional information about each setting.
25+
func poktrollAppConfigDefaults() PoktrollAppConfig {
26+
return PoktrollAppConfig{
27+
Telemetry: telemetry.PoktrollTelemetryConfig{
28+
CardinalityLevel: "medium",
29+
},
30+
}
31+
}
32+
1633
func InitSDKConfig() {
1734
once.Do(func() {
1835
checkOrInitSDKConfig()
@@ -90,6 +107,7 @@ func initAppConfig() (string, interface{}) {
90107
// The following code snippet is just for reference.
91108
type CustomAppConfig struct {
92109
serverconfig.Config `mapstructure:",squash"`
110+
Poktroll PoktrollAppConfig `mapstructure:"poktroll"`
93111
}
94112

95113
// Optionally allow the chain developer to overwrite the SDK's default
@@ -113,27 +131,48 @@ func initAppConfig() (string, interface{}) {
113131
srvCfg.MinGasPrices = "0.000000001upokt" // Also adjust ignite's `config.yml`.
114132
srvCfg.Mempool.MaxTxs = 10000
115133
srvCfg.Telemetry.Enabled = true
116-
srvCfg.Telemetry.PrometheusRetentionTime = 60 // in seconds. This turns on Prometheus support.
134+
// Positive non-zero value turns on Prometheus support.
135+
// Prometheus metrics are removed from the exporter when retention time is reached.
136+
srvCfg.Telemetry.PrometheusRetentionTime = 60 * 60 * 24 // in seconds.
117137
srvCfg.Telemetry.MetricsSink = "mem"
118138
srvCfg.Pruning = "nothing" // archiving node by default
119139
srvCfg.API.Enable = true
120140
srvCfg.GRPC.Enable = true
121141
srvCfg.GRPCWeb.Enable = true
122142

123143
customAppConfig := CustomAppConfig{
124-
Config: *srvCfg,
144+
Config: *srvCfg,
145+
Poktroll: poktrollAppConfigDefaults(),
125146
}
126147

127-
customAppTemplate := serverconfig.DefaultConfigTemplate
128-
// Edit the default template file
129-
//
130-
// customAppTemplate := serverconfig.DefaultConfigTemplate + `
131-
// [wasm]
132-
// # This is the maximum sdk gas (wasm and storage) that we allow for any x/wasm "smart" queries
133-
// query_gas_limit = 300000
134-
// # This is the number of wasm vm instances we keep cached in memory for speed-up
135-
// # Warning: this is currently unstable and may lead to crashes, best to keep for 0 unless testing locally
136-
// lru_size = 0`
137-
138-
return customAppTemplate, customAppConfig
148+
return customPoktrollAppConfigTemplate(), customAppConfig
149+
}
150+
151+
// customPoktrollAppConfigTemplate extends the default configuration `app.toml` file with our own configs.
152+
// They are going to be used by validators and full-nodes.
153+
// These configs are rendered using default values from `poktrollAppConfigDefaults()`.
154+
func customPoktrollAppConfigTemplate() string {
155+
return serverconfig.DefaultConfigTemplate + `
156+
###############################################################################
157+
### Poktroll ###
158+
###############################################################################
159+
160+
# Poktroll-specific app configuration for Full Nodes and Validators.
161+
[poktroll]
162+
163+
# Telemetry configuration in addition to the [telemetry] settings.
164+
[poktroll.telemetry]
165+
166+
# Cardinality level for telemetry metrics collection
167+
# This controls the level of detail (number of unique labels) in metrics.
168+
# Options:
169+
# - "low": Collects basic metrics with low cardinality.
170+
# Suitable for production environments with tight performance constraints.
171+
# - "medium": Collects a moderate number of labels, balancing detail and performance.
172+
# Suitable for moderate workloads or staging environments.
173+
# - "high": WARNING: WILL CAUSE STRESS TO YOUR MONITORING ENVIRONMENT! Collects detailed metrics with high
174+
# cardinality, including labels with many unique values (e.g., application_id, session_id).
175+
# Recommended for debugging or testing environments.
176+
cardinality-level = "{{ .Poktroll.Telemetry.CardinalityLevel }}"
177+
`
139178
}

config.yml

+13-11
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,11 @@ validators:
9191
# minimum-gas-prices: 0.000000001upokt
9292
telemetry:
9393
enabled: true
94-
prometheus-retention-time: "600" # seconds
94+
poktroll:
95+
telemetry:
96+
# "high" produces a lot of timeseries.
97+
# ONLY suitable for small networks such as LocalNet.
98+
cardinality-level: high
9599
config:
96100
moniker: "validator1"
97101
consensus:
@@ -145,22 +149,22 @@ genesis:
145149
# Application module
146150
- address: pokt1rl3gjgzexmplmds3tq3r3yk84zlwdl6djzgsvm
147151
coins:
148-
- amount: "100000068" # Equals to the total of all app stakes below
152+
- amount: "200000068" # MUST BE equal to the total of all app stakes below
149153
denom: upokt
150154
# Supplier module
151155
- address: pokt1j40dzzmn6cn9kxku7a5tjnud6hv37vesr5ccaa
152156
coins:
153-
- amount: "1000068" # Equals to the total of all supplier stakes below
157+
- amount: "1000068" # MUST BE equal to the total of all supplier stakes below
154158
denom: upokt
155159
# Gateway module
156160
- address: pokt1f6j7u6875p2cvyrgjr0d2uecyzah0kget9vlpl
157161
coins:
158-
- amount: "1000068" # Equals to the total of all gateway stakes below
162+
- amount: "1000068" # MUST BE equal to the total of all gateway stakes below
159163
denom: upokt
160164
# Service module
161165
- address: pokt1nhmtqf4gcmpxu0p6e53hpgtwj0llmsqpxtumcf
162166
coins:
163-
- amount: "1000000000" # Equals to one add_service_fee below
167+
- amount: "1000000000" # MUST BE equal to one add_service_fee below
164168
denom: upokt
165169
application:
166170
params:
@@ -171,9 +175,8 @@ genesis:
171175
denom: upokt
172176
applicationList:
173177
- address: pokt1mrqt5f7qh8uxs27cjm9t7v9e74a9vvdnq5jva4
174-
delegatee_gateway_addresses: [
175-
pokt15vzxjqklzjtlz7lahe8z2dfe9nm5vxwwmscne4
176-
]
178+
delegatee_gateway_addresses:
179+
[pokt15vzxjqklzjtlz7lahe8z2dfe9nm5vxwwmscne4]
177180
service_configs:
178181
- service_id: anvil
179182
stake:
@@ -182,9 +185,8 @@ genesis:
182185
amount: "100000068" # ~100 POKT
183186
denom: upokt
184187
- address: pokt184zvylazwu4queyzpl0gyz9yf5yxm2kdhh9hpm
185-
delegatee_gateway_addresses: [
186-
pokt15vzxjqklzjtlz7lahe8z2dfe9nm5vxwwmscne4
187-
]
188+
delegatee_gateway_addresses:
189+
[pokt15vzxjqklzjtlz7lahe8z2dfe9nm5vxwwmscne4]
188190
service_configs:
189191
- service_id: rest
190192
stake:

go.mod

+1-1
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ require (
8282
require (
8383
cosmossdk.io/x/tx v0.13.4
8484
github.com/jhump/protoreflect v1.16.0
85+
github.com/mitchellh/mapstructure v1.5.0
8586
)
8687

8788
require (
@@ -224,7 +225,6 @@ require (
224225
github.com/minio/highwayhash v1.0.2 // indirect
225226
github.com/mitchellh/go-homedir v1.1.0 // indirect
226227
github.com/mitchellh/go-testing-interface v1.14.1 // indirect
227-
github.com/mitchellh/mapstructure v1.5.0 // indirect
228228
github.com/moby/docker-image-spec v1.3.1 // indirect
229229
github.com/moby/term v0.5.0 // indirect
230230
github.com/morikuni/aec v1.0.0 // indirect

0 commit comments

Comments
 (0)