Skip to content

Commit d90614d

Browse files
committed
Add stream support for CLI relayminer relay cmd
1 parent c15b725 commit d90614d

File tree

12 files changed

+761
-242
lines changed

12 files changed

+761
-242
lines changed

Makefile

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,31 @@ PNF_ADDRESS = pokt1eeeksh2tvkh7wzmfrljnhw4wrhs55lcuvmekkw
2727

2828
MODULES := application gateway pocket service session supplier proof tokenomics
2929

30+
# Patterns for classified help categories
31+
HELP_PATTERNS := \
32+
'^(help|help-params|help-unclassified|list):' \
33+
'^(ignite_build|ignite_pocketd_build|ignite_serve|ignite_serve_reset|ignite_release.*|cosmovisor_start_node):' \
34+
'^(go_develop|go_develop_and_test|proto_regen|go_mockgen|go_testgen_fixtures|go_testgen_accounts|go_imports):' \
35+
'^(test_all|test_unit|test_e2e|test_integration|test_timing|test_govupgrade|test_e2e_relay|go_test_verbose|go_test):' \
36+
'^(go_lint|go_vet|go_sec|gosec_version_fix|check_todos):' \
37+
'^(localnet_up|localnet_up_quick|localnet_down|localnet_regenesis|localnet_cancel_upgrade|localnet_show_upgrade_plan):' \
38+
'^testnet_.*:' \
39+
'^(acc_.*|pocketd_addr|pocketd_key):' \
40+
'^query_.*:' \
41+
'^app_.*:' \
42+
'^supplier_.*:' \
43+
'^gateway_.*:' \
44+
'^(relay_.*|claim_.*|ping_.*):' \
45+
'^session_.*:' \
46+
'^ibc_.*:' \
47+
'^release_.*:' \
48+
'^docker_test_.*:' \
49+
'^(go_docs|docusaurus_.*|gen_.*_docs):' \
50+
'^(install_.*|check_.*|grove_.*|act_.*|trigger_ci|docker_wipe):' \
51+
'^telegram_.*:' \
52+
'^claudesync_.*:' \
53+
'^params_.*:'
54+
3055
BRANCH := $(shell git rev-parse --abbrev-ref HEAD)
3156
COMMIT := $(shell git log -1 --format='%H')
3257

@@ -439,3 +464,53 @@ include ./makefiles/ignite.mk
439464
include ./makefiles/release.mk
440465
include ./makefiles/tools.mk
441466
include ./makefiles/ibc.mk
467+
468+
###############################
469+
### Global Error Handling ###
470+
###############################
471+
472+
# Catch-all rule for undefined targets
473+
# This must be defined AFTER includes so color variables are available
474+
# and it acts as a fallback for any undefined target
475+
%:
476+
@echo ""
477+
@echo "$(RED)❌ Error: Unknown target '$(BOLD)$@$(RESET)$(RED)'$(RESET)"
478+
@echo ""
479+
@if echo "$@" | grep -q "^localnet"; then \
480+
echo "$(YELLOW)💡 Hint: LocalNet targets available:$(RESET)"; \
481+
echo " Run: $(CYAN)make help$(RESET) and check the '🌐 LocalNet Operations' section"; \
482+
elif echo "$@" | grep -q "^testnet"; then \
483+
echo "$(YELLOW)💡 Hint: TestNet targets available:$(RESET)"; \
484+
echo " Run: $(CYAN)make help$(RESET) and check the '🔗 TestNet Operations' section"; \
485+
elif echo "$@" | grep -q "^app"; then \
486+
echo "$(YELLOW)💡 Hint: Application targets available:$(RESET)"; \
487+
echo " Run: $(CYAN)make help$(RESET) and check the '🛡️ Applications' section"; \
488+
elif echo "$@" | grep -q "^supplier"; then \
489+
echo "$(YELLOW)💡 Hint: Supplier targets available:$(RESET)"; \
490+
echo " Run: $(CYAN)make help$(RESET) and check the '🏭 Suppliers' section"; \
491+
elif echo "$@" | grep -q "^gateway"; then \
492+
echo "$(YELLOW)💡 Hint: Gateway targets available:$(RESET)"; \
493+
echo " Run: $(CYAN)make help$(RESET) and check the '🌉 Gateways' section"; \
494+
elif echo "$@" | grep -q "^test"; then \
495+
echo "$(YELLOW)💡 Hint: Testing targets available:$(RESET)"; \
496+
echo " Run: $(CYAN)make help$(RESET) and check the '🧪 Testing' section"; \
497+
elif echo "$@" | grep -q "^params"; then \
498+
echo "$(YELLOW)💡 Hint: Parameter management targets available:$(RESET)"; \
499+
echo " Run: $(CYAN)make help-params$(RESET) to see all parameter commands"; \
500+
elif echo "$@" | grep -q "^ignite"; then \
501+
echo "$(YELLOW)💡 Hint: Ignite/build targets available:$(RESET)"; \
502+
echo " Run: $(CYAN)make help$(RESET) and check the '🔨 Build & Run' section"; \
503+
elif echo "$@" | grep -q "^go_"; then \
504+
echo "$(YELLOW)💡 Hint: Go development targets available:$(RESET)"; \
505+
echo " Run: $(CYAN)make help$(RESET) and check the '⚙️ Development' or '✅ Linting & Quality' sections"; \
506+
elif echo "$@" | grep -q "^docker"; then \
507+
echo "$(YELLOW)💡 Hint: Docker targets available:$(RESET)"; \
508+
echo " Run: $(CYAN)make help$(RESET) and check the '🐳 Docker Testing' section"; \
509+
else \
510+
echo "$(YELLOW)💡 Available help commands:$(RESET)"; \
511+
echo " $(CYAN)make help$(RESET) - See all available targets"; \
512+
echo " $(CYAN)make help-params$(RESET) - See parameter management commands"; \
513+
echo " $(CYAN)make help-unclassified$(RESET) - See uncategorized targets"; \
514+
fi
515+
@echo ""
516+
@exit 1

