Skip to content

Commit

Permalink
Merge pull request #21 from provenance-io/release-pio/v0.44.5
Browse files Browse the repository at this point in the history
feat: pio/v0.44.5
  • Loading branch information
fkneeland-figure authored Jan 12, 2022
2 parents 33dbf6a + 26d31b9 commit f672cad
Show file tree
Hide file tree
Showing 64 changed files with 338 additions and 58 deletions.
14 changes: 14 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,19 @@ Ref: https://keepachangelog.com/en/1.0.0/

## [Unreleased]

# Provenance Specific releases

## [v0.44.3-pio-1.8.rc1](https://github.com/provenance-io/cosmos-sdk/releases/tag/v0.44.3-pio-1.8.rc1)

* Updated baseapp and added custom fee handler to support provenance message fee module. (https://github.com/provenance-io/provenance/issues/354)

## [v0.44.3-rosetta-fix](https://github.com/provenance-io/cosmos-sdk/tag/v0.44.3-rosetta-fix)

* Upgraded Rosetta to v0.7.2 which includes the following prs to cosmos upstream: [10432](https://github.com/cosmos/cosmos-sdk/pull/10432) and [10707](https://github.com/cosmos/cosmos-sdk/pull/10707)


# Upstream releases

## [v0.44.5](https://github.com/cosmos/cosmos-sdk/releases/tag/v0.44.5) - 2021-12-02

### Improvements
Expand All @@ -60,6 +73,7 @@ Ref: https://keepachangelog.com/en/1.0.0/
* (bank) [\#10394](https://github.com/cosmos/cosmos-sdk/pull/10394) Fix: query account balance by ibc denom.
* [\10608](https://github.com/cosmos/cosmos-sdk/pull/10608) Change the order of module migration by pushing x/auth to the end. Auth module depends on other modules and should be run last. We have updated the documentation to provide more details how to change module migration order. This is technically a breaking change, but only impacts updates between the upgrades with version change, hence migrating from the previous patch release doesn't cause new migration and doesn't break the state.


## [v0.44.3](https://github.com/cosmos/cosmos-sdk/releases/tag/v0.44.3) - 2021-10-21

### Improvements
Expand Down
9 changes: 1 addition & 8 deletions RELEASE_NOTES.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,3 @@
# Cosmos SDK v0.44.5 Release Notes

This release introduces bug fixes and improvements on the Cosmos SDK v0.44 series:

- Emit ante handler events for failed transactions: ant events can cause blockchain change (eg tx fees) and related events should be emitted.
- (fix) Upgrade IAVL to 0.17.3 to solve race condition bug in IAVL.

See the [Cosmos SDK v0.44.5 Changelog](https://github.com/cosmos/cosmos-sdk/blob/v0.44.5/CHANGELOG.md) for the exhaustive list of all changes.

**Full Changelog**: https://github.com/cosmos/cosmos-sdk/compare/v0.44.4...v0.44.5
This release adds the updates from cosmos-sdk upstream v0.44.4 and v0.44.5 to the msg fee and rosetta fixes added into the Provenanced fork at v0.44.3
6 changes: 3 additions & 3 deletions baseapp/abci.go
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ func (app *BaseApp) CheckTx(req abci.RequestCheckTx) abci.ResponseCheckTx {
panic(fmt.Sprintf("unknown RequestCheckTx type: %s", req.Type))
}

gInfo, result, anteEvents, err := app.runTx(mode, req.Tx)
gInfo, result, anteEvents, _, err := app.runTx(mode, req.Tx)
if err != nil {
return sdkerrors.ResponseCheckTxWithEvents(err, gInfo.GasWanted, gInfo.GasUsed, anteEvents, app.trace)
}
Expand Down Expand Up @@ -272,7 +272,7 @@ func (app *BaseApp) DeliverTx(req abci.RequestDeliverTx) abci.ResponseDeliverTx
telemetry.SetGauge(float32(gInfo.GasWanted), "tx", "gas", "wanted")
}()

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

gInfo, res, err := app.Simulate(txBytes)
gInfo, res, _, err := app.Simulate(txBytes)
if err != nil {
return sdkerrors.QueryResult(sdkerrors.Wrap(err, "failed to simulate tx"))
}
Expand Down
56 changes: 43 additions & 13 deletions baseapp/baseapp.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ type BaseApp struct { // nolint: maligned
router sdk.Router // handle any kind of message
queryRouter sdk.QueryRouter // router for redirecting query calls
grpcQueryRouter *GRPCQueryRouter // router for redirecting gRPC query calls
msgServiceRouter *MsgServiceRouter // router for redirecting Msg service messages
msgServiceRouter IMsgServiceRouter // router for redirecting Msg service messages
interfaceRegistry types.InterfaceRegistry
txDecoder sdk.TxDecoder // unmarshal []byte into sdk.Tx

Expand Down Expand Up @@ -133,6 +133,8 @@ type BaseApp struct { // nolint: maligned
// indexEvents defines the set of events in the form {eventType}.{attributeKey},
// which informs Tendermint what to index. If empty, all events will be indexed.
indexEvents map[string]struct{}

feeHandler sdk.FeeHandler
}

// NewBaseApp returns a reference to an initialized BaseApp. It accepts a
Expand Down Expand Up @@ -195,8 +197,13 @@ func (app *BaseApp) Trace() bool {
return app.trace
}

// sets MsgServiceRouter of the BaseApp.
func (app *BaseApp) SetMsgServiceRouter(msgServiceRouter IMsgServiceRouter) {
app.msgServiceRouter = msgServiceRouter
}

// MsgServiceRouter returns the MsgServiceRouter of a BaseApp.
func (app *BaseApp) MsgServiceRouter() *MsgServiceRouter { return app.msgServiceRouter }
func (app *BaseApp) MsgServiceRouter() IMsgServiceRouter { return app.msgServiceRouter }

// MountStores mounts all IAVL or DB stores to the provided keys in the BaseApp
// multistore.
Expand Down Expand Up @@ -572,7 +579,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) (gInfo sdk.GasInfo, result *sdk.Result, anteEvents []abci.Event, err error) {
func (app *BaseApp) runTx(mode runTxMode, txBytes []byte) (gInfo sdk.GasInfo, result *sdk.Result, anteEvents []abci.Event, txCtx sdk.Context, 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 All @@ -584,7 +591,7 @@ func (app *BaseApp) runTx(mode runTxMode, txBytes []byte) (gInfo sdk.GasInfo, re
// only run the tx if there is block gas remaining
if mode == runTxModeDeliver && ctx.BlockGasMeter().IsOutOfGas() {
gInfo = sdk.GasInfo{GasUsed: ctx.BlockGasMeter().GasConsumed()}
return gInfo, nil, nil, sdkerrors.Wrap(sdkerrors.ErrOutOfGas, "no block gas left to run tx")
return gInfo, nil, nil, ctx, sdkerrors.Wrap(sdkerrors.ErrOutOfGas, "no block gas left to run tx")
}

var startingGas uint64
Expand Down Expand Up @@ -620,12 +627,12 @@ func (app *BaseApp) runTx(mode runTxMode, txBytes []byte) (gInfo sdk.GasInfo, re

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

msgs := tx.GetMsgs()
if err := validateBasicTxMsgs(msgs); err != nil {
return sdk.GasInfo{}, nil, nil, err
return sdk.GasInfo{}, nil, nil, ctx, err
}

if app.anteHandler != nil {
Expand Down Expand Up @@ -661,7 +668,7 @@ func (app *BaseApp) runTx(mode runTxMode, txBytes []byte) (gInfo sdk.GasInfo, re
gasWanted = ctx.GasMeter().Limit()

if err != nil {
return gInfo, nil, nil, err
return gInfo, nil, nil, ctx, err
}

msCache.Write()
Expand All @@ -678,15 +685,38 @@ func (app *BaseApp) runTx(mode runTxMode, txBytes []byte) (gInfo sdk.GasInfo, re
// Result if any single message fails or does not have a registered Handler.
result, err = app.runMsgs(runMsgCtx, msgs, mode)
if err == nil && mode == runTxModeDeliver {
msCache.Write()

if len(anteEvents) > 0 {
// append the events in the order of occurrence
result.Events = append(anteEvents, result.Events...)
// apply fee logic calls
feeEvents, err := FeeInvoke(mode, app, runMsgCtx)
// if err from FeeInvoke then don't write to cache
if err == nil {
msCache.Write()
// these are the ante events propagated only on success, that now means that fee charging has happened successfully.
if len(anteEvents) > 0 {
// append the events in the order of occurrence
result.Events = append(anteEvents, result.Events...)
}
// additional fee events
if len(feeEvents) > 0 {
// append the fee events at the end of the other events, since they get charged at the end of the Tx
result.Events = append(result.Events, feeEvents.ToABCIEvents()...)
}
}
}

return gInfo, result, anteEvents, err
return gInfo, result, anteEvents, ctx, err
}

// FeeInvoke apply fee logic and append events
func FeeInvoke(mode runTxMode, app *BaseApp, runMsgCtx sdk.Context) (sdk.Events, error) {
if app.feeHandler != nil {
// call the msgFee
_, eventsFromFeeHandler, err := app.feeHandler(runMsgCtx, mode == runTxModeSimulate)
if err != nil {
return nil, err
}
return eventsFromFeeHandler, nil
}
return nil, nil
}

// runMsgs iterates through a list of messages and executes them with the provided
Expand Down
4 changes: 2 additions & 2 deletions baseapp/baseapp_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1131,13 +1131,13 @@ func TestSimulateTx(t *testing.T) {
require.Nil(t, err)

// simulate a message, check gas reported
gInfo, result, err := app.Simulate(txBytes)
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)
gInfo, result, _, err = app.Simulate(txBytes)
require.NoError(t, err)
require.NotNil(t, result)
require.Equal(t, gasConsumed, gInfo.GasUsed)
Expand Down
7 changes: 7 additions & 0 deletions baseapp/msg_service_router.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,13 @@ func NewMsgServiceRouter() *MsgServiceRouter {
// MsgServiceHandler defines a function type which handles Msg service message.
type MsgServiceHandler = func(ctx sdk.Context, req sdk.Msg) (*sdk.Result, error)

type IMsgServiceRouter interface {
Handler(msg sdk.Msg) MsgServiceHandler
HandlerByTypeURL(typeURL string) MsgServiceHandler
RegisterService(sd *grpc.ServiceDesc, handler interface{})
SetInterfaceRegistry(interfaceRegistry codectypes.InterfaceRegistry)
}

// Handler returns the MsgServiceHandler for a given msg or nil if not found.
func (msr *MsgServiceRouter) Handler(msg sdk.Msg) MsgServiceHandler {
return msr.routes[sdk.MsgTypeURL(msg)]
Expand Down
9 changes: 9 additions & 0 deletions baseapp/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -237,3 +237,12 @@ func (app *BaseApp) SetInterfaceRegistry(registry types.InterfaceRegistry) {
app.grpcQueryRouter.SetInterfaceRegistry(registry)
app.msgServiceRouter.SetInterfaceRegistry(registry)
}

// SetFeeHandler sets the FeeHandler which if set will change the behavior of fee handling
func (app *BaseApp) SetFeeHandler(feeHandler sdk.FeeHandler) {
if app.sealed {
panic("SetKeeperHandler() on sealed BaseApp")
}

app.feeHandler = feeHandler
}
10 changes: 5 additions & 5 deletions baseapp/test_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@ func (app *BaseApp) Check(txEncoder sdk.TxEncoder, tx sdk.Tx) (sdk.GasInfo, *sdk
if err != nil {
return sdk.GasInfo{}, nil, sdkerrors.Wrapf(sdkerrors.ErrInvalidRequest, "%s", err)
}
gasInfo, result, _, err := app.runTx(runTxModeCheck, bz)
gasInfo, result, _, _, err := app.runTx(runTxModeCheck, bz)
return gasInfo, result, err
}

func (app *BaseApp) Simulate(txBytes []byte) (sdk.GasInfo, *sdk.Result, error) {
gasInfo, result, _, err := app.runTx(runTxModeSimulate, txBytes)
return gasInfo, result, err
func (app *BaseApp) Simulate(txBytes []byte) (sdk.GasInfo, *sdk.Result, sdk.Context, error) {
gasInfo, result, _, ctx, err := app.runTx(runTxModeSimulate, txBytes)
return gasInfo, result, ctx, err
}

func (app *BaseApp) Deliver(txEncoder sdk.TxEncoder, tx sdk.Tx) (sdk.GasInfo, *sdk.Result, error) {
Expand All @@ -30,7 +30,7 @@ func (app *BaseApp) Deliver(txEncoder sdk.TxEncoder, tx sdk.Tx) (sdk.GasInfo, *s
if err != nil {
return sdk.GasInfo{}, nil, sdkerrors.Wrapf(sdkerrors.ErrInvalidRequest, "%s", err)
}
gasInfo, result, _, err := app.runTx(runTxModeDeliver, bz)
gasInfo, result, _, _, err := app.runTx(runTxModeDeliver, bz)
return gasInfo, result, err
}

Expand Down
1 change: 1 addition & 0 deletions client/grpc_query_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//go:build norace
// +build norace

package client_test
Expand Down
3 changes: 2 additions & 1 deletion client/keys/add_ledger_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
//+build ledger test_ledger_mock
//go:build ledger || test_ledger_mock
// +build ledger test_ledger_mock

package keys

Expand Down
3 changes: 2 additions & 1 deletion client/keys/add_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,15 @@ import (

"github.com/tendermint/tendermint/libs/cli"

bip39 "github.com/cosmos/go-bip39"

"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/client/flags"
"github.com/cosmos/cosmos-sdk/crypto/hd"
"github.com/cosmos/cosmos-sdk/crypto/keyring"
"github.com/cosmos/cosmos-sdk/simapp"
"github.com/cosmos/cosmos-sdk/testutil"
sdk "github.com/cosmos/cosmos-sdk/types"
bip39 "github.com/cosmos/go-bip39"
)

func Test_runAddCmdBasic(t *testing.T) {
Expand Down
1 change: 1 addition & 0 deletions client/query_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//go:build norace
// +build norace

package client_test
Expand Down
1 change: 0 additions & 1 deletion contrib/images/simd-env/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ FROM golang:1.17-alpine AS build
RUN apk add build-base git linux-headers
WORKDIR /work
COPY go.mod go.sum /work/
COPY db/go.mod db/go.sum /work/db/
RUN go mod download
COPY ./ /work
RUN LEDGER_ENABLED=false make clean build
Expand Down
1 change: 1 addition & 0 deletions cosmovisor/process_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//go:build linux
// +build linux

package cosmovisor_test
Expand Down
1 change: 1 addition & 0 deletions cosmovisor/upgrade_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//go:build linux
// +build linux

package cosmovisor_test
Expand Down
3 changes: 2 additions & 1 deletion crypto/keyring/keyring_ledger_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
//+build ledger test_ledger_mock
//go:build ledger || test_ledger_mock
// +build ledger test_ledger_mock

package keyring

Expand Down
5 changes: 3 additions & 2 deletions crypto/keys/internal/ecdsa/privkey_internal_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@ import (
"crypto/ecdsa"
"crypto/elliptic"
"crypto/sha256"
"github.com/tendermint/tendermint/crypto"
"math/big"
"testing"

"github.com/tendermint/tendermint/crypto"

"github.com/stretchr/testify/suite"
)

Expand Down Expand Up @@ -80,7 +81,7 @@ func (suite *SKSuite) TestSign() {
// leave r untouched!
high_s := new(big.Int).Mod(new(big.Int).Neg(low_s), elliptic.P256().Params().N)

require.False(suite.pk.VerifySignature(msg, signatureRaw(r,high_s)))
require.False(suite.pk.VerifySignature(msg, signatureRaw(r, high_s)))

// Valid signature using low_s, but too long
sigCpy = make([]byte, len(sig)+2)
Expand Down
1 change: 1 addition & 0 deletions crypto/keys/secp256k1/secp256k1_cgo.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//go:build libsecp256k1
// +build libsecp256k1

package secp256k1
Expand Down
1 change: 1 addition & 0 deletions crypto/keys/secp256k1/secp256k1_cgo_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//go:build libsecp256k1
// +build libsecp256k1

package secp256k1
Expand Down
1 change: 1 addition & 0 deletions crypto/keys/secp256k1/secp256k1_nocgo_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//go:build !libsecp256k1
// +build !libsecp256k1

package secp256k1
Expand Down
1 change: 1 addition & 0 deletions crypto/ledger/ledger_mock.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//go:build ledger && test_ledger_mock
// +build ledger,test_ledger_mock

package ledger
Expand Down
1 change: 1 addition & 0 deletions crypto/ledger/ledger_real.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//go:build cgo && ledger && !test_ledger_mock
// +build cgo,ledger,!test_ledger_mock

package ledger
Expand Down
5 changes: 3 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ require (
github.com/armon/go-metrics v0.3.9
github.com/bgentry/speakeasy v0.1.0
github.com/btcsuite/btcd v0.22.0-beta
github.com/coinbase/rosetta-sdk-go v0.6.10
github.com/btcsuite/btcutil v1.0.3-0.20201208143702-a53e38424cce // indirect
github.com/coinbase/rosetta-sdk-go v0.7.2
github.com/confio/ics23/go v0.6.6
github.com/cosmos/btcutil v1.0.4
github.com/cosmos/go-bip39 v1.0.0
Expand All @@ -21,7 +22,7 @@ require (
github.com/gorilla/mux v1.8.0
github.com/grpc-ecosystem/go-grpc-middleware v1.3.0
github.com/grpc-ecosystem/grpc-gateway v1.16.0
github.com/hashicorp/golang-lru v0.5.4
github.com/hashicorp/golang-lru v0.5.5-0.20210104140557-80c98217689d
github.com/hdevalence/ed25519consensus v0.0.0-20210204194344-59a8610d2b87
github.com/improbable-eng/grpc-web v0.14.1
github.com/jhump/protoreflect v1.9.0
Expand Down
Loading

0 comments on commit f672cad

Please sign in to comment.