sort *all* GetSignBytes:

- call MustSortJSON before return JSON bytes to guarantee alphabetic
ordering

- moved SortJSON and MustSortJSON to types package to avoid cyclic
package dep
This commit is contained in:
Liamsi
2018-07-06 01:12:57 +01:00
parent 0f1ceb073e
commit b7f902fba5
20 changed files with 100 additions and 143 deletions
+1 -6
View File
@@ -3,7 +3,6 @@ package auth
import (
"encoding/json"
"github.com/cosmos/cosmos-sdk/server"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/tendermint/tendermint/crypto"
)
@@ -142,11 +141,7 @@ func StdSignBytes(chainID string, accnum int64, sequence int64, fee StdFee, msgs
if err != nil {
panic(err)
}
bz, err = server.SortJSON(bz)
if err != nil {
panic(err)
}
return bz
return sdk.MustSortJSON(bz)
}
// StdSignMsg is a convenience structure for passing along
+4 -21
View File
@@ -3,7 +3,6 @@ package bank
import (
"encoding/json"
"github.com/cosmos/cosmos-sdk/server"
sdk "github.com/cosmos/cosmos-sdk/types"
)
@@ -73,11 +72,7 @@ func (msg MsgSend) GetSignBytes() []byte {
if err != nil {
panic(err)
}
b, err = server.SortJSON(b)
if err != nil {
panic(err)
}
return b
return sdk.MustSortJSON(b)
}
// Implements Msg.
@@ -138,11 +133,7 @@ func (msg MsgIssue) GetSignBytes() []byte {
if err != nil {
panic(err)
}
b, err = server.SortJSON(b)
if err != nil {
panic(err)
}
return b
return sdk.MustSortJSON(b)
}
// Implements Msg.
@@ -171,11 +162,7 @@ func (in Input) GetSignBytes() []byte {
if err != nil {
panic(err)
}
bin, err = server.SortJSON(bin)
if err != nil {
panic(err)
}
return bin
return sdk.MustSortJSON(bin)
}
// ValidateBasic - validate transaction input
@@ -222,11 +209,7 @@ func (out Output) GetSignBytes() []byte {
if err != nil {
panic(err)
}
bin, err = server.SortJSON(bin)
if err != nil {
panic(err)
}
return bin
return sdk.MustSortJSON(bin)
}
// ValidateBasic - validate transaction output
+3 -16
View File
@@ -3,7 +3,6 @@ package gov
import (
"fmt"
"github.com/cosmos/cosmos-sdk/server"
sdk "github.com/cosmos/cosmos-sdk/types"
)
@@ -83,11 +82,7 @@ func (msg MsgSubmitProposal) GetSignBytes() []byte {
if err != nil {
panic(err)
}
b, err = server.SortJSON(b)
if err != nil {
panic(err)
}
return b
return sdk.MustSortJSON(b)
}
// Implements Msg.
@@ -154,11 +149,7 @@ func (msg MsgDeposit) GetSignBytes() []byte {
if err != nil {
panic(err)
}
b, err = server.SortJSON(b)
if err != nil {
panic(err)
}
return b
return sdk.MustSortJSON(b)
}
// Implements Msg.
@@ -222,11 +213,7 @@ func (msg MsgVote) GetSignBytes() []byte {
if err != nil {
panic(err)
}
b, err = server.SortJSON(b)
if err != nil {
panic(err)
}
return b
return sdk.MustSortJSON(b)
}
// Implements Msg.
+2 -2
View File
@@ -59,7 +59,7 @@ func (p IBCPacket) GetSignBytes() []byte {
if err != nil {
panic(err)
}
return b
return sdk.MustSortJSON(b)
}
// validator the ibc packey
@@ -131,5 +131,5 @@ func (msg IBCReceiveMsg) GetSignBytes() []byte {
if err != nil {
panic(err)
}
return b
return sdk.MustSortJSON(b)
}
+1 -1
View File
@@ -38,7 +38,7 @@ func (msg MsgUnrevoke) GetSignBytes() []byte {
if err != nil {
panic(err)
}
return b
return sdk.MustSortJSON(b)
}
// quick validity check
+7 -36
View File
@@ -3,7 +3,6 @@ package types
import (
"math"
"github.com/cosmos/cosmos-sdk/server"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/tendermint/tendermint/crypto"
)
@@ -64,11 +63,7 @@ func (msg MsgCreateValidator) GetSignBytes() []byte {
if err != nil {
panic(err)
}
b, err = server.SortJSON(b)
if err != nil {
panic(err)
}
return b
return sdk.MustSortJSON(b)
}
// quick validity check
@@ -119,11 +114,7 @@ func (msg MsgEditValidator) GetSignBytes() []byte {
if err != nil {
panic(err)
}
b, err = server.SortJSON(b)
if err != nil {
panic(err)
}
return b
return sdk.MustSortJSON(b)
}
// quick validity check
@@ -175,11 +166,7 @@ func (msg MsgDelegate) GetSignBytes() []byte {
if err != nil {
panic(err)
}
b, err = server.SortJSON(b)
if err != nil {
panic(err)
}
return b
return sdk.MustSortJSON(b)
}
// quick validity check
@@ -239,11 +226,7 @@ func (msg MsgBeginRedelegate) GetSignBytes() []byte {
if err != nil {
panic(err)
}
b, err = server.SortJSON(b)
if err != nil {
panic(err)
}
return b
return sdk.MustSortJSON(b)
}
// quick validity check
@@ -303,11 +286,7 @@ func (msg MsgCompleteRedelegate) GetSignBytes() []byte {
if err != nil {
panic(err)
}
b, err = server.SortJSON(b)
if err != nil {
panic(err)
}
return b
return sdk.MustSortJSON(b)
}
// quick validity check
@@ -359,11 +338,7 @@ func (msg MsgBeginUnbonding) GetSignBytes() []byte {
if err != nil {
panic(err)
}
b, err = server.SortJSON(b)
if err != nil {
panic(err)
}
return b
return sdk.MustSortJSON(b)
}
// quick validity check
@@ -412,11 +387,7 @@ func (msg MsgCompleteUnbonding) GetSignBytes() []byte {
if err != nil {
panic(err)
}
b, err = server.SortJSON(b)
if err != nil {
panic(err)
}
return b
return sdk.MustSortJSON(b)
}
// quick validity check