config.yml

Lines changed: 31 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -263,44 +263,41 @@ genesis:
263263
service_configs:
264264
- service_id: anvil
265265
stake:
266-
# NB: This value should be exactly 1upokt smaller than the value in
267-
# `application1_stake_config.yaml` so that the stake command causes a state change.
266+
# DEV_NOTE: Value should be exactly 1upokt smaller than `application1_stake_config.yaml` so that the stake command causes a state change.
268267
amount: "100000068" # ~100 POKT
269268
denom: upokt
270-
- address: pokt184zvylazwu4queyzpl0gyz9yf5yxm2kdhh9hpm
269+
- address: pokt1lqyu4v88vp8tzc86eaqr4lq8rwhssyn6rfwzex
271270
delegatee_gateway_addresses:
272271
[pokt15vzxjqklzjtlz7lahe8z2dfe9nm5vxwwmscne4]
273272
service_configs:
274-
- service_id: rest
273+
- service_id: anvilws
275274
stake:
276-
# NB: This value should be exactly 1upokt smaller than the value in
277-
# `application1_stake_config.yaml` so that the stake command causes a state change.
278275
amount: "100000068" # ~100 POKT
279276
denom: upokt
280-
- address: pokt1lqyu4v88vp8tzc86eaqr4lq8rwhssyn6rfwzex
277+
- address: pokt184zvylazwu4queyzpl0gyz9yf5yxm2kdhh9hpm
281278
delegatee_gateway_addresses:
282279
[pokt15vzxjqklzjtlz7lahe8z2dfe9nm5vxwwmscne4]
283280
service_configs:
284-
- service_id: anvilws
281+
- service_id: rest
285282
stake:
283+
# DEV_NOTE: Value should be exactly 1upokt smaller than `application1_stake_config.yaml` so that the stake command causes a state change.
286284
amount: "100000068" # ~100 POKT
287285
denom: upokt
288286
- address: pokt1pn64d94e6u5g8cllsnhgrl6t96ysnjw59j5gst
289287
delegatee_gateway_addresses:
290288
[pokt15vzxjqklzjtlz7lahe8z2dfe9nm5vxwwmscne4]
291289
service_configs:
292-
- service_id: static
290+
- service_id: ollama
293291
stake:
294-
amount: "10000000000000"
292+
# DEV_NOTE: Value should be exactly 1upokt smaller than `application1_stake_config.yaml` so that the stake command causes a state change.
293+
amount: "100000068" # ~100 POKT
295294
denom: upokt
296295
# For ref, see proto/poktroll/supplier/params.proto
297296
supplier:
298297
params:
299-
# TODO_MAINNET_MIGRATION(@olshansk): Determine realistic amount for minimum gateway stake amount.
300298
min_stake:
301299
amount: "1000000" # 1 POKT
302300
denom: upokt
303-
# TODO_MAINNET_MIGRATION(@olshansk): Determine realistic amount for supplier staking fee.
304301
staking_fee:
305302
amount: "1000000" # 1 POKT
306303
denom: upokt
@@ -324,6 +321,22 @@ genesis:
324321
rev_share:
325322
- address: pokt19a3t4yunp0dlpfjrp7qwnzwlrzd5fzs2gjaaaj
326323
rev_share_percentage: 100
324+
- service_id: rest
325+
endpoints:
326+
- configs: []
327+
rpc_type: REST
328+
url: http://relayminer1:8545
329+
rev_share:
330+
- address: pokt19a3t4yunp0dlpfjrp7qwnzwlrzd5fzs2gjaaaj
331+
rev_share_percentage: 100
332+
- service_id: ollama
333+
endpoints:
334+
- configs: []
335+
rpc_type: REST
336+
url: http://relayminer1:8545
337+
rev_share:
338+
- address: pokt19a3t4yunp0dlpfjrp7qwnzwlrzd5fzs2gjaaaj
339+
rev_share_percentage: 100
327340
- service_id: static
328341
endpoints:
329342
- configs: []
@@ -333,22 +346,20 @@ genesis:
333346
- address: pokt19a3t4yunp0dlpfjrp7qwnzwlrzd5fzs2gjaaaj
334347
rev_share_percentage: 100
335348
stake:
336-
# NB: This value should be exactly 1upokt smaller than the value in
349+
# DEV_NOTE: Value should be exactly 1upokt smaller than the value in
337350
# `supplier1_stake_config.yaml` so that the stake command causes a state change.
338351
amount: "1000068"
339352
denom: upokt
340353
# For ref, see proto/poktroll/gateway/params.proto
341354
gateway:
342355
params:
343-
# TODO_MAINNET_MIGRATION(@olshansk): Determine realistic amount for minimum gateway stake amount.
344356
min_stake:
345357
amount: "1000000" # 1 POKT
346358
denom: upokt
347359
gatewayList:
348360
- address: pokt15vzxjqklzjtlz7lahe8z2dfe9nm5vxwwmscne4
349361
stake:
350-
# NB: This value should be exactly 1upokt smaller than the value in
351-
# `gateway1_stake_config.yaml` so that the stake command causes a state change.
362+
# DEV_NOTE: Value should be exactly 1upokt smaller than the value in `gateway1_stake_config.yaml` so that the stake command causes a state change.
352363
amount: "1000068"
353364
denom: upokt
354365
# For ref, see proto/poktroll/service/params.proto
@@ -367,14 +378,14 @@ genesis:
367378
name: "anvilws"
368379
compute_units_per_relay: 100
369380
owner_address: pokt1cwnu460557x0z78jv3hhc7356hhkrgc86c87q5
370-
- id: ollama
371-
name: "ollama"
372-
compute_units_per_relay: 100
373-
owner_address: pokt1mx0klkkrj6v3dw8gs4nzlq0cq8lsktmx35t03e
374381
- id: rest
375382
name: "rest"
376383
compute_units_per_relay: 100
377384
owner_address: pokt1mx0klkkrj6v3dw8gs4nzlq0cq8lsktmx35t03e
385+
- id: ollama
386+
name: "ollama"
387+
compute_units_per_relay: 100
388+
owner_address: pokt1pn64d94e6u5g8cllsnhgrl6t96ysnjw59j5gst
378389
- id: static
379390
name: "static"
380391
compute_units_per_relay: 1

