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

Migrate {x/auth, x/gov, x/staking} missing CLI queries to proto #6994

Merged
merged 51 commits into from
Sep 10, 2020
Merged
Show file tree
Hide file tree
Changes from 43 commits
Commits
Show all changes
51 commits
Select commit Hold shift + click to select a range
e353cd0
Fix error code
sahith-narahari Aug 9, 2020
93fab54
Merge branch 'master' of github.com:cosmos/cosmos-sdk into sahith/upd…
sahith-narahari Aug 13, 2020
237c08f
Merge branch 'master' of github.com:cosmos/cosmos-sdk into sahith/upd…
sahith-narahari Aug 14, 2020
a8e1550
Merge branch 'master' into sahith/update-query-cli
anilcse Aug 17, 2020
ce925c3
Merge branch 'master' of github.com:cosmos/cosmos-sdk into sahith/upd…
anilcse Aug 18, 2020
97e1d87
Merge branch 'master' into sahith/update-query-cli
anilcse Aug 18, 2020
647d146
Merge branch 'sahith/update-query-cli' of github.com:cosmos/cosmos-sd…
anilcse Aug 18, 2020
bc70575
Fix decoder
anilcse Aug 22, 2020
e564ed1
Fix typo
anilcse Aug 22, 2020
f34a03b
Fix decode
anilcse Aug 24, 2020
810fcac
refactor
anilcse Aug 24, 2020
176592c
Merge branch 'master' into sahith/update-query-cli
anilcse Aug 24, 2020
d8d3264
Migrate SearchTxsResult to proto
anilcse Aug 25, 2020
d899405
Merge branch 'master' into sahith/update-query-cli
alexanderbez Aug 25, 2020
706bacc
fix MarkEventsToIndex
alexanderbez Aug 25, 2020
e228a57
lint++
alexanderbez Aug 25, 2020
95fccdd
Merge branch 'bez/fix-MarkEventsToIndex' of github.com:cosmos/cosmos-…
anilcse Aug 25, 2020
1991204
Merge branch 'sahith/update-query-cli' of github.com:cosmos/cosmos-sd…
anilcse Aug 25, 2020
a541306
Fix output
anilcse Aug 25, 2020
0ef79e6
Merge branch 'master' of ssh://github.com/cosmos/cosmos-sdk into sahi…
amaury1093 Aug 26, 2020
bc4498e
Add QueryTxCmd cli test
anilcse Aug 26, 2020
3c8bc53
Merge branch 'master' of github.com:cosmos/cosmos-sdk into sahith/upd…
anilcse Aug 26, 2020
66000da
Merge branch 'sahith/update-query-cli' of ssh://github.com/cosmos/cos…
amaury1093 Aug 26, 2020
d5dc3a4
Add fmt
amaury1093 Aug 27, 2020
b4a41c2
Merge branch 'master' of ssh://github.com/cosmos/cosmos-sdk into sahi…
amaury1093 Sep 1, 2020
2a02efc
Merge branch 'master' of ssh://github.com/cosmos/cosmos-sdk into sahi…
amaury1093 Sep 3, 2020
db5d236
Put txBuilder in types/tx
amaury1093 Sep 3, 2020
abcdee3
Add GetAnyTx in TxBuilder
amaury1093 Sep 3, 2020
aaa930a
Add new IsAnyTx
amaury1093 Sep 3, 2020
b187831
Rename to IntoAny
amaury1093 Sep 3, 2020
61e257e
Fix bug
amaury1093 Sep 3, 2020
6e10445
Merge branch 'master' into sahith/update-query-cli
amaury1093 Sep 3, 2020
0be2e5b
Merge branch 'sahith/update-query-cli' of ssh://github.com/cosmos/cos…
amaury1093 Sep 3, 2020
2dac31c
fmt
anilcse Sep 3, 2020
c8815e7
Merge branch 'master' of github.com:cosmos/cosmos-sdk into sahith/upd…
anilcse Sep 5, 2020
e08c852
Fix ibc CLI to use proto
anilcse Sep 5, 2020
1aa75c4
Merge branch 'sahith/update-query-cli' of github.com:cosmos/cosmos-sd…
anilcse Sep 5, 2020
bed75a8
Merge branch 'sahith/update-query-cli' of ssh://github.com/cosmos/cos…
amaury1093 Sep 7, 2020
aa9b78f
Fix any MarshalJSON
amaury1093 Sep 7, 2020
1ea476f
Fix test
amaury1093 Sep 7, 2020
cf17bcd
Make tx.Tx implement sdk.Tx
amaury1093 Sep 7, 2020
8fb572d
Register sdk.Tx
amaury1093 Sep 7, 2020
85a92e9
Fix lint
amaury1093 Sep 7, 2020
8b96e49
Allow DefaultJSONTxEncoder to take tx.Tx
amaury1093 Sep 7, 2020
c2e6f7f
refactor
anilcse Sep 7, 2020
97269db
Merge branch 'master' into sahith/update-query-cli
anilcse Sep 7, 2020
afca789
Rename variable
amaury1093 Sep 8, 2020
598be43
Merge branch 'master' into sahith/update-query-cli
alexanderbez Sep 8, 2020
1a406c9
Merge branch 'master' into sahith/update-query-cli
anilcse Sep 8, 2020
3ec3d52
Merge branch 'master' into sahith/update-query-cli
anilcse Sep 10, 2020
ff49992
remove fmt
anilcse Sep 10, 2020
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
9 changes: 8 additions & 1 deletion client/grpc/simulate/simulate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,12 @@ import (
"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/client/grpc/simulate"
"github.com/cosmos/cosmos-sdk/client/tx"
codectypes "github.com/cosmos/cosmos-sdk/codec/types"
"github.com/cosmos/cosmos-sdk/simapp"
"github.com/cosmos/cosmos-sdk/std"
"github.com/cosmos/cosmos-sdk/testutil/testdata"
sdk "github.com/cosmos/cosmos-sdk/types"
txtypes "github.com/cosmos/cosmos-sdk/types/tx"
"github.com/cosmos/cosmos-sdk/types/tx/signing"
authsigning "github.com/cosmos/cosmos-sdk/x/auth/signing"
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
Expand Down Expand Up @@ -98,9 +100,14 @@ func (s IntegrationTestSuite) TestSimulateService() {
)
txBuilder.SetSignatures(sigV2)

any, ok := txBuilder.(codectypes.IntoAny)
s.Require().True(ok)
cached := any.AsAny().GetCachedValue()
txTx, ok := cached.(*txtypes.Tx)
s.Require().True(ok)
res, err := s.queryClient.Simulate(
context.Background(),
&simulate.SimulateRequest{Tx: txBuilder.GetProtoTx()},
&simulate.SimulateRequest{Tx: txTx},
Comment on lines +103 to +110
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

GetProtoTx() is a little bit more verbose, but at least it makes sense in the StdTx case too.

)
s.Require().NoError(err)

Expand Down
1 change: 0 additions & 1 deletion client/tx/legacy.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import (

// ConvertTxToStdTx converts a transaction to the legacy StdTx format
func ConvertTxToStdTx(codec *codec.LegacyAmino, tx signing.Tx) (types.StdTx, error) {

if stdTx, ok := tx.(types.StdTx); ok {
return stdTx, nil
}
Expand Down
19 changes: 7 additions & 12 deletions client/tx/legacy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,26 +3,21 @@ package tx_test
import (
"testing"

"github.com/stretchr/testify/suite"

"github.com/cosmos/cosmos-sdk/simapp/params"

"github.com/cosmos/cosmos-sdk/x/auth/signing"

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

"github.com/cosmos/cosmos-sdk/client"
tx2 "github.com/cosmos/cosmos-sdk/client/tx"
"github.com/cosmos/cosmos-sdk/codec"
"github.com/cosmos/cosmos-sdk/simapp"
"github.com/cosmos/cosmos-sdk/simapp/params"
"github.com/cosmos/cosmos-sdk/std"
"github.com/cosmos/cosmos-sdk/x/auth/tx"
types3 "github.com/cosmos/cosmos-sdk/x/auth/types"

signing2 "github.com/cosmos/cosmos-sdk/types/tx/signing"

"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/testutil/testdata"
"github.com/cosmos/cosmos-sdk/types"
signing2 "github.com/cosmos/cosmos-sdk/types/tx/signing"
"github.com/cosmos/cosmos-sdk/x/auth/signing"
"github.com/cosmos/cosmos-sdk/x/auth/tx"
types3 "github.com/cosmos/cosmos-sdk/x/auth/types"
types2 "github.com/cosmos/cosmos-sdk/x/bank/types"
)

Expand Down
14 changes: 13 additions & 1 deletion client/tx/tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,11 @@ import (
"github.com/cosmos/cosmos-sdk/client/flags"
sim "github.com/cosmos/cosmos-sdk/client/grpc/simulate"
"github.com/cosmos/cosmos-sdk/client/input"
codectypes "github.com/cosmos/cosmos-sdk/codec/types"
sdk "github.com/cosmos/cosmos-sdk/types"
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
"github.com/cosmos/cosmos-sdk/types/rest"
"github.com/cosmos/cosmos-sdk/types/tx"
"github.com/cosmos/cosmos-sdk/types/tx/signing"
authsigning "github.com/cosmos/cosmos-sdk/x/auth/signing"
)
Expand Down Expand Up @@ -265,7 +267,17 @@ func BuildSimTx(txf Factory, msgs ...sdk.Msg) ([]byte, error) {
return nil, err
}

simReq := sim.SimulateRequest{Tx: txb.GetProtoTx()}
any, ok := txb.(codectypes.IntoAny)
if !ok {
return nil, fmt.Errorf("cannot simulate tx that cannot be wrapped into any")
}
cached := any.AsAny().GetCachedValue()
txTx, ok := cached.(*tx.Tx)
amaury1093 marked this conversation as resolved.
Show resolved Hide resolved
if !ok {
return nil, fmt.Errorf("cannot simulate amino tx")
}

simReq := sim.SimulateRequest{Tx: txTx}

return simReq.Marshal()
}
Expand Down
5 changes: 2 additions & 3 deletions client/tx/tx_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,12 @@ import (
"github.com/cosmos/cosmos-sdk/testutil"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/x/auth/signing"
"github.com/cosmos/cosmos-sdk/x/auth/types"
banktypes "github.com/cosmos/cosmos-sdk/x/bank/types"
)

func NewTestTxConfig() client.TxConfig {
_, cdc := simapp.MakeCodecs()
return types.StdTxConfig{Cdc: cdc}
cfg := simapp.MakeEncodingConfig()
return cfg.TxConfig
}

func TestCalculateGas(t *testing.T) {
Expand Down
3 changes: 0 additions & 3 deletions client/tx_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package client

import (
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/tx"
signingtypes "github.com/cosmos/cosmos-sdk/types/tx/signing"
"github.com/cosmos/cosmos-sdk/x/auth/signing"
)
Expand Down Expand Up @@ -36,8 +35,6 @@ type (
// also know how to encode itself.
TxBuilder interface {
GetTx() signing.Tx
// GetProtoTx returns the tx as a proto.Message.
GetProtoTx() *tx.Tx

SetMsgs(msgs ...sdk.Msg) error
SetSignatures(signatures ...signingtypes.SignatureV2) error
Expand Down
7 changes: 6 additions & 1 deletion codec/types/any.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ func (any *Any) Pack(x proto.Message) error {
func UnsafePackAny(x interface{}) *Any {
if msg, ok := x.(proto.Message); ok {
any, err := NewAnyWithValue(msg)
if err != nil {
if err == nil {
return any
}
}
Expand All @@ -107,3 +107,8 @@ func (any *Any) GetCachedValue() interface{} {
func (any *Any) ClearCachedValue() {
any.cachedValue = nil
}

// IntoAny represents a type that can be wrapped into an Any.
type IntoAny interface {
AsAny() *Any
}
2 changes: 1 addition & 1 deletion codec/types/compat.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ func (any *Any) UnmarshalAmino(bz []byte) error {
return nil
}

func (any Any) MarshalJSON() ([]byte, error) {
func (any *Any) MarshalJSON() ([]byte, error) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we need a pointer reference when marshaling?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using Any, any.compat (just below) is nil. Using *Any, any.compat is correct. I'm not 100% I understand why; it's set on this line btw.

I didn't dig too much into it, but anyways, without the reference, tests fail.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@amaurymartiny , this could be some weird concurrency issue.

If you use Any then a method receiver works on an object copy. Sometimes it's a source of errors in methods which modifies the object. Here all methods which modifies the object are using pointer receivers. So that's why my guess is that tests are doing something weird in parallel.

ac := any.compat
if ac == nil {
return nil, anyCompatError("JSON marshal", any)
Expand Down
27 changes: 27 additions & 0 deletions proto/cosmos/base/abci/v1beta1/abci.proto
Original file line number Diff line number Diff line change
Expand Up @@ -114,3 +114,30 @@ message TxMsgData {

repeated MsgData data = 1;
}

// SearchTxsResult defines a structure for querying txs pageable
message SearchTxsResult {
option (gogoproto.stringer) = true;

// Count of all txs
uint64 total_count = 1 [
(gogoproto.moretags) = "yaml:\"total_count\"",
(gogoproto.jsontag) = "total_count"
];
// Count of txs in current page
uint64 count = 2;
// Index of current page, start from 1
uint64 page_number = 3 [
(gogoproto.moretags) = "yaml:\"page_number\"",
(gogoproto.jsontag) = "page_number"
];
// Count of total pages
uint64 page_total = 4 [
(gogoproto.moretags) = "yaml:\"page_total\"",
(gogoproto.jsontag) = "page_total"
];
// Max count txs per page
uint64 limit = 5;
// List of txs in current page
repeated TxResponse txs = 6;
}
2 changes: 2 additions & 0 deletions std/codec.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"github.com/cosmos/cosmos-sdk/codec/types"
cryptocodec "github.com/cosmos/cosmos-sdk/crypto/codec"
sdk "github.com/cosmos/cosmos-sdk/types"
txtypes "github.com/cosmos/cosmos-sdk/types/tx"
vesting "github.com/cosmos/cosmos-sdk/x/auth/vesting/types"
)

Expand All @@ -17,5 +18,6 @@ func RegisterCodec(cdc *codec.LegacyAmino) {
// RegisterInterfaces registers Interfaces from sdk/types and vesting
func RegisterInterfaces(interfaceRegistry types.InterfaceRegistry) {
sdk.RegisterInterfaces(interfaceRegistry)
txtypes.RegisterInterfaces(interfaceRegistry)
vesting.RegisterInterfaces(interfaceRegistry)
}
Loading