Skip to content

Commit

Permalink
Merge branch 'master' into vincent/nft
Browse files Browse the repository at this point in the history
  • Loading branch information
chengwenxi authored Jul 20, 2021
2 parents 08cc1c7 + 6098d7e commit 42a99c9
Show file tree
Hide file tree
Showing 491 changed files with 41,823 additions and 40,996 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/linkchecker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- uses: gaurav-nelson/[email protected].12
- uses: gaurav-nelson/[email protected].13
with:
folder-path: "docs"
2 changes: 1 addition & 1 deletion .github/workflows/stale.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ jobs:
stale:
runs-on: ubuntu-latest
steps:
- uses: actions/stale@v3.0.19
- uses: actions/stale@v4
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
stale-pr-message: "This pull request has been automatically marked as stale because it has not had
Expand Down
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ artifacts
# Data - ideally these don't exist
baseapp/data/*
client/lcd/keys/*
mytestnet
.testnets

# Testing
coverage.txt
Expand Down
2 changes: 1 addition & 1 deletion .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ issues:
- text: "ST1016:"
linters:
- stylecheck
- path: "legacy"
- path: "migrations"
text: "SA1019:"
linters:
- staticcheck
Expand Down
98 changes: 90 additions & 8 deletions CHANGELOG.md

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -475,16 +475,16 @@ proto-update-deps:
### Localnet ###
###############################################################################

# Run a 4-node testnet locally
# Run a 4-node testnet locally via docker compose
localnet-start: build-linux localnet-stop
$(if $(shell $(DOCKER) inspect -f '{{ .Id }}' cosmossdk/simd-env 2>/dev/null),$(info found image cosmossdk/simd-env),$(MAKE) -C contrib/images simd-env)
if ! [ -f build/node0/simd/config/genesis.json ]; then $(DOCKER) run --rm \
if ! test -f build/node0/simd/config/genesis.json; then $(DOCKER) run --rm \
--user $(shell id -u):$(shell id -g) \
-v $(BUILDDIR):/simd:Z \
-v /etc/group:/etc/group:ro \
-v /etc/passwd:/etc/passwd:ro \
-v /etc/shadow:/etc/shadow:ro \
cosmossdk/simd-env testnet --v 4 -o . --starting-ip-address 192.168.10.2 --keyring-backend=test ; fi
cosmossdk/simd-env testnet init-files --v 4 -o . --starting-ip-address 192.168.10.2 --keyring-backend=test ; fi
docker-compose up -d

localnet-stop:
Expand Down
37 changes: 17 additions & 20 deletions baseapp/abci.go
Original file line number Diff line number Diff line change
Expand Up @@ -405,7 +405,7 @@ func (app *BaseApp) Query(req abci.RequestQuery) (res abci.ResponseQuery) {
// ref: https://github.com/cosmos/cosmos-sdk/pull/8039
defer func() {
if r := recover(); r != nil {
res = sdkerrors.QueryResult(sdkerrors.Wrapf(sdkerrors.ErrPanic, "%v", r))
res = sdkerrors.QueryResult(sdkerrors.Wrapf(sdkerrors.ErrPanic, "%v", r), app.trace)
}
}()

Expand All @@ -422,7 +422,7 @@ func (app *BaseApp) Query(req abci.RequestQuery) (res abci.ResponseQuery) {

path := splitPath(req.Path)
if len(path) == 0 {
sdkerrors.QueryResult(sdkerrors.Wrap(sdkerrors.ErrUnknownRequest, "no query path provided"))
sdkerrors.QueryResult(sdkerrors.Wrap(sdkerrors.ErrUnknownRequest, "no query path provided"), app.trace)
}

switch path[0] {
Expand All @@ -440,7 +440,7 @@ func (app *BaseApp) Query(req abci.RequestQuery) (res abci.ResponseQuery) {
return handleQueryCustom(app, path, req)
}

return sdkerrors.QueryResult(sdkerrors.Wrap(sdkerrors.ErrUnknownRequest, "unknown query path"))
return sdkerrors.QueryResult(sdkerrors.Wrap(sdkerrors.ErrUnknownRequest, "unknown query path"), app.trace)
}

// ListSnapshots implements the ABCI interface. It delegates to app.snapshotManager if set.
Expand Down Expand Up @@ -570,12 +570,12 @@ func (app *BaseApp) ApplySnapshotChunk(req abci.RequestApplySnapshotChunk) abci.
func (app *BaseApp) handleQueryGRPC(handler GRPCQueryHandler, req abci.RequestQuery) abci.ResponseQuery {
ctx, err := app.createQueryContext(req.Height, req.Prove)
if err != nil {
return sdkerrors.QueryResult(err)
return sdkerrors.QueryResult(err, app.trace)
}

res, err := handler(ctx, req)
if err != nil {
res = sdkerrors.QueryResult(gRPCErrorToSDKError(err))
res = sdkerrors.QueryResult(gRPCErrorToSDKError(err), app.trace)
res.Height = req.Height
return res
}
Expand Down Expand Up @@ -746,7 +746,7 @@ func handleQueryApp(app *BaseApp, path []string, req abci.RequestQuery) abci.Res

gInfo, res, err := app.Simulate(txBytes)
if err != nil {
return sdkerrors.QueryResult(sdkerrors.Wrap(err, "failed to simulate tx"))
return sdkerrors.QueryResult(sdkerrors.Wrap(err, "failed to simulate tx"), app.trace)
}

simRes := &sdk.SimulationResponse{
Expand All @@ -756,7 +756,7 @@ func handleQueryApp(app *BaseApp, path []string, req abci.RequestQuery) abci.Res

bz, err := codec.ProtoMarshalJSON(simRes, app.interfaceRegistry)
if err != nil {
return sdkerrors.QueryResult(sdkerrors.Wrap(err, "failed to JSON encode simulation response"))
return sdkerrors.QueryResult(sdkerrors.Wrap(err, "failed to JSON encode simulation response"), app.trace)
}

return abci.ResponseQuery{
Expand All @@ -773,23 +773,22 @@ func handleQueryApp(app *BaseApp, path []string, req abci.RequestQuery) abci.Res
}

default:
return sdkerrors.QueryResult(sdkerrors.Wrapf(sdkerrors.ErrUnknownRequest, "unknown query: %s", path))
return sdkerrors.QueryResult(sdkerrors.Wrapf(sdkerrors.ErrUnknownRequest, "unknown query: %s", path), app.trace)
}
}

return sdkerrors.QueryResult(
sdkerrors.Wrap(
sdkerrors.ErrUnknownRequest,
"expected second parameter to be either 'simulate' or 'version', neither was present",
),
)
), app.trace)
}

func handleQueryStore(app *BaseApp, path []string, req abci.RequestQuery) abci.ResponseQuery {
// "/store" prefix for store queries
queryable, ok := app.cms.(sdk.Queryable)
if !ok {
return sdkerrors.QueryResult(sdkerrors.Wrap(sdkerrors.ErrUnknownRequest, "multistore doesn't support queries"))
return sdkerrors.QueryResult(sdkerrors.Wrap(sdkerrors.ErrUnknownRequest, "multistore doesn't support queries"), app.trace)
}

req.Path = "/" + strings.Join(path[1:], "/")
Expand All @@ -799,8 +798,7 @@ func handleQueryStore(app *BaseApp, path []string, req abci.RequestQuery) abci.R
sdkerrors.Wrap(
sdkerrors.ErrInvalidRequest,
"cannot query with proof when height <= 1; please provide a valid height",
),
)
), app.trace)
}

resp := queryable.Query(req)
Expand All @@ -815,8 +813,7 @@ func handleQueryP2P(app *BaseApp, path []string) abci.ResponseQuery {
return sdkerrors.QueryResult(
sdkerrors.Wrap(
sdkerrors.ErrUnknownRequest, "path should be p2p filter <addr|id> <parameter>",
),
)
), app.trace)
}

var resp abci.ResponseQuery
Expand All @@ -833,7 +830,7 @@ func handleQueryP2P(app *BaseApp, path []string) abci.ResponseQuery {
}

default:
resp = sdkerrors.QueryResult(sdkerrors.Wrap(sdkerrors.ErrUnknownRequest, "expected second parameter to be 'filter'"))
resp = sdkerrors.QueryResult(sdkerrors.Wrap(sdkerrors.ErrUnknownRequest, "expected second parameter to be 'filter'"), app.trace)
}

return resp
Expand All @@ -846,17 +843,17 @@ func handleQueryCustom(app *BaseApp, path []string, req abci.RequestQuery) abci.
// The QueryRouter routes using path[1]. For example, in the path
// "custom/gov/proposal", QueryRouter routes using "gov".
if len(path) < 2 || path[1] == "" {
return sdkerrors.QueryResult(sdkerrors.Wrap(sdkerrors.ErrUnknownRequest, "no route for custom query specified"))
return sdkerrors.QueryResult(sdkerrors.Wrap(sdkerrors.ErrUnknownRequest, "no route for custom query specified"), app.trace)
}

querier := app.queryRouter.Route(path[1])
if querier == nil {
return sdkerrors.QueryResult(sdkerrors.Wrapf(sdkerrors.ErrUnknownRequest, "no custom querier found for route %s", path[1]))
return sdkerrors.QueryResult(sdkerrors.Wrapf(sdkerrors.ErrUnknownRequest, "no custom querier found for route %s", path[1]), app.trace)
}

ctx, err := app.createQueryContext(req.Height, req.Prove)
if err != nil {
return sdkerrors.QueryResult(err)
return sdkerrors.QueryResult(err, app.trace)
}

// Passes the rest of the path as an argument to the querier.
Expand All @@ -865,7 +862,7 @@ func handleQueryCustom(app *BaseApp, path []string, req abci.RequestQuery) abci.
// []string{"proposal", "test"} as the path.
resBytes, err := querier(ctx, path[2:], req)
if err != nil {
res := sdkerrors.QueryResult(err)
res := sdkerrors.QueryResult(err, app.trace)
res.Height = req.Height
return res
}
Expand Down
7 changes: 5 additions & 2 deletions baseapp/baseapp.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ import (
"github.com/cosmos/cosmos-sdk/store/rootmulti"
sdk "github.com/cosmos/cosmos-sdk/types"
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
"github.com/cosmos/cosmos-sdk/x/auth/legacy/legacytx"
sdktx "github.com/cosmos/cosmos-sdk/types/tx"
"github.com/cosmos/cosmos-sdk/x/auth/migrations/legacytx"
)

const (
Expand Down Expand Up @@ -449,6 +450,8 @@ func (app *BaseApp) StoreConsensusParams(ctx sdk.Context, cp *abci.ConsensusPara
app.paramStore.Set(ctx, ParamStoreKeyBlockParams, cp.Block)
app.paramStore.Set(ctx, ParamStoreKeyEvidenceParams, cp.Evidence)
app.paramStore.Set(ctx, ParamStoreKeyValidatorParams, cp.Validator)
// We're explicitly not storing the Tendermint app_version in the param store. It's
// stored instead in the x/upgrade store, with its own bump logic.
}

// getMaximumBlockGas gets the maximum gas from the consensus params. It panics
Expand Down Expand Up @@ -508,7 +511,7 @@ func validateBasicTxMsgs(msgs []sdk.Msg) error {
}

for _, msg := range msgs {
err := msg.ValidateBasic()
err := sdktx.ValidateMsg(msg)
if err != nil {
return err
}
Expand Down
32 changes: 16 additions & 16 deletions baseapp/baseapp_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import (
"github.com/cosmos/cosmos-sdk/testutil/testdata"
sdk "github.com/cosmos/cosmos-sdk/types"
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
"github.com/cosmos/cosmos-sdk/x/auth/legacy/legacytx"
"github.com/cosmos/cosmos-sdk/x/auth/migrations/legacytx"
)

var (
Expand Down Expand Up @@ -717,10 +717,10 @@ func (msg msgCounter) String() string { return "TODO" }
func (msg msgCounter) ProtoMessage() {}

// Implements Msg
func (msg msgCounter) Route() string { return routeMsgCounter }
func (msg msgCounter) Type() string { return "counter1" }
func (msg msgCounter) GetSignBytes() []byte { return nil }
func (msg msgCounter) GetSigners() []sdk.AccAddress { return nil }
func (msg msgCounter) Route() string { return routeMsgCounter }
func (msg msgCounter) Type() string { return "counter1" }
func (msg msgCounter) GetSignBytes() []byte { return nil }
func (msg msgCounter) GetSigners() []string { return nil }
func (msg msgCounter) ValidateBasic() error {
if msg.Counter >= 0 {
return nil
Expand Down Expand Up @@ -762,10 +762,10 @@ func (msg msgCounter2) String() string { return "TODO" }
func (msg msgCounter2) ProtoMessage() {}

// Implements Msg
func (msg msgCounter2) Route() string { return routeMsgCounter2 }
func (msg msgCounter2) Type() string { return "counter2" }
func (msg msgCounter2) GetSignBytes() []byte { return nil }
func (msg msgCounter2) GetSigners() []sdk.AccAddress { return nil }
func (msg msgCounter2) Route() string { return routeMsgCounter2 }
func (msg msgCounter2) Type() string { return "counter2" }
func (msg msgCounter2) GetSignBytes() []byte { return nil }
func (msg msgCounter2) GetSigners() []string { return nil }
func (msg msgCounter2) ValidateBasic() error {
if msg.Counter >= 0 {
return nil
Expand All @@ -779,13 +779,13 @@ type msgKeyValue struct {
Value []byte
}

func (msg msgKeyValue) Reset() {}
func (msg msgKeyValue) String() string { return "TODO" }
func (msg msgKeyValue) ProtoMessage() {}
func (msg msgKeyValue) Route() string { return routeMsgKeyValue }
func (msg msgKeyValue) Type() string { return "keyValue" }
func (msg msgKeyValue) GetSignBytes() []byte { return nil }
func (msg msgKeyValue) GetSigners() []sdk.AccAddress { return nil }
func (msg msgKeyValue) Reset() {}
func (msg msgKeyValue) String() string { return "TODO" }
func (msg msgKeyValue) ProtoMessage() {}
func (msg msgKeyValue) Route() string { return routeMsgKeyValue }
func (msg msgKeyValue) Type() string { return "keyValue" }
func (msg msgKeyValue) GetSignBytes() []byte { return nil }
func (msg msgKeyValue) GetSigners() []string { return nil }
func (msg msgKeyValue) ValidateBasic() error {
if msg.Key == nil {
return sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, "key cannot be nil")
Expand Down
20 changes: 3 additions & 17 deletions client/context.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,9 @@ import (
// Context implements a typical context created in SDK modules for transaction
// handling and queries.
type Context struct {
FromAddress sdk.AccAddress
Client rpcclient.Client
ChainID string
// Deprecated: Codec codec will be changed to Codec: codec.Codec
JSONCodec codec.JSONCodec
FromAddress sdk.AccAddress
Client rpcclient.Client
ChainID string
Codec codec.Codec
InterfaceRegistry codectypes.InterfaceRegistry
Input io.Reader
Expand Down Expand Up @@ -74,20 +72,8 @@ func (ctx Context) WithInput(r io.Reader) Context {
return ctx
}

// Deprecated: WithJSONCodec returns a copy of the Context with an updated JSONCodec.
func (ctx Context) WithJSONCodec(m codec.JSONCodec) Context {
ctx.JSONCodec = m
// since we are using ctx.Codec everywhere in the SDK, for backward compatibility
// we need to try to set it here as well.
if c, ok := m.(codec.Codec); ok {
ctx.Codec = c
}
return ctx
}

// WithCodec returns a copy of the Context with an updated Codec.
func (ctx Context) WithCodec(m codec.Codec) Context {
ctx.JSONCodec = m
ctx.Codec = m
return ctx
}
Expand Down
3 changes: 2 additions & 1 deletion client/context_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,8 @@ func TestCLIQueryConn(t *testing.T) {
cfg := network.DefaultConfig()
cfg.NumValidators = 1

n := network.New(t, cfg)
n, err := network.New(t, t.TempDir(), cfg)
require.NoError(t, err)
defer n.Cleanup()

testClient := testdata.NewQueryClient(n.Validators[0].ClientCtx)
Expand Down
26 changes: 18 additions & 8 deletions client/docs/config.json
Original file line number Diff line number Diff line change
@@ -1,17 +1,11 @@
{
"swagger": "2.0",
"info": {
"title": "Cosmos SDK - Legacy REST and gRPC Gateway docs",
"description": "A REST interface for state queries, legacy transactions",
"title": "Cosmos SDK - gRPC Gateway docs",
"description": "A REST interface for state queries",
"version": "1.0.0"
},
"apis": [
{
"url": "./client/docs/swagger_legacy.yaml",
"dereference": {
"circular": "ignore"
}
},
{
"url": "./tmp-swagger-gen/cosmos/auth/v1beta1/query.swagger.json",
"operationIds": {
Expand Down Expand Up @@ -106,6 +100,22 @@
"Params": "UpgradeParams"
}
}
},
{
"url": "./tmp-swagger-gen/cosmos/authz/v1beta1/query.swagger.json",
"operationIds": {
"rename": {
"Params": "AuthzParams"
}
}
},
{
"url": "./tmp-swagger-gen/cosmos/feegrant/v1beta1/query.swagger.json",
"operationIds": {
"rename": {
"Params": "FeegrantParams"
}
}
}
]
}
8 changes: 5 additions & 3 deletions client/docs/statik/statik.go

Large diffs are not rendered by default.

Loading

0 comments on commit 42a99c9

Please sign in to comment.