localnet/kubernetes/config-path-1.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,6 @@ shannon_config:
1313
gateway_private_key_hex: cf09805c952fa999e9a63a9f434147b0a5abfd10f268879694c6b5a70e1ae177
1414
owned_apps_private_keys_hex:
1515
- 2d00ef074d9b51e46886dc9a1df11e7b986611d0f336bdcf1f0adce3e037ec0a # anvil - app1 - pokt1mrqt5f7qh8uxs27cjm9t7v9e74a9vvdnq5jva4
16+
- 7cbbaa043b9b63baa7d6bb087483b0a6a9f82596c19dce4c5028eb43e5b63674 # anvilws - app3 - pokt1lqyu4v88vp8tzc86eaqr4lq8rwhssyn6rfwzex
17+
- 7e7571a8c61b0887ff8a9017bb4ad83c016b193234f9dc8b6a8ce10c7c483600 # rest - app2 - pokt184zvylazwu4queyzpl0gyz9yf5yxm2kdhh9hpm
18+
- 84e4f2257f24d9e1517d414b834bbbfa317e0d53fef21c1528a07a5fa8c70d57 # ollama - app4 - pokt1pn64d94e6u5g8cllsnhgrl6t96ysnjw59j5gst

localnet/kubernetes/values-pocketd-faucet.yaml

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ nameOverride: ""
1515
fullnameOverride: ""
1616

