Change address from bytes to bech32 strings (#7242)

* init

* Fix bank proto messages

* missing conversions

* remove casttype for addresses

* Fix tests

* Fix consaddress

* more test fixes

* Fix tests

* fixed tests

* migrate missing proto declarations

* format

* Fix format

* Fix alignment

* Fix more tests

* Fix ibc merge issue

* Fix fmt

* Fix more tests

* Fix missing address declarations

* Fix staking tests

* Fix more tests

* Fix config

* fixed tests

* Fix more tests

* Update staking grpc tests

* Fix merge issue

* fixed failing tests in x/distr

* fixed sim tests

* fixed failing tests

* Fix bugs

* Add logs

* fixed slashing issue

* Fix staking grpc tests

* Fix all bank tests :)

* Fix tests in distribution

* Fix more tests in distr

* Fix slashing tests

* Fix statking tests

* Fix evidence tests

* Fix gov tests

* Fix bug in create vesting account

* Fix test

* remove fmt

* fixed gov tests

* fixed x/ibc tests

* fixed x/ibc-transfer tests

* fixed staking tests

* fixed staking tests

* fixed test

* fixed distribution issue

* fix pagination test

* fmt

* lint

* fix build

* fix format

* revert tally tests

* revert tally tests

* lint

* Fix sim test

* revert

* revert

* fixed tally issue

* fix tests

* revert

* fmt

* refactor

* remove `GetAddress()`

* remove fmt

* revert fmt.Striger usage

* Fix tests

* Fix rest test

* disable interfacer lint check

* make proto-format

* add nolint rule

* remove stray println

