Skip to content

Commit

Permalink
chore: upgrade v0.45.8 (#133)
Browse files Browse the repository at this point in the history
* fix: update x/mint parameter validation (backport #12384) (#12396)

* chore: optimize get last completed upgrade (#12268)

* feat: improve GetLastCompletedUpgrade

* rename

* use var block

* fix: Simulation is not deterministic due to GenTx (backport #12374) (#12437)

* fix: use go install instead of go get in makefile (#12435)

* chore: fumpt sdk v45 series #12442

* feat: Move AppModule.BeginBlock and AppModule.EndBlock to extension interfaces (backport #12603) (#12638)

* feat: Move AppModule.BeginBlock and AppModule.EndBlock to extension interfaces (#12603)

## Description
Most modules right now have a no-op for AppModule.BeginBlock and AppModule.EndBlock. We should move these methods off the AppModule interface so we have less deadcode, and instead move them to extension interfaces.

1. I added `BeginBlockAppModule` and `EndBlockAppModule` interface.
2. Remove the dead-code from modules that do no implement them
3. Add type casting in the the module code to use the new interface

Closes: #12462

* feat: add message index event attribute to authz message execution (backport #12668) (#12673)

* chore(store): upgrade iavl to v0.19.0 (backport #12626) (#12697)

* feat: Add `GetParamSetIfExists` to prevent panic on breaking param changes (#12724)

* feat: Add convenience method for constructing key to access account's balance for a given denom (backport #12674) (#12745)

* feat: Add convenience method for constructing key to access account's balance for a given denom (#12674)

This PR adds a convenience method for constructing the key necessary to query for the account's balance of a given denom.

I ran into this issue since we are using ABCI query now to perform balance requests because we are also requesting merkle proofs for the returned balance [here](https://github.com/celestiaorg/celestia-node/pull/911/files#diff-0ee31f5a7bd88e9f758e6bebdf3ee36365519e55a451098d9638c39afe5eac42R144).

It would be nice to have a definitive convenience method for constructing the key.

[Ref.](github.com/celestiaorg/celestia-node/pull/911)

(cherry picked from commit a1777a8)

# Conflicts:
#	CHANGELOG.md
#	x/bank/legacy/v043/store.go
#	x/bank/types/keys.go

* Update CHANGELOG.md

* fix conflict

Co-authored-by: rene <[email protected]>
Co-authored-by: Marko <[email protected]>

* chore: bump tm in 0.45.x (#12784)

* bump tendermint version

* add changelog entry

* replace on jhump

* updates

* updates

* updates

Co-authored-by: Aleksandr Bezobchuk <[email protected]>

* chore: 0.45.7 changelog prep (#12821)

* prepare for release

* modify release notes

* docs(staking): typo in staking/state (backport #12834) (#12836)

* fix(docs): typo in staking/state (#12834)

(cherry picked from commit fe89212)

# Conflicts:
#	x/staking/spec/01_state.md

* updates

Co-authored-by: Ari Rubinstein <[email protected]>
Co-authored-by: Julien Robert <[email protected]>

* chore: fee payer event (backport #12850) (#12856)

* chore: changelog update (backport #12859) (#12862)

* fix: Use fixed length hex for pointer at FwdCapabilityKey (backport #11737) (#12818)

* fix: Use fixed length hex for pointer at FwdCapabilityKey (backport #11737)

* Update CHANGELOG.md

* add comments and unit tests

* feat: deterministic map iteration (backport #12781) (#12944)

* feat: deterministic map iteration (#12781)

## Description

We should ensure that events emitted are in a deterministic order on any node.

Sorry, the previous [PR-12693](cosmos/cosmos-sdk#12693) was closed due to wrong operation.

Close: #12693

* chore: bump tendermint to `0.34.21` and iavl to `0.19.1` (#12970)

* perf: Amortize clearing unsorted cache entries (Juno genesis fix) (backport #12885) (#12961)

* perf: Amortize clearing unsorted cache entries (Juno genesis fix) (#12885)

This change fixes a bounty by the Juno team.  Juno's invariant checks took 10 hours during their most recent chain halt. This PR cuts that down to 30 seconds.  See https://github.com/CosmosContracts/bounties#improve-speed-of-invariant-checks.

The root problem is deep in the `can-withdraw` invariant check, which calls this repeatedly: https://github.com/cosmos/cosmos-sdk/blob/main/x/distribution/keeper/store.go#L337.  Iterators have a chain of parents and in this case creates an iterator from the `cachekv` store.  For the genesis file, it has a cache of 500,000+ unsorted entries, which are sorted as strings here: https://github.com/cosmos/cosmos-sdk/blob/main/store/cachekv/store.go#L314.  Each delegation from `can-withdraw` uses this cache and many of the cache checks miss or are a very small range.  This means very few entries get removed from the unsorted cache and they have to be re-sorted on the next call.  With a full cache it takes about 180ms on my machine to sort them.

This change introduce a minimum number of entries that will get processed and removed from the unsorted list. It's set at the same value that directs the code to sort them in the first place.  This ensures the unsorted values get removed in a relative short amount of time, and amortizes the cost to ensure an individual check does not have to process the entire cache.

## Benchmarks
On running the benchmarks included in this change produces:
```shell
name                    old time/op    new time/op    delta
LargeUnsortedMisses-32     21.2s ± 9%      0.0s ± 1%   -99.91%  (p=0.000 n=20+17)

name                    old alloc/op   new alloc/op   delta
LargeUnsortedMisses-32    1.64GB ± 0%    0.00GB ± 0%   -99.83%  (p=0.000 n=19+19)

name                    old allocs/op  new allocs/op  delta
LargeUnsortedMisses-32     20.0k ± 0%     41.1k ± 0%  +105.23%  (p=0.000 n=19+20)
```

## Invariant checks results
This is what the invariant checks for Juno look like with this change (on a Hetzner AX101):

```shell
INF starting node with ABCI Tendermint in-process
4:11PM INF Starting multiAppConn service impl=multiAppConn module=proxy
4:11PM INF Starting localClient service connection=query impl=localClient module=abci-client
4:11PM INF Starting localClient service connection=snapshot impl=localClient module=abci-client
4:11PM INF Starting localClient service connection=mempool impl=localClient module=abci-client
4:11PM INF Starting localClient service connection=consensus impl=localClient module=abci-client
4:11PM INF Starting EventBus service impl=EventBus module=events
4:11PM INF Starting PubSub service impl=PubSub module=pubsub
4:11PM INF Starting IndexerService service impl=IndexerService module=txindex
4:11PM INF ABCI Handshake App Info hash= height=0 module=consensus protocol-version=0 software-version=v9.0.0-36-g8fd6f16
4:11PM INF ABCI Replay Blocks appHeight=0 module=consensus stateHeight=0 storeHeight=0
4:12PM INF asserting crisis invariants inv=1/11 module=x/crisis name=gov/module-account
4:12PM INF asserting crisis invariants inv=2/11 module=x/crisis name=distribution/nonnegative-outstanding
4:12PM INF asserting crisis invariants inv=3/11 module=x/crisis name=distribution/can-withdraw
4:12PM INF asserting crisis invariants inv=4/11 module=x/crisis name=distribution/reference-count
4:12PM INF asserting crisis invariants inv=5/11 module=x/crisis name=distribution/module-account
4:12PM INF asserting crisis invariants inv=6/11 module=x/crisis name=bank/nonnegative-outstanding
4:12PM INF asserting crisis invariants inv=7/11 module=x/crisis name=bank/total-supply
4:12PM INF asserting crisis invariants inv=8/11 module=x/crisis name=staking/module-accounts
4:12PM INF asserting crisis invariants inv=9/11 module=x/crisis name=staking/nonnegative-power
4:12PM INF asserting crisis invariants inv=10/11 module=x/crisis name=staking/positive-delegation
4:12PM INF asserting crisis invariants inv=11/11 module=x/crisis name=staking/delegator-shares
4:12PM INF asserted all invariants duration=28383.559601 height=4136532 module=x/crisis
```

## Alternatives
There is another PR which fixes this problem for the Juno genesis file cosmos/cosmos-sdk#12886. However, because of its concurrent nature, it happens to hit a large range relatively early, clearing the unsorted entries and allowing the rest of the checks to not sort it.

(cherry picked from commit 4fc1f73)

# Conflicts:
#	CHANGELOG.md

* fix conflict

Co-authored-by: blazeroni <[email protected]>
Co-authored-by: Julien Robert <[email protected]>
Co-authored-by: Marko <[email protected]>

* fix: proper error when parsing telemetry configuration (backport #12981) (#12999)

* ci: fix release notes not populated by goreleaser (#13019)

Co-authored-by: Julien Robert <[email protected]>

* fix: missing return statement in BaseApp.Query (backport #13046) (#13050)

* fix: missing return statement in BaseApp.Query (#13046)

## Description

Closes: #13040

* chore: v0.45.8 release changelog (#13053)

* chore: v0.45.8 release changelog

* fix issue name

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
Co-authored-by: Robert Zaremba <[email protected]>
Co-authored-by: Adu <[email protected]>
Co-authored-by: Julien Robert <[email protected]>
Co-authored-by: Jacob Gadikian <[email protected]>
Co-authored-by: Federico Kunze Küllmer <[email protected]>
Co-authored-by: rene <[email protected]>
Co-authored-by: Marko <[email protected]>
Co-authored-by: Aleksandr Bezobchuk <[email protected]>
Co-authored-by: Ari Rubinstein <[email protected]>
Co-authored-by: yihuang <[email protected]>
Co-authored-by: blazeroni <[email protected]>
  • Loading branch information
13 people committed Sep 27, 2022
1 parent ad32aa8 commit 477dadd
Show file tree
Hide file tree
Showing 384 changed files with 1,844 additions and 1,450 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
run: go version
- name: install tparse
run: |
export GO111MODULE="on" && go install github.com/mfridman/[email protected]
go install github.com/mfridman/[email protected]
- uses: actions/[email protected]
with:
path: ~/go/bin
Expand Down
2 changes: 1 addition & 1 deletion .goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,4 @@ snapshot:
name_template: SNAPSHOT-{{ .Commit }}

changelog:
skip: true
skip: false
36 changes: 36 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,42 @@ Ref: https://keepachangelog.com/en/1.0.0/

## [Unreleased]

## v0.45.8 - 2022-08-25

### Improvements

* [#12981](https://github.com/cosmos/cosmos-sdk/pull/12981) Return proper error when parsing telemetry configuration.
* [#12885](https://github.com/cosmos/cosmos-sdk/pull/12885) Amortize cost of processing cache KV store.
* [#12970](https://github.com/cosmos/cosmos-sdk/pull/12970) Bump Tendermint to `v0.34.21` and IAVL to `v0.19.1`.
* [#12693](https://github.com/cosmos/cosmos-sdk/pull/12693) Make sure the order of each node is consistent when emitting proto events.

### Bug Fixes

* [#13046](https://github.com/cosmos/cosmos-sdk/pull/13046) Fix missing return statement in BaseApp.Query.

## v0.45.7 - 2022-08-04

### Features

* (upgrade) [#12603](https://github.com/cosmos/cosmos-sdk/pull/12603) feat: Move AppModule.BeginBlock and AppModule.EndBlock to extension interfaces

### Improvements

* (events) [#12850](https://github.com/cosmos/cosmos-sdk/pull/12850) Add a new `fee_payer` attribute to the `tx` event that is emitted from the `DeductFeeDecorator` AnteHandler decorator.
* (x/params) [#12724](https://github.com/cosmos/cosmos-sdk/pull/12724) Add `GetParamSetIfExists` function to params `Subspace` to prevent panics on breaking changes.
* [#12668](https://github.com/cosmos/cosmos-sdk/pull/12668) Add `authz_msg_index` event attribute to message events emitted when executing via `MsgExec` through `x/authz`.
* [#12697](https://github.com/cosmos/cosmos-sdk/pull/12697) Upgrade IAVL to v0.19.0 with fast index and error propagation. NOTE: first start will take a while to propagate into new model.
- Note: after upgrading to this version it may take up to 15 minutes to migrate from 0.17 to 0.19. This time is used to create the fast cache introduced into IAVL for performance
* [#12784](https://github.com/cosmos/cosmos-sdk/pull/12784) Upgrade Tendermint to 0.34.20.
* (x/bank) [#12674](https://github.com/cosmos/cosmos-sdk/pull/12674) Add convenience function `CreatePrefixedAccountStoreKey()` to construct key to access account's balance for a given denom.

### Bug Fixes

* (x/mint) [#12384](https://github.com/cosmos/cosmos-sdk/pull/12384) Ensure `GoalBonded` must be positive when performing `x/mint` parameter validation.
* (simapp) [#12437](https://github.com/cosmos/cosmos-sdk/pull/12437) fix the non-determinstic behavior in simulations caused by `GenTx` and check
empty coins slice before it is used to create `banktype.MsgSend`.
* (x/capability) [12818](https://github.com/cosmos/cosmos-sdk/pull/12818) Use fixed length hex for pointer at FwdCapabilityKey.

## [v0.45.6](https://github.com/cosmos/cosmos-sdk/releases/tag/v0.45.6) - 2022-06-28

### Improvements
Expand Down
10 changes: 4 additions & 6 deletions RELEASE_NOTES.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
# Cosmos SDK v0.45.6 Release Notes
# Cosmos SDK v0.45.8 Release Notes

This release introduces a few bug fixes and improvements.
Notably, it fixes `GetLastCompleteUpgrade` in `x/upgrade` to properly return the latest upgrade.
This release introduces few improvements, such as the speed-up of the crisis invariant checks (thanks to a Juno bounty), and updated Tendermint and IAVL dependencies.

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

**Full Commit History**: https://github.com/cosmos/cosmos-sdk/compare/v0.45.5...v0.45.6
**Full Commit History**: https://github.com/cosmos/cosmos-sdk/compare/v0.45.7...v0.45.8
2 changes: 1 addition & 1 deletion baseapp/abci.go
Original file line number Diff line number Diff line change
Expand Up @@ -423,7 +423,7 @@ func (app *BaseApp) Query(req abci.RequestQuery) (res abci.ResponseQuery) {

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

switch path[0] {
Expand Down
4 changes: 1 addition & 3 deletions baseapp/baseapp.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,7 @@ const (
runTxModeDeliver // Deliver a transaction
)

var (
_ abci.Application = (*BaseApp)(nil)
)
var _ abci.Application = (*BaseApp)(nil)

type (
// Enum mode for app.runTx
Expand Down
5 changes: 2 additions & 3 deletions baseapp/baseapp_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ func useDefaultLoader(app *BaseApp) {
}

func initStore(t *testing.T, db dbm.DB, storeKey string, k, v []byte) {
rs := rootmulti.NewStore(db)
rs := rootmulti.NewStore(db, log.NewNopLogger())
rs.SetPruning(store.PruneNothing)
key := sdk.NewKVStoreKey(storeKey)
rs.MountStoreWithDB(key, store.StoreTypeIAVL, nil)
Expand All @@ -275,7 +275,7 @@ func initStore(t *testing.T, db dbm.DB, storeKey string, k, v []byte) {
}

func checkStore(t *testing.T, db dbm.DB, ver int64, storeKey string, k, v []byte) {
rs := rootmulti.NewStore(db)
rs := rootmulti.NewStore(db, log.NewNopLogger())
rs.SetPruning(store.PruneDefault)
key := sdk.NewKVStoreKey(storeKey)
rs.MountStoreWithDB(key, store.StoreTypeIAVL, nil)
Expand Down Expand Up @@ -1292,7 +1292,6 @@ func TestTxGasLimits(t *testing.T) {

return newCtx, nil
})

}

routerOpt := func(bapp *BaseApp) {
Expand Down
1 change: 0 additions & 1 deletion client/broadcast_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,5 +67,4 @@ func TestBroadcastError(t *testing.T) {
require.Equal(t, txHash, resp.TxHash)
}
}

}
2 changes: 1 addition & 1 deletion client/config/toml.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ func writeConfigToFile(configFilePath string, config *ClientConfig) error {
return err
}

return ioutil.WriteFile(configFilePath, buffer.Bytes(), 0600)
return ioutil.WriteFile(configFilePath, buffer.Bytes(), 0o600)
}

// ensureConfigPath creates a directory configPath if it does not exist
Expand Down
2 changes: 0 additions & 2 deletions client/debug/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@ $ %s debug addr cosmos1e0jnq2sun3dzjh8p2xq95kk0expwmd7shwjpfg
`, version.AppName),
Args: cobra.ExactArgs(1),
RunE: func(cmd *cobra.Command, args []string) error {

addrString := args[0]
var addr []byte

Expand All @@ -86,7 +85,6 @@ $ %s debug addr cosmos1e0jnq2sun3dzjh8p2xq95kk0expwmd7shwjpfg

if err3 != nil {
return fmt.Errorf("expected hex or bech32. Got errors: hex: %v, bech32 acc: %v, bech32 val: %v", err, err2, err3)

}
}
}
Expand Down
6 changes: 2 additions & 4 deletions client/docs/statik/statik.go

Large diffs are not rendered by default.

6 changes: 4 additions & 2 deletions client/grpc/tmservice/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,10 @@ type queryServer struct {
interfaceRegistry codectypes.InterfaceRegistry
}

var _ ServiceServer = queryServer{}
var _ codectypes.UnpackInterfacesMessage = &GetLatestValidatorSetResponse{}
var (
_ ServiceServer = queryServer{}
_ codectypes.UnpackInterfacesMessage = &GetLatestValidatorSetResponse{}
)

// NewQueryServer creates a new tendermint query server.
func NewQueryServer(clientCtx client.Context, interfaceRegistry codectypes.InterfaceRegistry) ServiceServer {
Expand Down
2 changes: 1 addition & 1 deletion client/grpc/tmservice/service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ func (s IntegrationTestSuite) TestQueryLatestValidatorSet() {
s.Require().Equal(true, ok)
s.Require().Equal(content, val.PubKey)

//with pagination
// with pagination
_, err = s.queryClient.GetLatestValidatorSet(context.Background(), &tmservice.GetLatestValidatorSetRequest{Pagination: &qtypes.PageRequest{
Offset: 0,
Limit: 10,
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
1 change: 0 additions & 1 deletion client/input/input_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,5 +53,4 @@ func TestReadLineFromBuf(t *testing.T) {
_, err := readLineFromBuf(buf)
require.ErrorIs(t, err, expectedErr)
})

}
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
2 changes: 1 addition & 1 deletion client/keys/import_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ HbP+c6JmeJy9JXe2rbbF1QtCX1gLqGcDQPBXiCtFvP7/8wTZtVOPj8vREzhZ9ElO

keyfile := filepath.Join(kbHome, "key.asc")

require.NoError(t, ioutil.WriteFile(keyfile, []byte(armoredKey), 0644))
require.NoError(t, ioutil.WriteFile(keyfile, []byte(armoredKey), 0o644))

defer func() {
_ = os.RemoveAll(kbHome)
Expand Down
2 changes: 1 addition & 1 deletion client/keys/list_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ func Test_runListCmd(t *testing.T) {
clientCtx := client.Context{}.WithKeyring(kb)
ctx := context.WithValue(context.Background(), client.ClientContextKey, &clientCtx)

path := "" //sdk.GetConfig().GetFullBIP44Path()
path := "" // sdk.GetConfig().GetFullBIP44Path()
_, err = kb.NewAccount("something", testdata.TestMnemonic, "", path, hd.Secp256k1)
require.NoError(t, err)

Expand Down
4 changes: 2 additions & 2 deletions client/keys/migrate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,12 @@ func Test_runMigrateCmd(t *testing.T) {

cmd := MigrateCommand()
cmd.Flags().AddFlagSet(Commands("home").PersistentFlags())
//mockIn := testutil.ApplyMockIODiscardOutErr(cmd)
// mockIn := testutil.ApplyMockIODiscardOutErr(cmd)
mockIn, mockOut := testutil.ApplyMockIO(cmd)

cmd.SetArgs([]string{
kbHome,
//fmt.Sprintf("--%s=%s", flags.FlagHome, kbHome),
// fmt.Sprintf("--%s=%s", flags.FlagHome, kbHome),
fmt.Sprintf("--%s=true", flags.FlagDryRun),
fmt.Sprintf("--%s=%s", flags.FlagKeyringBackend, keyring.BackendTest),
})
Expand Down
1 change: 0 additions & 1 deletion client/tx/legacy.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ func ConvertTxToStdTx(codec *codec.LegacyAmino, tx signing.Tx) (legacytx.StdTx,

err := CopyTx(tx, builder, true)
if err != nil {

return legacytx.StdTx{}, err
}

Expand Down
2 changes: 1 addition & 1 deletion codec/amino_codec_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ func TestAminoCodecUnpackAnyFails(t *testing.T) {
func TestAminoCodecFullDecodeAndEncode(t *testing.T) {
// This tx comes from https://github.com/cosmos/cosmos-sdk/issues/8117.
txSigned := `{"type":"cosmos-sdk/StdTx","value":{"msg":[{"type":"cosmos-sdk/MsgCreateValidator","value":{"description":{"moniker":"fulltest","identity":"satoshi","website":"example.com","details":"example inc"},"commission":{"rate":"0.500000000000000000","max_rate":"1.000000000000000000","max_change_rate":"0.200000000000000000"},"min_self_delegation":"1000000","delegator_address":"cosmos14pt0q5cwf38zt08uu0n6yrstf3rndzr5057jys","validator_address":"cosmosvaloper14pt0q5cwf38zt08uu0n6yrstf3rndzr52q28gr","pubkey":{"type":"tendermint/PubKeyEd25519","value":"CYrOiM3HtS7uv1B1OAkknZnFYSRpQYSYII8AtMMtev0="},"value":{"denom":"umuon","amount":"700000000"}}}],"fee":{"amount":[{"denom":"umuon","amount":"6000"}],"gas":"160000"},"signatures":[{"pub_key":{"type":"tendermint/PubKeySecp256k1","value":"AwAOXeWgNf1FjMaayrSnrOOKz+Fivr6DiI/i0x0sZCHw"},"signature":"RcnfS/u2yl7uIShTrSUlDWvsXo2p2dYu6WJC8VDVHMBLEQZWc8bsINSCjOnlsIVkUNNe1q/WCA9n3Gy1+0zhYA=="}],"memo":"","timeout_height":"0"}}`
var legacyCdc = simapp.MakeTestEncodingConfig().Amino
legacyCdc := simapp.MakeTestEncodingConfig().Amino
var tx legacytx.StdTx
err := legacyCdc.UnmarshalJSON([]byte(txSigned), &tx)
require.NoError(t, err)
Expand Down
4 changes: 2 additions & 2 deletions codec/any_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ func TestMarshalProtoPubKey(t *testing.T) {
var pkI cryptotypes.PubKey
err = ccfg.InterfaceRegistry.UnpackAny(&pkAny2, &pkI)
require.NoError(err)
var pk2 = pkAny2.GetCachedValue().(cryptotypes.PubKey)
pk2 := pkAny2.GetCachedValue().(cryptotypes.PubKey)
require.True(pk2.Equals(pk))

// **** test binary serialization ****
Expand All @@ -92,7 +92,7 @@ func TestMarshalProtoPubKey(t *testing.T) {
require.NoError(err)
err = ccfg.InterfaceRegistry.UnpackAny(&pkAny3, &pkI)
require.NoError(err)
var pk3 = pkAny3.GetCachedValue().(cryptotypes.PubKey)
pk3 := pkAny3.GetCachedValue().(cryptotypes.PubKey)
require.True(pk3.Equals(pk))
}

Expand Down
6 changes: 4 additions & 2 deletions codec/codec_common_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,8 @@ func testMarshaling(t *testing.T, cdc codec.Codec) {
&testdata.Cat{},
false,
true,
}}
},
}
if _, ok := cdc.(*codec.AminoCodec); ok {
testCases = append(testCases, testCase{
"any marshaling",
Expand All @@ -123,7 +124,8 @@ func testMarshaling(t *testing.T, cdc codec.Codec) {
func(i codec.ProtoMarshaler) ([]byte, error) { return cdc.MarshalJSON(i) },
func(i codec.ProtoMarshaler) []byte { return cdc.MustMarshalJSON(i) },
func(bz []byte, ptr codec.ProtoMarshaler) error { return cdc.UnmarshalJSON(bz, ptr) },
func(bz []byte, ptr codec.ProtoMarshaler) { cdc.MustUnmarshalJSON(bz, ptr) }}
func(bz []byte, ptr codec.ProtoMarshaler) { cdc.MustUnmarshalJSON(bz, ptr) },
}

t.Run(tc.name+"_BinaryBare",
func(t *testing.T) { testMarshalingTestCase(require.New(t), tc, m1) })
Expand Down
6 changes: 4 additions & 2 deletions codec/proto_codec.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,10 @@ type ProtoCodec struct {
interfaceRegistry types.InterfaceRegistry
}

var _ Codec = &ProtoCodec{}
var _ ProtoCodecMarshaler = &ProtoCodec{}
var (
_ Codec = &ProtoCodec{}
_ ProtoCodecMarshaler = &ProtoCodec{}
)

// NewProtoCodec returns a reference to a new ProtoCodec
func NewProtoCodec(interfaceRegistry types.InterfaceRegistry) *ProtoCodec {
Expand Down
4 changes: 2 additions & 2 deletions codec/proto_codec_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,8 @@ func mustAny(msg proto.Message) *types.Any {
}

func BenchmarkProtoCodecMarshalLengthPrefixed(b *testing.B) {
var pCdc = codec.NewProtoCodec(types.NewInterfaceRegistry())
var msg = &testdata.HasAnimal{
pCdc := codec.NewProtoCodec(types.NewInterfaceRegistry())
msg := &testdata.HasAnimal{
X: 1000,
Animal: mustAny(&testdata.HasAnimal{
X: 2000,
Expand Down
6 changes: 4 additions & 2 deletions codec/types/any_internal_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,10 @@ type Animal interface {
Greet() string
}

var _ Animal = (*Dog)(nil)
var _ proto.Message = (*Dog)(nil)
var (
_ Animal = (*Dog)(nil)
_ proto.Message = (*Dog)(nil)
)

func TestAnyPackUnpack(t *testing.T) {
registry := NewInterfaceRegistry()
Expand Down
3 changes: 3 additions & 0 deletions codec/unknownproto/benchmarks_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ func init() {
func BenchmarkRejectUnknownFields_serial(b *testing.B) {
benchmarkRejectUnknownFields(b, false)
}

func BenchmarkRejectUnknownFields_parallel(b *testing.B) {
benchmarkRejectUnknownFields(b, true)
}
Expand Down Expand Up @@ -82,9 +83,11 @@ func benchmarkRejectUnknownFields(b *testing.B, parallel bool) {
func BenchmarkProtoUnmarshal_serial(b *testing.B) {
benchmarkProtoUnmarshal(b, false)
}

func BenchmarkProtoUnmarshal_parallel(b *testing.B) {
benchmarkProtoUnmarshal(b, true)
}

func benchmarkProtoUnmarshal(b *testing.B, parallel bool) {
b.ReportAllocs()

Expand Down
12 changes: 8 additions & 4 deletions codec/unknownproto/unknown_fields.go
Original file line number Diff line number Diff line change
Expand Up @@ -162,8 +162,10 @@ func RejectUnknownFields(bz []byte, msg proto.Message, allowUnknownNonCriticals
return hasUnknownNonCriticals, nil
}

var protoMessageForTypeNameMu sync.RWMutex
var protoMessageForTypeNameCache = make(map[string]proto.Message)
var (
protoMessageForTypeNameMu sync.RWMutex
protoMessageForTypeNameCache = make(map[string]proto.Message)
)

// protoMessageForTypeName takes in a fully qualified name e.g. testdata.TestVersionFD1
// and returns a corresponding empty protobuf message that serves the prototype for typechecking.
Expand Down Expand Up @@ -382,8 +384,10 @@ type descriptorMatch struct {
desc *descriptor.DescriptorProto
}

var descprotoCacheMu sync.RWMutex
var descprotoCache = make(map[reflect.Type]*descriptorMatch)
var (
descprotoCacheMu sync.RWMutex
descprotoCache = make(map[reflect.Type]*descriptorMatch)
)

// getDescriptorInfo retrieves the mapping of field numbers to their respective field descriptors.
func getDescriptorInfo(desc descriptorIface, msg proto.Message) (map[int32]*descriptor.FieldDescriptorProto, *descriptor.DescriptorProto, error) {
Expand Down
18 changes: 5 additions & 13 deletions contrib/devtools/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -57,28 +57,20 @@ tools-stamp: statik runsim
# in a row.
touch $@

# Install the runsim binary with a temporary workaround of entering an outside
# directory as the "go get" command ignores the -mod option and will polute the
# go.{mod, sum} files.
#
# ref: https://github.com/golang/go/issues/30515
# Install the runsim binary
statik: $(STATIK)
$(STATIK):
@echo "Installing statik..."
@(cd /tmp && go get github.com/rakyll/[email protected])
@go install github.com/rakyll/[email protected]

# Install the runsim binary with a temporary workaround of entering an outside
# directory as the "go get" command ignores the -mod option and will polute the
# go.{mod, sum} files.
#
# ref: https://github.com/golang/go/issues/30515
# Install the runsim binary
runsim: $(RUNSIM)
$(RUNSIM):
@echo "Installing runsim..."
@(cd /tmp && go get github.com/cosmos/tools/cmd/[email protected])
@go install github.com/cosmos/tools/cmd/[email protected]

tools-clean:
rm -f $(STATIK) $(GOLANGCI_LINT) $(RUNSIM)
rm -f tools-stamp

.PHONY: tools-clean statik runsim
.PHONY: tools-clean statik runsim
Loading

0 comments on commit 477dadd

Please sign in to comment.