Skip to content

Commit

Permalink
Merge branch 'main' into mvt-features/docs/claims
Browse files Browse the repository at this point in the history
* main:
  [Documentation] Refactor poktroll documentation so its easier to navigate (#474)
  [LocalNet] Add observability stack (#475)
  [Tokenomics] Foundation PR to integrate `SessionAccountingSettlement` w/ the Claim & Proof lifecycle (#448)
  • Loading branch information
bryanchriswhite committed Apr 11, 2024
2 parents 380bff7 + dbb6a02 commit 972d781
Show file tree
Hide file tree
Showing 178 changed files with 9,364 additions and 2,838 deletions.
46 changes: 29 additions & 17 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,13 @@ APPGATE_SERVER ?= http://localhost:42069
POCKET_ADDR_PREFIX = pokt
CHAIN_ID = poktroll

# On-chain module account addresses. Search for `func TestModuleAddress` in the
# codebase to get an understanding of how we got these values.
APPLICATION_MODULE_ADDRESS = pokt1rl3gjgzexmplmds3tq3r3yk84zlwdl6djzgsvm
SUPPLIER_MODULE_ADDRESS = pokt1j40dzzmn6cn9kxku7a5tjnud6hv37vesr5ccaa
GATEWAY_MODULE_ADDRESS = pokt1f6j7u6875p2cvyrgjr0d2uecyzah0kget9vlpl
SERVICE_MODULE_ADDRESS = pokt1nhmtqf4gcmpxu0p6e53hpgtwj0llmsqpxtumcf

# Detect operating system
OS := $(shell uname -s)

Expand Down Expand Up @@ -186,18 +193,22 @@ warn_destructive: ## Print WARNING to the user
proto_ignite_gen: ## Generate protobuf artifacts using ignite
ignite generate proto-go --yes

.PHONY: proto_fix_self_import
proto_fix_self_import: ## TODO_TECHDEBT(@bryanchriswhite): Add a proper explanation for this make target explaining why it's necessary
@echo "Updating all instances of cosmossdk.io/api/poktroll to github.com/pokt-network/poktroll/api/poktroll..."
@find ./api/poktroll/ -type f | while read -r file; do \
$(SED) -i 's,cosmossdk.io/api/poktroll,github.com/pokt-network/poktroll/api/poktroll,g' "$$file"; \
done
@for dir in $(wildcard ./api/poktroll/*/); do \
module=$$(basename $$dir); \
echo "Processing module $$module"; \
echo "Further processing module $$module"; \
$(GREP) -lRP '\s+'$$module' "github.com/pokt-network/poktroll/api/poktroll/'$$module'"' ./api/poktroll/$$module | while read -r file; do \
echo "Modifying file: $$file"; \
$(SED) -i -E 's,^[[:space:]]+'$$module'[[:space:]]+"github.com/pokt-network/poktroll/api/poktroll/'$$module'",,' "$$file"; \
$(SED) -i 's,'$$module'\.,,g' "$$file"; \
done; \
done


.PHONY: proto_clean
proto_clean: ## Delete existing .pb.go or .pb.gw.go files
find . \( -name "*.pb.go" -o -name "*.pb.gw.go" \) | xargs --no-run-if-empty rm
Expand Down Expand Up @@ -337,7 +348,7 @@ load_test_simple: ## Runs the simplest load test through the whole stack (appgat
# e.g. TODO_HACK: This is a hack, we need to fix it later
# 2. If there's a specific issue, or specific person, add that in paranthesiss
# e.g. TODO(@Olshansk): Automatically link to the Github user https://github.com/olshansk
# e.g. TODO_INVESTIGATE(#420): Automatically link this to github issue https://github.com/pokt-network/pocket/issues/420
# e.g. TODO_INVESTIGATE(#420): Automatically link this to github issue https://github.com/pokt-network/poktroll/issues/420
# e.g. TODO_DISCUSS(@Olshansk, #420): Specific individual should tend to the action item in the specific ticket
# e.g. TODO_CLEANUP(core): This is not tied to an issue, or a person, but should only be done by the core team.
# e.g. TODO_CLEANUP: This is not tied to an issue, or a person, and can be done by the core team or external contributors.
Expand Down Expand Up @@ -390,7 +401,7 @@ gateway_list: ## List all the staked gateways

.PHONY: gateway_stake
gateway_stake: ## Stake tokens for the gateway specified (must specify the gateway env var)
poktrolld --home=$(POKTROLLD_HOME) tx gateway stake-gateway --config $(POKTROLLD_HOME)/config/$(STAKE) --keyring-backend test --from $(GATEWAY) --node $(POCKET_NODE) --chain-id $(CHAIN_ID)
poktrolld --home=$(POKTROLLD_HOME) tx gateway stake-gateway -y --config $(POKTROLLD_HOME)/config/$(STAKE) --keyring-backend test --from $(GATEWAY) --node $(POCKET_NODE) --chain-id $(CHAIN_ID)

.PHONY: gateway1_stake
gateway1_stake: ## Stake gateway1
Expand Down Expand Up @@ -430,7 +441,7 @@ app_list: ## List all the staked applications

.PHONY: app_stake
app_stake: ## Stake tokens for the application specified (must specify the APP and SERVICES env vars)
poktrolld --home=$(POKTROLLD_HOME) tx application stake-application --config $(POKTROLLD_HOME)/config/$(SERVICES) --keyring-backend test --from $(APP) --node $(POCKET_NODE) --chain-id $(CHAIN_ID)
poktrolld --home=$(POKTROLLD_HOME) tx application stake-application -y --config $(POKTROLLD_HOME)/config/$(SERVICES) --keyring-backend test --from $(APP) --node $(POCKET_NODE) --chain-id $(CHAIN_ID)

.PHONY: app1_stake
app1_stake: ## Stake app1 (also staked in genesis)
Expand Down Expand Up @@ -508,7 +519,7 @@ supplier_list: ## List all the staked supplier

.PHONY: supplier_stake
supplier_stake: ## Stake tokens for the supplier specified (must specify the SUPPLIER and SUPPLIER_CONFIG env vars)
poktrolld --home=$(POKTROLLD_HOME) tx supplier stake-supplier --config $(POKTROLLD_HOME)/config/$(SERVICES) --keyring-backend test --from $(SUPPLIER) --node $(POCKET_NODE) --chain-id $(CHAIN_ID)
poktrolld --home=$(POKTROLLD_HOME) tx supplier stake-supplier -y --config $(POKTROLLD_HOME)/config/$(SERVICES) --keyring-backend test --from $(SUPPLIER) --node $(POCKET_NODE) --chain-id $(CHAIN_ID)

.PHONY: supplier1_stake
supplier1_stake: ## Stake supplier1 (also staked in genesis)
Expand Down Expand Up @@ -567,20 +578,22 @@ get_session_app3_anvil: ## Retrieve the session for (app3, anvil, latest_height)

.PHONY: acc_balance_query
acc_balance_query: ## Query the balance of the account specified (make acc_balance_query ACC=pokt...)
@echo "~~~ Balances ~~~"
@echo "~ Balances ~"
poktrolld --home=$(POKTROLLD_HOME) q bank balances $(ACC) --node $(POCKET_NODE)
@echo "~~~ Spendable Balances ~~~"
@echo "~ Spendable Balances ~"
@echo "Querying spendable balance for $(ACC)"
poktrolld --home=$(POKTROLLD_HOME) q bank spendable-balances $(ACC) --node $(POCKET_NODE)

.PHONY: acc_balance_query_module_app
acc_balance_query_module_app: ## Query the balance of the network level "application" module
make acc_balance_query ACC=pokt1rl3gjgzexmplmds3tq3r3yk84zlwdl6djzgsvm

.PHONY: acc_balance_query_module_supplier
acc_balance_query_module_supplier: ## Query the balance of the network level "supplier" module
SUPPLIER1=$(make poktrolld_addr ACC_NAME=supplier1)
make acc_balance_query ACC=SUPPLIER1
.PHONY: acc_balance_query_modules
acc_balance_query_modules: ## Query the balance of the network level module accounts
@echo "### Application ###"
make acc_balance_query ACC=$(APPLICATION_MODULE_ADDRESS)
@echo "### Supplier ###"
make acc_balance_query ACC=$(SUPPLIER_MODULE_ADDRESS)
@echo "### Gateway ###"
make acc_balance_query ACC=$(GATEWAY_MODULE_ADDRESS)
@echo "### Service ###"
make acc_balance_query ACC=$(SERVICE_MODULE_ADDRESS)

.PHONY: acc_balance_query_app1
acc_balance_query_app1: ## Query the balance of app1
Expand All @@ -604,7 +617,6 @@ acc_balance_total_supply: ## Query the total supply of the network
acc_initialize_pubkeys: ## Make sure the account keeper has public keys for all available accounts
$(eval ADDRESSES=$(shell make -s ignite_acc_list | grep pokt | awk '{printf "%s ", $$2}' | sed 's/.$$//'))
$(eval PNF_ADDR=pokt1eeeksh2tvkh7wzmfrljnhw4wrhs55lcuvmekkw)
# @printf "Addresses: ${ADDRESSES}"
$(foreach addr, $(ADDRESSES),\
echo $(addr);\
poktrolld tx bank send \
Expand Down
133 changes: 120 additions & 13 deletions Tiltfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ hot_reload_dirs = ["app", "cmd", "tools", "x", "pkg"]
localnet_config_path = "localnet_config.yaml"
localnet_config_defaults = {
"validator": {"cleanupBeforeEachStart": True},
"observability": {"enabled": True},
"relayminers": {"count": 1},
"gateways": {"count": 1},
"appgateservers": {"count": 1},
Expand All @@ -36,13 +37,68 @@ if localnet_config["helm_chart_local_repo"]["enabled"]:
print("Using local helm chart repo " + helm_chart_local_repo)
chart_prefix = helm_chart_local_repo + "/charts/"


# Observability
print("Observability enabled: " + str(localnet_config["observability"]["enabled"]))
if localnet_config["observability"]["enabled"]:
print("Observability enabled")
helm_repo(
"prometheus-community", "https://prometheus-community.github.io/helm-charts"
)
helm_repo("grafana-helm-repo", "https://grafana.github.io/helm-charts")

helm_resource(
"observability",
"prometheus-community/kube-prometheus-stack",
flags=[
"--values=./localnet/kubernetes/observability-prometheus-stack.yaml",
],
resource_deps=["prometheus-community"],
)

helm_resource(
"loki",
"grafana-helm-repo/loki-stack",
flags=[
"--values=./localnet/kubernetes/observability-loki-stack.yaml",
],
resource_deps=["grafana-helm-repo"],
)

k8s_resource(
new_name="grafana",
workload="observability",
extra_pod_selectors=[{"app.kubernetes.io/name": "grafana"}],
port_forwards=["3003:3000"],
labels=["monitoring"],
links=[
link("localhost:3003", "Grafana"),
],
pod_readiness="wait",
discovery_strategy="selectors-only",
)

# Import our custom grafana dashboards into Kubernetes ConfigMap
configmap_create(
"protocol-dashboards", from_file=listdir("localnet/grafana-dashboards/")
)

# Grafana discovers dashboards to "import" via a label
local_resource(
"protocol-dashboards-label",
"kubectl label configmap protocol-dashboards grafana_dashboard=1 --overwrite",
resource_deps=["protocol-dashboards"],
)

# Import keyring/keybase files into Kubernetes ConfigMap
configmap_create(
"poktrolld-keys", from_file=listdir("localnet/poktrolld/keyring-test/")
)

# Import keyring/keybase files into Kubernetes Secret
secret_create_generic( "poktrolld-keys", from_file=listdir("localnet/poktrolld/keyring-test/"))
secret_create_generic(
"poktrolld-keys", from_file=listdir("localnet/poktrolld/keyring-test/")
)
# Import configuration files into Kubernetes ConfigMap
configmap_create(
"poktrolld-configs", from_file=listdir("localnet/poktrolld/config/"), watch=True
Expand Down Expand Up @@ -93,7 +149,12 @@ COPY bin/poktrolld /usr/local/bin/poktrolld
WORKDIR /
""",
only=["./bin/poktrolld"],
entrypoint=["/tilt-restart-wrapper", "--watch_file=/tmp/.restart-proc", "--entr_flags=-r", "poktrolld"],
entrypoint=[
"/tilt-restart-wrapper",
"--watch_file=/tmp/.restart-proc",
"--entr_flags=-r",
"poktrolld",
],
live_update=[sync("bin/poktrolld", "/usr/local/bin/poktrolld")],
)

Expand All @@ -111,6 +172,8 @@ helm_resource(
"--values=./localnet/kubernetes/values-validator.yaml",
"--set=persistence.cleanupBeforeEachStart="
+ str(localnet_config["validator"]["cleanupBeforeEachStart"]),
"--set=serviceMonitor.enabled="
+ str(localnet_config["observability"]["enabled"]),
],
image_deps=["poktrolld"],
image_keys=[("image.repository", "image.tag")],
Expand All @@ -126,20 +189,34 @@ for x in range(localnet_config["relayminers"]["count"]):
flags=[
"--values=./localnet/kubernetes/values-common.yaml",
"--values=./localnet/kubernetes/values-relayminer-common.yaml",
"--values=./localnet/kubernetes/values-relayminer-"+str(actor_number)+".yaml",
"--values=./localnet/kubernetes/values-relayminer-"
+ str(actor_number)
+ ".yaml",
"--set=metrics.serviceMonitor.enabled="
+ str(localnet_config["observability"]["enabled"]),
],
image_deps=["poktrolld"],
image_keys=[("image.repository", "image.tag")],
)
k8s_resource(
"relayminer" + str(actor_number),
"relayminer" + str(actor_number),
labels=["supplier_nodes"],
resource_deps=["validator"],
links=[
link(
"http://localhost:3003/d/relayminer/relayminer?orgId=1&var-relayminer=relayminer"
+ str(actor_number),
"Grafana dashboard",
),
],
port_forwards=[
str(8084+actor_number)+":8545", # relayminer1 - exposes 8545, relayminer2 exposes 8546, etc.
str(40044+actor_number)+":40005", # DLV port. relayminer1 - exposes 40045, relayminer2 exposes 40046, etc.
str(8084 + actor_number)
+ ":8545", # relayminer1 - exposes 8545, relayminer2 exposes 8546, etc.
str(40044 + actor_number)
+ ":40005", # DLV port. relayminer1 - exposes 40045, relayminer2 exposes 40046, etc.
# Run `curl localhost:PORT` to see the current snapshot of relayminer metrics.
str(9069+actor_number)+":9090", # Relayminer metrics port. relayminer1 - exposes 9070, relayminer2 exposes 9071, etc.
str(9069 + actor_number)
+ ":9090", # Relayminer metrics port. relayminer1 - exposes 9070, relayminer2 exposes 9071, etc.
],
)

Expand All @@ -154,6 +231,8 @@ for x in range(localnet_config["appgateservers"]["count"]):
"--values=./localnet/kubernetes/values-common.yaml",
"--values=./localnet/kubernetes/values-appgateserver.yaml",
"--set=config.signing_key=app" + str(actor_number),
"--set=metrics.serviceMonitor.enabled="
+ str(localnet_config["observability"]["enabled"]),
],
image_deps=["poktrolld"],
image_keys=[("image.repository", "image.tag")],
Expand All @@ -162,11 +241,21 @@ for x in range(localnet_config["appgateservers"]["count"]):
"appgateserver" + str(actor_number),
labels=["applications"],
resource_deps=["validator"],
links=[
link(
"http://localhost:3003/d/appgateserver/protocol-appgate-server?orgId=1&refresh=5s&var-appgateserver=appgateserver"
+ str(actor_number),
"Grafana dashboard",
),
],
port_forwards=[
str(42068+actor_number)+":42069", # appgateserver1 - exposes 42069, appgateserver2 exposes 42070, etc.
str(40054+actor_number)+":40006", # DLV port. appgateserver1 - exposes 40055, appgateserver2 exposes 40056, etc.
str(42068 + actor_number)
+ ":42069", # appgateserver1 - exposes 42069, appgateserver2 exposes 42070, etc.
str(40054 + actor_number)
+ ":40006", # DLV port. appgateserver1 - exposes 40055, appgateserver2 exposes 40056, etc.
# Run `curl localhost:PORT` to see the current snapshot of appgateserver metrics.
str(9079+actor_number)+":9090", # appgateserver metrics port. appgateserver1 - exposes 9080, appgateserver2 exposes 9081, etc.
str(9079 + actor_number)
+ ":9090", # appgateserver metrics port. appgateserver1 - exposes 9080, appgateserver2 exposes 9081, etc.
],
)

Expand All @@ -181,6 +270,8 @@ for x in range(localnet_config["gateways"]["count"]):
"--values=./localnet/kubernetes/values-common.yaml",
"--values=./localnet/kubernetes/values-gateway.yaml",
"--set=config.signing_key=gateway" + str(actor_number),
"--set=metrics.serviceMonitor.enabled="
+ str(localnet_config["observability"]["enabled"]),
],
image_deps=["poktrolld"],
image_keys=[("image.repository", "image.tag")],
Expand All @@ -189,18 +280,34 @@ for x in range(localnet_config["gateways"]["count"]):
"gateway" + str(actor_number),
labels=["gateways"],
resource_deps=["validator"],
links=[
link(
"http://localhost:3003/d/appgateserver/protocol-appgate-server?orgId=1&refresh=5s&var-appgateserver=gateway"
+ str(actor_number),
"Grafana dashboard",
),
],
port_forwards=[
str(42078+actor_number)+":42069", # gateway1 - exposes 42079, gateway2 exposes 42080, etc.
str(40064+actor_number)+":40006", # DLV port. gateway1 - exposes 40065, gateway2 exposes 40066, etc.
str(42078 + actor_number)
+ ":42069", # gateway1 - exposes 42079, gateway2 exposes 42080, etc.
str(40064 + actor_number)
+ ":40006", # DLV port. gateway1 - exposes 40065, gateway2 exposes 40066, etc.
# Run `curl localhost:PORT` to see the current snapshot of gateway metrics.
str(9089+actor_number)+":9090", # gateway metrics port. gateway1 - exposes 9090, gateway2 exposes 9091, etc.
str(9089 + actor_number)
+ ":9090", # gateway metrics port. gateway1 - exposes 9090, gateway2 exposes 9091, etc.
],
)

k8s_resource(
"validator",
labels=["pocket_network"],
port_forwards=["36657", "36658", "40004"],
links=[
link(
"http://localhost:3003/d/cosmoscometbft/protocol-cometbft-dashboard?orgId=1&from=now-1h&to=now",
"Validator dashboard",
),
],
)

k8s_resource("anvil", labels=["data_nodes"], port_forwards=["8547"])
Loading

0 comments on commit 972d781

Please sign in to comment.