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

refactor!: rm GetSignBytes #16062

Merged
merged 27 commits into from
May 30, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
3d7a2e7
refactor!: rm usages of .GetSignBytes
kocubinski May 11, 2023
8ea6ade
fix server/mock/app_test.go
kocubinski May 11, 2023
22972a0
"fix" x/bank simulation tests
kocubinski May 11, 2023
9c7ab5b
must sort json in ProtoCodec.MarshalAminoJSON
kocubinski May 12, 2023
14d288f
mv legacy coin format fn, fix distribution sims tests
kocubinski May 12, 2023
3021c32
fix lots of tests
kocubinski May 13, 2023
d1ba723
wip
kocubinski May 15, 2023
ca1a0b4
Merge branch 'main' of github.com:cosmos/cosmos-sdk into kocubinski/r…
kocubinski May 15, 2023
dfa22b1
Merge branch 'main' of github.com:cosmos/cosmos-sdk into kocubinski/r…
kocubinski May 15, 2023
4208d52
Add missing attribute to proto, other test fixes too
kocubinski May 15, 2023
d18763f
Something unknown happening in MsgSubmitProposal
kocubinski May 16, 2023
3869992
add missing annotation
kocubinski May 16, 2023
ff11dbd
Merge branch 'main' of github.com:cosmos/cosmos-sdk into kocubinski/r…
kocubinski May 16, 2023
56fc906
fix x/feegrant tests
kocubinski May 16, 2023
0b19b09
rm unneeded method
kocubinski May 16, 2023
da9d445
comment out deref in test
kocubinski May 16, 2023
dce0f2d
fix linter faults
kocubinski May 16, 2023
9a9dcbd
Add CHANGELOG
kocubinski May 16, 2023
a4d981d
Add UPGRADING notes
kocubinski May 16, 2023
ac10b70
fmt
kocubinski May 16, 2023
0f9e5a3
proofing
kocubinski May 16, 2023
beb7863
Merge branch 'main' into kocubinski/rm-getsignbytes
kocubinski May 16, 2023
6cfc30b
merge main
kocubinski May 30, 2023
d75af77
lint fixes
kocubinski May 30, 2023
6fa8d80
fix legacy amino test
kocubinski May 30, 2023
2ddc9ea
fix intergration tests
kocubinski May 30, 2023
b70101c
Merge branch 'main' into kocubinski/rm-getsignbytes
kocubinski May 30, 2023
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
Next Next commit
refactor!: rm usages of .GetSignBytes
  • Loading branch information