Co-authored-by: aleem1314 <aleem.md789@gmail.com>
Co-authored-by: atheesh <atheesh@vitwit.com>
This commit is contained in:
Anil Kumar Kammari
2020-09-25 10:25:37 +00:00
committed by GitHub
co-authored by aleem1314 atheesh
parent 91ca8ad3c1
commit d55c1a2665
247 changed files with 5815 additions and 7810 deletions
+13 -10
View File
@@ -40,7 +40,8 @@ type TxResponse struct {
Code uint32 `protobuf:"varint,4,opt,name=code,proto3" json:"code,omitempty"`
// Result bytes, if any.
Data string `protobuf:"bytes,5,opt,name=data,proto3" json:"data,omitempty"`
// The output of the application's logger (raw string). May be non-deterministic.
// The output of the application's logger (raw string). May be
// non-deterministic.
RawLog string `protobuf:"bytes,6,opt,name=raw_log,json=rawLog,proto3" json:"raw_log,omitempty"`
// The output of the application's logger (typed). May be non-deterministic.
Logs ABCIMessageLogs `protobuf:"bytes,7,rep,name=logs,proto3,castrepeated=ABCIMessageLogs" json:"logs"`
@@ -52,8 +53,9 @@ type TxResponse struct {
GasUsed int64 `protobuf:"varint,10,opt,name=gas_used,json=gasUsed,proto3" json:"gas_used,omitempty"`
// The request transaction bytes.
Tx *types.Any `protobuf:"bytes,11,opt,name=tx,proto3" json:"tx,omitempty"`
// Time of the previous block. For heights > 1, it's the weighted median of the
// timestamps of the valid votes in the block.LastCommit. For height == 1, it's genesis time.
// Time of the previous block. For heights > 1, it's the weighted median of
// the timestamps of the valid votes in the block.LastCommit. For height == 1,
// it's genesis time.
Timestamp string `protobuf:"bytes,12,opt,name=timestamp,proto3" json:"timestamp,omitempty"`
}
@@ -313,13 +315,13 @@ func (m *GasInfo) GetGasUsed() uint64 {
// Result is the union of ResponseFormat and ResponseCheckTx.
type Result struct {
// Data is any data returned from message or handler execution. It MUST be length
// prefixed in order to separate data from multiple message executions.
// Data is any data returned from message or handler execution. It MUST be
// length prefixed in order to separate data from multiple message executions.
Data []byte `protobuf:"bytes,1,opt,name=data,proto3" json:"data,omitempty"`
// Log contains the log information from message or handler execution.
Log string `protobuf:"bytes,2,opt,name=log,proto3" json:"log,omitempty"`
// Events contains a slice of Event objects that were emitted during message or
// handler execution.
// Events contains a slice of Event objects that were emitted during message
// or handler execution.
Events []types1.Event `protobuf:"bytes,3,rep,name=events,proto3" json:"events"`
}
@@ -401,7 +403,8 @@ func (m *SimulationResponse) GetResult() *Result {
return nil
}
// MsgData defines the data returned in a Result object during message execution.
// MsgData defines the data returned in a Result object during message
// execution.
type MsgData struct {
MsgType string `protobuf:"bytes,1,opt,name=msg_type,json=msgType,proto3" json:"msg_type,omitempty"`
Data []byte `protobuf:"bytes,2,opt,name=data,proto3" json:"data,omitempty"`
@@ -453,8 +456,8 @@ func (m *MsgData) GetData() []byte {
return nil
}
// TxMsgData defines a list of MsgData. A transaction will have a MsgData object for
// each message.
// TxMsgData defines a list of MsgData. A transaction will have a MsgData object
// for each message.
type TxMsgData struct {
Data []*MsgData `protobuf:"bytes,1,rep,name=data,proto3" json:"data,omitempty"`
}
+1
View File
@@ -185,6 +185,7 @@ func (aa AccAddress) MarshalYAML() (interface{}, error) {
func (aa *AccAddress) UnmarshalJSON(data []byte) error {
var s string
err := json.Unmarshal(data, &s)
if err != nil {
return err
}
+5 -4
View File
@@ -42,8 +42,9 @@ type PageRequest struct {
// If left empty it will default to a value to be set by each app.
Limit uint64 `protobuf:"varint,3,opt,name=limit,proto3" json:"limit,omitempty"`
// count_total is set to true to indicate that the result set should include
// a count of the total number of items available for pagination in UIs. count_total
// is only respected when offset is used. It is ignored when key is set.
// a count of the total number of items available for pagination in UIs.
// count_total is only respected when offset is used. It is ignored when key
// is set.
CountTotal bool `protobuf:"varint,4,opt,name=count_total,json=countTotal,proto3" json:"count_total,omitempty"`
}
@@ -108,8 +109,8 @@ func (m *PageRequest) GetCountTotal() bool {
return false
}
// PageResponse is to be embedded in gRPC response messages where the corresponding
// request message has used PageRequest.
// PageResponse is to be embedded in gRPC response messages where the
// corresponding request message has used PageRequest.
//
// message SomeResponse {
// repeated Bar results = 1;
+2 -1
View File
@@ -11,6 +11,7 @@ import (
"github.com/cosmos/cosmos-sdk/baseapp"
"github.com/cosmos/cosmos-sdk/codec"
"github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1"
"github.com/cosmos/cosmos-sdk/simapp"
"github.com/cosmos/cosmos-sdk/store"
"github.com/cosmos/cosmos-sdk/store/prefix"
@@ -46,7 +47,7 @@ func TestPagination(t *testing.T) {
balances = append(balances, sdk.NewInt64Coin(denom, 100))
}
addr1 := sdk.AccAddress([]byte("addr1"))
addr1 := sdk.AccAddress(secp256k1.GenPrivKey().PubKey().Address())
acc1 := app.AccountKeeper.NewAccountWithAddress(ctx, addr1)
app.AccountKeeper.SetAccount(ctx, acc1)
require.NoError(t, app.BankKeeper.SetBalances(ctx, addr1, balances))
+11 -8
View File
@@ -28,13 +28,15 @@ const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package
type SignMode int32
const (
// SIGN_MODE_UNSPECIFIED specifies an unknown signing mode and will be rejected
// SIGN_MODE_UNSPECIFIED specifies an unknown signing mode and will be
// rejected
SignMode_SIGN_MODE_UNSPECIFIED SignMode = 0
// SIGN_MODE_DIRECT specifies a signing mode which uses SignDoc and is verified
// with raw bytes from Tx
// SIGN_MODE_DIRECT specifies a signing mode which uses SignDoc and is
// verified with raw bytes from Tx
SignMode_SIGN_MODE_DIRECT SignMode = 1
// SIGN_MODE_TEXTUAL is a future signing mode that will verify some human-readable
// textual representation on top of the binary representation from SIGN_MODE_DIRECT
// SIGN_MODE_TEXTUAL is a future signing mode that will verify some
// human-readable textual representation on top of the binary representation
// from SIGN_MODE_DIRECT
SignMode_SIGN_MODE_TEXTUAL SignMode = 2
// SIGN_MODE_LEGACY_AMINO_JSON is a backwards compatibility mode which uses
// Amino JSON and will be removed in the future
@@ -109,9 +111,10 @@ func (m *SignatureDescriptors) GetSignatures() []*SignatureDescriptor {
return nil
}
// SignatureDescriptor is a convenience type which represents the full data for a
// signature including the public key of the signer, signing modes and the signature
// itself. It is primarily used for coordinating signatures between clients.
// SignatureDescriptor is a convenience type which represents the full data for
// a signature including the public key of the signer, signing modes and the
// signature itself. It is primarily used for coordinating signatures between
// clients.
type SignatureDescriptor struct {
// public_key is the public key of the signer
PublicKey *types.Any `protobuf:"bytes,1,opt,name=public_key,json=publicKey,proto3" json:"public_key,omitempty"`
+39 -26
View File
@@ -32,11 +32,12 @@ const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package
type Tx struct {
// body is the processable content of the transaction
Body *TxBody `protobuf:"bytes,1,opt,name=body,proto3" json:"body,omitempty"`
// auth_info is the authorization related content of the transaction, specifically
// signers, signer modes and fee
// auth_info is the authorization related content of the transaction,
// specifically signers, signer modes and fee
AuthInfo *AuthInfo `protobuf:"bytes,2,opt,name=auth_info,json=authInfo,proto3" json:"auth_info,omitempty"`
// signatures is a list of signatures that matches the length and order of AuthInfo's signer_infos to
// allow connecting signature meta information like public key and signing mode by position.
// signatures is a list of signatures that matches the length and order of
// AuthInfo's signer_infos to allow connecting signature meta information like
// public key and signing mode by position.
Signatures [][]byte `protobuf:"bytes,3,rep,name=signatures,proto3" json:"signatures,omitempty"`
}
@@ -94,17 +95,21 @@ func (m *Tx) GetSignatures() [][]byte {
return nil
}
// TxRaw is a variant of Tx that pins the signer's exact binary representation of body and
// auth_info. This is used for signing, broadcasting and verification. The binary
// `serialize(tx: TxRaw)` is stored in Tendermint and the hash `sha256(serialize(tx: TxRaw))`
// becomes the "txhash", commonly used as the transaction ID.
// TxRaw is a variant of Tx that pins the signer's exact binary representation
// of body and auth_info. This is used for signing, broadcasting and
// verification. The binary `serialize(tx: TxRaw)` is stored in Tendermint and
// the hash `sha256(serialize(tx: TxRaw))` becomes the "txhash", commonly used
// as the transaction ID.
type TxRaw struct {
// body_bytes is a protobuf serialization of a TxBody that matches the representation in SignDoc.
// body_bytes is a protobuf serialization of a TxBody that matches the
// representation in SignDoc.
BodyBytes []byte `protobuf:"bytes,1,opt,name=body_bytes,json=bodyBytes,proto3" json:"body_bytes,omitempty"`
// auth_info_bytes is a protobuf serialization of an AuthInfo that matches the representation in SignDoc.
// auth_info_bytes is a protobuf serialization of an AuthInfo that matches the
// representation in SignDoc.
AuthInfoBytes []byte `protobuf:"bytes,2,opt,name=auth_info_bytes,json=authInfoBytes,proto3" json:"auth_info_bytes,omitempty"`
// signatures is a list of signatures that matches the length and order of AuthInfo's signer_infos to
// allow connecting signature meta information like public key and signing mode by position.
// signatures is a list of signatures that matches the length and order of
// AuthInfo's signer_infos to allow connecting signature meta information like
// public key and signing mode by position.
Signatures [][]byte `protobuf:"bytes,3,rep,name=signatures,proto3" json:"signatures,omitempty"`
}
@@ -164,9 +169,11 @@ func (m *TxRaw) GetSignatures() [][]byte {
// SignDoc is the type used for generating sign bytes for SIGN_MODE_DIRECT.
type SignDoc struct {
// body_bytes is protobuf serialization of a TxBody that matches the representation in TxRaw.
// body_bytes is protobuf serialization of a TxBody that matches the
// representation in TxRaw.
BodyBytes []byte `protobuf:"bytes,1,opt,name=body_bytes,json=bodyBytes,proto3" json:"body_bytes,omitempty"`
// auth_info_bytes is a protobuf serialization of an AuthInfo that matches the representation in TxRaw.
// auth_info_bytes is a protobuf serialization of an AuthInfo that matches the
// representation in TxRaw.
AuthInfoBytes []byte `protobuf:"bytes,2,opt,name=auth_info_bytes,json=authInfoBytes,proto3" json:"auth_info_bytes,omitempty"`
// chain_id is the unique identifier of the chain this transaction targets.
// It prevents signed transactions from being used on another chain by an
@@ -239,12 +246,14 @@ func (m *SignDoc) GetAccountNumber() uint64 {
// TxBody is the body of a transaction that all signers sign over.
type TxBody struct {
// messages is a list of messages to be executed. The required signers of those messages define
// the number and order of elements in AuthInfo's signer_infos and Tx's signatures.
// Each required signer address is added to the list only the first time it occurs.
// messages is a list of messages to be executed. The required signers of
// those messages define the number and order of elements in AuthInfo's
// signer_infos and Tx's signatures. Each required signer address is added to
// the list only the first time it occurs.
//
// By convention, the first required signer (usually from the first message) is referred
// to as the primary signer and pays the fee for the whole transaction.
// By convention, the first required signer (usually from the first message)
// is referred to as the primary signer and pays the fee for the whole
// transaction.
Messages []*types.Any `protobuf:"bytes,1,rep,name=messages,proto3" json:"messages,omitempty"`
// memo is any arbitrary memo to be added to the transaction
Memo string `protobuf:"bytes,2,opt,name=memo,proto3" json:"memo,omitempty"`
@@ -329,11 +338,13 @@ func (m *TxBody) GetNonCriticalExtensionOptions() []*types.Any {
return nil
}
// AuthInfo describes the fee and signer modes that are used to sign a transaction.
// AuthInfo describes the fee and signer modes that are used to sign a
// transaction.
type AuthInfo struct {
// signer_infos defines the signing modes for the required signers. The number
// and order of elements must match the required signers from TxBody's messages.
// The first element is the primary signer and the one which pays the fee.
// and order of elements must match the required signers from TxBody's
// messages. The first element is the primary signer and the one which pays
// the fee.
SignerInfos []*SignerInfo `protobuf:"bytes,1,rep,name=signer_infos,json=signerInfos,proto3" json:"signer_infos,omitempty"`
// Fee is the fee and gas limit for the transaction. The first signer is the
// primary signer and the one which pays the fee. The fee can be calculated
@@ -389,7 +400,8 @@ func (m *AuthInfo) GetFee() *Fee {
return nil
}
// SignerInfo describes the public key and signing mode of a single top-level signer.
// SignerInfo describes the public key and signing mode of a single top-level
// signer.
type SignerInfo struct {
// public_key is the public key of the signer. It is optional for accounts
// that already exist in state. If unset, the verifier can use the required \
@@ -399,8 +411,8 @@ type SignerInfo struct {
// structure to support nested multisig pubkey's
ModeInfo *ModeInfo `protobuf:"bytes,2,opt,name=mode_info,json=modeInfo,proto3" json:"mode_info,omitempty"`
// sequence is the sequence of the account, which describes the
// number of committed transactions signed by a given address. It is used to prevent
// replay attacks.
// number of committed transactions signed by a given address. It is used to
// prevent replay attacks.
Sequence uint64 `protobuf:"varint,3,opt,name=sequence,proto3" json:"sequence,omitempty"`
}
@@ -548,7 +560,8 @@ func (*ModeInfo) XXX_OneofWrappers() []interface{} {
}
// Single is the mode info for a single signer. It is structured as a message
// to allow for additional fields such as locale for SIGN_MODE_TEXTUAL in the future
// to allow for additional fields such as locale for SIGN_MODE_TEXTUAL in the
// future
type ModeInfo_Single struct {
// mode is the signing mode of the single signer
Mode signing.SignMode `protobuf:"varint,1,opt,name=mode,proto3,enum=cosmos.tx.signing.v1beta1.SignMode" json:"mode,omitempty"`