diff --git a/CHANGELOG.md b/CHANGELOG.md index ed9aea5a9f73..8c514bdb386c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -41,7 +41,7 @@ Ref: https://keepachangelog.com/en/1.0.0/ ### Features * (baseapp) [#205](https://github.com/crypto-org-chain/cosmos-sdk/pull/205) Add `TxExecutor` baseapp option, add `TxIndex`/`TxCount`/`MsgIndex`/`BlockGasUsed` fields to `Context, to support tx parallel execution. -* (baseapp) [#206](https://github.com/crypto-org-chain/cosmos-sdk/pull/206) Support mount object store in baseapp, add `ObjectStore` api in context. +* (baseapp) [#206](https://github.com/crypto-org-chain/cosmos-sdk/pull/206) Support mount object store in baseapp, add `ObjectStore` api in context, [#585](https://github.com/crypto-org-chain/cosmos-sdk/pull/585) Skip snapshot for object store. * (bank) [#237](https://github.com/crypto-org-chain/cosmos-sdk/pull/237) Support virtual accounts in sending coins. * [#243](https://github.com/crypto-org-chain/cosmos-sdk/pull/243) Support `RunAtomic` API in `Context` to use new CoW branched cache store. * [#248](https://github.com/crypto-org-chain/cosmos-sdk/pull/248) Init btree store lazily to save allocations when no content insert into it. diff --git a/core/coins/format.go b/core/coins/format.go index 315c96d78f46..7b1e49f2b7e2 100644 --- a/core/coins/format.go +++ b/core/coins/format.go @@ -84,6 +84,11 @@ func FormatCoins(coins []*basev1beta1.Coin, metadata []*bankv1beta1.Metadata) (s if err != nil { return "", err } + // If a coin contains a comma, return an error given that the output + // could be misinterpreted by the user as 2 different coins. + if strings.Contains(formatted[i], ",") { + return "", fmt.Errorf("coin %s contains a comma", formatted[i]) + } } if len(coins) == 0 { diff --git a/store/cachemulti/store.go b/store/cachemulti/store.go index 60eb9d9a802b..8b1c4531008a 100644 --- a/store/cachemulti/store.go +++ b/store/cachemulti/store.go @@ -6,6 +6,7 @@ import ( "cosmossdk.io/store/tracekv" "cosmossdk.io/store/types" + dbm "github.com/cosmos/cosmos-db" ) // storeNameCtxKey is the TraceContext metadata key that identifies @@ -57,7 +58,7 @@ func NewFromKVStore( // NewStore creates a new Store object from a mapping of store keys to // CacheWrapper objects. Each CacheWrapper store is a branched store. func NewStore( - stores map[types.StoreKey]types.CacheWrapper, + _ dbm.DB, stores map[types.StoreKey]types.CacheWrapper, _ map[string]types.StoreKey, traceWriter io.Writer, traceContext types.TraceContext, ) Store { return NewFromKVStore(stores, traceWriter, traceContext) diff --git a/store/rootmulti/store.go b/store/rootmulti/store.go index a3f00f342958..bb3bc04ac4f2 100644 --- a/store/rootmulti/store.go +++ b/store/rootmulti/store.go @@ -565,7 +565,7 @@ func (rs *Store) CacheMultiStore() types.CacheMultiStore { } stores[k] = store } - return cachemulti.NewStore(stores, rs.traceWriter, rs.getTracingContext()) + return cachemulti.NewFromKVStore(stores, rs.traceWriter, rs.getTracingContext()) } // CacheMultiStoreWithVersion is analogous to CacheMultiStore except that it @@ -627,7 +627,7 @@ func (rs *Store) CacheMultiStoreWithVersion(version int64) (types.CacheMultiStor cachedStores[key] = cacheStore } - return cachemulti.NewStore(cachedStores, rs.traceWriter, rs.getTracingContext()), nil + return cachemulti.NewFromKVStore(cachedStores, rs.traceWriter, rs.getTracingContext()), nil } // GetStore returns a mounted Store for a given StoreKey. If the StoreKey does @@ -854,7 +854,7 @@ func (rs *Store) Snapshot(height uint64, protoWriter protoio.Writer) error { switch store := rs.GetCommitStore(key).(type) { case *iavl.Store: stores = append(stores, namedStore{name: key.Name(), Store: store}) - case *transient.Store, *mem.Store: + case *transient.Store, *mem.Store, *transient.ObjStore: // Non-persisted stores shouldn't be snapshotted continue default: diff --git a/x/auth/ante/sigverify.go b/x/auth/ante/sigverify.go index 341ccf65cf85..9f7c18d57cb2 100644 --- a/x/auth/ante/sigverify.go +++ b/x/auth/ante/sigverify.go @@ -31,8 +31,6 @@ var ( key = make([]byte, secp256k1.PubKeySize) simSecp256k1Pubkey = &secp256k1.PubKey{Key: key} simSecp256k1Sig [64]byte - - SigVerificationResultCacheKey = "ante:SigVerificationResult" ) func init() { @@ -252,44 +250,44 @@ func OnlyLegacyAminoSigners(sigData signing.SignatureData) bool { } } -func (svd SigVerificationDecorator) anteHandle(ctx sdk.Context, tx sdk.Tx, simulate bool) error { +func (svd SigVerificationDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simulate bool, next sdk.AnteHandler) (newCtx sdk.Context, err error) { sigTx, ok := tx.(authsigning.Tx) if !ok { - return errorsmod.Wrap(sdkerrors.ErrTxDecode, "invalid transaction type") + return ctx, errorsmod.Wrap(sdkerrors.ErrTxDecode, "invalid transaction type") } // stdSigs contains the sequence number, account number, and signatures. // When simulating, this would just be a 0-length slice. sigs, err := sigTx.GetSignaturesV2() if err != nil { - return err + return ctx, err } signers, err := sigTx.GetSigners() if err != nil { - return err + return ctx, err } // check that signer length and signature length are the same if len(sigs) != len(signers) { - return errorsmod.Wrapf(sdkerrors.ErrUnauthorized, "invalid number of signer; expected: %d, got %d", len(signers), len(sigs)) + return ctx, errorsmod.Wrapf(sdkerrors.ErrUnauthorized, "invalid number of signer; expected: %d, got %d", len(signers), len(sigs)) } for i, sig := range sigs { acc, err := GetSignerAcc(ctx, svd.ak, signers[i]) if err != nil { - return err + return ctx, err } // retrieve pubkey pubKey := acc.GetPubKey() if !simulate && pubKey == nil { - return errorsmod.Wrap(sdkerrors.ErrInvalidPubKey, "pubkey on account is not set") + return ctx, errorsmod.Wrap(sdkerrors.ErrInvalidPubKey, "pubkey on account is not set") } // Check account sequence number. if sig.Sequence != acc.GetSequence() { - return errorsmod.Wrapf( + return ctx, errorsmod.Wrapf( sdkerrors.ErrWrongSequence, "account sequence mismatch, expected %d, got %d", acc.GetSequence(), sig.Sequence, ) @@ -319,7 +317,7 @@ func (svd SigVerificationDecorator) anteHandle(ctx sdk.Context, tx sdk.Tx, simul } adaptableTx, ok := tx.(authsigning.V2AdaptableTx) if !ok { - return fmt.Errorf("expected tx to implement V2AdaptableTx, got %T", tx) + return ctx, fmt.Errorf("expected tx to implement V2AdaptableTx, got %T", tx) } txData := adaptableTx.GetSigningTxData() err = authsigning.VerifySignature(ctx, pubKey, signerData, sig.Data, svd.signModeHandler, txData) @@ -332,27 +330,12 @@ func (svd SigVerificationDecorator) anteHandle(ctx sdk.Context, tx sdk.Tx, simul } else { errMsg = fmt.Sprintf("signature verification failed; please verify account number (%d) and chain-id (%s): (%s)", accNum, chainID, err.Error()) } - return errorsmod.Wrap(sdkerrors.ErrUnauthorized, errMsg) + return ctx, errorsmod.Wrap(sdkerrors.ErrUnauthorized, errMsg) } } } - return nil -} -func (svd SigVerificationDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simulate bool, next sdk.AnteHandler) (newCtx sdk.Context, err error) { - if v, ok := ctx.GetIncarnationCache(SigVerificationResultCacheKey); ok { - // can't convert `nil` to interface - if v != nil { - err = v.(error) - } - } else { - err = svd.anteHandle(ctx, tx, simulate) - ctx.SetIncarnationCache(SigVerificationResultCacheKey, err) - } - if err != nil { - return ctx, err - } return next(ctx, tx, simulate) }