Skip to content

Commit

Permalink
Merge remote-tracking branch 'pokt/main' into feat/tx-context
Browse files Browse the repository at this point in the history
* pokt/main:
  [Miner] feat: add block client (#65)
  [Supplier] Add `ServiceConfigs` to `SupplierStaking` (#114)
  [AppGate] Add the MaxDelegatedGateways parameter (#109)
  [Test] Temporarily skip a flaky test `TestEventsQueryClient_Subscribe_Succeeds` (#121)
  [AppGate] Implement DelegateToGateway and add Tests (#90)
  [E2E] Add (Un)Stake Tests (#88)
  • Loading branch information
bryanchriswhite committed Nov 1, 2023
2 parents c1ec4cc + e85cc8a commit 38b9a6c
Show file tree
Hide file tree
Showing 67 changed files with 4,930 additions and 586 deletions.
40 changes: 31 additions & 9 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -256,15 +256,15 @@ app_stake: ## Stake tokens for the application specified (must specify the APP a

.PHONY: app1_stake
app1_stake: ## Stake app1
SERVICES=svc1,svc2 APP=app1 make app_stake
APP=app1 SERVICES=anvil,svc1,svc2 make app_stake

.PHONY: app2_stake
app2_stake: ## Stake app2
SERVICES=svc2,svc3 APP=app2 make app_stake
APP=app2 SERVICES=anvil,svc2,svc3 make app_stake

.PHONY: app3_stake
app3_stake: ## Stake app3
SERVICES=svc3,svc4 APP=app3 make app_stake
APP=app3 SERVICES=anvil,svc3,svc4 make app_stake

.PHONY: app_unstake
app_unstake: ## Unstake an application (must specify the APP env var)
Expand All @@ -282,6 +282,22 @@ app2_unstake: ## Unstake app2
app3_unstake: ## Unstake app3
APP=app3 make app_unstake

.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
pocketd --home=$(POCKETD_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

.PHONY: app2_delegate_gateway2
app2_delegate_gateway2: ## Delegate trust to gateway2
APP=app2 GATEWAY_ADDR=pokt15w3fhfyc0lttv7r585e2ncpf6t2kl9uh8rsnyz make app_delegate

.PHONY: app3_delegate_gateway3
app3_delegate_gateway3: ## Delegate trust to gateway3
APP=app3 GATEWAY_ADDR=pokt1zhmkkd0rh788mc9prfq0m2h88t9ge0j83gnxya make app_delegate

#################
### Suppliers ###
#################
Expand All @@ -290,21 +306,23 @@ app3_unstake: ## Unstake app3
supplier_list: ## List all the staked supplier
pocketd --home=$(POCKETD_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)
pocketd --home=$(POCKETD_HOME) tx supplier stake-supplier 1000upokt --keyring-backend test --from $(SUPPLIER) --node $(POCKET_NODE)
pocketd --home=$(POCKETD_HOME) tx supplier stake-supplier 1000upokt "$(SERVICES)" --keyring-backend test --from $(SUPPLIER) --node $(POCKET_NODE)

.PHONY: supplier1_stake
supplier1_stake: ## Stake supplier1
SUPPLIER=supplier1 make supplier_stake
SUPPLIER=supplier1 SERVICES="anvil;http://anvil:8547,svc1;http://localhost:8081" make supplier_stake

.PHONY: supplier2_stake
supplier2_stake: ## Stake supplier2
SUPPLIER=supplier2 make supplier_stake
SUPPLIER=supplier2 SERVICES="anvil;http://anvil:8547,svc2;http://localhost:8082" make supplier_stake

.PHONY: supplier3_stake
supplier3_stake: ## Stake supplier3
SUPPLIER=supplier3 make supplier_stake
SUPPLIER=supplier3 SERVICES="anvil;http://anvil:8547,svc3;http://localhost:8083" make supplier_stake

.PHONY: supplier_unstake
supplier_unstake: ## Unstake an supplier (must specify the SUPPLIER env var)
Expand Down Expand Up @@ -334,10 +352,14 @@ acc_balance_query: ## Query the balance of the account specified (make acc_balan
@echo "Querying spendable balance for $(ACC)"
pocketd --home=$(POCKETD_HOME) q bank spendable-balances $(ACC) --node $(POCKET_NODE)

.PHONY: acc_balance_query_app_module
acc_balance_query_app_module: ## Query the balance of the network level "application" module
.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

.PHONY: acc_balance_query_app1
acc_balance_query_app1: ## Query the balance of app1
make acc_balance_query ACC=pokt1mrqt5f7qh8uxs27cjm9t7v9e74a9vvdnq5jva4
Expand Down
103 changes: 80 additions & 23 deletions Tiltfile
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
load('ext://restart_process', 'docker_build_with_restart')
load('ext://helm_resource', "helm_resource", 'helm_repo')
load("ext://restart_process", "docker_build_with_restart")
load("ext://helm_resource", "helm_resource", "helm_repo")

# A list of directories where changes trigger a hot-reload of the sequencer
hot_reload_dirs = ['app', 'cmd', 'tools', 'x']
hot_reload_dirs = ["app", "cmd", "tools", "x"]

# Create a localnet config file from defaults, and if a default configuration doesn't exist, populate it with default values
localnet_config_path = "localnet_config.yaml"
localnet_config_defaults = {
"relayers": {"count": 1},
"gateways": {"count": 1},
# By default, we use the `helm_repo` function below to point to the remote repository
# but can update it to the locally cloned repo for testing & development
# By default, we use the `helm_repo` function below to point to the remote repository
# but can update it to the locally cloned repo for testing & development
"helm_chart_local_repo": {"enabled": False, "path": "../helm-charts"},
}
localnet_config_file = read_yaml(localnet_config_path, default=localnet_config_defaults)
Expand All @@ -35,6 +35,7 @@ if localnet_config["helm_chart_local_repo"]["enabled"]:
sequencer_chart = helm_chart_local_repo + "/charts/poktroll-sequencer"
poktroll_chart = helm_chart_local_repo + "/charts/poktroll"


# Import files into Kubernetes ConfigMap
def read_files_from_directory(directory):
files = listdir(directory)
Expand All @@ -45,53 +46,109 @@ def read_files_from_directory(directory):
config_map_data[filename] = content
return config_map_data


def generate_config_map_yaml(name, data):
config_map_object = {
"apiVersion": "v1",
"kind": "ConfigMap",
"metadata": {"name": name},
"data": data
"data": data,
}
return encode_yaml(config_map_object)


# Import keyring/keybase files into Kubernetes ConfigMap
k8s_yaml(generate_config_map_yaml("pocketd-keys", read_files_from_directory("localnet/pocketd/keyring-test/"))) # pocketd/keys
k8s_yaml(
generate_config_map_yaml(
"pocketd-keys", read_files_from_directory("localnet/pocketd/keyring-test/")
)
) # pocketd/keys
# Import configuration files into Kubernetes ConfigMap
k8s_yaml(generate_config_map_yaml("pocketd-configs", read_files_from_directory("localnet/pocketd/config/"))) # pocketd/configs
k8s_yaml(
generate_config_map_yaml(
"pocketd-configs", read_files_from_directory("localnet/pocketd/config/")
)
) # pocketd/configs

# Hot reload protobuf changes
local_resource('hot-reload: generate protobufs', 'ignite generate proto-go -y', deps=['proto'], labels=["hot-reloading"])
local_resource(
"hot-reload: generate protobufs",
"ignite generate proto-go -y",
deps=["proto"],
labels=["hot-reloading"],
)
# Hot reload the pocketd binary used by the k8s cluster
local_resource('hot-reload: pocketd', 'GOOS=linux ignite chain build --skip-proto --output=./bin --debug -v', deps=hot_reload_dirs, labels=["hot-reloading"], resource_deps=['hot-reload: generate protobufs'])
local_resource(
"hot-reload: pocketd",
"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
local_resource('hot-reload: pocketd - 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'])
local_resource(
"hot-reload: pocketd - 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
docker_build_with_restart(
"pocketd",
'.',
".",
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/pocketd /usr/local/bin/pocketd
WORKDIR /
""",
only=["./bin/pocketd"],
entrypoint=[
"/bin/sh", "/scripts/pocket.sh"
],
entrypoint=["/bin/sh", "/scripts/pocket.sh"],
live_update=[sync("bin/pocketd", "/usr/local/bin/pocketd")],
)

# Run celestia and anvil nodes
k8s_yaml(['localnet/kubernetes/celestia-rollkit.yaml', 'localnet/kubernetes/anvil.yaml'])
k8s_yaml(
["localnet/kubernetes/celestia-rollkit.yaml", "localnet/kubernetes/anvil.yaml"]
)

# Run pocket-specific nodes (sequencer, relayers, etc...)
helm_resource("sequencer", sequencer_chart, flags=['--values=./localnet/kubernetes/values-common.yaml'], image_deps=["pocketd"], image_keys=[('image.repository', 'image.tag')])
helm_resource("relayers", poktroll_chart, flags=['--values=./localnet/kubernetes/values-common.yaml', '--set=replicaCount=' + str(localnet_config["relayers"]["count"])], image_deps=["pocketd"], image_keys=[('image.repository', 'image.tag')])
helm_resource(
"sequencer",
sequencer_chart,
flags=["--values=./localnet/kubernetes/values-common.yaml"],
image_deps=["pocketd"],
image_keys=[("image.repository", "image.tag")],
)
helm_resource(
"relayers",
poktroll_chart,
flags=[
"--values=./localnet/kubernetes/values-common.yaml",
"--set=replicaCount=" + str(localnet_config["relayers"]["count"]),
],
image_deps=["pocketd"],
image_keys=[("image.repository", "image.tag")],
)

# Configure tilt resources (tilt labels and port forawards) for all of the nodes above
k8s_resource('celestia-rollkit', labels=["blockchains"], port_forwards=['26657', '26658', '26659'])
k8s_resource('sequencer', labels=["blockchains"], resource_deps=['celestia-rollkit'], port_forwards=['36657', '40004'])
k8s_resource('relayers', labels=["blockchains"], resource_deps=['sequencer'], port_forwards=['8545', '8546', '40005'])
k8s_resource('anvil', labels=["blockchains"], port_forwards=['8547'])
# Configure tilt resources (tilt labels and port forwards) for all of the nodes above
k8s_resource(
"celestia-rollkit",
labels=["blockchains"],
port_forwards=["26657", "26658", "26659"],
)
k8s_resource(
"sequencer",
labels=["blockchains"],
resource_deps=["celestia-rollkit"],
port_forwards=["36657", "40004"],
)
k8s_resource(
"relayers",
labels=["blockchains"],
resource_deps=["sequencer"],
port_forwards=["8545", "8546", "40005"],
)
k8s_resource("anvil", labels=["blockchains"], port_forwards=["8547"])
24 changes: 13 additions & 11 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"io"
"os"
"path/filepath"

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

autocliv1 "cosmossdk.io/api/cosmos/autocli/v1"
Expand Down Expand Up @@ -585,16 +586,6 @@ func New(
)
sessionModule := sessionmodule.NewAppModule(appCodec, app.SessionKeeper, app.AccountKeeper, app.BankKeeper)

app.ApplicationKeeper = *applicationmodulekeeper.NewKeeper(
appCodec,
keys[applicationmoduletypes.StoreKey],
keys[applicationmoduletypes.MemStoreKey],
app.GetSubspace(applicationmoduletypes.ModuleName),

app.BankKeeper,
)
applicationModule := applicationmodule.NewAppModule(appCodec, app.ApplicationKeeper, app.AccountKeeper, app.BankKeeper)

app.SupplierKeeper = *suppliermodulekeeper.NewKeeper(
appCodec,
keys[suppliermoduletypes.StoreKey],
Expand All @@ -612,10 +603,21 @@ func New(
app.GetSubspace(gatewaymoduletypes.ModuleName),

app.BankKeeper,
app.AccountKeeper,
)
gatewayModule := gatewaymodule.NewAppModule(appCodec, app.GatewayKeeper, app.AccountKeeper, app.BankKeeper)

app.ApplicationKeeper = *applicationmodulekeeper.NewKeeper(
appCodec,
keys[applicationmoduletypes.StoreKey],
keys[applicationmoduletypes.MemStoreKey],
app.GetSubspace(applicationmoduletypes.ModuleName),

app.BankKeeper,
app.AccountKeeper,
app.GatewayKeeper,
)
applicationModule := applicationmodule.NewAppModule(appCodec, app.ApplicationKeeper, app.AccountKeeper, app.BankKeeper)

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

/**** IBC Routing ****/
Expand Down
2 changes: 2 additions & 0 deletions config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,8 @@ genesis:
- amount: "10000"
denom: upokt
application:
params:
maxDelegatedGateways: 7
applicationList:
- address: pokt1mrqt5f7qh8uxs27cjm9t7v9e74a9vvdnq5jva4
stake:
Expand Down
Loading

0 comments on commit 38b9a6c

Please sign in to comment.