Prefer sending tx_bytes to Simulate gRPC endpoint (#8926)
* First run * Remove dead code * Make test pass * Proto gen * Fix lint * Add changelog * Fix tests * Fix test * Update x/auth/tx/service.go Co-authored-by: Marie Gauthier <marie.gauthier63@gmail.com> * Remove protoTxProvider * Add grpc-gateway test * Add comment * move to api breaking * lesser diff * remove conflict * empty commit to rerun CI * empty commit to rerun CI Co-authored-by: Marie Gauthier <marie.gauthier63@gmail.com> Co-authored-by: Alessio Treglia <alessio@tendermint.com> Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
This commit is contained in:
parent
7ac436d2f7
commit
1fa2c22d8a
@ -65,6 +65,8 @@ Ref: https://keepachangelog.com/en/1.0.0/
|
||||
* (x/upgrade) [\#8743](https://github.com/cosmos/cosmos-sdk/pull/8743) `UpgradeHandler` includes a new argument `VersionMap` which helps facilitate in-place migrations.
|
||||
* (x/auth) [\#8129](https://github.com/cosmos/cosmos-sdk/pull/8828) Updated `SigVerifiableTx.GetPubKeys` method signature to return error.
|
||||
* [\#8682](https://github.com/cosmos/cosmos-sdk/pull/8682) `ante.NewAnteHandler` updated to receive all positional params as `ante.HandlerOptions` struct. If required fields aren't set, throws error accordingly.
|
||||
* (client) [\#8926](https://github.com/cosmos/cosmos-sdk/pull/8926) `client/tx.PrepareFactory` has been converted to a private function, as it's only used internally.
|
||||
* (auth/tx) [\#8926](https://github.com/cosmos/cosmos-sdk/pull/8926) The `ProtoTxProvider` interface used as a workaround for transaction simulation has been removed.
|
||||
|
||||
### State Machine Breaking
|
||||
|
||||
@ -110,6 +112,10 @@ Ref: https://keepachangelog.com/en/1.0.0/
|
||||
|
||||
This release fixes security vulnerability identified in the simapp.
|
||||
|
||||
### Deprecated
|
||||
|
||||
* (grpc) [\#8926](https://github.com/cosmos/cosmos-sdk/pull/8926) The `tx` field in `SimulateRequest` has been deprecated, prefer to pass `tx_bytes` instead.
|
||||
|
||||
## [v0.42.0](https://github.com/cosmos/cosmos-sdk/releases/tag/v0.42.0) - 2021-03-08
|
||||
|
||||
**IMPORTANT**: This release contains an important security fix for all non Cosmos Hub chains running Stargate version of the Cosmos SDK (>0.40). Non-hub chains should not be using any version of the SDK in the v0.40.x or v0.41.x release series. See [#8461](https://github.com/cosmos/cosmos-sdk/pull/8461) for more details.
|
||||
|
||||
@ -2,11 +2,13 @@ package tx
|
||||
|
||||
import (
|
||||
"bufio"
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"os"
|
||||
|
||||
gogogrpc "github.com/gogo/protobuf/grpc"
|
||||
"github.com/spf13/pflag"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/client"
|
||||
@ -20,7 +22,6 @@ import (
|
||||
"github.com/cosmos/cosmos-sdk/types/tx"
|
||||
"github.com/cosmos/cosmos-sdk/types/tx/signing"
|
||||
authsigning "github.com/cosmos/cosmos-sdk/x/auth/signing"
|
||||
authtx "github.com/cosmos/cosmos-sdk/x/auth/tx"
|
||||
)
|
||||
|
||||
// GenerateOrBroadcastTxCLI will either generate and print and unsigned transaction
|
||||
@ -50,7 +51,7 @@ func GenerateTx(clientCtx client.Context, txf Factory, msgs ...sdk.Msg) error {
|
||||
return errors.New("cannot estimate gas in offline mode")
|
||||
}
|
||||
|
||||
_, adjusted, err := CalculateGas(clientCtx.QueryWithData, txf, msgs...)
|
||||
_, adjusted, err := CalculateGas(clientCtx, txf, msgs...)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@ -76,13 +77,13 @@ func GenerateTx(clientCtx client.Context, txf Factory, msgs ...sdk.Msg) error {
|
||||
// given set of messages. It will also simulate gas requirements if necessary.
|
||||
// It will return an error upon failure.
|
||||
func BroadcastTx(clientCtx client.Context, txf Factory, msgs ...sdk.Msg) error {
|
||||
txf, err := PrepareFactory(clientCtx, txf)
|
||||
txf, err := prepareFactory(clientCtx, txf)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if txf.SimulateAndExecute() || clientCtx.Simulate {
|
||||
_, adjusted, err := CalculateGas(clientCtx.QueryWithData, txf, msgs...)
|
||||
_, adjusted, err := CalculateGas(clientCtx, txf, msgs...)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@ -142,8 +143,9 @@ func BroadcastTx(clientCtx client.Context, txf Factory, msgs ...sdk.Msg) error {
|
||||
// BaseReq. Upon any error, the error will be written to the http.ResponseWriter.
|
||||
// Note that this function returns the legacy StdTx Amino JSON format for compatibility
|
||||
// with legacy clients.
|
||||
// Deprecated: We are removing Amino soon.
|
||||
func WriteGeneratedTxResponse(
|
||||
ctx client.Context, w http.ResponseWriter, br rest.BaseReq, msgs ...sdk.Msg,
|
||||
clientCtx client.Context, w http.ResponseWriter, br rest.BaseReq, msgs ...sdk.Msg,
|
||||
) {
|
||||
gasAdj, ok := rest.ParseFloat64OrReturnBadRequest(w, br.GasAdjustment, flags.DefaultGasAdjustment)
|
||||
if !ok {
|
||||
@ -163,7 +165,7 @@ func WriteGeneratedTxResponse(
|
||||
WithMemo(br.Memo).
|
||||
WithChainID(br.ChainID).
|
||||
WithSimulateAndExecute(br.Simulate).
|
||||
WithTxConfig(ctx.TxConfig).
|
||||
WithTxConfig(clientCtx.TxConfig).
|
||||
WithTimeoutHeight(br.TimeoutHeight)
|
||||
|
||||
if br.Simulate || gasSetting.Simulate {
|
||||
@ -172,7 +174,7 @@ func WriteGeneratedTxResponse(
|
||||
return
|
||||
}
|
||||
|
||||
_, adjusted, err := CalculateGas(ctx.QueryWithData, txf, msgs...)
|
||||
_, adjusted, err := CalculateGas(clientCtx, txf, msgs...)
|
||||
if rest.CheckInternalServerError(w, err) {
|
||||
return
|
||||
}
|
||||
@ -180,7 +182,7 @@ func WriteGeneratedTxResponse(
|
||||
txf = txf.WithGas(adjusted)
|
||||
|
||||
if br.Simulate {
|
||||
rest.WriteSimulationResponse(w, ctx.LegacyAmino, txf.Gas())
|
||||
rest.WriteSimulationResponse(w, clientCtx.LegacyAmino, txf.Gas())
|
||||
return
|
||||
}
|
||||
}
|
||||
@ -190,12 +192,12 @@ func WriteGeneratedTxResponse(
|
||||
return
|
||||
}
|
||||
|
||||
stdTx, err := ConvertTxToStdTx(ctx.LegacyAmino, tx.GetTx())
|
||||
stdTx, err := ConvertTxToStdTx(clientCtx.LegacyAmino, tx.GetTx())
|
||||
if rest.CheckInternalServerError(w, err) {
|
||||
return
|
||||
}
|
||||
|
||||
output, err := ctx.LegacyAmino.MarshalJSON(stdTx)
|
||||
output, err := clientCtx.LegacyAmino.MarshalJSON(stdTx)
|
||||
if rest.CheckInternalServerError(w, err) {
|
||||
return
|
||||
}
|
||||
@ -268,46 +270,35 @@ func BuildSimTx(txf Factory, msgs ...sdk.Msg) ([]byte, error) {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
protoProvider, ok := txb.(authtx.ProtoTxProvider)
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("cannot simulate amino tx")
|
||||
}
|
||||
simReq := tx.SimulateRequest{Tx: protoProvider.GetProtoTx()}
|
||||
|
||||
return simReq.Marshal()
|
||||
return txf.txConfig.TxEncoder()(txb.GetTx())
|
||||
}
|
||||
|
||||
// CalculateGas simulates the execution of a transaction and returns the
|
||||
// simulation response obtained by the query and the adjusted gas amount.
|
||||
func CalculateGas(
|
||||
queryFunc func(string, []byte) ([]byte, int64, error), txf Factory, msgs ...sdk.Msg,
|
||||
) (tx.SimulateResponse, uint64, error) {
|
||||
clientCtx gogogrpc.ClientConn, txf Factory, msgs ...sdk.Msg,
|
||||
) (*tx.SimulateResponse, uint64, error) {
|
||||
txBytes, err := BuildSimTx(txf, msgs...)
|
||||
if err != nil {
|
||||
return tx.SimulateResponse{}, 0, err
|
||||
return nil, 0, err
|
||||
}
|
||||
|
||||
// TODO This should use the generated tx service Client.
|
||||
// https://github.com/cosmos/cosmos-sdk/issues/7726
|
||||
bz, _, err := queryFunc("/cosmos.tx.v1beta1.Service/Simulate", txBytes)
|
||||
txSvcClient := tx.NewServiceClient(clientCtx)
|
||||
simRes, err := txSvcClient.Simulate(context.Background(), &tx.SimulateRequest{
|
||||
TxBytes: txBytes,
|
||||
})
|
||||
if err != nil {
|
||||
return tx.SimulateResponse{}, 0, err
|
||||
}
|
||||
|
||||
var simRes tx.SimulateResponse
|
||||
|
||||
if err := simRes.Unmarshal(bz); err != nil {
|
||||
return tx.SimulateResponse{}, 0, err
|
||||
return nil, 0, err
|
||||
}
|
||||
|
||||
return simRes, uint64(txf.GasAdjustment() * float64(simRes.GasInfo.GasUsed)), nil
|
||||
}
|
||||
|
||||
// PrepareFactory ensures the account defined by ctx.GetFromAddress() exists and
|
||||
// prepareFactory 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. A new Factory with
|
||||
// the updated fields will be returned.
|
||||
func PrepareFactory(clientCtx client.Context, txf Factory) (Factory, error) {
|
||||
func prepareFactory(clientCtx client.Context, txf Factory) (Factory, error) {
|
||||
from := clientCtx.GetFromAddress()
|
||||
|
||||
if err := txf.accountRetriever.EnsureExists(clientCtx, from); err != nil {
|
||||
|
||||
@ -1,10 +1,12 @@
|
||||
package tx_test
|
||||
|
||||
import (
|
||||
"errors"
|
||||
gocontext "context"
|
||||
"fmt"
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/require"
|
||||
"google.golang.org/grpc"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/client"
|
||||
"github.com/cosmos/cosmos-sdk/client/tx"
|
||||
@ -24,30 +26,34 @@ func NewTestTxConfig() client.TxConfig {
|
||||
return cfg.TxConfig
|
||||
}
|
||||
|
||||
func TestCalculateGas(t *testing.T) {
|
||||
makeQueryFunc := func(gasUsed uint64, wantErr bool) func(string, []byte) ([]byte, int64, error) {
|
||||
return func(string, []byte) ([]byte, int64, error) {
|
||||
if wantErr {
|
||||
return nil, 0, errors.New("query failed")
|
||||
}
|
||||
simRes := &txtypes.SimulateResponse{
|
||||
GasInfo: &sdk.GasInfo{GasUsed: gasUsed, GasWanted: gasUsed},
|
||||
Result: &sdk.Result{Data: []byte("tx data"), Log: "log"},
|
||||
}
|
||||
// mockContext is a mock client.Context to return abitrary simulation response, used to
|
||||
// unit test CalculateGas.
|
||||
type mockContext struct {
|
||||
gasUsed uint64
|
||||
wantErr bool
|
||||
}
|
||||
|
||||
bz, err := simRes.Marshal()
|
||||
if err != nil {
|
||||
return nil, 0, err
|
||||
}
|
||||
|
||||
return bz, 0, nil
|
||||
}
|
||||
func (m mockContext) Invoke(grpcCtx gocontext.Context, method string, req, reply interface{}, opts ...grpc.CallOption) (err error) {
|
||||
if m.wantErr {
|
||||
return fmt.Errorf("mock err")
|
||||
}
|
||||
|
||||
*(reply.(*txtypes.SimulateResponse)) = txtypes.SimulateResponse{
|
||||
GasInfo: &sdk.GasInfo{GasUsed: m.gasUsed, GasWanted: m.gasUsed},
|
||||
Result: &sdk.Result{Data: []byte("tx data"), Log: "log"},
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
func (mockContext) NewStream(gocontext.Context, *grpc.StreamDesc, string, ...grpc.CallOption) (grpc.ClientStream, error) {
|
||||
panic("not implemented")
|
||||
}
|
||||
|
||||
func TestCalculateGas(t *testing.T) {
|
||||
type args struct {
|
||||
queryFuncGasUsed uint64
|
||||
queryFuncWantErr bool
|
||||
adjustment float64
|
||||
mockGasUsed uint64
|
||||
mockWantErr bool
|
||||
adjustment float64
|
||||
}
|
||||
|
||||
testCases := []struct {
|
||||
@ -70,8 +76,11 @@ func TestCalculateGas(t *testing.T) {
|
||||
WithTxConfig(txCfg).WithSignMode(txCfg.SignModeHandler().DefaultMode())
|
||||
|
||||
t.Run(stc.name, func(t *testing.T) {
|
||||
queryFunc := makeQueryFunc(stc.args.queryFuncGasUsed, stc.args.queryFuncWantErr)
|
||||
simRes, gotAdjusted, err := tx.CalculateGas(queryFunc, txf.WithGasAdjustment(stc.args.adjustment))
|
||||
mockClientCtx := mockContext{
|
||||
gasUsed: tc.args.mockGasUsed,
|
||||
wantErr: tc.args.mockWantErr,
|
||||
}
|
||||
simRes, gotAdjusted, err := tx.CalculateGas(mockClientCtx, txf.WithGasAdjustment(stc.args.adjustment))
|
||||
if stc.expPass {
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, simRes.GasInfo.GasUsed, stc.wantEstimate)
|
||||
@ -79,7 +88,7 @@ func TestCalculateGas(t *testing.T) {
|
||||
require.NotNil(t, simRes.Result)
|
||||
} else {
|
||||
require.Error(t, err)
|
||||
require.Nil(t, simRes.Result)
|
||||
require.Nil(t, simRes)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
@ -7257,7 +7257,8 @@ RPC method.
|
||||
|
||||
| Field | Type | Label | Description |
|
||||
| ----- | ---- | ----- | ----------- |
|
||||
| `tx` | [Tx](#cosmos.tx.v1beta1.Tx) | | tx is the transaction to simulate. |
|
||||
| `tx` | [Tx](#cosmos.tx.v1beta1.Tx) | | **Deprecated.** tx is the transaction to simulate. Deprecated. Send raw tx bytes instead. |
|
||||
| `tx_bytes` | [bytes](#bytes) | | tx_bytes is the raw transaction. |
|
||||
|
||||
|
||||
|
||||
|
||||
@ -305,15 +305,13 @@ func simulateTx() error {
|
||||
// Simulate the tx via gRPC. We create a new client for the Protobuf Tx
|
||||
// service.
|
||||
txClient := tx.NewServiceClient(grpcConn)
|
||||
// We then call the BroadcastTx method on this client.
|
||||
protoTx := txBuilderToProtoTx(txBuilder)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
txBytes := /* Fill in with your signed transaction bytes. */
|
||||
|
||||
// We then call the Simulate method on this client.
|
||||
grpcRes, err := txClient.Simulate(
|
||||
context.Background(),
|
||||
&tx.SimulateRequest{
|
||||
Tx: protoTx,
|
||||
TxBytes: txBytes,
|
||||
},
|
||||
)
|
||||
if err != nil {
|
||||
@ -324,16 +322,6 @@ func simulateTx() error {
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// txBuilderToProtoTx converts a txBuilder into a proto tx.Tx.
|
||||
func txBuilderToProtoTx(txBuilder client.TxBuilder) (*tx.Tx, error) { // nolint
|
||||
protoProvider, ok := txBuilder.(authtx.ProtoTxProvider)
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("expected proto tx builder, got %T", txBuilder)
|
||||
}
|
||||
|
||||
return protoProvider.GetProtoTx(), nil
|
||||
}
|
||||
```
|
||||
|
||||
## Using REST
|
||||
|
||||
@ -101,7 +101,10 @@ message BroadcastTxResponse {
|
||||
// RPC method.
|
||||
message SimulateRequest {
|
||||
// tx is the transaction to simulate.
|
||||
cosmos.tx.v1beta1.Tx tx = 1;
|
||||
// Deprecated. Send raw tx bytes instead.
|
||||
cosmos.tx.v1beta1.Tx tx = 1 [deprecated=true];
|
||||
// tx_bytes is the raw transaction.
|
||||
bytes tx_bytes = 2;
|
||||
}
|
||||
|
||||
// SimulateResponse is the response type for the
|
||||
|
||||
@ -25,7 +25,6 @@ import (
|
||||
"github.com/cosmos/cosmos-sdk/snapshots"
|
||||
"github.com/cosmos/cosmos-sdk/store"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
authclient "github.com/cosmos/cosmos-sdk/x/auth/client"
|
||||
authcmd "github.com/cosmos/cosmos-sdk/x/auth/client/cli"
|
||||
"github.com/cosmos/cosmos-sdk/x/auth/types"
|
||||
vestingcli "github.com/cosmos/cosmos-sdk/x/auth/vesting/client/cli"
|
||||
@ -66,8 +65,6 @@ func NewRootCmd() (*cobra.Command, params.EncodingConfig) {
|
||||
}
|
||||
|
||||
func initRootCmd(rootCmd *cobra.Command, encodingConfig params.EncodingConfig) {
|
||||
authclient.Codec = encodingConfig.Marshaler
|
||||
|
||||
rootCmd.AddCommand(
|
||||
genutilcli.InitCmd(simapp.ModuleBasics, simapp.DefaultNodeHome),
|
||||
genutilcli.CollectGenTxsCmd(banktypes.GenesisBalancesIterator{}, simapp.DefaultNodeHome),
|
||||
|
||||
@ -339,7 +339,10 @@ func (m *BroadcastTxResponse) GetTxResponse() *types.TxResponse {
|
||||
// RPC method.
|
||||
type SimulateRequest struct {
|
||||
// tx is the transaction to simulate.
|
||||
Tx *Tx `protobuf:"bytes,1,opt,name=tx,proto3" json:"tx,omitempty"`
|
||||
// Deprecated. Send raw tx bytes instead.
|
||||
Tx *Tx `protobuf:"bytes,1,opt,name=tx,proto3" json:"tx,omitempty"` // Deprecated: Do not use.
|
||||
// tx_bytes is the raw transaction.
|
||||
TxBytes []byte `protobuf:"bytes,2,opt,name=tx_bytes,json=txBytes,proto3" json:"tx_bytes,omitempty"`
|
||||
}
|
||||
|
||||
func (m *SimulateRequest) Reset() { *m = SimulateRequest{} }
|
||||
@ -375,6 +378,7 @@ func (m *SimulateRequest) XXX_DiscardUnknown() {
|
||||
|
||||
var xxx_messageInfo_SimulateRequest proto.InternalMessageInfo
|
||||
|
||||
// Deprecated: Do not use.
|
||||
func (m *SimulateRequest) GetTx() *Tx {
|
||||
if m != nil {
|
||||
return m.Tx
|
||||
@ -382,6 +386,13 @@ func (m *SimulateRequest) GetTx() *Tx {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *SimulateRequest) GetTxBytes() []byte {
|
||||
if m != nil {
|
||||
return m.TxBytes
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// SimulateResponse is the response type for the
|
||||
// Service.SimulateRPC method.
|
||||
type SimulateResponse struct {
|
||||
@ -569,59 +580,59 @@ func init() {
|
||||
}
|
||||
|
||||
var fileDescriptor_e0b00a618705eca7 = []byte{
|
||||
// 817 bytes of a gzipped FileDescriptorProto
|
||||
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x55, 0xcf, 0x6f, 0xe3, 0x44,
|
||||
0x14, 0x8e, 0x9d, 0xa5, 0xc9, 0xbe, 0xa4, 0x4b, 0x76, 0x5a, 0x96, 0x90, 0x05, 0x37, 0xeb, 0x25,
|
||||
0x6d, 0x14, 0x09, 0x5b, 0x0d, 0x20, 0x55, 0x88, 0x4b, 0x7e, 0xb5, 0x54, 0xd0, 0xa6, 0x72, 0xca,
|
||||
0xa1, 0x08, 0x29, 0x72, 0x92, 0xa9, 0x6b, 0xd1, 0x78, 0x52, 0xcf, 0xa4, 0x72, 0xd4, 0x56, 0x48,
|
||||
0x1c, 0x39, 0x21, 0xf1, 0x67, 0xf0, 0x4f, 0x70, 0xe4, 0x58, 0x89, 0x0b, 0x47, 0xd4, 0xf0, 0x47,
|
||||
0x70, 0x44, 0x1e, 0x4f, 0x12, 0x27, 0x75, 0xda, 0x8a, 0x53, 0xde, 0x64, 0xbe, 0xf7, 0xbd, 0xef,
|
||||
0x7d, 0xf3, 0x66, 0x0c, 0x1b, 0x5d, 0x42, 0xfb, 0x84, 0xea, 0xcc, 0xd3, 0x2f, 0xb7, 0x3b, 0x98,
|
||||
0x99, 0xdb, 0x3a, 0xc5, 0xee, 0xa5, 0xdd, 0xc5, 0xda, 0xc0, 0x25, 0x8c, 0xa0, 0x97, 0x01, 0x40,
|
||||
0x63, 0x9e, 0x26, 0x00, 0xb9, 0x0f, 0x2d, 0x42, 0xac, 0x73, 0xac, 0x9b, 0x03, 0x5b, 0x37, 0x1d,
|
||||
0x87, 0x30, 0x93, 0xd9, 0xc4, 0xa1, 0x41, 0x42, 0xee, 0xad, 0x60, 0xec, 0x98, 0x14, 0xeb, 0x66,
|
||||
0xa7, 0x6b, 0x4f, 0x89, 0xfd, 0x85, 0x00, 0xe5, 0xee, 0x97, 0x65, 0x9e, 0xd8, 0x5b, 0xb7, 0x88,
|
||||
0x45, 0x78, 0xa8, 0xfb, 0x91, 0xf8, 0xb7, 0x14, 0xa6, 0xbd, 0x18, 0x62, 0x77, 0x34, 0xcd, 0x1c,
|
||||
0x98, 0x96, 0xed, 0x70, 0x0d, 0x01, 0x56, 0xfd, 0x4d, 0x02, 0xb4, 0x87, 0xd9, 0xb1, 0x47, 0x1b,
|
||||
0x97, 0xd8, 0x61, 0x06, 0xbe, 0x18, 0x62, 0xca, 0xd0, 0x2b, 0x58, 0xc1, 0xfe, 0x9a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9, 0x29, 0xdf, 0x01, 0xe9, 0x61,
|
||||
0x83, 0xa3, 0xd5, 0xef, 0x61, 0x6d, 0xae, 0x8c, 0x30, 0xae, 0x01, 0xa9, 0x90, 0x1f, 0xbc, 0xd4,
|
||||
0x53, 0xed, 0x80, 0x99, 0x1d, 0xea, 0x0e, 0xbc, 0xdb, 0xb2, 0xfb, 0xc3, 0x73, 0x93, 0x4d, 0x4e,
|
||||
0x1b, 0x15, 0x40, 0x66, 0x9e, 0x20, 0x5c, 0x72, 0x22, 0x32, 0xf3, 0xd4, 0x9f, 0x25, 0xc8, 0xcc,
|
||||
0x52, 0x85, 0xaa, 0x2f, 0x21, 0x69, 0x99, 0xb4, 0x6d, 0x3b, 0xa7, 0x44, 0x30, 0xbc, 0x59, 0x2e,
|
||||
0x69, 0xcf, 0xa4, 0xfb, 0xce, 0x29, 0x31, 0x12, 0x56, 0x10, 0xa0, 0x1d, 0x58, 0x71, 0x31, 0x1d,
|
||||
0x9e, 0x33, 0x31, 0x9f, 0xf9, 0xe5, 0xb9, 0x06, 0xc7, 0x19, 0x02, 0xaf, 0xaa, 0x90, 0xe6, 0xd3,
|
||||
0x35, 0xe9, 0x01, 0xc1, 0xb3, 0x33, 0x93, 0x9e, 0x71, 0x0d, 0xcf, 0x0d, 0x1e, 0xab, 0x37, 0xb0,
|
||||
0x2a, 0x30, 0x42, 0xec, 0xd3, 0x1a, 0x5d, 0x74, 0x5a, 0xfe, 0x7f, 0x4e, 0x97, 0xbe, 0x82, 0x84,
|
||||
0xb8, 0x15, 0x28, 0x0b, 0xeb, 0x4d, 0xa3, 0xde, 0x30, 0xda, 0xd5, 0x93, 0xf6, 0xb7, 0x87, 0xad,
|
||||
0xa3, 0x46, 0x6d, 0x7f, 0x77, 0xbf, 0x51, 0xcf, 0xc4, 0x50, 0x06, 0xd2, 0xd3, 0x9d, 0x4a, 0xab,
|
||||
0x96, 0x91, 0xd0, 0x4b, 0x58, 0x9d, 0xfe, 0x53, 0x6f, 0xb4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96, 0x08, 0xa8, 0xd6, 0xfe, 0xb8, 0x53, 0xa4,
|
||||
0xdb, 0x3b, 0x45, 0xfa, 0xfb, 0x4e, 0x91, 0x7e, 0x19, 0x2b, 0xb1, 0xdf, 0xc7, 0x8a, 0x74, 0x3b,
|
||||
0x56, 0x62, 0x7f, 0x8d, 0x95, 0xd8, 0x77, 0x05, 0xcb, 0x66, 0x67, 0xc3, 0x8e, 0xd6, 0x25, 0xfd,
|
||||
0x49, 0x7e, 0xf0, 0xf3, 0x09, 0xed, 0xfd, 0xa0, 0xb3, 0xd1, 0x00, 0xfb, 0x84, 0x9d, 0x15, 0xfe,
|
||||
0xf9, 0xfa, 0xf4, 0xbf, 0x00, 0x00, 0x00, 0xff, 0xff, 0x7b, 0x64, 0xf5, 0xff, 0x95, 0x07, 0x00,
|
||||
0x00,
|
||||
// 831 bytes of a gzipped FileDescriptorProto
|
||||
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x55, 0x41, 0x8f, 0xdb, 0x44,
|
||||
0x14, 0x5e, 0x3b, 0x65, 0x93, 0xbe, 0x64, 0x4b, 0x3a, 0xbb, 0x14, 0x93, 0x82, 0x37, 0x75, 0xc9,
|
||||
0x36, 0x44, 0xc2, 0x56, 0x03, 0x48, 0x08, 0x71, 0x89, 0x93, 0x74, 0x59, 0x41, 0x9b, 0x6a, 0xb2,
|
||||
0x08, 0x15, 0x21, 0x45, 0x4e, 0x32, 0xf5, 0x5a, 0x6c, 0x3c, 0x59, 0xcf, 0x64, 0xe5, 0xa8, 0xad,
|
||||
0x90, 0x38, 0x72, 0x42, 0xe2, 0x67, 0xf0, 0x27, 0x38, 0x72, 0x5c, 0x89, 0x0b, 0x47, 0xb4, 0xe1,
|
||||
0x47, 0x70, 0x44, 0x1e, 0x4f, 0x12, 0x27, 0xeb, 0x74, 0x11, 0xa7, 0xbc, 0xc9, 0x7c, 0xef, 0x7b,
|
||||
0xdf, 0xfb, 0x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0x76, 0xd7,
|
||||
0x76, 0xba, 0xcf, 0x9e, 0x34, 0x8b, 0x6a, 0x4a, 0x4a, 0x43, 0xec, 0x64, 0xea, 0xff, 0x64, 0x20,
|
||||
0xdb, 0x8d, 0x1f, 0x57, 0xf4, 0x02, 0x72, 0xf3, 0x11, 0x40, 0x46, 0x8a, 0x83, 0x6b, 0x93, 0x57,
|
||||
0xba, 0xff, 0x5a, 0x8c, 0x9c, 0xd8, 0x83, 0x1f, 0xff, 0xf8, 0xfb, 0x17, 0xb5, 0x6c, 0xdc, 0xb5,
|
||||
0x52, 0x5e, 0x75, 0x09, 0xfe, 0x4c, 0xa9, 0xa1, 0x33, 0x78, 0x43, 0x9c, 0x27, 0xda, 0x4f, 0x61,
|
||||
0x4d, 0x4e, 0x43, 0xa9, 0xbc, 0x19, 0x20, 0x6b, 0x56, 0x44, 0xcd, 0x7d, 0xf4, 0x9e, 0x95, 0xf6,
|
||||
0xa4, 0x33, 0xeb, 0x45, 0x34, 0x41, 0xaf, 0xd0, 0x0f, 0x90, 0x4f, 0x5c, 0x55, 0x54, 0x79, 0xdd,
|
||||
0x0d, 0x5f, 0x96, 0x3f, 0xb8, 0x0e, 0x26, 0x45, 0xdc, 0x13, 0x22, 0xee, 0x1a, 0x77, 0xd2, 0x45,
|
||||
0x44, 0x3d, 0xbf, 0x84, 0x7c, 0xe2, 0x91, 0x4d, 0x15, 0x70, 0xf5, 0x93, 0x91, 0x2a, 0x20, 0xe5,
|
||||
0xad, 0x36, 0x74, 0x21, 0x40, 0x43, 0x1b, 0x04, 0xd8, 0xcd, 0xdf, 0x2f, 0x75, 0xe5, 0xe2, 0x52,
|
||||
0x57, 0xfe, 0xba, 0xd4, 0x95, 0x9f, 0x67, 0xfa, 0xd6, 0x6f, 0x33, 0x5d, 0xb9, 0x98, 0xe9, 0x5b,
|
||||
0x7f, 0xce, 0xf4, 0xad, 0x6f, 0x2b, 0xae, 0xc7, 0x4f, 0x26, 0x7d, 0x73, 0x40, 0x47, 0xf3, 0xfc,
|
||||
0xf8, 0xe7, 0x43, 0x36, 0xfc, 0xde, 0xe2, 0xd3, 0x31, 0x89, 0x08, 0xfb, 0xdb, 0xe2, 0xeb, 0xf6,
|
||||
0xd1, 0xbf, 0x01, 0x00, 0x00, 0xff, 0xff, 0xe4, 0x86, 0xcd, 0x5c, 0xb4, 0x07, 0x00, 0x00,
|
||||
}
|
||||
|
||||
// Reference imports to suppress errors if they are not otherwise used.
|
||||
@ -1022,6 +1033,13 @@ func (m *SimulateRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) {
|
||||
_ = i
|
||||
var l int
|
||||
_ = l
|
||||
if len(m.TxBytes) > 0 {
|
||||
i -= len(m.TxBytes)
|
||||
copy(dAtA[i:], m.TxBytes)
|
||||
i = encodeVarintService(dAtA, i, uint64(len(m.TxBytes)))
|
||||
i--
|
||||
dAtA[i] = 0x12
|
||||
}
|
||||
if m.Tx != nil {
|
||||
{
|
||||
size, err := m.Tx.MarshalToSizedBuffer(dAtA[:i])
|
||||
@ -1258,6 +1276,10 @@ func (m *SimulateRequest) Size() (n int) {
|
||||
l = m.Tx.Size()
|
||||
n += 1 + l + sovService(uint64(l))
|
||||
}
|
||||
l = len(m.TxBytes)
|
||||
if l > 0 {
|
||||
n += 1 + l + sovService(uint64(l))
|
||||
}
|
||||
return n
|
||||
}
|
||||
|
||||
@ -1859,6 +1881,40 @@ func (m *SimulateRequest) Unmarshal(dAtA []byte) error {
|
||||
return err
|
||||
}
|
||||
iNdEx = postIndex
|
||||
case 2:
|
||||
if wireType != 2 {
|
||||
return fmt.Errorf("proto: wrong wireType = %d for field TxBytes", wireType)
|
||||
}
|
||||
var byteLen int
|
||||
for shift := uint(0); ; shift += 7 {
|
||||
if shift >= 64 {
|
||||
return ErrIntOverflowService
|
||||
}
|
||||
if iNdEx >= l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
b := dAtA[iNdEx]
|
||||
iNdEx++
|
||||
byteLen |= int(b&0x7F) << shift
|
||||
if b < 0x80 {
|
||||
break
|
||||
}
|
||||
}
|
||||
if byteLen < 0 {
|
||||
return ErrInvalidLengthService
|
||||
}
|
||||
postIndex := iNdEx + byteLen
|
||||
if postIndex < 0 {
|
||||
return ErrInvalidLengthService
|
||||
}
|
||||
if postIndex > l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
m.TxBytes = append(m.TxBytes[:0], dAtA[iNdEx:postIndex]...)
|
||||
if m.TxBytes == nil {
|
||||
m.TxBytes = []byte{}
|
||||
}
|
||||
iNdEx = postIndex
|
||||
default:
|
||||
iNdEx = preIndex
|
||||
skippy, err := skipService(dAtA[iNdEx:])
|
||||
|
||||
@ -19,15 +19,6 @@ import (
|
||||
"github.com/cosmos/cosmos-sdk/x/auth/legacy/legacytx"
|
||||
)
|
||||
|
||||
// Codec defines the x/auth account codec to be used for use with the
|
||||
// AccountRetriever. The application must be sure to set this to their respective
|
||||
// codec that implements the Codec interface and must be the same codec that
|
||||
// passed to the x/auth module.
|
||||
//
|
||||
// TODO:/XXX: Using a package-level global isn't ideal and we should consider
|
||||
// refactoring the module manager to allow passing in the correct module codec.
|
||||
var Codec codec.Marshaler
|
||||
|
||||
// GasEstimateResponse defines a response definition for tx gas estimation.
|
||||
type GasEstimateResponse struct {
|
||||
GasEstimate uint64 `json:"gas_estimate" yaml:"gas_estimate"`
|
||||
|
||||
@ -35,7 +35,6 @@ var (
|
||||
_ client.TxBuilder = &wrapper{}
|
||||
_ ante.HasExtensionOptionsTx = &wrapper{}
|
||||
_ ExtensionOptionsTxBuilder = &wrapper{}
|
||||
_ ProtoTxProvider = &wrapper{}
|
||||
)
|
||||
|
||||
// ExtensionOptionsTxBuilder defines a TxBuilder that can also set extensions.
|
||||
@ -356,8 +355,3 @@ func (w *wrapper) SetNonCriticalExtensionOptions(extOpts ...*codectypes.Any) {
|
||||
w.tx.Body.NonCriticalExtensionOptions = extOpts
|
||||
w.bodyBz = nil
|
||||
}
|
||||
|
||||
// ProtoTxProvider is a type which can provide a proto transaction.
|
||||
type ProtoTxProvider interface {
|
||||
GetProtoTx() *tx.Tx
|
||||
}
|
||||
|
||||
@ -6,6 +6,7 @@ import (
|
||||
"strings"
|
||||
|
||||
gogogrpc "github.com/gogo/protobuf/grpc"
|
||||
"github.com/golang/protobuf/proto" //nolint:staticcheck
|
||||
"github.com/grpc-ecosystem/grpc-gateway/runtime"
|
||||
"google.golang.org/grpc/codes"
|
||||
"google.golang.org/grpc/status"
|
||||
@ -92,17 +93,25 @@ func (s txServer) GetTxsEvent(ctx context.Context, req *txtypes.GetTxsEventReque
|
||||
|
||||
// Simulate implements the ServiceServer.Simulate RPC method.
|
||||
func (s txServer) Simulate(ctx context.Context, req *txtypes.SimulateRequest) (*txtypes.SimulateResponse, error) {
|
||||
if req == nil || req.Tx == nil {
|
||||
if req == nil {
|
||||
return nil, status.Error(codes.InvalidArgument, "invalid empty tx")
|
||||
}
|
||||
|
||||
err := req.Tx.UnpackInterfaces(s.interfaceRegistry)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
txBytes := req.TxBytes
|
||||
if txBytes == nil && req.Tx != nil {
|
||||
// This block is for backwards-compatibility.
|
||||
// We used to support passing a `Tx` in req. But if we do that, sig
|
||||
// verification might not pass, because the .Marshal() below might not
|
||||
// be the same marshaling done by the client.
|
||||
var err error
|
||||
txBytes, err = proto.Marshal(req.Tx)
|
||||
if err != nil {
|
||||
return nil, status.Errorf(codes.InvalidArgument, "invalid tx; %v", err)
|
||||
}
|
||||
}
|
||||
txBytes, err := req.Tx.Marshal()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
||||
if txBytes == nil {
|
||||
return nil, status.Errorf(codes.InvalidArgument, "empty txBytes is not allowed")
|
||||
}
|
||||
|
||||
gasInfo, result, err := s.simulate(txBytes)
|
||||
|
||||
@ -7,14 +7,13 @@ import (
|
||||
"fmt"
|
||||
"testing"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/testutil/testdata"
|
||||
|
||||
"github.com/stretchr/testify/suite"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/client"
|
||||
"github.com/cosmos/cosmos-sdk/client/flags"
|
||||
clienttx "github.com/cosmos/cosmos-sdk/client/tx"
|
||||
"github.com/cosmos/cosmos-sdk/testutil/network"
|
||||
"github.com/cosmos/cosmos-sdk/testutil/testdata"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
|
||||
"github.com/cosmos/cosmos-sdk/types/query"
|
||||
@ -22,7 +21,6 @@ import (
|
||||
"github.com/cosmos/cosmos-sdk/types/tx"
|
||||
"github.com/cosmos/cosmos-sdk/types/tx/signing"
|
||||
authclient "github.com/cosmos/cosmos-sdk/x/auth/client"
|
||||
authtx "github.com/cosmos/cosmos-sdk/x/auth/tx"
|
||||
bankcli "github.com/cosmos/cosmos-sdk/x/bank/client/testutil"
|
||||
banktypes "github.com/cosmos/cosmos-sdk/x/bank/types"
|
||||
)
|
||||
@ -81,10 +79,14 @@ func (s *IntegrationTestSuite) TearDownSuite() {
|
||||
}
|
||||
|
||||
func (s IntegrationTestSuite) TestSimulateTx_GRPC() {
|
||||
val := s.network.Validators[0]
|
||||
txBuilder := s.mkTxBuilder()
|
||||
// Convert the txBuilder to a tx.Tx.
|
||||
protoTx, err := txBuilderToProtoTx(txBuilder)
|
||||
s.Require().NoError(err)
|
||||
// Encode the txBuilder to txBytes.
|
||||
txBytes, err := val.ClientCtx.TxConfig.TxEncoder()(txBuilder.GetTx())
|
||||
s.Require().NoError(err)
|
||||
|
||||
testCases := []struct {
|
||||
name string
|
||||
@ -93,8 +95,9 @@ func (s IntegrationTestSuite) TestSimulateTx_GRPC() {
|
||||
expErrMsg string
|
||||
}{
|
||||
{"nil request", nil, true, "request cannot be nil"},
|
||||
{"empty request", &tx.SimulateRequest{}, true, "invalid empty tx"},
|
||||
{"valid request", &tx.SimulateRequest{Tx: protoTx}, false, ""},
|
||||
{"empty request", &tx.SimulateRequest{}, true, "empty txBytes is not allowed"},
|
||||
{"valid request with proto tx (deprecated)", &tx.SimulateRequest{Tx: protoTx}, false, ""},
|
||||
{"valid request with tx_bytes", &tx.SimulateRequest{TxBytes: txBytes}, false, ""},
|
||||
}
|
||||
|
||||
for _, tc := range testCases {
|
||||
@ -122,6 +125,9 @@ func (s IntegrationTestSuite) TestSimulateTx_GRPCGateway() {
|
||||
// Convert the txBuilder to a tx.Tx.
|
||||
protoTx, err := txBuilderToProtoTx(txBuilder)
|
||||
s.Require().NoError(err)
|
||||
// Encode the txBuilder to txBytes.
|
||||
txBytes, err := val.ClientCtx.TxConfig.TxEncoder()(txBuilder.GetTx())
|
||||
s.Require().NoError(err)
|
||||
|
||||
testCases := []struct {
|
||||
name string
|
||||
@ -129,8 +135,9 @@ func (s IntegrationTestSuite) TestSimulateTx_GRPCGateway() {
|
||||
expErr bool
|
||||
expErrMsg string
|
||||
}{
|
||||
{"empty request", &tx.SimulateRequest{}, true, "invalid empty tx"},
|
||||
{"valid request", &tx.SimulateRequest{Tx: protoTx}, false, ""},
|
||||
{"empty request", &tx.SimulateRequest{}, true, "empty txBytes is not allowed"},
|
||||
{"valid request with proto tx (deprecated)", &tx.SimulateRequest{Tx: protoTx}, false, ""},
|
||||
{"valid request with tx_bytes", &tx.SimulateRequest{TxBytes: txBytes}, false, ""},
|
||||
}
|
||||
|
||||
for _, tc := range testCases {
|
||||
@ -495,9 +502,19 @@ func (s IntegrationTestSuite) mkTxBuilder() client.TxBuilder {
|
||||
return txBuilder
|
||||
}
|
||||
|
||||
// protoTxProvider is a type which can provide a proto transaction. It is a
|
||||
// workaround to get access to the wrapper TxBuilder's method GetProtoTx().
|
||||
// Deprecated: It's only used for testing the deprecated Simulate gRPC endpoint
|
||||
// using a proto Tx field.
|
||||
type protoTxProvider interface {
|
||||
GetProtoTx() *tx.Tx
|
||||
}
|
||||
|
||||
// txBuilderToProtoTx converts a txBuilder into a proto tx.Tx.
|
||||
// Deprecated: It's only used for testing the deprecated Simulate gRPC endpoint
|
||||
// using a proto Tx field.
|
||||
func txBuilderToProtoTx(txBuilder client.TxBuilder) (*tx.Tx, error) { // nolint
|
||||
protoProvider, ok := txBuilder.(authtx.ProtoTxProvider)
|
||||
protoProvider, ok := txBuilder.(protoTxProvider)
|
||||
if !ok {
|
||||
return nil, sdkerrors.Wrapf(sdkerrors.ErrInvalidType, "expected proto tx builder, got %T", txBuilder)
|
||||
}
|
||||
|
||||
@ -5,12 +5,10 @@ package rest_test
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/simapp"
|
||||
"github.com/cosmos/cosmos-sdk/testutil/network"
|
||||
"github.com/cosmos/cosmos-sdk/types"
|
||||
"github.com/cosmos/cosmos-sdk/types/errors"
|
||||
"github.com/cosmos/cosmos-sdk/types/rest"
|
||||
authclient "github.com/cosmos/cosmos-sdk/x/auth/client"
|
||||
"github.com/cosmos/cosmos-sdk/x/auth/legacy/legacytx"
|
||||
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
|
||||
bankrest "github.com/cosmos/cosmos-sdk/x/bank/client/rest"
|
||||
@ -18,9 +16,6 @@ import (
|
||||
)
|
||||
|
||||
func (s *IntegrationTestSuite) TestCoinSend() {
|
||||
encodingConfig := simapp.MakeTestEncodingConfig()
|
||||
authclient.Codec = encodingConfig.Marshaler
|
||||
|
||||
val := s.network.Validators[0]
|
||||
|
||||
account, err := getAccountInfo(val)
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user