Skip to content

Commit

Permalink
reconcile: Make changes closer to main
Browse files Browse the repository at this point in the history
  • Loading branch information
red-0ne committed Feb 10, 2024
1 parent 5f32352 commit 0807acd
Show file tree
Hide file tree
Showing 22 changed files with 290 additions and 128 deletions.
40 changes: 33 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
.SILENT:

POKTROLLD_HOME := ./localnet/poktrolld
POCKET_NODE = tcp://127.0.0.1:36657 # The pocket rollup node (full node and sequencer in the localnet context)
APPGATE_SERVER = http://localhost:42069
SHELL = /bin/sh
POKTROLLD_HOME ?= ./localnet/poktrolld
POCKET_NODE ?= tcp://127.0.0.1:36657 # The pocket rollup node (full node and sequencer in the localnet context)
APPGATE_SERVER ?= http://localhost:42069
POCKET_ADDR_PREFIX = pokt

####################
Expand Down Expand Up @@ -166,7 +167,7 @@ localnet_down: ## Delete resources created by localnet
tilt down

.PHONY: localnet_regenesis
localnet_regenesis: ## Regenerate the localnet genesis file
localnet_regenesis: acc_initialize_pubkeys_warn_message ## Regenerate the localnet genesis file
# NOTE: intentionally not using --home <dir> flag to avoid overwriting the test keyring
# NB: Currently the stake => power calculation is constant; however, cosmos-sdk
# intends to make this parameterizable in the future.
Expand Down Expand Up @@ -207,7 +208,7 @@ go_imports: check_go_version ## Run goimports on all go files
#############

.PHONY: test_e2e
test_e2e: ## Run all E2E tests
test_e2e: acc_initialize_pubkeys_warn_message ## Run all E2E tests
export POCKET_NODE=$(POCKET_NODE) && \
export APPGATE_SERVER=$(APPGATE_SERVER) && \
POKTROLLD_HOME=../../$(POKTROLLD_HOME) && \
Expand Down Expand Up @@ -369,7 +370,6 @@ app_list: ## List all the staked applications
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)

# TODO_IMPROVE(#180): Make sure genesis-staked actors are available via AccountKeeper
.PHONY: app1_stake
app1_stake: ## Stake app1 (also staked in genesis)
APP=app1 SERVICES=application1_stake_config.yaml make app_stake
Expand Down Expand Up @@ -529,6 +529,32 @@ acc_balance_query_app1: ## Query the balance of app1
acc_balance_total_supply: ## Query the total supply of the network
poktrolld --home=$(POKTROLLD_HOME) q bank total --node $(POCKET_NODE)

# NB: Ignite does not populate `pub_key` in `accounts` within `genesis.json` leading
# to queries like this to fail: `poktrolld query account pokt1<addr> --node $(POCKET_NODE).
# We attempted using a `tx multi-send` from the `faucet` to all accounts, but
# that also did not solve this problem because the account itself must sign the
# transaction for its public key to be populated in the account keeper. As such,
# the solution is to send funds from every account in genesis to some address
# (PNF was selected ambigously) to make sure their public keys are populated.

.PHONY: acc_initialize_pubkeys
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 \
$(addr) $(PNF_ADDR) 1000upokt \
--yes \
--home=$(POKTROLLD_HOME) \
--node $(POCKET_NODE);)

.PHONY: acc_initialize_pubkeys_warn_message
acc_initialize_pubkeys_warn_message: ## Print a warning message about the need to run `make acc_initialize_pubkeys`
@printf "!!! YOU MUST RUN THE FOLLOWING COMMAND ONCE FOR E2E TESTS TO WORK AFTER THE NETWORK HAS STARTED!!!\n"\
"\t\tmake acc_initialize_pubkeys\n"

