From 825a2c00ed69b7c709b57c083791b27f374968b9 Mon Sep 17 00:00:00 2001 From: Simon Noetzlin Date: Thu, 29 Aug 2024 15:11:23 +0200 Subject: [PATCH 1/3] fix consumer chains query cli --- contrib/create-consumer-msg.json | 8 ++++ contrib/local-node.sh | 66 ++++++++++++++++++++++++++++++++ 2 files changed, 74 insertions(+) create mode 100644 contrib/create-consumer-msg.json create mode 100755 contrib/local-node.sh diff --git a/contrib/create-consumer-msg.json b/contrib/create-consumer-msg.json new file mode 100644 index 0000000000..3cd527ca35 --- /dev/null +++ b/contrib/create-consumer-msg.json @@ -0,0 +1,8 @@ +{ + "chain_id" : "consumer-1", + "metadata": { + "name": "consumer-1-metadata-name", + "description":"consumer-1-metadata-description", + "metadata": "consumer-1-metadata-metadata" + } +} diff --git a/contrib/local-node.sh b/contrib/local-node.sh new file mode 100755 index 0000000000..8974ce3c9f --- /dev/null +++ b/contrib/local-node.sh @@ -0,0 +1,66 @@ +#!/bin/bash +set -eux + +# User balance of stake tokens +USER_COINS="100000000000stake" +# Amount of stake tokens staked +STAKE="100000000stake" +# Node IP address +NODE_IP="127.0.0.1" + +# Home directory +HOME_DIR="$HOME" + +# Validator moniker +MONIKER="coordinator" + +# Validator directory +PROV_NODE_DIR=${HOME_DIR}/provider-${MONIKER} + +# Coordinator key +PROV_KEY=${MONIKER}-key + + +# Clean start +pkill -f interchain-security-pd &> /dev/null || true +rm -rf ${PROV_NODE_DIR} + +# Build file and node directory structure +interchain-security-pd init $MONIKER --chain-id provider --home ${PROV_NODE_DIR} + jq ".app_state.gov.voting_params.voting_period = \"20s\" | .app_state.staking.params.unbonding_time = \"86400s\"" \ + ${PROV_NODE_DIR}/config/genesis.json > \ + ${PROV_NODE_DIR}/edited_genesis.json && mv ${PROV_NODE_DIR}/edited_genesis.json ${PROV_NODE_DIR}/config/genesis.json + +sleep 1 + +# Create account keypair +interchain-security-pd keys add $PROV_KEY --home ${PROV_NODE_DIR} --keyring-backend test --output json > ${PROV_NODE_DIR}/${PROV_KEY}.json 2>&1 +sleep 1 + +# Add stake to user +PROV_ACCOUNT_ADDR=$(jq -r '.address' ${PROV_NODE_DIR}/${PROV_KEY}.json) +interchain-security-pd genesis add-genesis-account $PROV_ACCOUNT_ADDR $USER_COINS --home ${PROV_NODE_DIR} --keyring-backend test +sleep 1 + + +# Stake 1/1000 user's coins +interchain-security-pd genesis gentx $PROV_KEY $STAKE --chain-id provider --home ${PROV_NODE_DIR} --keyring-backend test --moniker $MONIKER +sleep 1 + +interchain-security-pd genesis collect-gentxs --home ${PROV_NODE_DIR} --gentx-dir ${PROV_NODE_DIR}/config/gentx/ +sleep 1 + +sed -i -r "/node =/ s/= .*/= \"tcp:\/\/${NODE_IP}:26658\"/" ${PROV_NODE_DIR}/config/client.toml +sed -i -r 's/timeout_commit = "5s"/timeout_commit = "3s"/g' ${PROV_NODE_DIR}/config/config.toml +sed -i -r 's/timeout_propose = "3s"/timeout_propose = "1s"/g' ${PROV_NODE_DIR}/config/config.toml +sed -i -r 's/minimum-gas-prices = ""/minimum-gas-prices = "0stake"/g' ${PROV_NODE_DIR}/config/app.toml + + +# Start gaia +interchain-security-pd start \ + --home ${PROV_NODE_DIR} \ + --rpc.laddr tcp://${NODE_IP}:26658 \ + --grpc.address ${NODE_IP}:9091 \ + --address tcp://${NODE_IP}:26655 \ + --p2p.laddr tcp://${NODE_IP}:26656 \ + --grpc-web.enable=false &> ${PROV_NODE_DIR}/logs & \ No newline at end of file From 9af41b8da309d3147682e75362d240528433bb65 Mon Sep 17 00:00:00 2001 From: Simon Noetzlin Date: Thu, 29 Aug 2024 15:20:39 +0200 Subject: [PATCH 2/3] add consumer-chain cli command --- contrib/create-consumer-msg.json | 8 ---- contrib/local-node.sh | 66 ------------------------------ x/ccv/provider/client/cli/query.go | 28 +++++++++++++ 3 files changed, 28 insertions(+), 74 deletions(-) delete mode 100644 contrib/create-consumer-msg.json delete mode 100755 contrib/local-node.sh diff --git a/contrib/create-consumer-msg.json b/contrib/create-consumer-msg.json deleted file mode 100644 index 3cd527ca35..0000000000 --- a/contrib/create-consumer-msg.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "chain_id" : "consumer-1", - "metadata": { - "name": "consumer-1-metadata-name", - "description":"consumer-1-metadata-description", - "metadata": "consumer-1-metadata-metadata" - } -} diff --git a/contrib/local-node.sh b/contrib/local-node.sh deleted file mode 100755 index 8974ce3c9f..0000000000 --- a/contrib/local-node.sh +++ /dev/null @@ -1,66 +0,0 @@ -#!/bin/bash -set -eux - -# User balance of stake tokens -USER_COINS="100000000000stake" -# Amount of stake tokens staked -STAKE="100000000stake" -# Node IP address -NODE_IP="127.0.0.1" - -# Home directory -HOME_DIR="$HOME" - -# Validator moniker -MONIKER="coordinator" - -# Validator directory -PROV_NODE_DIR=${HOME_DIR}/provider-${MONIKER} - -# Coordinator key -PROV_KEY=${MONIKER}-key - - -# Clean start -pkill -f interchain-security-pd &> /dev/null || true -rm -rf ${PROV_NODE_DIR} - -# Build file and node directory structure -interchain-security-pd init $MONIKER --chain-id provider --home ${PROV_NODE_DIR} - jq ".app_state.gov.voting_params.voting_period = \"20s\" | .app_state.staking.params.unbonding_time = \"86400s\"" \ - ${PROV_NODE_DIR}/config/genesis.json > \ - ${PROV_NODE_DIR}/edited_genesis.json && mv ${PROV_NODE_DIR}/edited_genesis.json ${PROV_NODE_DIR}/config/genesis.json - -sleep 1 - -# Create account keypair -interchain-security-pd keys add $PROV_KEY --home ${PROV_NODE_DIR} --keyring-backend test --output json > ${PROV_NODE_DIR}/${PROV_KEY}.json 2>&1 -sleep 1 - -# Add stake to user -PROV_ACCOUNT_ADDR=$(jq -r '.address' ${PROV_NODE_DIR}/${PROV_KEY}.json) -interchain-security-pd genesis add-genesis-account $PROV_ACCOUNT_ADDR $USER_COINS --home ${PROV_NODE_DIR} --keyring-backend test -sleep 1 - - -# Stake 1/1000 user's coins -interchain-security-pd genesis gentx $PROV_KEY $STAKE --chain-id provider --home ${PROV_NODE_DIR} --keyring-backend test --moniker $MONIKER -sleep 1 - -interchain-security-pd genesis collect-gentxs --home ${PROV_NODE_DIR} --gentx-dir ${PROV_NODE_DIR}/config/gentx/ -sleep 1 - -sed -i -r "/node =/ s/= .*/= \"tcp:\/\/${NODE_IP}:26658\"/" ${PROV_NODE_DIR}/config/client.toml -sed -i -r 's/timeout_commit = "5s"/timeout_commit = "3s"/g' ${PROV_NODE_DIR}/config/config.toml -sed -i -r 's/timeout_propose = "3s"/timeout_propose = "1s"/g' ${PROV_NODE_DIR}/config/config.toml -sed -i -r 's/minimum-gas-prices = ""/minimum-gas-prices = "0stake"/g' ${PROV_NODE_DIR}/config/app.toml - - -# Start gaia -interchain-security-pd start \ - --home ${PROV_NODE_DIR} \ - --rpc.laddr tcp://${NODE_IP}:26658 \ - --grpc.address ${NODE_IP}:9091 \ - --address tcp://${NODE_IP}:26655 \ - --p2p.laddr tcp://${NODE_IP}:26656 \ - --grpc-web.enable=false &> ${PROV_NODE_DIR}/logs & \ No newline at end of file diff --git a/x/ccv/provider/client/cli/query.go b/x/ccv/provider/client/cli/query.go index 1d6e26350b..800d6b7740 100644 --- a/x/ccv/provider/client/cli/query.go +++ b/x/ccv/provider/client/cli/query.go @@ -39,6 +39,7 @@ func NewQueryCmd() *cobra.Command { cmd.AddCommand(CmdValidatorConsumerCommissionRate()) cmd.AddCommand(CmdBlocksUntilNextEpoch()) cmd.AddCommand(CmdConsumerIdFromClientId()) + cmd.AddCommand(CmdConsumerChain()) return cmd } @@ -553,3 +554,30 @@ func CmdConsumerIdFromClientId() *cobra.Command { return cmd } + +func CmdConsumerChain() *cobra.Command { + cmd := &cobra.Command{ + Use: "consumer-chain [consumer-id]", + Short: "Query the consumer chain associated with the consumer id", + Args: cobra.ExactArgs(1), + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx, err := client.GetClientQueryContext(cmd) + if err != nil { + return err + } + queryClient := types.NewQueryClient(clientCtx) + + req := &types.QueryConsumerChainRequest{ConsumerId: args[0]} + res, err := queryClient.QueryConsumerChain(cmd.Context(), req) + if err != nil { + return err + } + + return clientCtx.PrintProto(res) + }, + } + + flags.AddQueryFlagsToCmd(cmd) + + return cmd +} From d9fbca8a531e49d1b28a44553054631c705a94d5 Mon Sep 17 00:00:00 2001 From: Simon Noetzlin Date: Thu, 29 Aug 2024 15:21:19 +0200 Subject: [PATCH 3/3] fix consumer chains cli bug --- x/ccv/provider/client/cli/query.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/x/ccv/provider/client/cli/query.go b/x/ccv/provider/client/cli/query.go index 800d6b7740..be516d584f 100644 --- a/x/ccv/provider/client/cli/query.go +++ b/x/ccv/provider/client/cli/query.go @@ -89,7 +89,7 @@ func CmdConsumerChains() *cobra.Command { req := &types.QueryConsumerChainsRequest{} - if args[0] != "" { + if len(args) >= 1 && args[0] != "" { phase, err := strconv.ParseInt(args[0], 10, 32) if err != nil { return err @@ -97,7 +97,7 @@ func CmdConsumerChains() *cobra.Command { req.Phase = types.ConsumerPhase(phase) } - if args[1] != "" { + if len(args) == 2 && args[1] != "" { limit, err := strconv.ParseInt(args[1], 10, 32) if err != nil { return err