Skip to content

Commit

Permalink
TEST-50 address nit from Aidan's PR review
Browse files Browse the repository at this point in the history
  • Loading branch information
riley-stride committed Jun 10, 2022
1 parent d172349 commit 9046671
Show file tree
Hide file tree
Showing 17 changed files with 87 additions and 196 deletions.
28 changes: 1 addition & 27 deletions Dockerfile.icq
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
FROM golang:1.17-bullseye

# TODO uncomment update
# TODO uncomment update if installs are breaking below
# RUN apt update
RUN apt install git

Expand All @@ -9,24 +9,6 @@ RUN apt-get install jq --yes

WORKDIR /src/app

# TODO remove PAT | access private stride repo using the below personal access token, per https://www.digitalocean.com/community/tutorials/how-to-use-a-private-go-module-in-your-own-project
# RUN export GOPRIVATE=github.com/Stride-Labs/stride
# RUN go env -w GOPRIVATE=github.com/Stride-Labs/stride
# ENV GOPRIVATE github.com/Stride-Labs/stride
# RUN touch ~/.netrc
# RUN echo $GOPRIVATE
# RUN echo "machine github.com login riley-stride password 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" >> ~/.netrc
# RUN cat ~/.netrc
# RUN echo '[url "ssh://[email protected]/"]' >> ~/.gitconfig
# RUN echo ' insteadOf = https://github.com/' >> ~/.gitconfig
# RUN go get "github.com/Stride-Labs/stride"