kocubinski committed May 11, 2023
commit 3d7a2e7ebe0a1c29e23de46b0ae1f5207793f0ea
317 changes: 161 additions & 156 deletions api/cosmos/tx/v1beta1/tx.pulsar.go

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,8 @@ require (

// Below are the long-lived replace of the Cosmos SDK
replace (
// TODO remove after cosmossdk.io/api release
cosmossdk.io/api => ./api
// TODO: remove me after collections 0.2. is released.
cosmossdk.io/collections => ./collections
cosmossdk.io/core => ./core
Expand Down
2 changes: 0 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,6 @@ cloud.google.com/go/storage v1.6.0/go.mod h1:N7U0C8pVQ/+NIKOBQyamJIeKQKkZ+mxpohl
cloud.google.com/go/storage v1.8.0/go.mod h1:Wv1Oy7z6Yz3DshWRJFhqM/UCfaWIRTdp0RXyy7KQOVs=
cloud.google.com/go/storage v1.10.0/go.mod h1:FLPqc6j+Ki4BU591ie1oL6qBQGu2Bl/tZ9ullr3+Kg0=
cloud.google.com/go/storage v1.14.0/go.mod h1:GrKmX003DSIwi9o29oFT7YDnHYwZoctc3fOKtUw0Xmo=
cosmossdk.io/api v0.4.1 h1:0ikaYM6GyxTYYcfBiyR8YnLCfhNnhKpEFnaSepCTmqg=
cosmossdk.io/api v0.4.1/go.mod h1:jR7k5ok90LxW2lFUXvd8Vpo/dr4PpiyVegxdm7b1ZdE=
cosmossdk.io/depinject v1.0.0-alpha.3 h1:6evFIgj//Y3w09bqOUOzEpFj5tsxBqdc5CfkO7z+zfw=
cosmossdk.io/depinject v1.0.0-alpha.3/go.mod h1:eRbcdQ7MRpIPEM5YUJh8k97nxHpYbc3sMUnEtt8HPWU=
cosmossdk.io/errors v1.0.0-beta.7.0.20230429155654-3ee8242364e4 h1:rOy7iw7HlwKc5Af5qIHLXdBx/F98o6du/I/WGwOW6eA=
Expand Down
17 changes: 13 additions & 4 deletions proto/cosmos/tx/v1beta1/tx.proto
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
syntax = "proto3";
package cosmos.tx.v1beta1;

import "amino/amino.proto";
import "gogoproto/gogo.proto";
import "cosmos/crypto/multisig/v1beta1/multisig.proto";
import "cosmos/base/v1beta1/coin.proto";
Expand Down Expand Up @@ -205,8 +206,12 @@ message ModeInfo {
// which must be above some miminum to be accepted into the mempool.
message Fee {
// amount is the amount of coins to be paid as a fee
repeated cosmos.base.v1beta1.Coin amount = 1
[(gogoproto.nullable) = false, (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins"];
repeated cosmos.base.v1beta1.Coin amount = 1 [
(gogoproto.nullable) = false,
(gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins",
(amino.dont_omitempty) = true,
(amino.encoding) = "legacy_coins"
];

// gas_limit is the maximum gas that can be used in transaction processing
// before an out of gas error occurs
Expand All @@ -228,8 +233,12 @@ message Fee {
// Since: cosmos-sdk 0.46
message Tip {
// amount is the amount of the tip
repeated cosmos.base.v1beta1.Coin amount = 1
[(gogoproto.nullable) = false, (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins"];
repeated cosmos.base.v1beta1.Coin amount = 1 [
(gogoproto.nullable) = false,
(gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins",
(amino.dont_omitempty) = true,
(amino.encoding) = "legacy_coins"
];
// tipper is the address of the account paying for the tip
string tipper = 2 [(cosmos_proto.scalar) = "cosmos.AddressString"];
}
Expand Down
4 changes: 0 additions & 4 deletions server/mock/tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,10 +100,6 @@ func (msg *KVStoreTx) GetMsgs() []sdk.Msg {
return []sdk.Msg{msg}
}

func (msg *KVStoreTx) GetSignBytes() []byte {
return msg.bytes
}

// Should the app be calling this? Or only handlers?
func (msg *KVStoreTx) ValidateBasic() error {
return nil
Expand Down
9 changes: 0 additions & 9 deletions testutil/testdata/tx.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package testdata

import (
"encoding/json"
"testing"

"gotest.tools/v3/assert"
Expand Down Expand Up @@ -78,14 +77,6 @@ func NewTestMsg(addrs ...sdk.AccAddress) *TestMsg {

var _ sdk.Msg = (*TestMsg)(nil)

func (msg *TestMsg) GetSignBytes() []byte {
bz, err := json.Marshal(msg.Signers)
if err != nil {
panic(err)
}
return sdk.MustSortJSON(bz)
}

func (msg *TestMsg) GetSigners() []sdk.AccAddress {
signers := make([]sdk.AccAddress, 0, len(msg.Signers))
for _, addr := range msg.Signers {
Expand Down
4 changes: 2 additions & 2 deletions types/result.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,11 @@ import (
"github.com/cosmos/gogoproto/proto"

cmtproto "github.com/cometbft/cometbft/proto/tendermint/types"

"github.com/cosmos/cosmos-sdk/codec"
codectypes "github.com/cosmos/cosmos-sdk/codec/types"
)

var cdc = codec.NewLegacyAmino()

func (gi GasInfo) String() string {
bz, _ := codec.MarshalYAML(codec.NewProtoCodec(nil), &gi)
return string(bz)
Expand Down Expand Up @@ -49,6 +48,7 @@ func NewABCIMessageLog(i uint32, log string, events Events) ABCIMessageLog {
// String implements the fmt.Stringer interface for the ABCIMessageLogs type.
func (logs ABCIMessageLogs) String() (str string) {
if logs != nil {
cdc := codec.NewLegacyAmino()
raw, err := cdc.MarshalJSON(logs)
if err == nil {
str = string(raw)
Expand Down
133 changes: 68 additions & 65 deletions types/tx/tx.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 7 additions & 6 deletions x/auth/migrations/legacytx/stdsign.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,17 +44,18 @@ type StdSignDoc struct {
Tip *StdTip `json:"tip,omitempty" yaml:"tip"`
}

var RegressionTestingAminoCodec *codec.LegacyAmino

// StdSignBytes returns the bytes to sign for a transaction.
// Deprecated: Please use x/tx/signing/aminojson instead.
func StdSignBytes(chainID string, accnum, sequence, timeout uint64, fee StdFee, msgs []sdk.Msg, memo string, tip *tx.Tip) []byte {
if RegressionTestingAminoCodec == nil {
panic(fmt.Errorf("must set RegressionTestingAminoCodec before calling StdSignBytes"))
}
msgsBytes := make([]json.RawMessage, 0, len(msgs))
for _, msg := range msgs {
legacyMsg, ok := msg.(LegacyMsg)
if !ok {
panic(fmt.Errorf("expected %T when using amino JSON", (*LegacyMsg)(nil)))
}

msgsBytes = append(msgsBytes, json.RawMessage(legacyMsg.GetSignBytes()))
bz := RegressionTestingAminoCodec.MustMarshalJSON(msg)
msgsBytes = append(msgsBytes, sdk.MustSortJSON(bz))
}

var stdTip *StdTip
Expand Down
5 changes: 0 additions & 5 deletions x/auth/migrations/legacytx/stdsignmsg.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,6 @@ type StdSignMsg struct {
Memo string `json:"memo" yaml:"memo"`
}

// get message bytes
func (msg StdSignMsg) Bytes() []byte {
return StdSignBytes(msg.ChainID, msg.AccountNumber, msg.Sequence, msg.TimeoutHeight, msg.Fee, msg.Msgs, msg.Memo, nil)
}

func (msg StdSignMsg) UnpackInterfaces(unpacker types.AnyUnpacker) error {
for _, m := range msg.Msgs {
err := types.UnpackInterfaces(m, unpacker)
Expand Down
Loading