Skip to content

Commit

Permalink
chore: upgrade v0.45.5 (#131)
Browse files Browse the repository at this point in the history
* fix: decrement types.Dec max length to keep decimal bits in DecimalPrecisionBits (backport #11772) (#11805)

* fix: Bug reading password from a buffer when reader returns EOF (backport #11796) (#11810)

* refactor: improve error messages (backport #11762) (#11887)

* refactor: improve error messages (#11762)

## Description

Closes: #XXXX

* feat: add feegrant query to see allowances from a given granter (backport #10947) (#11885)

* fix: grants by granter pagination `total` (#11813) (#11828)

* refactor: remove redacted message (backport #11960) (#12002)

* fix: index ante events for failed tx (backport: #12013) (#12017)

* fix: Make rechecking a tx check the sequence number #12060 (#12062)

(cherry picked from commit 8eaff8f)

Co-authored-by: Dev Ojha <ValarDragon@users.noreply.github.com>

* fix: cli `grants-by-grantee`, `grants-by-granter` cmds (backport #11983) (#12025)

* fix: cli `grants-by-grantee`, `grants-by-granter` cmds (#11983)

## Description

ref: #11362

* fix: add base account getter (backport #12154) (#12161)

* fix: add base account getter (#12154)

(cherry picked from commit a39be7b)

# Conflicts:
#	CHANGELOG.md

* fix conflict

Co-authored-by: mmsqe <tqd0800210105@gmail.com>
Co-authored-by: Julien Robert <julien@rbrt.fr>

* refactor: Simplify SimulationManager setup (backport #12153) (#12159)

* refactor: Simplify SimulationManager setup (#12153)

(cherry picked from commit 544afb6)

# Conflicts:
#	CHANGELOG.md
#	simapp/app.go

* fix conflict

* fix conflict

Co-authored-by: Dev Ojha <ValarDragon@users.noreply.github.com>
Co-authored-by: Julien Robert <julien@rbrt.fr>

* perf: modify DelegatorSharesInvariant for better performance (#12170) (#12179)

* chore: remove direct reliance on staking from slashing (backport #12177) (#12181)

* fix(upgrades): perform no-op if 'from' and 'to' migration version are equal (#12174) (#12192)

* chore(types): add MustAccAddressFromBech32 util func (backport #12201) (#12205)

* Revert "fix: add base account getter (backport #12154) (#12161)" (#12213)

* chore: prep release notes + cl (#12207)

* fix: install tparse workflow

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
Co-authored-by: Julien Robert <julien@rbrt.fr>
Co-authored-by: yihuang <huang@crypto.com>
Co-authored-by: Dev Ojha <ValarDragon@users.noreply.github.com>
Co-authored-by: mmsqe <tqd0800210105@gmail.com>
Co-authored-by: Aleksandr Bezobchuk <alexanderbez@users.noreply.github.com>
  • Loading branch information
7 people authored Jul 18, 2022
1 parent 61366e1 commit 9be8f9f
Show file tree
Hide file tree
Showing 75 changed files with 2,540 additions and 1,588 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 get github.com/mfridman/tparse@v0.8.3
export GO111MODULE="on" && go install github.com/mfridman/tparse@v0.8.3
- uses: actions/cache@v2.1.6
with:
path: ~/go/bin
Expand Down
2,081 changes: 1,048 additions & 1,033 deletions CHANGELOG.md

Large diffs are not rendered by default.

12 changes: 6 additions & 6 deletions RELEASE_NOTES.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# Cosmos SDK v0.45.4 Release Notes
# Cosmos SDK v0.45.5 Release Notes

This release introduces a few bug fixes and improvements. Notably, it adds an
error check to the `NewNode` call in the `server` package, which would allow nodes
to sync correctly.
This release introduces a few bug fixes and improvements. Notably, it removes
the redacted error message, fixes a few bugs in the `types` package, and
indexing of events for failed txs.

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

**Full Commit History**: https://github.com/cosmos/cosmos-sdk/compare/v0.45.3...v0.45.4
**Full Commit History**: https://github.com/cosmos/cosmos-sdk/compare/v0.45.4...v0.45.5
2 changes: 1 addition & 1 deletion baseapp/abci.go
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ func (app *BaseApp) DeliverTx(req abci.RequestDeliverTx) abci.ResponseDeliverTx
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)
return sdkerrors.ResponseDeliverTxWithEvents(err, gInfo.GasWanted, gInfo.GasUsed, sdk.MarkEventsToIndex(anteEvents, app.indexEvents), app.trace)
}

return abci.ResponseDeliverTx{
Expand Down
18 changes: 16 additions & 2 deletions client/input/input.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package input

import (
"bufio"
"errors"
"fmt"
"io"
"os"
Expand Down Expand Up @@ -83,12 +84,25 @@ func inputIsTty() bool {
return isatty.IsTerminal(os.Stdin.Fd()) || isatty.IsCygwinTerminal(os.Stdin.Fd())
}

// readLineFromBuf reads one line from stdin.
// readLineFromBuf reads one line from reader.
// Subsequent calls reuse the same buffer, so we don't lose
// any input when reading a password twice (to verify)
func readLineFromBuf(buf *bufio.Reader) (string, error) {
pass, err := buf.ReadString('\n')
if err != nil {

switch {
case errors.Is(err, io.EOF):
// If by any chance the error is EOF, but we were actually able to read
// something from the reader then don't return the EOF error.
// If we didn't read anything from the reader and got the EOF error, then
// it's safe to return EOF back to the caller.
if len(pass) > 0 {
// exit the switch statement
break
}
return "", err

case err != nil:
return "", err
}

Expand Down
57 changes: 57 additions & 0 deletions client/input/input_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
package input

import (
"bufio"
"errors"
"io"
"testing"

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

type fakeReader struct {
fnc func(p []byte) (int, error)
}

func (f fakeReader) Read(p []byte) (int, error) {
return f.fnc(p)
}

var _ io.Reader = fakeReader{}

func TestReadLineFromBuf(t *testing.T) {
var fr fakeReader

t.Run("it correctly returns the password when reader returns EOF", func(t *testing.T) {
fr.fnc = func(p []byte) (int, error) {
return copy(p, []byte("hello")), io.EOF
}
buf := bufio.NewReader(fr)

pass, err := readLineFromBuf(buf)
require.NoError(t, err)
require.Equal(t, "hello", pass)
})

t.Run("it returns EOF if reader has been exhausted", func(t *testing.T) {
fr.fnc = func(p []byte) (int, error) {
return 0, io.EOF
}
buf := bufio.NewReader(fr)

_, err := readLineFromBuf(buf)
require.ErrorIs(t, err, io.EOF)
})

t.Run("it returns the error if it's not EOF regardles if it read something or not", func(t *testing.T) {
expectedErr := errors.New("oh no")
fr.fnc = func(p []byte) (int, error) {
return copy(p, []byte("hello")), expectedErr
}
buf := bufio.NewReader(fr)

_, err := readLineFromBuf(buf)
require.ErrorIs(t, err, expectedErr)
})

}
46 changes: 44 additions & 2 deletions docs/core/proto-docs.md
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,8 @@
- [cosmos/feegrant/v1beta1/query.proto](#cosmos/feegrant/v1beta1/query.proto)
- [QueryAllowanceRequest](#cosmos.feegrant.v1beta1.QueryAllowanceRequest)
- [QueryAllowanceResponse](#cosmos.feegrant.v1beta1.QueryAllowanceResponse)
- [QueryAllowancesByGranterRequest](#cosmos.feegrant.v1beta1.QueryAllowancesByGranterRequest)
- [QueryAllowancesByGranterResponse](#cosmos.feegrant.v1beta1.QueryAllowancesByGranterResponse)
- [QueryAllowancesRequest](#cosmos.feegrant.v1beta1.QueryAllowancesRequest)
- [QueryAllowancesResponse](#cosmos.feegrant.v1beta1.QueryAllowancesResponse)

Expand Down Expand Up @@ -932,6 +934,8 @@ the provide method with expiration time.
GrantAuthorization extends a grant with both the addresses of the grantee and granter.
It is used in genesis.proto and query.proto

Since: cosmos-sdk 0.45.2


| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
Expand Down Expand Up @@ -1156,10 +1160,10 @@ Query defines the gRPC querier service.
| `Grants` | [QueryGrantsRequest](#cosmos.authz.v1beta1.QueryGrantsRequest) | [QueryGrantsResponse](#cosmos.authz.v1beta1.QueryGrantsResponse) | Returns list of `Authorization`, granted to the grantee by the granter. | GET|/cosmos/authz/v1beta1/grants|
| `GranterGrants` | [QueryGranterGrantsRequest](#cosmos.authz.v1beta1.QueryGranterGrantsRequest) | [QueryGranterGrantsResponse](#cosmos.authz.v1beta1.QueryGranterGrantsResponse) | GranterGrants returns list of `GrantAuthorization`, granted by granter.

Since: cosmos-sdk 0.46 | GET|/cosmos/authz/v1beta1/grants/granter/{granter}|
Since: cosmos-sdk 0.45.2 | GET|/cosmos/authz/v1beta1/grants/granter/{granter}|
| `GranteeGrants` | [QueryGranteeGrantsRequest](#cosmos.authz.v1beta1.QueryGranteeGrantsRequest) | [QueryGranteeGrantsResponse](#cosmos.authz.v1beta1.QueryGranteeGrantsResponse) | GranteeGrants returns a list of `GrantAuthorization` by grantee.

Since: cosmos-sdk 0.46 | GET|/cosmos/authz/v1beta1/grants/grantee/{grantee}|
Since: cosmos-sdk 0.45.2 | GET|/cosmos/authz/v1beta1/grants/grantee/{grantee}|

<!-- end services -->

Expand Down Expand Up @@ -4850,6 +4854,38 @@ QueryAllowanceResponse is the response type for the Query/Allowance RPC method.



<a name="cosmos.feegrant.v1beta1.QueryAllowancesByGranterRequest"></a>

### QueryAllowancesByGranterRequest
QueryAllowancesByGranterRequest is the request type for the Query/AllowancesByGranter RPC method.


| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| `granter` | [string](#string) | | |
| `pagination` | [cosmos.base.query.v1beta1.PageRequest](#cosmos.base.query.v1beta1.PageRequest) | | pagination defines an pagination for the request. |






<a name="cosmos.feegrant.v1beta1.QueryAllowancesByGranterResponse"></a>

### QueryAllowancesByGranterResponse
QueryAllowancesByGranterResponse is the response type for the Query/AllowancesByGranter RPC method.


| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| `allowances` | [Grant](#cosmos.feegrant.v1beta1.Grant) | repeated | allowances that have been issued by the granter. |
| `pagination` | [cosmos.base.query.v1beta1.PageResponse](#cosmos.base.query.v1beta1.PageResponse) | | pagination defines an pagination for the response. |






<a name="cosmos.feegrant.v1beta1.QueryAllowancesRequest"></a>

### QueryAllowancesRequest
Expand Down Expand Up @@ -4897,6 +4933,7 @@ Query defines the gRPC querier service.
| ----------- | ------------ | ------------- | ------------| ------- | -------- |
| `Allowance` | [QueryAllowanceRequest](#cosmos.feegrant.v1beta1.QueryAllowanceRequest) | [QueryAllowanceResponse](#cosmos.feegrant.v1beta1.QueryAllowanceResponse) | Allowance returns fee granted to the grantee by the granter. | GET|/cosmos/feegrant/v1beta1/allowance/{granter}/{grantee}|
| `Allowances` | [QueryAllowancesRequest](#cosmos.feegrant.v1beta1.QueryAllowancesRequest) | [QueryAllowancesResponse](#cosmos.feegrant.v1beta1.QueryAllowancesResponse) | Allowances returns all the grants for address. | GET|/cosmos/feegrant/v1beta1/allowances/{grantee}|
| `AllowancesByGranter` | [QueryAllowancesByGranterRequest](#cosmos.feegrant.v1beta1.QueryAllowancesByGranterRequest) | [QueryAllowancesByGranterResponse](#cosmos.feegrant.v1beta1.QueryAllowancesByGranterResponse) | AllowancesByGranter returns all the grants given by an address Since v0.46 | GET|/cosmos/feegrant/v1beta1/issued/{granter}|

<!-- end services -->

Expand Down Expand Up @@ -7592,6 +7629,11 @@ SignMode represents a signing mode with its own security guarantees.
| SIGN_MODE_DIRECT | 1 | SIGN_MODE_DIRECT specifies a signing mode which uses SignDoc and is verified with raw bytes from Tx |
| SIGN_MODE_TEXTUAL | 2 | SIGN_MODE_TEXTUAL is a future signing mode that will verify some human-readable textual representation on top of the binary representation from SIGN_MODE_DIRECT |
| SIGN_MODE_LEGACY_AMINO_JSON | 127 | SIGN_MODE_LEGACY_AMINO_JSON is a backwards compatibility mode which uses Amino JSON and will be removed in the future |
| SIGN_MODE_EIP_191 | 191 | SIGN_MODE_EIP_191 specifies the sign mode for EIP 191 signing on the Cosmos SDK. Ref: https://eips.ethereum.org/EIPS/eip-191

Currently, SIGN_MODE_EIP_191 is registered as a SignMode enum variant, but is not implemented on the SDK by default. To enable EIP-191, you need to pass a custom `TxConfig` that has an implementation of `SignModeHandler` for EIP-191. The SDK may decide to fully support EIP-191 in the future.

Since: cosmos-sdk 0.45.2 |


<!-- end enums -->
Expand Down
6 changes: 3 additions & 3 deletions proto/cosmos/base/snapshots/v1beta1/snapshot.proto
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,12 @@ message SnapshotStoreItem {

// SnapshotIAVLItem is an exported IAVL node.
message SnapshotIAVLItem {
bytes key = 1;
bytes value = 2;
bytes key = 1;
bytes value = 2;
// version is block height
int64 version = 3;
// height is depth of the tree.
int32 height = 4;
int32 height = 4;
}

// SnapshotExtensionMeta contains metadata about an external snapshotter.
Expand Down
23 changes: 23 additions & 0 deletions proto/cosmos/feegrant/v1beta1/query.proto
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,12 @@ service Query {
rpc Allowances(QueryAllowancesRequest) returns (QueryAllowancesResponse) {
option (google.api.http).get = "/cosmos/feegrant/v1beta1/allowances/{grantee}";
}

// AllowancesByGranter returns all the grants given by an address
// Since v0.46
rpc AllowancesByGranter(QueryAllowancesByGranterRequest) returns (QueryAllowancesByGranterResponse) {
option (google.api.http).get = "/cosmos/feegrant/v1beta1/issued/{granter}";
}
}

// QueryAllowanceRequest is the request type for the Query/Allowance RPC method.
Expand Down Expand Up @@ -53,3 +59,20 @@ message QueryAllowancesResponse {
// pagination defines an pagination for the response.
cosmos.base.query.v1beta1.PageResponse pagination = 2;
}

// QueryAllowancesByGranterRequest is the request type for the Query/AllowancesByGranter RPC method.
message QueryAllowancesByGranterRequest {
string granter = 1;

// pagination defines an pagination for the request.
cosmos.base.query.v1beta1.PageRequest pagination = 2;
}

// QueryAllowancesByGranterResponse is the response type for the Query/AllowancesByGranter RPC method.
message QueryAllowancesByGranterResponse {
// allowances that have been issued by the granter.
repeated cosmos.feegrant.v1beta1.Grant allowances = 1;

// pagination defines an pagination for the response.
cosmos.base.query.v1beta1.PageResponse pagination = 2;
}
6 changes: 3 additions & 3 deletions proto/cosmos/tx/v1beta1/service.proto
Original file line number Diff line number Diff line change
Expand Up @@ -157,9 +157,9 @@ message GetBlockWithTxsRequest {
// Since: cosmos-sdk 0.45.2
message GetBlockWithTxsResponse {
// txs are the transactions in the block.
repeated cosmos.tx.v1beta1.Tx txs = 1;
.tendermint.types.BlockID block_id = 2;
.tendermint.types.Block block = 3;
repeated cosmos.tx.v1beta1.Tx txs = 1;
.tendermint.types.BlockID block_id = 2;
.tendermint.types.Block block = 3;
// pagination defines a pagination for the response.
cosmos.base.query.v1beta1.PageResponse pagination = 4;
}
16 changes: 3 additions & 13 deletions server/rosetta/converter.go
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,6 @@ func (c converter) UnsignedTx(ops []*rosettatypes.Operation) (tx authsigning.Tx,
}

return builder.GetTx(), nil

}

// Msg unmarshals the rosetta metadata to the given sdk.Msg
Expand Down Expand Up @@ -334,7 +333,6 @@ func (c converter) BalanceOps(status string, events []abci.Event) []*rosettatype
// has changed and rosetta needs to reflect those changes too.
// The balance operations are multiple, one for each denom.
func sdkEventToBalanceOperations(status string, event abci.Event) (operations []*rosettatypes.Operation, isBalanceEvent bool) {

var (
accountIdentifier string
coinChange sdk.Coins
Expand All @@ -345,10 +343,7 @@ func sdkEventToBalanceOperations(status string, event abci.Event) (operations []
default:
return nil, false
case banktypes.EventTypeCoinSpent:
spender, err := sdk.AccAddressFromBech32((string)(event.Attributes[0].Value))
if err != nil {
panic(err)
}
spender := sdk.MustAccAddressFromBech32((string)(event.Attributes[0].Value))
coins, err := sdk.ParseCoinsNormalized((string)(event.Attributes[1].Value))
if err != nil {
panic(err)
Expand All @@ -359,10 +354,7 @@ func sdkEventToBalanceOperations(status string, event abci.Event) (operations []
accountIdentifier = spender.String()

case banktypes.EventTypeCoinReceived:
receiver, err := sdk.AccAddressFromBech32((string)(event.Attributes[0].Value))
if err != nil {
panic(err)
}
receiver := sdk.MustAccAddressFromBech32((string)(event.Attributes[0].Value))
coins, err := sdk.ParseCoinsNormalized((string)(event.Attributes[1].Value))
if err != nil {
panic(err)
Expand Down Expand Up @@ -516,7 +508,7 @@ func (c converter) HashToTxType(hashBytes []byte) (txType TransactionType, realH
// StatusToSyncStatus converts a tendermint status to rosetta sync status
func (c converter) SyncStatus(status *tmcoretypes.ResultStatus) *rosettatypes.SyncStatus {
// determine sync status
var stage = StatusPeerSynced
stage := StatusPeerSynced
if status.SyncInfo.CatchingUp {
stage = StatusPeerSyncing
}
Expand Down Expand Up @@ -584,7 +576,6 @@ func (c converter) Peers(peers []tmcoretypes.Peer) []*rosettatypes.Peer {
// OpsAndSigners takes transactions bytes and returns the operation, is signed is true it will return
// the account identifiers which have signed the transaction
func (c converter) OpsAndSigners(txBytes []byte) (ops []*rosettatypes.Operation, signers []*rosettatypes.AccountIdentifier, err error) {

rosTx, err := c.ToRosetta().Tx(txBytes, nil)
if err != nil {
return nil, nil, err
Expand Down Expand Up @@ -678,7 +669,6 @@ func (c converter) PubKey(pubKey *rosettatypes.PublicKey) (cryptotypes.PubKey, e

// SigningComponents takes a sdk tx and construction metadata and returns signable components
func (c converter) SigningComponents(tx authsigning.Tx, metadata *ConstructionMetadata, rosPubKeys []*rosettatypes.PublicKey) (txBytes []byte, payloadsToSign []*rosettatypes.SigningPayload, err error) {

// verify metadata correctness
feeAmount, err := sdk.ParseCoinsNormalized(metadata.GasPrice)
if err != nil {
Expand Down
18 changes: 4 additions & 14 deletions simapp/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -373,20 +373,10 @@ func NewSimApp(
//
// NOTE: this is not required apps that don't use the simulator for fuzz testing
// transactions
app.sm = module.NewSimulationManager(
auth.NewAppModule(appCodec, app.AccountKeeper, authsims.RandomGenesisAccounts),
bank.NewAppModule(appCodec, app.BankKeeper, app.AccountKeeper),
capability.NewAppModule(appCodec, *app.CapabilityKeeper),
feegrantmodule.NewAppModule(appCodec, app.AccountKeeper, app.BankKeeper, app.FeeGrantKeeper, app.interfaceRegistry),
gov.NewAppModule(appCodec, app.GovKeeper, app.AccountKeeper, app.BankKeeper),
mint.NewAppModule(appCodec, app.MintKeeper, app.AccountKeeper),
staking.NewAppModule(appCodec, app.StakingKeeper, app.AccountKeeper, app.BankKeeper),
distr.NewAppModule(appCodec, app.DistrKeeper, app.AccountKeeper, app.BankKeeper, app.StakingKeeper),
slashing.NewAppModule(appCodec, app.SlashingKeeper, app.AccountKeeper, app.BankKeeper, app.StakingKeeper),
params.NewAppModule(app.ParamsKeeper),
evidence.NewAppModule(app.EvidenceKeeper),
authzmodule.NewAppModule(appCodec, app.AuthzKeeper, app.AccountKeeper, app.BankKeeper, app.interfaceRegistry),
)
overrideModules := map[string]module.AppModuleSimulation{
authtypes.ModuleName: auth.NewAppModule(app.appCodec, app.AccountKeeper, authsims.RandomGenesisAccounts),
}
app.sm = module.NewSimulationManagerFromAppModules(app.mm.Modules, overrideModules)

app.sm.RegisterStoreDecoders()

Expand Down
11 changes: 3 additions & 8 deletions simapp/export.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,10 +84,8 @@ func (app *SimApp) prepForZeroHeightGenesis(ctx sdk.Context, jailAllowedAddrs []
panic(err)
}

delAddr, err := sdk.AccAddressFromBech32(delegation.DelegatorAddress)
if err != nil {
panic(err)
}
delAddr := sdk.MustAccAddressFromBech32(delegation.DelegatorAddress)

_, _ = app.DistrKeeper.WithdrawDelegationRewards(ctx, delAddr, valAddr)
}

Expand Down Expand Up @@ -119,10 +117,7 @@ func (app *SimApp) prepForZeroHeightGenesis(ctx sdk.Context, jailAllowedAddrs []
if err != nil {
panic(err)
}
delAddr, err := sdk.AccAddressFromBech32(del.DelegatorAddress)
if err != nil {
panic(err)
}
delAddr := sdk.MustAccAddressFromBech32(del.DelegatorAddress)
app.DistrKeeper.Hooks().BeforeDelegationCreated(ctx, delAddr, valAddr)
app.DistrKeeper.Hooks().AfterDelegationModified(ctx, delAddr, valAddr)
}
Expand Down
Loading

0 comments on commit 9be8f9f

Please sign in to comment.