# ENV GIT_SSH_COMMAND="ssh -i /src/app/test -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no"
# RUN git config --global url."[email protected]:".insteadOf "https://github.com/"
## TODO(security) switch this for a proper download without PAT
# TODO move token to gitignored file and echo it here
# RUN git clone https://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:[email protected]/Stride-Labs/interchain-queries.git
# RUN git clone https://github.com/Stride-Labs/interchain-queries.git
RUN git clone https://github.com/Stride-Labs/icq.git
RUN cp -r icq/* .
RUN rm -rf interchain-queries
Expand All @@ -36,12 +18,7 @@ RUN mkdir stride_ref
RUN mkdir stride_ref/stride
COPY . /src/app/stride_ref/stride
WORKDIR /src/app/stride_ref/stride
# RUN go mod download
WORKDIR /src/app

# RUN go get github.com/ingenuity-build/interchain-queries/cmd
# RUN go get github.com/ingenuity-build/interchain-queries/pkg/runner

RUN go get github.com/Stride-Labs/interchain-queries/cmd
RUN go get github.com/Stride-Labs/interchain-queries/pkg/runner
RUN go mod download
Expand All @@ -51,8 +28,5 @@ RUN ln -s /src/app/interchain-queries /usr/local/bin
RUN adduser --system --home /icq --disabled-password --disabled-login icq -U 1000
USER icq

# CMD ["interchain-queries", "run"]




55 changes: 37 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,28 @@
# stride
# Stride
Bringing liquid staking to Cosmos

## Making changes to this repository
The easiest way to develop cosmos-sdk applications is by using the ignite cli to scaffold code. Ignite (developed by the core cosmos team at Tendermint) makes it possible to scaffold new chains, run relayers, build cosmos related proto files, add messages/queries, add new data structures and more. The drawback of creating thousands of lines of code using ignite is that it is difficult to discern which changes were made by the ignite cli and which changes were made manually by developers. To make it easier to review code written using ignite and to make it easier to retrace our steps if something breaks later, add a commit for each ignite command directly after executing it.

For example, adding a new message type and updating the logic of that message would be two commits.
```
// add the new data type
>>> ignite scaffold list loan amount fee collateral deadline state borrower lender
>>> git add . && git commit -m 'ignite scaffold list loan amount fee collateral deadline state borrower lender'
// make some updates to the keeper method in your code editor
>>> git add . && git commit -m 'update loan list keeper method'
```

An example of a PR using this strategy can be found [here](https://github.com/Stride-Labs/stride/pull/1). Notice, it's easy to differentiate between changes made by ignite and those made manually by reviewing commits. For example, in commit fd3e254bc0, it's easy to see that [a few lines were changes manually](https://github.com/Stride-Labs/stride/pull/1/commits/fd3e254bc0844fe65f5e98f12b366feef2a285f9) even though nearly ~300k LOC were scaffolded.

## Code review format
Opening a PR will automatically create Summary and Test plan fields in the PR description. In the summary, add a high-level summary of what the change entails and the ignite commands run.
**Summary**
Updating some code.
**Test plan**
yolo, we're in testnet

## What is Stride?

**stride** is a blockchain built using Cosmos SDK and Tendermint and created with [Starport](https://starport.com).

Expand Down Expand Up @@ -57,44 +81,39 @@ curl https://get.starport.com/Stride-Labs/stride@latest! | sudo bash

## Build

Please run `make init` to build and serve 3 Stride nodes, 3 Gaia nodes, and 1 Hermes relayer on docker images.

You can run `make init build=stride` (the default option) to
Please run `make init` to build and serve 3 Stride nodes, 3 Gaia nodes, and 1 Hermes relayer on docker images.

You can run `make init build=stride` (the default option) to
1. Run `ignite chain build` to build the Stride binary
2. Rebuild Stride, using cache when possible
3. Spin up the 7 docker containers and start all processes

Alternatively, you can run `make init build=strideall` to re-build the docker image from scratch.

If you want to re-build all images, you can run `make init build=base` to:

1. Run `ignite chain build` to build the Stride binary
2. Rebuild Stride, Gaia, Hermes, and ICQ docker images, using cache when possible
2. Rebuild Stride, Gaia, Hermes and ICQ docker images, using cache when possible
3. Spin up the 7 docker containers and start all processes

Alternatively, you can run `make init build=all` to

Alternatively, you can run `make init build=all` to
1. Run `ignite chain build` to build the Stride binary
2. Fully rebuild Stride, Gaia, Hermes, and ICQ docker images, ignoring the cache
2. Fully rebuild Stride, Gaia, Hermes and ICQ docker images, ignoring the cache
3. Spin up the 7 docker containers and start all processes

Or, if you just want to re-serve, run `make init build=none` to

Or, if you just want to re-serve, run `make init build=none` to
1. Use existing Stride binary
2. Use existing docker images
2. Use existing docker images
3. Spin up the 7 docker containers and start all processes

## Build (Lower Level)

Proceed with lower-level building at your own discretion. Only `make init` is well-supported.
Proceed with lower-level building at your own discretion. Only `make init` is well-supported.

You can run `sh scripts/init.sh` to achieve the same output as the above. The following flags are supported

1. `-b` This will run `ignite chain build`
2. `-d` This will re-build all docker images, using cache
3. `-f` This will re-build all docker images, ignoring cache.
4. `-s` This will re-build Stride's docker images, using cache.
5. `-a` This will re-build Stride's docker images, ignoring cache.
3. `-f` This will re-build all docker images, ignoring cache.
4. `-s` This will re-build Stride's docker images, using cache.
5. `-a` This will re-build Stride's docker images, ignoring cache.

At the end, all 7 docker images will be served.
At the end, all 7 docker images will be served.
4 changes: 0 additions & 4 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -361,17 +361,13 @@ func NewStrideApp(
appCodec, keys[ibchost.StoreKey], app.GetSubspace(ibchost.ModuleName), app.StakingKeeper, app.UpgradeKeeper, scopedIBCKeeper,
)

// interchainQueryModule := interchainquery.NewAppModule(appCodec, app.InterchainqueryKeeper)
// icaControllerIBCModule := icacontroller.NewIBCModule(app.ICAControllerKeeper, interchainQueryModule)

// register the proposal types
govRouter := govtypes.NewRouter()
govRouter.AddRoute(govtypes.RouterKey, govtypes.ProposalHandler).
AddRoute(paramproposal.RouterKey, params.NewParamChangeProposalHandler(app.ParamsKeeper)).
AddRoute(distrtypes.RouterKey, distr.NewCommunityPoolSpendProposalHandler(app.DistrKeeper)).
AddRoute(upgradetypes.RouterKey, upgrade.NewSoftwareUpgradeProposalHandler(app.UpgradeKeeper)).
AddRoute(ibcclienttypes.RouterKey, ibcclient.NewClientProposalHandler(app.IBCKeeper.ClientKeeper))
// AddRoute(interchainquerytypes.ModuleName, ibcclient.NewClientProposalHandler(icaControllerIBCModule))

// Create Transfer Keepers
app.TransferKeeper = ibctransferkeeper.NewKeeper(
Expand Down
14 changes: 1 addition & 13 deletions proto/interchainquery/genesis.proto
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ message Query {
string chain_id = 3;
string query_type = 4;
bytes request = 8;
// TODO(TEST-66) add proofops
map<string, string> query_parameters = 5;
string period = 6 [
(cosmos_proto.scalar) = "cosmos.Int",
Expand Down Expand Up @@ -47,17 +48,4 @@ message GenesisState {

// Query defines the gRPC querier service.
service QueryService {
// QueryInterchainAccountFromAddress returns the interchain account for given owner address on a given connection pair
rpc InterchainAccountFromAddress(QueryServiceInterchainAccountFromAddressRequest) returns (QueryServiceInterchainAccountFromAddressResponse);
}

// QueryInterchainAccountFromAddressRequest is the request type for the Query/InterchainAccountAddress RPC
message QueryServiceInterchainAccountFromAddressRequest {
string owner = 1;
string connection_id = 2 [(gogoproto.moretags) = "yaml:\"connection_id\""];
}

// QueryInterchainAccountFromAddressResponse the response type for the Query/InterchainAccountAddress RPC
message QueryServiceInterchainAccountFromAddressResponse {
string interchain_account_address = 1 [(gogoproto.moretags) = "yaml:\"interchain_account_address\""];
}
3 changes: 1 addition & 2 deletions proto/interchainquery/tx.proto
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,11 @@ service Msg {
returns (MsgSubmitQueryResponseResponse) {
option (google.api.http) = {
post : "/interchainquery/tx/submitquery"
// post : "/interchainquery/tx/v1beta1/submitquery"
body : "*"
};
};
rpc QueryBalance(MsgQueryBalance) returns (MsgQueryBalanceResponse);
rpc QueryExchangerate(MsgQueryExchangerate) returns (MsgQueryExchangerateResponse);
rpc QueryExchangerate(MsgQueryExchangerate) returns (MsgQueryExchangerateResponse);
rpc QueryDelegatedbalance(MsgQueryDelegatedbalance) returns (MsgQueryDelegatedbalanceResponse);
// this line is used by starport scaffolding # proto/tx/rpc
}
Expand Down
6 changes: 3 additions & 3 deletions scripts/account_vars.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ STRIDE_ADDRESS_2=$($BASE_RUN keys show val2 --home $STATE/stride2 --keyring-back
STRIDE_ADDRESS_3=$($BASE_RUN keys show val3 --home $STATE/stride3 --keyring-backend test -a)

# Gaia
GAIA1_EXEC="docker-compose --ansi never exec -T gaia1 gaiad --home /gaia/.gaiad"
GAIA2_EXEC="docker-compose --ansi never exec -T gaia2 gaiad --home /gaia/.gaiad"
GAIA3_EXEC="docker-compose --ansi never exec -T gaia3 gaiad --home /gaia/.gaiad"
GAIA1_EXEC="docker-compose --ansi never exec -T gaia1 gaiad --home /gaia/.gaiad --chain-id GAIA"
GAIA2_EXEC="docker-compose --ansi never exec -T gaia2 gaiad --home /gaia/.gaiad --chain-id GAIA"
GAIA3_EXEC="docker-compose --ansi never exec -T gaia3 gaiad --home /gaia/.gaiad --chain-id GAIA"
GAIA_ADDRESS_1=$($GAIA1_EXEC keys show gval1 --keyring-backend test -a --home=/gaia/.gaiad)
GAIA_ADDRESS_2=$($GAIA2_EXEC keys show gval2 --keyring-backend test -a --home=/gaia/.gaiad)
GAIA_ADDRESS_3=$($GAIA3_EXEC keys show gval3 --keyring-backend test -a --home=/gaia/.gaiad)
Expand Down
3 changes: 2 additions & 1 deletion scripts/init.sh
Original file line number Diff line number Diff line change
Expand Up @@ -136,11 +136,12 @@ docker-compose build icq --no-cache
ICQ_RUN="docker-compose --ansi never run -T icq interchain-queries"

echo "\nAdd ICQ relayer addresses for Stride and Gaia:"
## TODO replace XXX-testnet in lens config with stride_1 and gaia_1 to match env vars here
# TODO(TEST-82) redefine stride-testnet in lens' config to $main_chain and gaia-testnet to $main-gaia-chain, then replace those below with $main_chain and $main_gaia_chain
$ICQ_RUN keys restore test "$ICQ_STRIDE_KEY" --chain stride-testnet
$ICQ_RUN keys restore test "$ICQ_GAIA_KEY" --chain gaia-testnet

echo "\nICQ addresses for Stride and Gaia:"
# TODO(TEST-83) pull these addresses dynamically using jq
ICQ_ADDRESS_STRIDE="stride12vfkpj7lpqg0n4j68rr5kyffc6wu55dzqewda4"
# echo $ICQ_ADDRESS_STRIDE
ICQ_ADDRESS_GAIA="cosmos1g6qdx6kdhpf000afvvpte7hp0vnpzapuyxp8uf"
Expand Down
7 changes: 6 additions & 1 deletion scripts/test_icq.sh
Original file line number Diff line number Diff line change
@@ -1,14 +1,19 @@
#!/bin/bash

# TODO(TEST-80) migrate tests to bats

STR1_EXEC="docker-compose --ansi never exec -T stride1 strided --home /stride/.strided --chain-id STRIDE"
GAIA1_EXEC="docker-compose --ansi never exec -T gaia1 gaiad --home /gaia/.gaiad"
GAIA1_EXEC="docker-compose --ansi never exec -T gaia1 gaiad --home /gaia/.gaiad --chain-id GAIA""
ICQ_EXEC="docker-compose --ansi never exec -T icq interchain-queries"
# Set up: fund account on Stride
# TODO(TEST-83) pull these addresses dynamically using jq
$STR1_EXEC tx bank send val1 stride12vfkpj7lpqg0n4j68rr5kyffc6wu55dzqewda4 5000000ustrd \
--keyring-backend test -y
sleep 10
# # Test: query balance
# TODO(TEST-83) pull these addresses dynamically using jq
$STR1_EXEC tx interchainquery query-balance GAIA cosmos1t2aqq3c6mt8fa6l5ady44manvhqf77sywjcldv uatom \
--connection-id connection-1 --keyring-backend test -y --from val1
sleep 15
Expand Down
1 change: 0 additions & 1 deletion x/interchainquery/client/cli/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,5 @@ func GetQueryCmd() *cobra.Command {
RunE: client.ValidateCmd,
}

// cmd.AddCommand(getInterchainAccountCmd())
return cmd
}
2 changes: 2 additions & 0 deletions x/interchainquery/client/cli/tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ func GetTxCmd() *cobra.Command {

cmd.AddCommand(
QueryBalanceCmd(),
// TODO(TEST-53) remove cli access to ICQ queries pre-launch
SubmitQueryResponse(),
)
cmd.AddCommand(CmdQueryExchangerate())
Expand Down Expand Up @@ -75,6 +76,7 @@ func QueryBalanceCmd() *cobra.Command {

func SubmitQueryResponse() *cobra.Command {
cmd := &cobra.Command{
// TODO(TEST-77) camel case
Use: "submitqueryresponse [chain_id] [query_id] [result] [height] [from_address]",
Short: `Submit Query Response.`,
Long: `
Expand Down
2 changes: 2 additions & 0 deletions x/interchainquery/client/cli/tx_query_exchangerate.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,10 @@ import (

var _ = strconv.Itoa(0)

// TODO(TEST-78) rename from query-XXX => update-XXX
func CmdQueryExchangerate() *cobra.Command {
cmd := &cobra.Command{
// TODO(TEST-77) camel case
Use: "query-exchangerate [chain-id]",
Short: "Broadcast message query-exchangerate",
Args: cobra.ExactArgs(1),
Expand Down
2 changes: 1 addition & 1 deletion x/interchainquery/keeper/abci.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ func (k Keeper) EndBlocker(ctx sdk.Context) {
sdk.NewAttribute(types.AttributeKeyChainId, queryInfo.ChainId),
sdk.NewAttribute(types.AttributeKeyConnectionId, queryInfo.ConnectionId),
sdk.NewAttribute(types.AttributeKeyType, queryInfo.QueryType),
// TODO add height
// TODO(TEST-79) understand and use proper height
sdk.NewAttribute(types.AttributeKeyHeight, "0"),
sdk.NewAttribute(types.AttributeKeyRequest, hex.EncodeToString(queryInfo.Request)),
)
Expand Down
4 changes: 0 additions & 4 deletions x/interchainquery/keeper/callbacks.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,6 @@ func (k Keeper) CallbackHandler() Callbacks {
return Callbacks{k, make(map[string]Callback)}
}

// // callback handler
// func (c Callbacks) Call(id string, ctx sdk.Context, args proto.Message) error {
// return c.callbacks[id](c.k, ctx, args)
// }
//callback handler
func (c Callbacks) Call(ctx sdk.Context, id string, args []byte, query types.Query) error {
return c.callbacks[id](c.k, ctx, args, query)
Expand Down
6 changes: 4 additions & 2 deletions x/interchainquery/keeper/keeper.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,16 @@ import (

// Keeper of this module maintains collections of registered zones.
type Keeper struct {
cdc codec.Codec
storeKey sdk.StoreKey
cdc codec.Codec
storeKey sdk.StoreKey
// TODO(TEST-80) remove stakeibc and bankkeeper access once exchrage logic moves to stakeibc module
BankKeeper bankkeeper.Keeper
StakeibcKeeper stakeibckeeper.Keeper
callbacks map[string]types.QueryCallbacks
}

// NewKeeper returns a new instance of zones Keeper
// TODO(TEST-80) remove stakeibc and bankkeeper access once exchrage logic moves to stakeibc module
func NewKeeper(cdc codec.Codec, storeKey sdk.StoreKey, bankKeeper bankkeeper.Keeper, stakeibcKeeper stakeibckeeper.Keeper) Keeper {
return Keeper{
cdc: cdc,
Expand Down
Loading

0 comments on commit 9046671

Please sign in to comment.