Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Session] Add support for GetSession via the CLI + deps #123

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
b2c94aa
Beginning work on CLI getSession
Olshansk Nov 1, 2023
68ded80
Updated the Makefile and replace [] & <> for POSIX consistency
Olshansk Nov 1, 2023
66a328a
Snapshot - progressing on tests
Olshansk Nov 1, 2023
9a24b12
Fixed the hydration tests
Olshansk Nov 1, 2023
45dd78a
Fixed more hydration tests
Olshansk Nov 1, 2023
d306302
Improve CLI tests
Olshansk Nov 1, 2023
4725df9
Added more request validation
Olshansk Nov 1, 2023
d548105
Merge branch 'main' into issues/15/implement_get_session_cli
Olshansk Nov 1, 2023
0c4bfc3
Merge branch 'main' into issues/15/implement_get_session_cli
Olshansk Nov 1, 2023
3c539c0
All tests passing
Olshansk Nov 1, 2023
12dd5f2
Completed self review
Olshansk Nov 1, 2023
5ed793a
Tiny nits after recording video
Olshansk Nov 1, 2023
8b4a7ea
Merge branch 'main' into issues/15/implement_get_session_cli
Olshansk Nov 2, 2023
e00d389
Merge with main
Olshansk Nov 2, 2023
cab5395
Fix issues after merge with main
Olshansk Nov 2, 2023
5b675c8
Don't hard-code addresses
Olshansk Nov 2, 2023
736291b
Merge branch 'main' into issues/15/implement_get_session_cli
Olshansk Nov 3, 2023
0e99b08
Follow up on a few of Bryan's comments
Olshansk Nov 3, 2023
109f09a
Ran goimports -w app/app.go
Olshansk Nov 6, 2023
d5d03cd
Merge branch 'main' into issues/15/implement_get_session_cli
Olshansk Nov 7, 2023
73d78db
Update Makefile
Olshansk Nov 7, 2023
04b9ce0
Update x/session/keeper/session_hydrator_test.go
Olshansk Nov 7, 2023
dc8a37d
Update x/shared/helpers/service_test.go
Olshansk Nov 7, 2023
2c940f4
[Miner] feat: add `TxClient` (#94)
bryanchriswhite Nov 7, 2023
9bf5508
[Off-chain] refactor: keyring errors & helpers (#131)
bryanchriswhite Nov 7, 2023
6ebb23b
[Miner] feat: add supplier client (#42)
bryanchriswhite Nov 7, 2023
e24489a
Reply to some review comments
Olshansk Nov 7, 2023
b312089
Rename session errors
Olshansk Nov 7, 2023
bc92251
Add back miss &&
Olshansk Nov 7, 2023
f4c37da
Fixed a few failing tests
Olshansk Nov 7, 2023
9245065
Merge with issues/140/rename_serviceid_to_service
Olshansk Nov 7, 2023
44ef893
Fix all the remaining test
Olshansk Nov 7, 2023
4990027
Merge branch 'issues/140/rename_serviceid_to_service' into issues/15/…
Olshansk Nov 7, 2023
2525c87
Fix last failing test
Olshansk Nov 7, 2023
823262a
[Service] Rename the `ServiceId` proto to `Service` (#150)
Olshansk Nov 8, 2023
a70bbbb
Merge with main
Olshansk Nov 8, 2023
dd17f66
Fixing tests
Olshansk Nov 8, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .github/label-actions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ devnet-e2e-test:
comment: The CI will now also run the e2e tests on devnet, which increases the time it takes to complete all CI checks.
label:
- devnet
- push-image

# When `devnet-e2e-test` is removed, also delete `devnet` from the PR.
-devnet-e2e-test:
Expand Down Expand Up @@ -33,3 +34,4 @@ push-image:
prs:
unlabel:
- devnet
- devnet-e2e-test
13 changes: 7 additions & 6 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,13 @@ bin

# Before we provision the localnet, `ignite` creates the accounts, genesis, etc. for us
# As many of the files are dynamic, we only preserve the config files in git history.
localnet/pocketd/*
localnet/*/config/
!localnet/*/config/{app.toml,client.toml,config.toml}
localnet/poktrolld/*
localnet/*/config/*.json
!localnet/poktrolld/config/
!localnet/poktrolld/config/app.toml
!localnet/poktrolld/config/client.toml
!localnet/poktrolld/config/config.toml


# Macos
.DS_Store
Expand All @@ -45,9 +49,6 @@ localnet/*/config/
# Frontend utils
ts-client/

# asdf
.tool-versions

# Proto artifacts
**/*.pb.go
**/*.pb.gw.go
Expand Down
4 changes: 4 additions & 0 deletions .tool-versions
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Run `asdf plugin add golang` and `asdf install` to install the dependencies,
# and `asdf current` to switch to the versions of dependencies listed below
golang 1.20.10
go 1.20.10
100 changes: 72 additions & 28 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
.SILENT:

POCKETD_HOME := ./localnet/pocketd
POKTROLLD_HOME := ./localnet/poktrolld
POCKET_NODE = tcp://127.0.0.1:36657 # The pocket rollup node (full node and sequencer in the localnet context)
POCKET_ADDR_PREFIX = pokt

Expand Down Expand Up @@ -113,9 +113,10 @@ localnet_down: ## Delete resources created by localnet
localnet_regenesis: ## Regenerate the localnet genesis file
# NOTE: intentionally not using --home <dir> flag to avoid overwriting the test keyring
ignite chain init
cp -r ${HOME}/.pocket/keyring-test $(POCKETD_HOME)
cp ${HOME}/.pocket/config/*_key.json $(POCKETD_HOME)/config/
cp ${HOME}/.pocket/config/genesis.json $(POCKETD_HOME)/config/
mkdir -p $(POKTROLLD_HOME)/config/
cp -r ${HOME}/.pocket/keyring-test $(POKTROLLD_HOME)
cp ${HOME}/.pocket/config/*_key.json $(POKTROLLD_HOME)/config/
cp ${HOME}/.pocket/config/genesis.json $(POKTROLLD_HOME)/config/

###############
### Linting ###
Expand All @@ -134,7 +135,7 @@ go_imports: check_go_version ## Run goimports on all go files

.PHONY: test_e2e
test_e2e: ## Run all E2E tests
export POCKET_NODE=$(POCKET_NODE) POCKETD_HOME=../../$(POCKETD_HOME) && go test -v ./e2e/tests/... -tags=e2e
export POCKET_NODE=$(POCKET_NODE) POKTROLLD_HOME=../../$(POKTROLLD_HOME) && go test -v ./e2e/tests/... -tags=e2e

.PHONY: go_test
go_test: check_go_version ## Run all go tests
Expand Down Expand Up @@ -231,11 +232,11 @@ todo_this_commit: ## List all the TODOs needed to be done in this commit

.PHONY: gateway_list
gateway_list: ## List all the staked gateways
poktrolld --home=$(POCKETD_HOME) q gateway list-gateway --node $(POCKET_NODE)
poktrolld --home=$(POKTROLLD_HOME) q gateway list-gateway --node $(POCKET_NODE)

.PHONY: gateway_stake
gateway_stake: ## Stake tokens for the gateway specified (must specify the gateway env var)
poktrolld --home=$(POCKETD_HOME) tx gateway stake-gateway 1000upokt --keyring-backend test --from $(GATEWAY) --node $(POCKET_NODE)
poktrolld --home=$(POKTROLLD_HOME) tx gateway stake-gateway 1000upokt --keyring-backend test --from $(GATEWAY) --node $(POCKET_NODE)

.PHONY: gateway1_stake
gateway1_stake: ## Stake gateway1
Expand All @@ -251,7 +252,7 @@ gateway3_stake: ## Stake gateway3

.PHONY: gateway_unstake
gateway_unstake: ## Unstake an gateway (must specify the GATEWAY env var)
poktrolld --home=$(POCKETD_HOME) tx gateway unstake-gateway --keyring-backend test --from $(GATEWAY) --node $(POCKET_NODE)
poktrolld --home=$(POKTROLLD_HOME) tx gateway unstake-gateway --keyring-backend test --from $(GATEWAY) --node $(POCKET_NODE)

.PHONY: gateway1_unstake
gateway1_unstake: ## Unstake gateway1
Expand All @@ -271,11 +272,11 @@ gateway3_unstake: ## Unstake gateway3

.PHONY: app_list
app_list: ## List all the staked applications
poktrolld --home=$(POCKETD_HOME) q application list-application --node $(POCKET_NODE)
poktrolld --home=$(POKTROLLD_HOME) q application list-application --node $(POCKET_NODE)

.PHONY: app_stake
app_stake: ## Stake tokens for the application specified (must specify the APP and SERVICES env vars)
poktrolld --home=$(POCKETD_HOME) tx application stake-application 1000upokt $(SERVICES) --keyring-backend test --from $(APP) --node $(POCKET_NODE)
poktrolld --home=$(POKTROLLD_HOME) tx application stake-application 1000upokt $(SERVICES) --keyring-backend test --from $(APP) --node $(POCKET_NODE)

.PHONY: app1_stake
app1_stake: ## Stake app1
Expand All @@ -291,7 +292,7 @@ app3_stake: ## Stake app3

.PHONY: app_unstake
app_unstake: ## Unstake an application (must specify the APP env var)
poktrolld --home=$(POCKETD_HOME) tx application unstake-application --keyring-backend test --from $(APP) --node $(POCKET_NODE)
poktrolld --home=$(POKTROLLD_HOME) tx application unstake-application --keyring-backend test --from $(APP) --node $(POCKET_NODE)

.PHONY: app1_unstake
app1_unstake: ## Unstake app1
Expand All @@ -307,49 +308,55 @@ app3_unstake: ## Unstake app3

.PHONY: app_delegate
app_delegate: ## Delegate trust to a gateway (must specify the APP and GATEWAY_ADDR env vars). Requires the app to be staked
poktrolld --home=$(POCKETD_HOME) tx application delegate-to-gateway $(GATEWAY_ADDR) --keyring-backend test --from $(APP) --node $(POCKET_NODE)
poktrolld --home=$(POKTROLLD_HOME) tx application delegate-to-gateway $(GATEWAY_ADDR) --keyring-backend test --from $(APP) --node $(POCKET_NODE)

.PHONY: app1_delegate_gateway1
app1_delegate_gateway1: ## Delegate trust to gateway1
APP=app1 GATEWAY_ADDR=pokt15vzxjqklzjtlz7lahe8z2dfe9nm5vxwwmscne4 make app_delegate
GATEWAY1=$$(make poktrolld_addr ACC_NAME=gateway1) && \
APP=app1 GATEWAY_ADDR=$$GATEWAY1 make app_delegate

.PHONY: app2_delegate_gateway2
app2_delegate_gateway2: ## Delegate trust to gateway2
APP=app2 GATEWAY_ADDR=pokt15w3fhfyc0lttv7r585e2ncpf6t2kl9uh8rsnyz make app_delegate
GATEWAY2=$$(make poktrolld_addr ACC_NAME=gateway2) && \
Olshansk marked this conversation as resolved.
Show resolved Hide resolved
APP=app2 GATEWAY_ADDR=$$GATEWAY2 make app_delegate

.PHONY: app3_delegate_gateway3
app3_delegate_gateway3: ## Delegate trust to gateway3
APP=app3 GATEWAY_ADDR=pokt1zhmkkd0rh788mc9prfq0m2h88t9ge0j83gnxya make app_delegate
GATEWAY3=$$(make poktrolld_addr ACC_NAME=gateway3) && \
APP=app3 GATEWAY_ADDR=$$GATEWAY3 make app_delegate

.PHONY: app_undelegate
app_undelegate: ## Undelegate trust to a gateway (must specify the APP and GATEWAY_ADDR env vars). Requires the app to be staked
poktrolld --home=$(POCKETD_HOME) tx application undelegate-from-gateway $(GATEWAY_ADDR) --keyring-backend test --from $(APP) --node $(POCKET_NODE)
poktrolld --home=$(POKTROLLD_HOME) tx application undelegate-from-gateway $(GATEWAY_ADDR) --keyring-backend test --from $(APP) --node $(POCKET_NODE)

.PHONY: app1_undelegate_gateway1
app1_undelegate_gateway1: ## Undelegate trust to gateway1
APP=app1 GATEWAY_ADDR=pokt15vzxjqklzjtlz7lahe8z2dfe9nm5vxwwmscne4 make app_undelegate
GATEWAY1=$$(make poktrolld_addr ACC_NAME=gateway1) && \
APP=app1 GATEWAY_ADDR=$$GATEWAY1 make app_undelegate

.PHONY: app2_undelegate_gateway2
app2_undelegate_gateway2: ## Undelegate trust to gateway2
APP=app2 GATEWAY_ADDR=pokt15w3fhfyc0lttv7r585e2ncpf6t2kl9uh8rsnyz make app_undelegate
GATEWAY2=$$(make poktrolld_addr ACC_NAME=gateway2) && \
APP=app2 GATEWAY_ADDR=$$GATEWAY2 make app_undelegate

.PHONY: app3_undelegate_gateway3
app3_undelegate_gateway3: ## Undelegate trust to gateway3
APP=app3 GATEWAY_ADDR=pokt1zhmkkd0rh788mc9prfq0m2h88t9ge0j83gnxya make app_undelegate
GATEWAY3=$$(make poktrolld_addr ACC_NAME=gateway3) && \
APP=app3 GATEWAY_ADDR=$$GATEWAY3 make app_undelegate

#################
### Suppliers ###
#################

.PHONY: supplier_list
supplier_list: ## List all the staked supplier
poktrolld --home=$(POCKETD_HOME) q supplier list-supplier --node $(POCKET_NODE)
poktrolld --home=$(POKTROLLD_HOME) q supplier list-supplier --node $(POCKET_NODE)

# TODO(@Olshansk, @okdas): Add more services (in addition to anvil) for apps and suppliers to stake for.
# TODO_TECHDEBT: svc1, svc2 and svc3 below are only in place to make GetSession testable
.PHONY: supplier_stake
supplier_stake: ## Stake tokens for the supplier specified (must specify the APP env var)
poktrolld --home=$(POCKETD_HOME) tx supplier stake-supplier 1000upokt "$(SERVICES)" --keyring-backend test --from $(SUPPLIER) --node $(POCKET_NODE)
poktrolld --home=$(POKTROLLD_HOME) tx supplier stake-supplier 1000upokt "$(SERVICES)" --keyring-backend test --from $(SUPPLIER) --node $(POCKET_NODE)

.PHONY: supplier1_stake
supplier1_stake: ## Stake supplier1
Expand All @@ -365,7 +372,7 @@ supplier3_stake: ## Stake supplier3

.PHONY: supplier_unstake
supplier_unstake: ## Unstake an supplier (must specify the SUPPLIER env var)
poktrolld --home=$(POCKETD_HOME) tx supplier unstake-supplier --keyring-backend test --from $(SUPPLIER) --node $(POCKET_NODE)
poktrolld --home=$(POKTROLLD_HOME) tx supplier unstake-supplier --keyring-backend test --from $(SUPPLIER) --node $(POCKET_NODE)

.PHONY: supplier1_unstake
supplier1_unstake: ## Unstake supplier1
Expand All @@ -379,41 +386,66 @@ supplier2_unstake: ## Unstake supplier2
supplier3_unstake: ## Unstake supplier3
SUPPLIER=supplier3 make supplier_unstake

###############
### Session ###
###############

.PHONY: get_session
get_session: ## Retrieve the session given the following env vars: (APP_ADDR, SVC, HEIGHT)
pocketd --home=$(POCKETD_HOME) q session get-session $(APP) $(SVC) $(HEIGHT) --node $(POCKET_NODE)

.PHONY: get_session_app1_anvil
get_session_app1_anvil: ## Retrieve the session for (app1, anvil, latest_height)
APP1=$$(make poktrolld_addr ACC_NAME=app1) && \
APP=$$APP1 SVC=anvil HEIGHT=0 make get_session

.PHONY: get_session_app2_anvil
get_session_app2_anvil: ## Retrieve the session for (app2, anvil, latest_height)
APP2=$$(make poktrolld_addr ACC_NAME=app2) && \
APP=$$APP2 SVC=anvil HEIGHT=0 make get_session

.PHONY: get_session_app3_anvil
get_session_app3_anvil: ## Retrieve the session for (app3, anvil, latest_height)
APP3=$$(make poktrolld_addr ACC_NAME=app3) && \
APP=$$APP3 SVC=anvil HEIGHT=0 make get_session

################
### Accounts ###
################

.PHONY: acc_balance_query
acc_balance_query: ## Query the balance of the account specified (make acc_balance_query ACC=pokt...)
@echo "~~~ Balances ~~~"
poktrolld --home=$(POCKETD_HOME) q bank balances $(ACC) --node $(POCKET_NODE)
poktrolld --home=$(POKTROLLD_HOME) q bank balances $(ACC) --node $(POCKET_NODE)
@echo "~~~ Spendable Balances ~~~"
@echo "Querying spendable balance for $(ACC)"
poktrolld --home=$(POCKETD_HOME) q bank spendable-balances $(ACC) --node $(POCKET_NODE)
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
make acc_balance_query ACC=pokt1j40dzzmn6cn9kxku7a5tjnud6hv37vesr5ccaa
SUPPLIER1=$(make poktrolld_addr ACC_NAME=supplier1)
make acc_balance_query ACC=SUPPLIER1
Olshansk marked this conversation as resolved.
Show resolved Hide resolved

.PHONY: acc_balance_query_app1
acc_balance_query_app1: ## Query the balance of app1
make acc_balance_query ACC=pokt1mrqt5f7qh8uxs27cjm9t7v9e74a9vvdnq5jva4
APP1=$$(make poktrolld_addr ACC_NAME=app1) && \
make acc_balance_query ACC=$$APP1

.PHONY: acc_balance_total_supply
acc_balance_total_supply: ## Query the total supply of the network
poktrolld --home=$(POCKETD_HOME) q bank total --node $(POCKET_NODE)
poktrolld --home=$(POKTROLLD_HOME) q bank total --node $(POCKET_NODE)

######################
### Ignite Helpers ###
######################

.PHONY: ignite_acc_list
ignite_acc_list: ## List all the accounts in LocalNet
ignite account list --keyring-dir=$(POCKETD_HOME) --keyring-backend test --address-prefix $(POCKET_ADDR_PREFIX)
ignite account list --keyring-dir=$(POKTROLLD_HOME) --keyring-backend test --address-prefix $(POCKET_ADDR_PREFIX)

##################
### CI Helpers ###
Expand All @@ -427,8 +459,20 @@ trigger_ci: ## Trigger the CI pipeline by submitting an empty commit; See https:
#####################
### Documentation ###
#####################

.PHONY: go_docs
go_docs: check_godoc ## Generate documentation for the project
echo "Visit http://localhost:6060/pkg/pocket/"
godoc -http=:6060

.PHONY: openapi_gen
openapi_gen: ## Generate the OpenAPI spec for the Ignite API
ignite generate openapi --yes

######################
### Ignite Helpers ###
######################

.PHONY: poktrolld_addr
poktrolld_addr: ## Retrieve the address for an account by ACC_NAME
Olshansk marked this conversation as resolved.
Show resolved Hide resolved
@echo $(shell poktrolld keys show -a $(ACC_NAME))
28 changes: 14 additions & 14 deletions Tiltfile
Original file line number Diff line number Diff line change
Expand Up @@ -60,15 +60,15 @@ def generate_config_map_yaml(name, data):
# Import keyring/keybase files into Kubernetes ConfigMap
k8s_yaml(
generate_config_map_yaml(
"pocketd-keys", read_files_from_directory("localnet/pocketd/keyring-test/")
"poktrolld-keys", read_files_from_directory("localnet/poktrolld/keyring-test/")
)
) # pocketd/keys
) # poktrolld/keys
# Import configuration files into Kubernetes ConfigMap
k8s_yaml(
generate_config_map_yaml(
"pocketd-configs", read_files_from_directory("localnet/pocketd/config/")
"poktrolld-configs", read_files_from_directory("localnet/poktrolld/config/")
)
) # pocketd/configs
) # poktrolld/configs

# Hot reload protobuf changes
local_resource(
Expand All @@ -77,36 +77,36 @@ local_resource(
deps=["proto"],
labels=["hot-reloading"],
)
# Hot reload the pocketd binary used by the k8s cluster
# Hot reload the poktrolld binary used by the k8s cluster
local_resource(
"hot-reload: pocketd",
"hot-reload: poktrolld",
"GOOS=linux ignite chain build --skip-proto --output=./bin --debug -v",
deps=hot_reload_dirs,
labels=["hot-reloading"],
resource_deps=["hot-reload: generate protobufs"],
)
# Hot reload the local pocketd binary used by the CLI
# Hot reload the local poktrolld binary used by the CLI
local_resource(
"hot-reload: pocketd - local cli",
"hot-reload: poktrolld - local cli",
"ignite chain build --skip-proto --debug -v -o $(go env GOPATH)/bin",
deps=hot_reload_dirs,
labels=["hot-reloading"],
resource_deps=["hot-reload: generate protobufs"],
)

# Build an image with a pocketd binary
# Build an image with a poktrolld binary
docker_build_with_restart(
"pocketd",
"poktrolld",
".",
dockerfile_contents="""FROM golang:1.20.8
RUN apt-get -q update && apt-get install -qyy curl jq
RUN go install github.com/go-delve/delve/cmd/dlv@latest
COPY bin/poktrolld /usr/local/bin/pocketd
COPY bin/poktrolld /usr/local/bin/poktrolld
WORKDIR /
""",
only=["./bin/poktrolld"],
entrypoint=["/bin/sh", "/scripts/pocket.sh"],
live_update=[sync("bin/poktrolld", "/usr/local/bin/pocketd")],
live_update=[sync("bin/poktrolld", "/usr/local/bin/poktrolld")],
)

# Run celestia and anvil nodes
Expand All @@ -119,7 +119,7 @@ helm_resource(
"sequencer",
sequencer_chart,
flags=["--values=./localnet/kubernetes/values-common.yaml"],
image_deps=["pocketd"],
image_deps=["poktrolld"],
image_keys=[("image.repository", "image.tag")],
)
helm_resource(
Expand All @@ -129,7 +129,7 @@ helm_resource(
"--values=./localnet/kubernetes/values-common.yaml",
"--set=replicaCount=" + str(localnet_config["relayers"]["count"]),
],
image_deps=["pocketd"],
image_deps=["poktrolld"],
image_keys=[("image.repository", "image.tag")],
)

Expand Down
Loading