1717
flags:
18-
log_level: debug
18+
log-level: debug
1919
network: local
2020
node: tcp://validator-pocket-validator:26657
2121
keyring_backend: test
@@ -40,10 +40,12 @@ serviceAccount:
4040

4141
podAnnotations: {}
4242

43-
podSecurityContext: {}
43+
podSecurityContext:
44+
{}
4445
# fsGroup: 2000
4546

46-
securityContext: {}
47+
securityContext:
48+
{}
4749
# capabilities:
4850
# drop:
4951
# - ALL
@@ -58,7 +60,8 @@ service:
5860
ingress:
5961
enabled: false
6062
className: ""
61-
annotations: {}
63+
annotations:
64+
{}
6265
# kubernetes.io/ingress.class: nginx
6366
# kubernetes.io/tls-acme: "true"
6467
hosts:
@@ -71,7 +74,8 @@ ingress:
7174
# hosts:
7275
# - chart-example.local
7376

74-
resources: {}
77+
resources:
78+
{}
7579
# We usually recommend not to specify default resources and to leave this as a conscious
7680
# choice for the user. This also increases chances charts run on environments with little
7781
# resources, such as Minikube. If you do want to specify resources, uncomment the following

makefiles/relay.mk

Lines changed: 32 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,29 @@
1+
########################################
2+
### pocketd relayminer relay Helpers ###
3+
########################################
4+
5+
.PHONY: pocketd_relayminer_relay_JSONRPC
6+
pocketd_relayminer_relay_JSONRPC: test_e2e_env ## Send a JSONRPC relay through relayminer to a local anvil (test ETH) node
7+
pocketd relayminer relay \
8+
--app=pokt1mrqt5f7qh8uxs27cjm9t7v9e74a9vvdnq5jva4 \
9+
--payload='{"jsonrpc": "2.0", "id": 1, "method": "eth_blockNumber", "params": []}' \
10+
--home=./localnet/pocketd \
11+
--network=local \
12+
--supplier-public-endpoint-override=http://localhost:8085
13+
14+
15+
.PHONY: pocketd_relayminer_relay_NDJSONRPC
16+
pocketd_relayminer_relay_NDJSONRPC: test_e2e_env ## Send a NDJSONRPC relay through relayminer to a local OpenAI compatible API served by Ollama
17+
pocketd relayminer relay \
18+
--app=pokt1pn64d94e6u5g8cllsnhgrl6t96ysnjw59j5gst \
19+
--payload='{"messages":[{"role": "user", "content": "Count down from 10 to 0: ", "type": "text"}],"max_tokens":25, "model":"qwen:0.5b","stream":true}' \
20+
--home=./localnet/pocketd \
21+
--network=local \
22+
--supplier-public-endpoint-override=http://localhost:8085/v1/chat/completions
23+
24+
125
#####################
2-
### Relay Helpers ###
26+
### Curl Helpers ###
327
#####################
428

529
# TODO_MAINNET(@olshansk): Add all the permissionless/delegated/centralized variations once
@@ -23,18 +47,13 @@ send_relay_path_WEBSOCKET: check_path_up test_e2e_env ## Send a WEBSOCKET relay
2347
-H "App-Address: pokt1lqyu4v88vp8tzc86eaqr4lq8rwhssyn6rfwzex" \
2448
-H "Target-Service-Id: anvilws"
2549

26-
27-
# TODO_POST_MAINNET(@red-0ne): Re-enable this once PATH Gateway supports REST.
28-
# See https://github.com/buildwithgrove/path/issues/87
2950
.PHONY: send_relay_path_REST
30-
send_relay_path_REST: acc_initialize_pubkeys ## Send a REST relay through PATH to a local ollama (LLM) service
31-
@echo "Not implemented yet. Check if PATH supports REST relays yet: https://github.com/buildwithgrove/path/issues/87"
32-
# curl http://localhost:3070/v1/api/chat \
33-
# -H "Authorization: test_api_key" \
34-
# -H "Target-Service-Id: ollama" \
35-
# -H "App-Address: pokt1mrqt5f7qh8uxs27cjm9t7v9e74a9vvdnq5jva4" \
36-
# -d '{"model": "qwen:0.5b", "stream": false, "messages": [{"role": "user", "content":"count from 1 to 10"}]}'
37-
51+
send_relay_path_REST: check_path_up test_e2e_env ## Send a REST relay through PATH to a local ollama (LLM) service
52+
curl http://localhost:3069/v1/api/chat \
53+
-H "Authorization: test_api_key" \
54+
-H "Target-Service-Id: ollama" \
55+
-H "App-Address: pokt1pn64d94e6u5g8cllsnhgrl6t96ysnjw59j5gst" \
56+
-d '{"model": "qwen:0.5b", "stream": false, "messages": [{"role": "user", "content":"count from 1 to 10"}]}'
3857

