Skip to content

Commit

Permalink
[Code health] rename pocketd to poktroll (#157)
Browse files Browse the repository at this point in the history
* add more debug output

* Empty commit

* symlink to pocketd for now

* rename pocketd

* --wip-- [skip ci]

* removing pocketd completely

* also remove comment

* --wip-- [skip ci]

* add files

* change git rules
  • Loading branch information
okdas authored Nov 8, 2023
1 parent c66c251 commit 8cdb534
Show file tree
Hide file tree
Showing 18 changed files with 82 additions and 59 deletions.
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
3 changes: 3 additions & 0 deletions .tool-versions
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# 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
41 changes: 21 additions & 20 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,7 +308,7 @@ 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
Expand All @@ -323,7 +324,7 @@ app3_delegate_gateway3: ## Delegate trust to gateway3

.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
Expand All @@ -343,13 +344,13 @@ app3_undelegate_gateway3: ## Undelegate trust to gateway3

.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 +366,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 @@ -386,10 +387,10 @@ supplier3_unstake: ## Unstake supplier3
.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
Expand All @@ -405,15 +406,15 @@ acc_balance_query_app1: ## Query the balance of 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 Down
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
36 changes: 26 additions & 10 deletions e2e/tests/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@
package e2e

import (
"bytes"
"fmt"
"os"
"os/exec"
"strings"
)

var (
Expand All @@ -16,7 +18,7 @@ var (
// defaultRPCHost is the default RPC host that pocketd listens on
defaultRPCHost = "127.0.0.1"
// defaultHome is the default home directory for pocketd
defaultHome = os.Getenv("POCKETD_HOME")
defaultHome = os.Getenv("POKTROLLD_HOME")
)

func init() {
Expand All @@ -30,9 +32,10 @@ func init() {

// commandResult combines the stdout, stderr, and err of an operation
type commandResult struct {
Stdout string
Stderr string
Err error
Command string // the command that was executed
Stdout string // standard output
Stderr string // standard error
Err error // execution error, if any
}

// PocketClient is a single function interface for interacting with a node
Expand Down Expand Up @@ -67,13 +70,26 @@ func (p *pocketdBin) RunCommandOnHost(rpcUrl string, args ...string) (*commandRe
func (p *pocketdBin) runCmd(args ...string) (*commandResult, error) {
base := []string{"--home", defaultHome}
args = append(base, args...)
commandStr := "poktrolld " + strings.Join(args, " ") // Create a string representation of the command
cmd := exec.Command("poktrolld", args...)
r := &commandResult{}
out, err := cmd.Output()
if err != nil {
return nil, err

var stdoutBuf, stderrBuf bytes.Buffer
cmd.Stdout = &stdoutBuf
cmd.Stderr = &stderrBuf

err := cmd.Run()
r := &commandResult{
Command: commandStr, // Set the command string
Stdout: stdoutBuf.String(),
Stderr: stderrBuf.String(),
Err: err,
}
r.Stdout = string(out)
p.result = r
return r, nil

if err != nil {
// Include the command executed in the error message for context
err = fmt.Errorf("error running command [%s]: %v, stderr: %s", commandStr, err, stderrBuf.String())
}

return r, err
}
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/pokt-network/poktroll

go 1.19
go 1.20

require (
cosmossdk.io/api v0.3.1
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion x/application/client/cli/tx_delegate_to_gateway.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ that delegates authority to the gateway specified to sign relays requests for th
act on the behalf of the application during a session.
Example:
$ 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)`,
Args: cobra.ExactArgs(1),
RunE: func(cmd *cobra.Command, args []string) (err error) {
gatewayAddress := args[0]
Expand Down
2 changes: 1 addition & 1 deletion x/application/client/cli/tx_stake_application.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ func CmdStakeApplication() *cobra.Command {
will stake the tokens and serviceIds and associate them with the application specified by the 'from' address.
Example:
$ poktrolld --home=$(POCKETD_HOME) tx application stake-application 1000upokt svc1,svc2,svc3 --keyring-backend test --from $(APP) --node $(POCKET_NODE)`,
$ poktrolld --home=$(POKTROLLD_HOME) tx application stake-application 1000upokt svc1,svc2,svc3 --keyring-backend test --from $(APP) --node $(POCKET_NODE)`,
Args: cobra.ExactArgs(2),
RunE: func(cmd *cobra.Command, args []string) (err error) {
stakeString := args[0]
Expand Down
2 changes: 1 addition & 1 deletion x/application/client/cli/tx_undelegate_from_gateway.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ that removes the authority from the gateway specified to sign relays requests fo
act on the behalf of the application during a session.
Example:
$ 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)`,
Args: cobra.ExactArgs(1),
RunE: func(cmd *cobra.Command, args []string) (err error) {
gatewayAddress := args[0]
Expand Down
2 changes: 1 addition & 1 deletion x/application/client/cli/tx_unstake_application.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ func CmdUnstakeApplication() *cobra.Command {
the application specified by the 'from' address.
Example:
$ 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)`,
Args: cobra.ExactArgs(0),
RunE: func(cmd *cobra.Command, args []string) (err error) {

Expand Down
2 changes: 1 addition & 1 deletion x/gateway/client/cli/tx_stake_gateway.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ func CmdStakeGateway() *cobra.Command {
Long: `Stake a gateway with the provided parameters. This is a broadcast operation that
will stake the tokens and associate them with the gateway specified by the 'from' address.
Example:
$ 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)`,
Args: cobra.ExactArgs(1),
RunE: func(cmd *cobra.Command, args []string) (err error) {
clientCtx, err := client.GetClientTxContext(cmd)
Expand Down
Loading

0 comments on commit 8cdb534

Please sign in to comment.