Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem: v0.47.x is outdated #197

Merged
merged 43 commits into from
Dec 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
80705f7
feat(gov): handle panics when executing x/gov proposals (backport #17…
mergify[bot] Sep 18, 2023
c65feec
refactor(store): add missing error checks in store (#17817)
julienrbrt Sep 20, 2023
a6f79a9
fix(baseapp): select txs correctly with no-op mempool (backport #1776…
mergify[bot] Sep 25, 2023
8d6c611
docs: small update for routes change (backport #17881) (#17887)
mergify[bot] Sep 26, 2023
e0ab380
chore: remove duplicate check (#17901)
tac0turtle Sep 27, 2023
f29fcc5
chore: remove tip posthandler (#17902)
tac0turtle Sep 27, 2023
85034c1
chore(auth): return accId in error (backport #17903) (#17906)
mergify[bot] Sep 27, 2023
353ae64
chore(store): check value (backport #17900) (#17908)
mergify[bot] Sep 27, 2023
afd4d9d
refactor(x/gov): remove gov vote and proposal based telemetry (backpo…
mergify[bot] Sep 27, 2023
d7c4bfd
docs: Typo on Application - Specific documentation (backport #17933)…
mergify[bot] Oct 1, 2023
2601e23
chore(staking): add delegator to events (backport #18006) (#18012)
mergify[bot] Oct 9, 2023
7d12782
feat(baseapp): expose `Mempool` (backport #17954) (#18010)
mergify[bot] Oct 9, 2023
02c403f
docs: fix typos (backport #18018) (#18020)
mergify[bot] Oct 9, 2023
d24d469
chore(x/consensus): check for nil params (backport #18041) (#18069)
mergify[bot] Oct 11, 2023
c121fcc
build(deps): bump cosmos/ledger-cosmos-go to v0.12.3 in v0.47 (#18105)
julienrbrt Oct 13, 2023
efa1226
chore: fix comments on bech32 (backport #18114) (#18117)
mergify[bot] Oct 13, 2023
91b44c5
fix(x/bank): miss keypair of SendEnabled to restore legacy param set …
mmsqe Oct 16, 2023
0469b11
build(deps): Bump github.com/cosmos/ledger-cosmos-go from 0.12.3 to 0…
dependabot[bot] Oct 17, 2023
1a306fd
feat(server): start grpc server and register services when starting i…
p-offtermatt Oct 19, 2023
d003fa1
refactor(x/gov): backport MinInitialDepositRatio validation from v0.5…
julienrbrt Oct 20, 2023
362f234
refactor(x/authz): extend validate genesis (backport #18042) (#18208)
mergify[bot] Oct 23, 2023
269a245
fix(authz): check string is not empty (backport #18209) (#18218)
mergify[bot] Oct 23, 2023
98a8bfe
chore(x/upgrade): Use ValidateBasic for Plan in ReadUpgradeInfoFromDi…
mergify[bot] Oct 24, 2023
af758d7
refactor(network): call `app.Close()` on network cleanup (backport #1…
mergify[bot] Oct 25, 2023
8c9ab2c
fix(server): don't hardcode grpc address to localhost (backport #1825…
mergify[bot] Oct 25, 2023
d3c9653
fix: use a lower file permission in file creation (backport #18206) (…
mergify[bot] Oct 26, 2023
00ee987
fix(snapshot): grant execution permissions to the snapshot dir for th…
mergify[bot] Oct 29, 2023
37ad929
build(deps): Bump cosmossdk.io/math from 1.1.2 to 1.2.0 (#18398)
dependabot[bot] Nov 7, 2023
03d578b
chore: prepare v0.47.6 release notes (#18342)
julienrbrt Nov 14, 2023
cb6d235
fix(client/tx): simulate with correct pk (backport #18472) (#18503)
mergify[bot] Nov 17, 2023
60112c6
feat(server): cmd flag to disable colored logs (backport #18478) (#18…
mergify[bot] Nov 19, 2023
d79964b
build(deps): Bump github.com/cometbft/cometbft from 0.37.2 to 0.37.3 …
dependabot[bot] Nov 20, 2023
58b0cdd
Revert "build(deps): Bump github.com/cometbft/cometbft from 0.37.2 to…
julienrbrt Nov 20, 2023
55c6d55
fix(server): properly parse multiple gas config (backport #18537) (#1…
mergify[bot] Nov 22, 2023
044ff4d
build(deps): Bump github.com/cometbft/cometbft from 0.37.2 to 0.37.4 …
dependabot[bot] Nov 27, 2023
3c7a090
feat(x/gov): better gov genesis validation (backport #18707) (#18712)
mergify[bot] Dec 13, 2023
6309fa7
docs: add ante precision (backport #18709) (#18730)
mergify[bot] Dec 13, 2023
371744b
fix(x/auth): remove misleading gas wanted value from tx simulation fa…
mergify[bot] Dec 19, 2023
9c1fa8c
docs: add index page for learn section (backport #18777) (#18779)
mergify[bot] Dec 19, 2023
929e76b
docs: fix for links (backport #18816) (#18819)
mergify[bot] Dec 19, 2023
9e60114
fix(baseapp): Reset GasMeter before deliverTX v0.47.x backport (#18826)
Eric-Warehime Dec 20, 2023
d09f40d
chore: prepare v0.47.7 (#18765)
julienrbrt Dec 20, 2023
fb8e3a4
Merge tag 'v0.47.7' into release/v0.47.x
mmsqe Dec 21, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 23 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,17 +37,39 @@ Ref: https://keepachangelog.com/en/1.0.0/

## [Unreleased]

## [v0.47.7](https://github.com/cosmos/cosmos-sdk/releases/tag/v0.47.7) - 2023-12-20

### Improvements

* (x/gov) [#18707](https://github.com/cosmos/cosmos-sdk/pull/18707) Improve genesis validation.
* (server) [#18478](https://github.com/cosmos/cosmos-sdk/pull/18478) Add command flag to disable colored logs.

### Bug Fixes

* (baseapp) [#18609](https://github.com/cosmos/cosmos-sdk/issues/18609) Fixed accounting in the block gas meter after BeginBlock and before DeliverTx, ensuring transaction processing always starts with the expected zeroed out block gas meter.
* (server) [#18537](https://github.com/cosmos/cosmos-sdk/pull/18537) Fix panic when defining minimum gas config as `100stake;100uatom`. Use a `,` delimiter instead of `;`. Fixes the server config getter to use the correct delimiter.
* (client/tx) [#18472](https://github.com/cosmos/cosmos-sdk/pull/18472) Utilizes the correct Pubkey when simulating a transaction.

## [v0.47.6](https://github.com/cosmos/cosmos-sdk/releases/tag/v0.47.6) - 2023-11-14

### Features

* (server) [#18110](https://github.com/cosmos/cosmos-sdk/pull/18110) Start gRPC & API server in standalone mode.

### Improvements

* (baseapp) [#17954](https://github.com/cosmos/cosmos-sdk/issues/17954) Add `Mempool()` method on `BaseApp` to allow access to the mempool.
* (x/gov) [#17780](https://github.com/cosmos/cosmos-sdk/pull/17780) Recover panics and turn them into errors when executing x/gov proposals.

### Bug Fixes

* (server) [#18254](https://github.com/cosmos/cosmos-sdk/pull/18254) Don't hardcode gRPC address to localhost.
* (server) [#18251](https://github.com/cosmos/cosmos-sdk/pull/18251) Call `baseapp.Close()` when app started as grpc only.
* (baseapp) [#17769](https://github.com/cosmos/cosmos-sdk/pull/17769) Ensure we respect block size constraints in the `DefaultProposalHandler`'s `PrepareProposal` handler when a nil or no-op mempool is used. We provide a `TxSelector` type to assist in making transaction selection generalized. We also fix a comparison bug in tx selection when `req.maxTxBytes` is reached.
* (config) [#17649](https://github.com/cosmos/cosmos-sdk/pull/17649) Fix `mempool.max-txs` configuration is invalid in `app.config`.
* (mempool) [#17668](https://github.com/cosmos/cosmos-sdk/pull/17668) Fix `PriorityNonceIterator.Next()` nil pointer ref for min priority at the end of iteration.
* (x/auth) [#17902](https://github.com/cosmos/cosmos-sdk/pull/17902) Remove tip posthandler.
* (x/bank) [#194](https://github.com/crypto-org-chain/cosmos-sdk/pull/194) Add miss keypair of SendEnabled to restore legacy param set before migration.
* (x/bank) [#18107](https://github.com/cosmos/cosmos-sdk/pull/18107) Add missing keypair of SendEnabled to restore legacy param set before migration.

### Client Breaking Changes

Expand Down
16 changes: 8 additions & 8 deletions RELEASE_NOTES.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
# Cosmos SDK v0.47.5 Release Notes
# Cosmos SDK v0.47.7 Release Notes

💬 [**Release Discussion**](https://github.com/orgs/cosmos/discussions/categories/announcements)

## 🚀 Highlights

Get ready for v0.50.0 and start integrating with the next [Cosmos SDK](https://github.com/cosmos/cosmos-sdk/releases/tag/v0.50.0-rc.0) release.
v0.50 is there, the v0.47.x line is now supported for bug fixes only, as per our release policy.
Start integrating with [Cosmos SDK Eden (v0.50)](https://github.com/cosmos/cosmos-sdk/releases/tag/v0.50.2) and enjoy and the new features and performance improvements.

For this 5th patch release of the `v0.47.x` line, some of the notable changes include:
For this 7th patch release of the `v0.47.x` line, some of the notable changes include:

* A new command for importing private keys encoded in hex. This complements the existing `import` command that supports mnemonic and key files.
Use `<appd> keys import <name> <hex>` to import a private key encoded in hex.
* A new command, `rpc.QueryEventForTxCmd` for querying a transaction by its hash and blocking until the transaction is included in a block. It is useful as an alternative to the legacy `--sync block`.
* A bug fix in the `app.toml` parsing for the `minimum-gas-prices` parameter.
* A bug fix to properly simulate a transaction when using a multisig.

Check out the [changelog](https://github.com/cosmos/cosmos-sdk/blob/v0.47.5/CHANGELOG.md) for an exhaustive list of changes or [compare changes](https://github.com/cosmos/cosmos-sdk/compare/release/v0.47.4...v0.47.5) from last release.
Check out the [changelog](https://github.com/cosmos/cosmos-sdk/blob/v0.47.5/CHANGELOG.md) for an exhaustive list of changes or [compare changes](https://github.com/cosmos/cosmos-sdk/compare/v0.47.6...v0.47.7) from last release.

Refer to the [upgrading guide](https://github.com/cosmos/cosmos-sdk/blob/release/v0.47.x/UPGRADING.md) when migrating from `v0.46.x` to `v0.47.0`.
Refer to the [upgrading guide](https://github.com/cosmos/cosmos-sdk/blob/release/v0.50.x/UPGRADING.md) when migrating from `v0.47.x` to `v0.50.x`.
4 changes: 4 additions & 0 deletions baseapp/abci.go
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,10 @@
}
}

// Reset the gas meter so that the AnteHandlers aren't required to
gasMeter = app.getBlockGasMeter(app.deliverState.ctx)

Check warning

Code scanning / CodeQL

Panic in BeginBock or EndBlock consensus methods Warning

path flow from Begin/EndBlock to a panic call
path flow from Begin/EndBlock to a panic call
path flow from Begin/EndBlock to a panic call
path flow from Begin/EndBlock to a panic call
path flow from Begin/EndBlock to a panic call
app.deliverState.ctx = app.deliverState.ctx.WithBlockGasMeter(gasMeter)

return res
}

Expand Down
5 changes: 5 additions & 0 deletions baseapp/baseapp.go
Original file line number Diff line number Diff line change
Expand Up @@ -352,6 +352,11 @@ func (app *BaseApp) LastBlockHeight() int64 {
return app.cms.LastCommitID().Version
}

// Mempool returns the Mempool of the app.
func (app *BaseApp) Mempool() mempool.Mempool {
return app.mempool
}

// Init initializes the app. It seals the app, preventing any
// further modifications. In addition, it validates the app against
// the earlier provided settings. Returns an error if validation fails.
Expand Down
35 changes: 35 additions & 0 deletions baseapp/baseapp_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,41 @@ func NewBaseAppSuiteWithSnapshots(t *testing.T, cfg SnapshotsConfig, opts ...fun
return suite
}

func TestAnteHandlerGasMeter(t *testing.T) {
// run BeginBlock and assert that the gas meter passed into the first Txn's AnteHandlers is zeroed out
anteOpt := func(bapp *baseapp.BaseApp) {
bapp.SetAnteHandler(func(ctx sdk.Context, tx sdk.Tx, simulate bool) (newCtx sdk.Context, err error) {
gasMeter := ctx.BlockGasMeter()
require.NotNil(t, gasMeter)
require.Equal(t, sdk.Gas(0), gasMeter.GasConsumed())
return ctx, nil
})
}
// set the beginBlocker to use some gas
beginBlockerOpt := func(bapp *baseapp.BaseApp) {
bapp.SetBeginBlocker(func(ctx sdk.Context, req abci.RequestBeginBlock) abci.ResponseBeginBlock {
ctx.BlockGasMeter().ConsumeGas(1, "beginBlocker gas consumption")
return abci.ResponseBeginBlock{}
})
}

suite := NewBaseAppSuite(t, anteOpt, beginBlockerOpt)

_ = suite.baseApp.InitChain(abci.RequestInitChain{
ConsensusParams: &tmproto.ConsensusParams{},
})

// Run BeginBlock to consume some gas
header := tmproto.Header{Height: 1}
suite.baseApp.BeginBlock(abci.RequestBeginBlock{Header: header})

// Run our first Tx (make sure the AnteHandler doesn't see gas consumed in BeginBlock
tx := newTxCounter(t, suite.txConfig, 0, 0)
txBytes, err := suite.txConfig.TxEncoder()(tx)
require.NoError(t, err)
suite.baseApp.DeliverTx(abci.RequestDeliverTx{Tx: txBytes})
}

func TestLoadVersion(t *testing.T) {
logger := defaultLogger()
pruningOpt := baseapp.SetPruning(pruningtypes.NewPruningOptions(pruningtypes.PruningNothing))
Expand Down
5 changes: 3 additions & 2 deletions client/flags/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,9 @@ const (
FlagOutput = tmcli.OutputFlag

// Tendermint logging flags
FlagLogLevel = "log_level"
FlagLogFormat = "log_format"
FlagLogLevel = "log_level"
FlagLogFormat = "log_format"
FlagLogNoColor = "log_no_color"
)

// LineBreak can be included in a command list to provide a blank line
Expand Down
40 changes: 29 additions & 11 deletions client/tx/factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import (
"github.com/cosmos/cosmos-sdk/client/flags"
codectypes "github.com/cosmos/cosmos-sdk/codec/types"
"github.com/cosmos/cosmos-sdk/crypto/keyring"
"github.com/cosmos/cosmos-sdk/crypto/keys/multisig"
"github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1"
cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types"
sdk "github.com/cosmos/cosmos-sdk/types"
Expand All @@ -34,6 +35,7 @@ type Factory struct {
timeoutHeight uint64
gasAdjustment float64
chainID string
fromName string
offline bool
generateOnly bool
memo string
Expand Down Expand Up @@ -86,6 +88,7 @@ func NewFactoryCLI(clientCtx client.Context, flagSet *pflag.FlagSet) (Factory, e
accountRetriever: clientCtx.AccountRetriever,
keybase: clientCtx.Keyring,
chainID: clientCtx.ChainID,
fromName: clientCtx.FromName,
offline: clientCtx.Offline,
generateOnly: clientCtx.GenerateOnly,
gas: gasSetting.Gas,
Expand Down Expand Up @@ -414,10 +417,8 @@ func (f Factory) BuildSimTx(msgs ...sdk.Msg) ([]byte, error) {
// Create an empty signature literal as the ante handler will populate with a
// sentinel pubkey.
sig := signing.SignatureV2{
PubKey: pk,
Data: &signing.SingleSignatureData{
SignMode: f.signMode,
},
PubKey: pk,
Data: f.getSimSignatureData(pk),
Sequence: f.Sequence(),
}
if err := txb.SetSignatures(sig); err != nil {
Expand All @@ -438,16 +439,13 @@ func (f Factory) getSimPK() (cryptotypes.PubKey, error) {
pk cryptotypes.PubKey = &secp256k1.PubKey{} // use default public key type
)

// Use the first element from the list of keys in order to generate a valid
// pubkey that supports multiple algorithms.
if f.simulateAndExecute && f.keybase != nil {
records, _ := f.keybase.List()
if len(records) == 0 {
return nil, errors.New("cannot build signature for simulation, key records slice is empty")
record, err := f.keybase.Key(f.fromName)
if err != nil {
return nil, err
}

// take the first record just for simulation purposes
pk, ok = records[0].PubKey.GetCachedValue().(cryptotypes.PubKey)
pk, ok = record.PubKey.GetCachedValue().(cryptotypes.PubKey)
if !ok {
return nil, errors.New("cannot build signature for simulation, failed to convert proto Any to public key")
}
Expand All @@ -456,6 +454,26 @@ func (f Factory) getSimPK() (cryptotypes.PubKey, error) {
return pk, nil
}

// getSimSignatureData based on the pubKey type gets the correct SignatureData type
// to use for building a simulation tx.
func (f Factory) getSimSignatureData(pk cryptotypes.PubKey) signing.SignatureData {
multisigPubKey, ok := pk.(*multisig.LegacyAminoPubKey)
if !ok {
return &signing.SingleSignatureData{SignMode: f.signMode}
}

multiSignatureData := make([]signing.SignatureData, 0, multisigPubKey.Threshold)
for i := uint32(0); i < multisigPubKey.Threshold; i++ {
multiSignatureData = append(multiSignatureData, &signing.SingleSignatureData{
SignMode: f.SignMode(),
})
}

return &signing.MultiSignatureData{
Signatures: multiSignatureData,
}
}

// Prepare ensures the account defined by ctx.GetFromAddress() exists and
// if the account number and/or the account sequence number are zero (not set),
// they will be queried for and set on the provided Factory.
Expand Down
100 changes: 93 additions & 7 deletions client/tx/factory_test.go
Original file line number Diff line number Diff line change
@@ -1,34 +1,120 @@
package tx_test
package tx

import (
"testing"

"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/client/tx"
"github.com/stretchr/testify/require"

"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/codec"
"github.com/cosmos/cosmos-sdk/crypto/hd"
"github.com/cosmos/cosmos-sdk/crypto/keyring"
"github.com/cosmos/cosmos-sdk/crypto/keys/multisig"
"github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1"
"github.com/cosmos/cosmos-sdk/crypto/types"
"github.com/cosmos/cosmos-sdk/testutil/testdata"
"github.com/cosmos/cosmos-sdk/types/tx/signing"

codectypes "github.com/cosmos/cosmos-sdk/codec/types"
cryptocodec "github.com/cosmos/cosmos-sdk/crypto/codec"
)

func TestFactoryPrepate(t *testing.T) {
func TestFactoryPrepare(t *testing.T) {
t.Parallel()

factory := tx.Factory{}
factory := Factory{}
clientCtx := client.Context{}

output, err := factory.Prepare(clientCtx.WithOffline(true))
require.NoError(t, err)
require.Equal(t, output, factory)

factory = tx.Factory{}.WithAccountRetriever(client.MockAccountRetriever{ReturnAccNum: 10, ReturnAccSeq: 1}).WithAccountNumber(5)
factory = Factory{}.WithAccountRetriever(client.MockAccountRetriever{ReturnAccNum: 10, ReturnAccSeq: 1}).WithAccountNumber(5)
output, err = factory.Prepare(clientCtx.WithFrom("foo"))
require.NoError(t, err)
require.NotEqual(t, output, factory)
require.Equal(t, output.AccountNumber(), uint64(5))
require.Equal(t, output.Sequence(), uint64(1))

factory = tx.Factory{}.WithAccountRetriever(client.MockAccountRetriever{ReturnAccNum: 10, ReturnAccSeq: 1})
factory = Factory{}.WithAccountRetriever(client.MockAccountRetriever{ReturnAccNum: 10, ReturnAccSeq: 1})
output, err = factory.Prepare(clientCtx.WithFrom("foo"))
require.NoError(t, err)
require.NotEqual(t, output, factory)
require.Equal(t, output.AccountNumber(), uint64(10))
require.Equal(t, output.Sequence(), uint64(1))
}

func TestFactory_getSimPKType(t *testing.T) {
// setup keyring
registry := codectypes.NewInterfaceRegistry()
cryptocodec.RegisterInterfaces(registry)
k := keyring.NewInMemory(codec.NewProtoCodec(registry))

tests := []struct {
name string
fromName string
genKey func(fromName string, k keyring.Keyring) error
wantType types.PubKey
}{
{
name: "simple key",
fromName: "testKey",
genKey: func(fromName string, k keyring.Keyring) error {
_, err := k.NewAccount(fromName, testdata.TestMnemonic, "", "", hd.Secp256k1)
return err
},
wantType: (*secp256k1.PubKey)(nil),
},
{
name: "multisig key",
fromName: "multiKey",
genKey: func(fromName string, k keyring.Keyring) error {
pk := multisig.NewLegacyAminoPubKey(1, []types.PubKey{&multisig.LegacyAminoPubKey{}})
_, err := k.SaveMultisig(fromName, pk)
return err
},
wantType: (*multisig.LegacyAminoPubKey)(nil),
},
}

for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
err := tt.genKey(tt.fromName, k)
require.NoError(t, err)
f := Factory{
keybase: k,
fromName: tt.fromName,
simulateAndExecute: true,
}
got, err := f.getSimPK()
require.NoError(t, err)
require.IsType(t, tt.wantType, got)
})
}
}

func TestFactory_getSimSignatureData(t *testing.T) {
tests := []struct {
name string
pk types.PubKey
wantType any
}{
{
name: "simple pubkey",
pk: &secp256k1.PubKey{},
wantType: (*signing.SingleSignatureData)(nil),
},
{
name: "multisig pubkey",
pk: &multisig.LegacyAminoPubKey{},
wantType: (*signing.MultiSignatureData)(nil),
},
}

for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
got := Factory{}.getSimSignatureData(tt.pk)
require.IsType(t, tt.wantType, got)
})
}
}
Loading
Loading