3958
##################################
4059
#### Relay Util Test Requests ####
@@ -49,48 +68,4 @@ test_relay_util_100: check_path_up check_relay_util ## Test anvil PATH behind G
4968
-H "App-Address: pokt1mrqt5f7qh8uxs27cjm9t7v9e74a9vvdnq5jva4" \
5069
-d '{"jsonrpc":"2.0","method":"eth_blockNumber","id":1}' \
5170
-x 100 \
52-
-b
53-
54-
.PHONY: test_baseline_static_server_load
55-
test_baseline_static_server_load: ## Establish baseline load test performance against static nginx chainid server (default: R=100000 T=16 C=5000 D=30s)
56-
@echo "=== Load Testing Options ==="
57-
@echo "Parameters:"
58-
@echo " R: Requests per second rate (default: 100,000)"
59-
@echo " T: Number of threads (default: 16)"
60-
@echo " C: Concurrent connections (default: 5,000)"
61-
@echo " D: Test duration (default: 30s)"
62-
@echo ""
63-
@echo "Examples:"
64-
@echo " make test_baseline_static_server_load # Default test"
65-
@echo " make test_baseline_static_server_load R=10000 C=1000 # Light load"
66-
@echo " make test_baseline_static_server_load R=5000 C=500 D=10s # Quick test"
67-
@echo " make test_baseline_static_server_load R=200000 T=32 C=15000 D=45s # Maximum load"
68-
@echo ""
69-
@echo "Running test with: R=$(or $(R),100000) T=$(or $(T),16) C=$(or $(C),5000) D=$(or $(D),30s)"
70-
@echo "=========================="
71-
kubectl exec -it deployment/wrk2 -- wrk -R $(or $(R),100000) -L -d $(or $(D),30s) -t $(or $(T),16) -c $(or $(C),5000) http://nginx-chainid/
72-
73-
.PHONY: test_relayminer_only_load
74-
test_relayminer_only_load: ## Generate and run load test against RelayMiner using real RelayRequest data (default: R=512 t=16 c=256 d=300s)
75-
@echo "=== RelayRequest Load Testing ==="
76-
@echo "This tool generates proper RelayRequest data and runs load tests against RelayMiner endpoints"
77-
@echo ""
78-
@echo "Parameters:"
79-
@echo " R: Requests per second rate (default: 512)"
80-
@echo " d: Test duration (default: 300s)"
81-
@echo " t: Number of threads (default: 16)"
82-
@echo " c: Concurrent connections (default: 256)"
83-
@echo ""
84-
@echo "Examples:"
85-
@echo " make test_relayminer_only_load # Default test"
86-
@echo " make test_relayminer_only_load R=1000 d=60s # Higher rate, shorter duration"
87-
@echo " make test_relayminer_only_load R=100 t=4 c=50 d=30s # Light load test"
88-
@echo " make test_relayminer_only_load R=2000 t=32 c=1000 # Heavy load test"
89-
@echo ""
90-
@echo "Running with: R=$(or $(R),512) d=$(or $(d),300s) t=$(or $(t),16) c=$(or $(c),256)"
91-
@echo "================================"
92-
go run tools/scripts/wrk2_relays/main.go \
93-
-R $(or $(R),512) \
94-
-d $(or $(d),300s) \
95-
-t $(or $(t),16) \
96-
-c $(or $(c),256)
71+
-b

pkg/network/http/http_client.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,8 +102,7 @@ func NewDefaultHTTPClientWithDebugMetrics() *HTTPClientWithDebugMetrics {
102102
IdleConnTimeout: 90 * time.Second, // Reduced from 300s - shorter idle to free resources
103103

104104
// Timeout settings optimized for quick failure detection
105-
TLSHandshakeTimeout: 5 * time.Second, // Fast TLS timeout since handshakes typically complete in ~100ms
106-
ResponseHeaderTimeout: 5 * time.Second, // Header timeout to allow for server processing time
105+
TLSHandshakeTimeout: 5 * time.Second, // Fast TLS timeout since handshakes typically complete in ~100ms
107106

108107
// Performance optimizations
109108
DisableKeepAlives: false, // Enable connection reuse to reduce connection overhead

0 commit comments

Comments
 (0)