Skip to content

Commit

Permalink
[Session] Add support for GetSession via the CLI + deps (#163)
Browse files Browse the repository at this point in the history
- Update the CLI code flow to be able to call `GetSession`
- Add make targets to trigger `GetSession`
- Replace `[]` with `<>` in all CLI functions to differentiate required vs optional params
- Made a couple changes to `SessionHydrator` (and added tests) to account additional error cases

https://github.com/pokt-network/poktroll/assets/1892194/56425906-d06f-4c41-b8a5-d210d8a450cd

---

Co-authored-by: Bryan White <[email protected]>
Co-authored-by: Daniel Olshansky <[email protected]>
Co-authored-by: Dima Kniazev <[email protected]>
  • Loading branch information
3 people authored Nov 8, 2023
1 parent b39195a commit 8700722
Show file tree
Hide file tree
Showing 31 changed files with 1,293 additions and 732 deletions.
59 changes: 51 additions & 8 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -312,31 +312,37 @@ app_delegate: ## Delegate trust to a gateway (must specify the APP and GATEWAY_A

.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) && \
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=$(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 ###
Expand Down Expand Up @@ -380,6 +386,29 @@ 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 ###
################
Expand All @@ -398,11 +427,13 @@ acc_balance_query_module_app: ## Query the balance of the network level "applica

.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

.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
Expand All @@ -428,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
@echo $(shell poktrolld keys show -a $(ACC_NAME))
22 changes: 11 additions & 11 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -575,17 +575,6 @@ func New(
)
serviceModule := servicemodule.NewAppModule(appCodec, app.ServiceKeeper, app.AccountKeeper, app.BankKeeper)

app.SessionKeeper = *sessionmodulekeeper.NewKeeper(
appCodec,
keys[sessionmoduletypes.StoreKey],
keys[sessionmoduletypes.MemStoreKey],
app.GetSubspace(sessionmoduletypes.ModuleName),

app.ApplicationKeeper,
app.SupplierKeeper,
)
sessionModule := sessionmodule.NewAppModule(appCodec, app.SessionKeeper, app.AccountKeeper, app.BankKeeper)

app.SupplierKeeper = *suppliermodulekeeper.NewKeeper(
appCodec,
keys[suppliermoduletypes.StoreKey],
Expand Down Expand Up @@ -618,6 +607,17 @@ func New(
)
applicationModule := applicationmodule.NewAppModule(appCodec, app.ApplicationKeeper, app.AccountKeeper, app.BankKeeper)

app.SessionKeeper = *sessionmodulekeeper.NewKeeper(
appCodec,
keys[sessionmoduletypes.StoreKey],
keys[sessionmoduletypes.MemStoreKey],
app.GetSubspace(sessionmoduletypes.ModuleName),

app.ApplicationKeeper,
app.SupplierKeeper,
)
sessionModule := sessionmodule.NewAppModule(appCodec, app.SessionKeeper, app.AccountKeeper, app.BankKeeper)

// this line is used by starport scaffolding # stargate/app/keeperDefinition

/**** IBC Routing ****/
Expand Down
Loading

0 comments on commit 8700722

Please sign in to comment.