##############
### Claims ###
##############
Expand Down Expand Up @@ -656,4 +682,4 @@ act_list: check_act ## List all github actions that can be executed locally with
act_reviewdog: check_act check_gh ## Run the reviewdog workflow locally like so: `GITHUB_TOKEN=$(gh auth token) make act_reviewdog`
$(eval CONTAINER_ARCH := $(shell make -s detect_arch))
@echo "Detected architecture: $(CONTAINER_ARCH)"
act -v -s GITHUB_TOKEN=$(GITHUB_TOKEN) -W .github/workflows/reviewdog.yml --container-architecture $(CONTAINER_ARCH)
act -v -s GITHUB_TOKEN=$(GITHUB_TOKEN) -W .github/workflows/reviewdog.yml --container-architecture $(CONTAINER_ARCH)
4 changes: 2 additions & 2 deletions api/poktroll/gateway/gateway.pulsar.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

123 changes: 61 additions & 62 deletions api/poktroll/gateway/query.pulsar.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 0 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -327,9 +327,7 @@ require (
google.golang.org/api v0.153.0 // indirect
google.golang.org/appengine v1.6.8 // indirect
google.golang.org/genproto v0.0.0-20240102182953-50ed04b92917 // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20240116215550-a9fa1716bcac // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20240116215550-a9fa1716bcac // indirect
google.golang.org/grpc v1.60.1 // indirect
gopkg.in/ini.v1 v1.67.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
gotest.tools/v3 v3.5.1 // indirect
Expand Down
4 changes: 2 additions & 2 deletions proto/poktroll/gateway/gateway.proto
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import "gogoproto/gogo.proto";
import "cosmos/base/v1beta1/coin.proto";

message Gateway {
string address = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"];
cosmos.base.v1beta1.Coin stake = 2;
string address = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"]; // The Bech32 address of the gateway
cosmos.base.v1beta1.Coin stake = 2; // The total amount of uPOKT the gateway has staked
}

1 change: 0 additions & 1 deletion proto/poktroll/gateway/params.proto
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,4 @@ message Params {
option (amino.name) = "poktroll/x/gateway/Params";
option (gogoproto.equal) = true;


}
2 changes: 1 addition & 1 deletion proto/poktroll/gateway/query.proto
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ message QueryParamsResponse {
}

message QueryGetGatewayRequest {
string address = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"];
string address = 1;
}

message QueryGetGatewayResponse {
Expand Down
14 changes: 9 additions & 5 deletions x/gateway/keeper/msg_server_stake_gateway.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,16 @@ import (
"context"
"fmt"

sdkerrors "cosmossdk.io/errors"
sdk "github.com/cosmos/cosmos-sdk/types"

"github.com/pokt-network/poktroll/x/gateway/types"
)

func (k msgServer) StakeGateway(goCtx context.Context, msg *types.MsgStakeGateway) (*types.MsgStakeGatewayResponse, error) {
func (k msgServer) StakeGateway(
goCtx context.Context,
msg *types.MsgStakeGateway,
) (*types.MsgStakeGatewayResponse, error) {
ctx := sdk.UnwrapSDKContext(goCtx)

logger := k.Logger().With("method", "StakeGateway")
Expand Down Expand Up @@ -74,13 +78,13 @@ func (k msgServer) updateGateway(
) error {
// Checks if the the msg address is the same as the current owner
if msg.Address != gateway.Address {
return types.ErrGatewayUnauthorized.Wrapf("msg Address (%s) != gateway address (%s)", msg.Address, gateway.Address)
return sdkerrors.Wrapf(types.ErrGatewayUnauthorized, "msg Address (%s) != gateway address (%s)", msg.Address, gateway.Address)
}
if msg.Stake.IsZero() {
return types.ErrGatewayInvalidStake.Wrap("stake amount cannot be 0")
if msg.Stake == nil {
return sdkerrors.Wrapf(types.ErrGatewayInvalidStake, "stake amount cannot be nil")
}
if msg.Stake.IsLTE(*gateway.Stake) {
return types.ErrGatewayInvalidStake.Wrapf("stake amount %v must be higher than previous stake amount %v", msg.Stake, gateway.Stake)
return sdkerrors.Wrapf(types.ErrGatewayInvalidStake, "stake amount %v must be higher than previous stake amount %v", msg.Stake, gateway.Stake)
}
gateway.Stake = msg.Stake
return nil
Expand Down
Loading

0 comments on commit 0807acd

Please sign in to comment.