Skip to content

Commit

Permalink
[backports] v0.40.0-rc1 (#7590)
Browse files Browse the repository at this point in the history
* Update Encoding Doc for 0.40 (#7430)

* Remove deprecated docs and add first guidelines to protobuf migration

* Add conventions

* Reorder and add more FAQ doc

* Update guidelines for pb msg definitions

* Use commit hash in github links

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>

* docs: Update "Basics" section (#7416)

* Prettier

* docs: Update "Basics" section

* appcli -> appd

* Better wording

* Fix to appCodec

* Add gRPC mention

* Add grpc

* Reference simapp code

* Update docs/basics/accounts.md

Co-authored-by: Marie Gauthier <marie.gauthier63@gmail.com>

* Add section about gRPC query services

* Optional LegacyQuerierHandler

* Clearer docs

* Update docs/basics/app-anatomy.md

Co-authored-by: Marie Gauthier <marie.gauthier63@gmail.com>

* Update docs/basics/app-anatomy.md

Co-authored-by: Federico Kunze <31522760+fedekunze@users.noreply.github.com>

* Address comments

* Address comments

* Update docs/basics/accounts.md

Co-authored-by: Marie Gauthier <marie.gauthier63@gmail.com>
Co-authored-by: Federico Kunze <31522760+fedekunze@users.noreply.github.com>

* Fix misbehaviour handling for solo machine (#7515)

* add timestamp to SignatureAndData

Add timestamp field to signature and data. Add ValidateBasic check for timestamp. Add ValidateBasic test. Update misbehaviour handler to use supplied timestamp.

* fix typo

* add timestamp check

* fix lint

Co-authored-by: Federico Kunze <31522760+fedekunze@users.noreply.github.com>

* update solo machine specs (#7512)

* update solo machine specs

* update concepts

* self review fixes

* Apply suggestions from code review

* add note on upgarding solo machines

Co-authored-by: Federico Kunze <31522760+fedekunze@users.noreply.github.com>

* Corrected 'unsafe-reset-all' help text (#7504)

* Merge PR #7415: Return empty store tree on non-existing version

* tendermint: update sdk to rc5 (#7527)

* update sdk to rc5

* Update baseapp/params.go

Co-authored-by: Aleksandr Bezobchuk <alexanderbez@users.noreply.github.com>

* Bump github.com/spf13/cobra from 1.0.0 to 1.1.0 (#7553)

Bumps [github.com/spf13/cobra](https://github.com/spf13/cobra) from 1.0.0 to 1.1.0.
- [Release notes](https://github.com/spf13/cobra/releases)
- [Changelog](https://github.com/spf13/cobra/blob/master/CHANGELOG.md)
- [Commits](spf13/cobra@v1.0.0...v1.1.0)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* remove test_utils.go in tm client (#7522)

* remove test_utils from tm client

* fix build

* fix lint?

* fix lint?

* apply @fedekunze review suggestion

* add tests as per @alessio suggestion

* fix typo

* ibc: cleanup channel types test (#7521)

* Update Building Modules documentation (#7473)

* Update module-manager.md

* Update modules #messages doc

* Fix typo

* Update message implementation example link

* Update messages-and-queries.md#queries doc

* Update querier.md

* Update handler.md

* Update links in beginblock-endblock.md

* Update keeper.md

* Update invariants.md

* Update genesis.md

* Update module-interfaces.md#transaction-commands

* Update module-interfaces.md#query-commands

* Update module-interfaces.md#flags

* Update module-interfaces.md#rest

* Update structure.md

* Update module-interfaces.md#grpc

* Update errors.md

* Update module-interfaces.md#grpc-gateway-rest

* Add more info on swagger

* Address comments

* Fix go.sum

* Fix app-anatomy.md

* Update docs/building-modules/module-interfaces.md

Co-authored-by: Federico Kunze <31522760+fedekunze@users.noreply.github.com>

* Update docs/building-modules/querier.md

Co-authored-by: Federico Kunze <31522760+fedekunze@users.noreply.github.com>

* Update docs/building-modules/querier.md

Co-authored-by: Federico Kunze <31522760+fedekunze@users.noreply.github.com>

* Update docs/building-modules/module-interfaces.md

Co-authored-by: Federico Kunze <31522760+fedekunze@users.noreply.github.com>

* Update docs/building-modules/module-interfaces.md

Co-authored-by: Federico Kunze <31522760+fedekunze@users.noreply.github.com>

* Address part of review comments

* Update old ref of RegisterQueryService

* Add example code for Manager

* Update queriers.md to query-services.md and refs

* Add new query-services.md

* Revert "Update old ref of RegisterQueryService"

This reverts commit 1ea1ea8.

* Update keeper.md

* Update handler.md

* Update handler.md

* Update messages-and-queries.md

* Update docs/basics/app-anatomy.md

Co-authored-by: Amaury Martiny <amaury.martiny@protonmail.com>

* Update docs/building-modules/intro.md

Co-authored-by: Amaury Martiny <amaury.martiny@protonmail.com>

* Fix typo

Co-authored-by: Federico Kunze <31522760+fedekunze@users.noreply.github.com>
Co-authored-by: Amaury Martiny <amaury.martiny@protonmail.com>

* client: add GetAccount and GetAccountWithHeight to AccountRetriever (#7558)

* client: add GetAccount and GetAccountWithHeight to AccountRetriever

* update ADR

* address comments from review

* Add the option of emitting amino encoded json from the CLI (#7221)

* Add the option of emitting amino encoded json

* Update AMINO JSON serialization with ConvertTxToStdTx

* Make the Amino flag more self documenting by serializing the BroadcastRequest type instead of StdTx

* Handle amino encoding error

* Update x/auth/client/cli/tx_multisign.go

Co-authored-by: Alessio Treglia <alessio@tendermint.com>

* Update x/auth/client/cli/tx_sign.go

Co-authored-by: Alessio Treglia <alessio@tendermint.com>

* Apply suggestions from code review

Co-authored-by: Alessio Treglia <alessio@tendermint.com>

* Fix go format

Co-authored-by: Federico Kunze <31522760+fedekunze@users.noreply.github.com>
Co-authored-by: Alessio Treglia <alessio@tendermint.com>
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>

* ibc: update solo machine client command (#7579)

Co-authored-by: Federico Kunze <31522760+fedekunze@users.noreply.github.com>

* docs: Revert SPEC-SPEC and update x/{auth,bank,evidence,slashing} (#7407)

* Revert some changes from #7404

* Update x/slashing

* Address review comments

* Small tweak

Co-authored-by: Federico Kunze <31522760+fedekunze@users.noreply.github.com>
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>

* remove id in localhost (#7577)

Co-authored-by: Federico Kunze <31522760+fedekunze@users.noreply.github.com>
Co-authored-by: Christopher Goes <cwgoes@pluranimity.org>

* update changelog

* Update CHANGELOG.md

Co-authored-by: Aleksandr Bezobchuk <alexanderbez@users.noreply.github.com>

* Fix solomachine cmds (#7581)

* fix solo machine cli cmds

* polish

Co-authored-by: Federico Kunze <31522760+fedekunze@users.noreply.github.com>
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>

* simapp: use tmjson on InitChainer (#7514)

Co-authored-by: Alessio Treglia <alessio@tendermint.com>

* [IAVL]: Bump to v0.15.0-rc4 (#7549)

* iavl 0.15.0-rc4 version bump

* update comments on error modes for store.LoadStore

* update CONFIO_URL in makefile

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>

* Handle nil *Any in UnpackAny and add panic handler for tx decoding (#7594)

* Handle nil any in UnpackAny

* Add test

* Add flag back

* Update runTx signature

* Update Simulate signature

* Update calls to Simulate

* Add txEncoder in baseapp

* Fix TestTxWithoutPublicKey

* Wrap errors

* Use amino in baseapp tests

* Add txEncoder arg to Check & Deliver

* Fix gas in test

* Fix remaining base app tests

* Rename to amionTxEncoder

* Update codec/types/interface_registry.go

Co-authored-by: Aaron Craelius <aaron@regen.network>

* golangci-lint fix

Co-authored-by: Amaury Martiny <amaury.martiny@protonmail.com>
Co-authored-by: Aaron Craelius <aaron@regen.network>
Co-authored-by: Cory Levinson <cjlevinson@gmail.com>
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>

Co-authored-by: Marie Gauthier <marie.gauthier63@gmail.com>
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
Co-authored-by: Amaury Martiny <amaury.martiny@protonmail.com>
Co-authored-by: Federico Kunze <31522760+fedekunze@users.noreply.github.com>
Co-authored-by: colin axnér <25233464+colin-axner@users.noreply.github.com>
Co-authored-by: Neeraj Murarka <njmurarka@users.noreply.github.com>
Co-authored-by: Riccardo Montagnin <riccardo.montagnin@gmail.com>
Co-authored-by: Marko <marbar3778@yahoo.com>
Co-authored-by: Aleksandr Bezobchuk <alexanderbez@users.noreply.github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Zaki Manian <zaki@manian.org>
Co-authored-by: Alessio Treglia <alessio@tendermint.com>
Co-authored-by: Christopher Goes <cwgoes@pluranimity.org>
Co-authored-by: Aaron Craelius <aaron@regen.network>
  • Loading branch information
15 people committed Oct 19, 2020
1 parent 3dd64be commit d2a6cce
Show file tree
Hide file tree
Showing 131 changed files with 2,708 additions and 2,150 deletions.
18 changes: 16 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,27 @@ Ref: https://keepachangelog.com/en/1.0.0/

# Changelog

## v0.40.0-rc1 - [Unreleased]
## v0.40.0-rc1 - 2020-10-19

### Client Breaking Changes

* __General__
* __Modules__
* (x/staking) [\#7499](https://github.com/cosmos/cosmos-sdk/pull/7499) `BondStatus` is now a protobuf `enum` instead of an `int32`, and JSON serialized using its protobuf name, so expect names like `BOND_STATUS_UNBONDING` as opposed to `Unbonding`.

### Features

* (cli) \#7221 Add the option of emitting amino encoded json from the CLI

### Bug Fixes

* (kvstore) [\#7415](https://github.com/cosmos/cosmos-sdk/pull/7415) Allow new stores to be registered during on-chain upgrades.

### Improvements

* (tendermint) \#7527 Update sdk to tendermint 0.34-rc5
* (iavl) \#7549 Update sdk to IAVL 0.15.0-rc4


## v0.40.0-rc0 - 2020-10-13

v0.40.0, known as the Stargate release of the Cosmos SDK, is one of the largest releases
Expand Down
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -387,10 +387,10 @@ proto-check-breaking-docker:
@$(DOCKER_BUF) check breaking --against-input $(HTTPS_GIT)#branch=master
.PHONY: proto-check-breaking-ci

TM_URL = https://raw.githubusercontent.com/tendermint/tendermint/3359e0bf2f8414d9687f9eecda67b899d64a9cd1/proto/tendermint
TM_URL = https://raw.githubusercontent.com/tendermint/tendermint/v0.34.0-rc5/proto/tendermint
GOGO_PROTO_URL = https://raw.githubusercontent.com/regen-network/protobuf/cosmos
COSMOS_PROTO_URL = https://raw.githubusercontent.com/regen-network/cosmos-proto/master
CONFIO_URL = https://raw.githubusercontent.com/confio/ics23/v0.6.2
CONFIO_URL = https://raw.githubusercontent.com/confio/ics23/v0.6.3

TM_CRYPTO_TYPES = third_party/proto/tendermint/crypto
TM_ABCI_TYPES = third_party/proto/tendermint/abci
Expand Down
21 changes: 3 additions & 18 deletions baseapp/abci.go
Original file line number Diff line number Diff line change
Expand Up @@ -213,11 +213,6 @@ func (app *BaseApp) EndBlock(req abci.RequestEndBlock) (res abci.ResponseEndBloc
func (app *BaseApp) CheckTx(req abci.RequestCheckTx) abci.ResponseCheckTx {
defer telemetry.MeasureSince(time.Now(), "abci", "check_tx")

tx, err := app.txDecoder(req.Tx)
if err != nil {
return sdkerrors.ResponseCheckTx(err, 0, 0, app.trace)
}

var mode runTxMode

switch {
Expand All @@ -231,7 +226,7 @@ func (app *BaseApp) CheckTx(req abci.RequestCheckTx) abci.ResponseCheckTx {
panic(fmt.Sprintf("unknown RequestCheckTx type: %s", req.Type))
}

gInfo, result, err := app.runTx(mode, req.Tx, tx)
gInfo, result, err := app.runTx(mode, req.Tx)
if err != nil {
return sdkerrors.ResponseCheckTx(err, gInfo.GasWanted, gInfo.GasUsed, app.trace)
}
Expand All @@ -253,11 +248,6 @@ func (app *BaseApp) CheckTx(req abci.RequestCheckTx) abci.ResponseCheckTx {
func (app *BaseApp) DeliverTx(req abci.RequestDeliverTx) abci.ResponseDeliverTx {
defer telemetry.MeasureSince(time.Now(), "abci", "deliver_tx")

tx, err := app.txDecoder(req.Tx)
if err != nil {
return sdkerrors.ResponseDeliverTx(err, 0, 0, app.trace)
}

gInfo := sdk.GasInfo{}
resultStr := "successful"

Expand All @@ -268,7 +258,7 @@ func (app *BaseApp) DeliverTx(req abci.RequestDeliverTx) abci.ResponseDeliverTx
telemetry.SetGauge(float32(gInfo.GasWanted), "tx", "gas", "wanted")
}()

gInfo, result, err := app.runTx(runTxModeDeliver, req.Tx, tx)
gInfo, result, err := app.runTx(runTxModeDeliver, req.Tx)
if err != nil {
resultStr = "failed"
return sdkerrors.ResponseDeliverTx(err, gInfo.GasWanted, gInfo.GasUsed, app.trace)
Expand Down Expand Up @@ -673,12 +663,7 @@ func handleQueryApp(app *BaseApp, path []string, req abci.RequestQuery) abci.Res
case "simulate":
txBytes := req.Data

tx, err := app.txDecoder(txBytes)
if err != nil {
return sdkerrors.QueryResult(sdkerrors.Wrap(err, "failed to decode tx"))
}

gInfo, res, err := app.Simulate(txBytes, tx)
gInfo, res, err := app.Simulate(txBytes)
if err != nil {
return sdkerrors.QueryResult(sdkerrors.Wrap(err, "failed to simulate tx"))
}
Expand Down
7 changes: 6 additions & 1 deletion baseapp/baseapp.go
Original file line number Diff line number Diff line change
Expand Up @@ -550,7 +550,7 @@ func (app *BaseApp) cacheTxContext(ctx sdk.Context, txBytes []byte) (sdk.Context
// Note, gas execution info is always returned. A reference to a Result is
// returned if the tx does not run out of gas and if all the messages are valid
// and execute successfully. An error is returned otherwise.
func (app *BaseApp) runTx(mode runTxMode, txBytes []byte, tx sdk.Tx) (gInfo sdk.GasInfo, result *sdk.Result, err error) {
func (app *BaseApp) runTx(mode runTxMode, txBytes []byte) (gInfo sdk.GasInfo, result *sdk.Result, err error) {
// NOTE: GasWanted should be returned by the AnteHandler. GasUsed is
// determined by the GasMeter. We need access to the context to get the gas
// meter so we initialize upfront.
Expand Down Expand Up @@ -596,6 +596,11 @@ func (app *BaseApp) runTx(mode runTxMode, txBytes []byte, tx sdk.Tx) (gInfo sdk.
}
}()

tx, err := app.txDecoder(txBytes)
if err != nil {
return sdk.GasInfo{}, nil, err
}

msgs := tx.GetMsgs()
if err := validateBasicTxMsgs(msgs); err != nil {
return sdk.GasInfo{}, nil, err
Expand Down
43 changes: 26 additions & 17 deletions baseapp/baseapp_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +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"
)

var (
Expand Down Expand Up @@ -97,6 +98,14 @@ func registerTestCodec(cdc *codec.LegacyAmino) {
cdc.RegisterConcrete(&msgNoRoute{}, "cosmos-sdk/baseapp/msgNoRoute", nil)
}

// aminoTxEncoder creates a amino TxEncoder for testing purposes.
func aminoTxEncoder() sdk.TxEncoder {
cdc := codec.NewLegacyAmino()
registerTestCodec(cdc)

return legacytx.StdTxConfig{Cdc: cdc}.TxEncoder()
}

// simple one store baseapp
func setupBaseApp(t *testing.T, options ...func(*BaseApp)) *BaseApp {
app := newBaseApp(t.Name(), options...)
Expand Down Expand Up @@ -422,7 +431,7 @@ func TestLoadVersionPruning(t *testing.T) {

for _, v := range []int64{1, 2, 4} {
_, err = app.cms.CacheMultiStoreWithVersion(v)
require.Error(t, err)
require.NoError(t, err)
}

for _, v := range []int64{3, 5, 6, 7} {
Expand Down Expand Up @@ -1118,13 +1127,13 @@ func TestSimulateTx(t *testing.T) {
require.Nil(t, err)

// simulate a message, check gas reported
gInfo, result, err := app.Simulate(txBytes, tx)
gInfo, result, err := app.Simulate(txBytes)
require.NoError(t, err)
require.NotNil(t, result)
require.Equal(t, gasConsumed, gInfo.GasUsed)

// simulate again, same result
gInfo, result, err = app.Simulate(txBytes, tx)
gInfo, result, err = app.Simulate(txBytes)
require.NoError(t, err)
require.NotNil(t, result)
require.Equal(t, gasConsumed, gInfo.GasUsed)
Expand Down Expand Up @@ -1171,7 +1180,7 @@ func TestRunInvalidTransaction(t *testing.T) {
// transaction with no messages
{
emptyTx := &txTest{}
_, result, err := app.Deliver(emptyTx)
_, result, err := app.Deliver(aminoTxEncoder(), emptyTx)
require.Error(t, err)
require.Nil(t, result)

Expand All @@ -1198,7 +1207,7 @@ func TestRunInvalidTransaction(t *testing.T) {

for _, testCase := range testCases {
tx := testCase.tx
_, result, err := app.Deliver(tx)
_, result, err := app.Deliver(aminoTxEncoder(), tx)

if testCase.fail {
require.Error(t, err)
Expand All @@ -1215,7 +1224,7 @@ func TestRunInvalidTransaction(t *testing.T) {
// transaction with no known route
{
unknownRouteTx := txTest{[]sdk.Msg{msgNoRoute{}}, 0, false}
_, result, err := app.Deliver(unknownRouteTx)
_, result, err := app.Deliver(aminoTxEncoder(), unknownRouteTx)
require.Error(t, err)
require.Nil(t, result)

Expand All @@ -1224,7 +1233,7 @@ func TestRunInvalidTransaction(t *testing.T) {
require.EqualValues(t, sdkerrors.ErrUnknownRequest.ABCICode(), code, err)

unknownRouteTx = txTest{[]sdk.Msg{msgCounter{}, msgNoRoute{}}, 0, false}
_, result, err = app.Deliver(unknownRouteTx)
_, result, err = app.Deliver(aminoTxEncoder(), unknownRouteTx)
require.Error(t, err)
require.Nil(t, result)

Expand Down Expand Up @@ -1274,7 +1283,7 @@ func TestTxGasLimits(t *testing.T) {
}
}()

count := tx.(*txTest).Counter
count := tx.(txTest).Counter
newCtx.GasMeter().ConsumeGas(uint64(count), "counter-ante")

return newCtx, nil
Expand All @@ -1284,7 +1293,7 @@ func TestTxGasLimits(t *testing.T) {

routerOpt := func(bapp *BaseApp) {
r := sdk.NewRoute(routeMsgCounter, func(ctx sdk.Context, msg sdk.Msg) (*sdk.Result, error) {
count := msg.(msgCounter).Counter
count := msg.(*msgCounter).Counter
ctx.GasMeter().ConsumeGas(uint64(count), "counter-handler")
return &sdk.Result{}, nil
})
Expand Down Expand Up @@ -1322,7 +1331,7 @@ func TestTxGasLimits(t *testing.T) {

for i, tc := range testCases {
tx := tc.tx
gInfo, result, err := app.Deliver(tx)
gInfo, result, err := app.Deliver(aminoTxEncoder(), tx)

// check gas used and wanted
require.Equal(t, tc.gasUsed, gInfo.GasUsed, fmt.Sprintf("tc #%d; gas: %v, result: %v, err: %s", i, gInfo, result, err))
Expand Down Expand Up @@ -1359,7 +1368,7 @@ func TestMaxBlockGasLimits(t *testing.T) {
}
}()

count := tx.(*txTest).Counter
count := tx.(txTest).Counter
newCtx.GasMeter().ConsumeGas(uint64(count), "counter-ante")

return
Expand All @@ -1368,7 +1377,7 @@ func TestMaxBlockGasLimits(t *testing.T) {

routerOpt := func(bapp *BaseApp) {
r := sdk.NewRoute(routeMsgCounter, func(ctx sdk.Context, msg sdk.Msg) (*sdk.Result, error) {
count := msg.(msgCounter).Counter
count := msg.(*msgCounter).Counter
ctx.GasMeter().ConsumeGas(uint64(count), "counter-handler")
return &sdk.Result{}, nil
})
Expand Down Expand Up @@ -1412,7 +1421,7 @@ func TestMaxBlockGasLimits(t *testing.T) {

// execute the transaction multiple times
for j := 0; j < tc.numDelivers; j++ {
_, result, err := app.Deliver(tx)
_, result, err := app.Deliver(aminoTxEncoder(), tx)

ctx := app.getState(runTxModeDeliver).ctx

Expand Down Expand Up @@ -1480,7 +1489,7 @@ func TestCustomRunTxPanicHandler(t *testing.T) {
{
tx := newTxCounter(0, 0)

require.PanicsWithValue(t, customPanicMsg, func() { app.Deliver(tx) })
require.PanicsWithValue(t, customPanicMsg, func() { app.Deliver(aminoTxEncoder(), tx) })
}
}

Expand Down Expand Up @@ -1589,7 +1598,7 @@ func TestGasConsumptionBadTx(t *testing.T) {

routerOpt := func(bapp *BaseApp) {
r := sdk.NewRoute(routeMsgCounter, func(ctx sdk.Context, msg sdk.Msg) (*sdk.Result, error) {
count := msg.(msgCounter).Counter
count := msg.(*msgCounter).Counter
ctx.GasMeter().ConsumeGas(uint64(count), "counter-handler")
return &sdk.Result{}, nil
})
Expand Down Expand Up @@ -1668,7 +1677,7 @@ func TestQuery(t *testing.T) {
require.Equal(t, 0, len(res.Value))

// query is still empty after a CheckTx
_, resTx, err := app.Check(tx)
_, resTx, err := app.Check(aminoTxEncoder(), tx)
require.NoError(t, err)
require.NotNil(t, resTx)
res = app.Query(query)
Expand All @@ -1678,7 +1687,7 @@ func TestQuery(t *testing.T) {
header := tmproto.Header{Height: app.LastBlockHeight() + 1}
app.BeginBlock(abci.RequestBeginBlock{Header: header})

_, resTx, err = app.Deliver(tx)
_, resTx, err = app.Deliver(aminoTxEncoder(), tx)
require.NoError(t, err)
require.NotNil(t, resTx)
res = app.Query(query)
Expand Down
33 changes: 0 additions & 33 deletions baseapp/helpers.go

This file was deleted.

4 changes: 2 additions & 2 deletions baseapp/params.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@ func ValidateEvidenceParams(i interface{}) error {
return fmt.Errorf("evidence maximum age time duration must be positive: %v", v.MaxAgeDuration)
}

if v.MaxNum <= 0 {
return fmt.Errorf("evidence maximum number of evidence must be positive: %v", v.MaxNum)
if v.MaxBytes < 0 {
return fmt.Errorf("maximum evidence bytes must be positive: %v", v.MaxBytes)
}

return nil
Expand Down
4 changes: 2 additions & 2 deletions baseapp/params_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ func TestValidateEvidenceParams(t *testing.T) {
{nil, true},
{&tmproto.EvidenceParams{}, true},
{tmproto.EvidenceParams{}, true},
{tmproto.EvidenceParams{MaxAgeNumBlocks: -1, MaxAgeDuration: 18004000, MaxNum: 50}, true},
{tmproto.EvidenceParams{MaxAgeNumBlocks: 360000, MaxAgeDuration: 18004000, MaxNum: 50}, false},
{tmproto.EvidenceParams{MaxAgeNumBlocks: -1, MaxAgeDuration: 18004000, MaxBytes: 5000000}, true},
{tmproto.EvidenceParams{MaxAgeNumBlocks: 360000, MaxAgeDuration: 18004000, MaxBytes: 5000000}, false},
}

for _, tc := range testCases {
Expand Down
46 changes: 46 additions & 0 deletions baseapp/test_helpers.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
package baseapp

import (
tmproto "github.com/tendermint/tendermint/proto/tendermint/types"

sdk "github.com/cosmos/cosmos-sdk/types"
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
)

func (app *BaseApp) Check(txEncoder sdk.TxEncoder, tx sdk.Tx) (sdk.GasInfo, *sdk.Result, error) {
// runTx expects tx bytes as argument, so we encode the tx argument into
// bytes. Note that runTx will actually decode those bytes again. But since
// this helper is only used in tests/simulation, it's fine.
bz, err := txEncoder(tx)
if err != nil {
return sdk.GasInfo{}, nil, sdkerrors.Wrapf(sdkerrors.ErrInvalidRequest, "%s", err)
}
return app.runTx(runTxModeCheck, bz)
}

func (app *BaseApp) Simulate(txBytes []byte) (sdk.GasInfo, *sdk.Result, error) {
return app.runTx(runTxModeSimulate, txBytes)
}

func (app *BaseApp) Deliver(txEncoder sdk.TxEncoder, tx sdk.Tx) (sdk.GasInfo, *sdk.Result, error) {
// See comment for Check().
bz, err := txEncoder(tx)
if err != nil {
return sdk.GasInfo{}, nil, sdkerrors.Wrapf(sdkerrors.ErrInvalidRequest, "%s", err)
}
return app.runTx(runTxModeDeliver, bz)
}

// Context with current {check, deliver}State of the app used by tests.
func (app *BaseApp) NewContext(isCheckTx bool, header tmproto.Header) sdk.Context {
if isCheckTx {
return sdk.NewContext(app.checkState.ms, header, true, app.logger).
WithMinGasPrices(app.minGasPrices)
}

return sdk.NewContext(app.deliverState.ms, header, false, app.logger)
}

func (app *BaseApp) NewUncachedContext(isCheckTx bool, header tmproto.Header) sdk.Context {
return sdk.NewContext(app.cms, header, isCheckTx, app.logger)
}
Loading

0 comments on commit d2a6cce

Please sign in to comment.