diff --git a/CHANGELOG.md b/CHANGELOG.md index 5ba9a2307f..4f932fe066 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -51,6 +51,7 @@ * (wasm) [\#253](https://github.com/line/lbm-sdk/pull/253) remove MaxGas const * (wasm) [\#254](https://github.com/line/lbm-sdk/pull/254) Specify wasm event types * (x) [\#255](https://github.com/line/lbm-sdk/pull/255) Remove legacy from modules +* (perf) [\#320](https:/github.com/line/lbm-sdk/pull/320) internal objects optimization (BaseAccount, Balance & Supply) ### Bug Fixes * (test) [\#92](https://github.com/line/lbm-sdk/pull/92) Fix SendToModuleAccountTest diff --git a/docs/core/proto-docs.md b/docs/core/proto-docs.md index f0c725b801..aea9ed50ce 100644 --- a/docs/core/proto-docs.md +++ b/docs/core/proto-docs.md @@ -300,6 +300,17 @@ - [DataType](#ibc.lightclients.solomachine.v1.DataType) +- [lbm/crypto/ed25519/keys.proto](#lbm/crypto/ed25519/keys.proto) + - [PrivKey](#lbm.crypto.ed25519.PrivKey) + - [PubKey](#lbm.crypto.ed25519.PubKey) + +- [lbm/crypto/multisig/keys.proto](#lbm/crypto/multisig/keys.proto) + - [LegacyAminoPubKey](#lbm.crypto.multisig.LegacyAminoPubKey) + +- [lbm/crypto/secp256k1/keys.proto](#lbm/crypto/secp256k1/keys.proto) + - [PrivKey](#lbm.crypto.secp256k1.PrivKey) + - [PubKey](#lbm.crypto.secp256k1.PubKey) + - [lbm/auth/v1beta1/auth.proto](#lbm/auth/v1beta1/auth.proto) - [BaseAccount](#lbm.auth.v1beta1.BaseAccount) - [ModuleAccount](#lbm.auth.v1beta1.ModuleAccount) @@ -440,21 +451,10 @@ - [Msg](#lbm.crisis.v1beta1.Msg) -- [lbm/crypto/ed25519/keys.proto](#lbm/crypto/ed25519/keys.proto) - - [PrivKey](#lbm.crypto.ed25519.PrivKey) - - [PubKey](#lbm.crypto.ed25519.PubKey) - -- [lbm/crypto/multisig/keys.proto](#lbm/crypto/multisig/keys.proto) - - [LegacyAminoPubKey](#lbm.crypto.multisig.LegacyAminoPubKey) - - [lbm/crypto/multisig/v1beta1/multisig.proto](#lbm/crypto/multisig/v1beta1/multisig.proto) - [CompactBitArray](#lbm.crypto.multisig.v1beta1.CompactBitArray) - [MultiSignature](#lbm.crypto.multisig.v1beta1.MultiSignature) -- [lbm/crypto/secp256k1/keys.proto](#lbm/crypto/secp256k1/keys.proto) - - [PrivKey](#lbm.crypto.secp256k1.PrivKey) - - [PubKey](#lbm.crypto.secp256k1.PubKey) - - [lbm/distribution/v1beta1/distribution.proto](#lbm/distribution/v1beta1/distribution.proto) - [CommunityPoolSpendProposal](#lbm.distribution.v1beta1.CommunityPoolSpendProposal) - [CommunityPoolSpendProposalWithDeposit](#lbm.distribution.v1beta1.CommunityPoolSpendProposalWithDeposit) @@ -5039,6 +5039,140 @@ data sign byte encodings. + +

Top

+ +## lbm/crypto/ed25519/keys.proto + + + + + +### PrivKey +PrivKey defines a ed25519 private key. + + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `key` | [bytes](#bytes) | | | + + + + + + + + +### PubKey +PubKey defines a ed25519 public key +Key is the compressed form of the pubkey. The first byte depends is a 0x02 byte +if the y-coordinate is the lexicographically largest of the two associated with +the x-coordinate. Otherwise the first byte is a 0x03. +This prefix is followed with the x-coordinate. + + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `key` | [bytes](#bytes) | | | + + + + + + + + + + + + + + + + +

Top

+ +## lbm/crypto/multisig/keys.proto + + + + + +### LegacyAminoPubKey +LegacyAminoPubKey specifies a public key type +which nests multiple public keys and a threshold, +it uses legacy amino address rules. + + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `threshold` | [uint32](#uint32) | | | +| `public_keys` | [google.protobuf.Any](#google.protobuf.Any) | repeated | | + + + + + + + + + + + + + + + + +

Top

+ +## lbm/crypto/secp256k1/keys.proto + + + + + +### PrivKey +PrivKey defines a secp256k1 private key. + + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `key` | [bytes](#bytes) | | | + + + + + + + + +### PubKey +PubKey defines a secp256k1 public key +Key is the compressed form of the pubkey. The first byte depends is a 0x02 byte +if the y-coordinate is the lexicographically largest of the two associated with +the x-coordinate. Otherwise the first byte is a 0x03. +This prefix is followed with the x-coordinate. + + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `key` | [bytes](#bytes) | | | + + + + + + + + + + + + + + +

Top

@@ -5057,7 +5191,9 @@ type for additional functionality (e.g. vesting). | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | | `address` | [string](#string) | | | -| `pub_key` | [google.protobuf.Any](#google.protobuf.Any) | | | +| `ed25519_pub_key` | [lbm.crypto.ed25519.PubKey](#lbm.crypto.ed25519.PubKey) | | | +| `secp256k1_pub_key` | [lbm.crypto.secp256k1.PubKey](#lbm.crypto.secp256k1.PubKey) | | | +| `multisig_pub_key` | [lbm.crypto.multisig.LegacyAminoPubKey](#lbm.crypto.multisig.LegacyAminoPubKey) | | | | `sequence` | [uint64](#uint64) | | | @@ -6815,90 +6951,6 @@ Msg defines the bank Msg service. - -

Top

- -## lbm/crypto/ed25519/keys.proto - - - - - -### PrivKey -PrivKey defines a ed25519 private key. - - -| Field | Type | Label | Description | -| ----- | ---- | ----- | ----------- | -| `key` | [bytes](#bytes) | | | - - - - - - - - -### PubKey -PubKey defines a ed25519 public key -Key is the compressed form of the pubkey. The first byte depends is a 0x02 byte -if the y-coordinate is the lexicographically largest of the two associated with -the x-coordinate. Otherwise the first byte is a 0x03. -This prefix is followed with the x-coordinate. - - -| Field | Type | Label | Description | -| ----- | ---- | ----- | ----------- | -| `key` | [bytes](#bytes) | | | - - - - - - - - - - - - - - - - -

Top

- -## lbm/crypto/multisig/keys.proto - - - - - -### LegacyAminoPubKey -LegacyAminoPubKey specifies a public key type -which nests multiple public keys and a threshold, -it uses legacy amino address rules. - - -| Field | Type | Label | Description | -| ----- | ---- | ----- | ----------- | -| `threshold` | [uint32](#uint32) | | | -| `public_keys` | [google.protobuf.Any](#google.protobuf.Any) | repeated | | - - - - - - - - - - - - - - -

Top

@@ -6941,56 +6993,6 @@ signed and with which modes. - - - - - - - - - - - -

Top

- -## lbm/crypto/secp256k1/keys.proto - - - - - -### PrivKey -PrivKey defines a secp256k1 private key. - - -| Field | Type | Label | Description | -| ----- | ---- | ----- | ----------- | -| `key` | [bytes](#bytes) | | | - - - - - - - - -### PubKey -PubKey defines a secp256k1 public key -Key is the compressed form of the pubkey. The first byte depends is a 0x02 byte -if the y-coordinate is the lexicographically largest of the two associated with -the x-coordinate. Otherwise the first byte is a 0x03. -This prefix is followed with the x-coordinate. - - -| Field | Type | Label | Description | -| ----- | ---- | ----- | ----------- | -| `key` | [bytes](#bytes) | | | - - - - - diff --git a/proto/lbm/auth/v1beta1/auth.proto b/proto/lbm/auth/v1beta1/auth.proto index e92e0dfee7..d376d6e69d 100644 --- a/proto/lbm/auth/v1beta1/auth.proto +++ b/proto/lbm/auth/v1beta1/auth.proto @@ -1,9 +1,11 @@ syntax = "proto3"; package lbm.auth.v1beta1; +import "lbm/crypto/ed25519/keys.proto"; +import "lbm/crypto/multisig/keys.proto"; +import "lbm/crypto/secp256k1/keys.proto"; import "cosmos_proto/cosmos.proto"; import "gogoproto/gogo.proto"; -import "google/protobuf/any.proto"; option go_package = "github.com/line/lbm-sdk/x/auth/types"; @@ -17,10 +19,14 @@ message BaseAccount { option (cosmos_proto.implements_interface) = "AccountI"; - string address = 1; - google.protobuf.Any pub_key = 2 - [(gogoproto.jsontag) = "public_key,omitempty", (gogoproto.moretags) = "yaml:\"public_key\""]; - uint64 sequence = 3; + string address = 1; + lbm.crypto.ed25519.PubKey ed25519_pub_key = 2 + [(gogoproto.jsontag) = "ed25519_public_key,omitempty", (gogoproto.moretags) = "yaml:\"ed25519_public_key\""]; + lbm.crypto.secp256k1.PubKey secp256k1_pub_key = 3 + [(gogoproto.jsontag) = "secp256k1_public_key,omitempty", (gogoproto.moretags) = "yaml:\"secp256k1_public_key\""]; + lbm.crypto.multisig.LegacyAminoPubKey multisig_pub_key = 4 + [(gogoproto.jsontag) = "multisig_public_key,omitempty", (gogoproto.moretags) = "yaml:\"multisig_public_key\""]; + uint64 sequence = 5; } // ModuleAccount defines an account for modules that holds coins on a pool. diff --git a/proto/lbm/gov/v1beta1/gov.proto b/proto/lbm/gov/v1beta1/gov.proto index aa92d1ebeb..0c6ddc2b91 100644 --- a/proto/lbm/gov/v1beta1/gov.proto +++ b/proto/lbm/gov/v1beta1/gov.proto @@ -103,9 +103,9 @@ enum ProposalStatus { message TallyResult { option (gogoproto.equal) = true; - string yes = 1 [(gogoproto.customtype) = "github.com/line/lbm-sdk/types.Int", (gogoproto.nullable) = false]; - string abstain = 2 [(gogoproto.customtype) = "github.com/line/lbm-sdk/types.Int", (gogoproto.nullable) = false]; - string no = 3 [(gogoproto.customtype) = "github.com/line/lbm-sdk/types.Int", (gogoproto.nullable) = false]; + string yes = 1 [(gogoproto.customtype) = "github.com/line/lbm-sdk/types.Int", (gogoproto.nullable) = false]; + string abstain = 2 [(gogoproto.customtype) = "github.com/line/lbm-sdk/types.Int", (gogoproto.nullable) = false]; + string no = 3 [(gogoproto.customtype) = "github.com/line/lbm-sdk/types.Int", (gogoproto.nullable) = false]; string no_with_veto = 4 [ (gogoproto.customtype) = "github.com/line/lbm-sdk/types.Int", (gogoproto.nullable) = false, diff --git a/proto/lbm/staking/v1beta1/tx.proto b/proto/lbm/staking/v1beta1/tx.proto index 00a1b8458c..793c838194 100644 --- a/proto/lbm/staking/v1beta1/tx.proto +++ b/proto/lbm/staking/v1beta1/tx.proto @@ -65,10 +65,8 @@ message MsgEditValidator { // it's not mandatory to update. If not updated, the deserialized rate will be // zero with no way to distinguish if an update was intended. // REF: #2373 - string commission_rate = 3 [ - (gogoproto.customtype) = "github.com/line/lbm-sdk/types.Dec", - (gogoproto.moretags) = "yaml:\"commission_rate\"" - ]; + string commission_rate = 3 + [(gogoproto.customtype) = "github.com/line/lbm-sdk/types.Dec", (gogoproto.moretags) = "yaml:\"commission_rate\""]; string min_self_delegation = 4 [ (gogoproto.customtype) = "github.com/line/lbm-sdk/types.Int", (gogoproto.moretags) = "yaml:\"min_self_delegation\"" diff --git a/x/auth/keeper/keeper.go b/x/auth/keeper/keeper.go index be6445698b..26927f7119 100644 --- a/x/auth/keeper/keeper.go +++ b/x/auth/keeper/keeper.go @@ -182,14 +182,13 @@ func (ak AccountKeeper) decodeAccount(bz []byte) types.AccountI { // MarshalAccount protobuf serializes an Account interface func (ak AccountKeeper) MarshalAccount(accountI types.AccountI) ([]byte, error) { // nolint:interfacer - return ak.cdc.MarshalInterface(accountI) + return types.MarshalAccountX(ak.cdc, accountI) } // UnmarshalAccount returns an Account interface from raw encoded account // bytes of a Proto-based Account type func (ak AccountKeeper) UnmarshalAccount(bz []byte) (types.AccountI, error) { - var acc types.AccountI - return acc, ak.cdc.UnmarshalInterface(bz, &acc) + return types.UnmarshalAccountX(ak.cdc, bz) } // GetCodec return codec.Marshaler object used by the keeper diff --git a/x/auth/types/account.go b/x/auth/types/account.go index e2d7a90615..ed529cf4e3 100644 --- a/x/auth/types/account.go +++ b/x/auth/types/account.go @@ -1,17 +1,23 @@ package types import ( + "bytes" "encoding/json" "errors" "fmt" + "strconv" "strings" + "github.com/gogo/protobuf/jsonpb" "github.com/gogo/protobuf/proto" "github.com/line/ostracon/crypto" "gopkg.in/yaml.v2" "github.com/line/lbm-sdk/codec" codectypes "github.com/line/lbm-sdk/codec/types" + "github.com/line/lbm-sdk/crypto/keys/ed25519" + "github.com/line/lbm-sdk/crypto/keys/multisig" + "github.com/line/lbm-sdk/crypto/keys/secp256k1" cryptotypes "github.com/line/lbm-sdk/crypto/types" sdk "github.com/line/lbm-sdk/types" ) @@ -22,6 +28,9 @@ var ( _ codectypes.UnpackInterfacesMessage = (*BaseAccount)(nil) _ GenesisAccount = (*ModuleAccount)(nil) _ ModuleAccountI = (*ModuleAccount)(nil) + + BaseAccountSig = []byte("bacc") + ModuleAccountSig = []byte("macc") ) // NewBaseAccount creates a new BaseAccount object @@ -69,27 +78,30 @@ func (acc *BaseAccount) SetAddress(addr sdk.AccAddress) error { // GetPubKey - Implements sdk.AccountI. func (acc BaseAccount) GetPubKey() (pk cryptotypes.PubKey) { - if acc.PubKey == nil { - return nil - } - content, ok := acc.PubKey.GetCachedValue().(cryptotypes.PubKey) - if !ok { - return nil + if acc.Ed25519PubKey != nil { + return acc.Ed25519PubKey + } else if acc.Secp256K1PubKey != nil { + return acc.Secp256K1PubKey + } else if acc.MultisigPubKey != nil { + return acc.MultisigPubKey } - return content + return nil } // SetPubKey - Implements sdk.AccountI. func (acc *BaseAccount) SetPubKey(pubKey cryptotypes.PubKey) error { if pubKey == nil { - acc.PubKey = nil - return nil + acc.Ed25519PubKey, acc.Secp256K1PubKey, acc.MultisigPubKey = nil, nil, nil + } else if pk, ok := pubKey.(*ed25519.PubKey); ok { + acc.Ed25519PubKey, acc.Secp256K1PubKey, acc.MultisigPubKey = pk, nil, nil + } else if pk, ok := pubKey.(*secp256k1.PubKey); ok { + acc.Ed25519PubKey, acc.Secp256K1PubKey, acc.MultisigPubKey = nil, pk, nil + } else if pk, ok := pubKey.(*multisig.LegacyAminoPubKey); ok { + acc.Ed25519PubKey, acc.Secp256K1PubKey, acc.MultisigPubKey = nil, nil, pk + } else { + return fmt.Errorf("invalid pubkey") } - any, err := codectypes.NewAnyWithValue(pubKey) - if err == nil { - acc.PubKey = any - } - return err + return nil } // GetSequence - Implements sdk.AccountI. @@ -105,7 +117,7 @@ func (acc *BaseAccount) SetSequence(seq uint64) error { // Validate checks for errors on the account fields func (acc BaseAccount) Validate() error { - if acc.Address == "" || acc.PubKey == nil { + if acc.Address == "" || acc.GetPubKey() == nil { return nil } @@ -132,11 +144,22 @@ func (acc BaseAccount) MarshalYAML() (interface{}, error) { // UnpackInterfaces implements UnpackInterfacesMessage.UnpackInterfaces func (acc BaseAccount) UnpackInterfaces(unpacker codectypes.AnyUnpacker) error { - if acc.PubKey == nil { - return nil + if acc.MultisigPubKey != nil { + return codectypes.UnpackInterfaces(acc.MultisigPubKey, unpacker) } - var pubKey cryptotypes.PubKey - return unpacker.UnpackAny(acc.PubKey, &pubKey) + return nil +} + +func (acc *BaseAccount) MarshalX() ([]byte, error) { + bz, err := acc.Marshal() + if err != nil { + return nil, err + } + t := BaseAccountSig + b := make([]byte, len(t)+len(bz)) + copy(b, t) + copy(b[len(t):], bz) + return b, nil } // NewModuleAddress creates an AccAddress from the hash of the module's name @@ -216,6 +239,18 @@ func (ma ModuleAccount) Validate() error { return ma.BaseAccount.Validate() } +func (ma *ModuleAccount) MarshalX() ([]byte, error) { + bz, err := ma.Marshal() + if err != nil { + return nil, err + } + t := ModuleAccountSig + b := make([]byte, len(t)+len(bz)) + copy(b, t) + copy(b[len(t):], bz) + return b, nil +} + type moduleAccountPretty struct { Address sdk.AccAddress `json:"address" yaml:"address"` PubKey string `json:"public_key" yaml:"public_key"` @@ -301,6 +336,41 @@ type AccountI interface { // Ensure that account implements stringer String() string + + MarshalX() ([]byte, error) +} + +func MarshalAccountX(cdc codec.BinaryMarshaler, acc AccountI) ([]byte, error) { + if bacc, ok := acc.(*BaseAccount); ok && bacc.MultisigPubKey == nil { + return acc.MarshalX() + } else if macc, ok := acc.(*ModuleAccount); ok && macc.MultisigPubKey == nil { + return acc.MarshalX() + } else { + return cdc.MarshalInterface(acc) + } +} + +func UnmarshalAccountX(cdc codec.BinaryMarshaler, bz []byte) (AccountI, error) { + sigLen := len(BaseAccountSig) + if len(bz) < sigLen { + return nil, fmt.Errorf("invalid data") + } + if bytes.Equal(bz[:sigLen], BaseAccountSig) { + acc := &BaseAccount{} + if err := acc.Unmarshal(bz[sigLen:]); err != nil { + return nil, err + } + return acc, nil + } else if bytes.Equal(bz[:sigLen], ModuleAccountSig) { + acc := &ModuleAccount{} + if err := acc.Unmarshal(bz[sigLen:]); err != nil { + return nil, err + } + return acc, nil + } else { + var acc AccountI + return acc, cdc.UnmarshalInterface(bz, &acc) + } } // ModuleAccountI defines an account interface for modules that hold tokens in @@ -334,3 +404,121 @@ type GenesisAccount interface { Validate() error } + +// custom json marshaler for BaseAccount & ModuleAccount + +type BaseAccountJSON struct { + Address string `json:"address"` + PubKey json.RawMessage `json:"pub_key"` + Sequence string `json:"sequence"` +} + +func (acc BaseAccount) MarshalJSONPB(m *jsonpb.Marshaler) ([]byte, error) { + var bi BaseAccountJSON + + bi.Address = acc.GetAddress().String() + bi.Sequence = strconv.FormatUint(acc.Sequence, 10) + var bz []byte + var err error + if acc.Ed25519PubKey != nil { + bz, err = codec.ProtoMarshalJSON(acc.Ed25519PubKey, m.AnyResolver) + } + if acc.Secp256K1PubKey != nil { + bz, err = codec.ProtoMarshalJSON(acc.Secp256K1PubKey, m.AnyResolver) + } + if acc.MultisigPubKey != nil { + bz, err = codec.ProtoMarshalJSON(acc.MultisigPubKey, m.AnyResolver) + } + if err != nil { + return nil, err + } + bi.PubKey = bz + return json.Marshal(bi) +} + +func (acc *BaseAccount) UnmarshalJSONPB(m *jsonpb.Unmarshaler, bz []byte) error { + var bi BaseAccountJSON + + err := json.Unmarshal(bz, &bi) + if err != nil { + return err + } + /* TODO: do we need to validate address format here + err = sdk.ValidateAccAddress(bi.Address) + if err != nil { + return err + } + */ + + acc.Address = bi.Address + acc.Sequence, err = strconv.ParseUint(bi.Sequence, 10, 64) + if err != nil { + return err + } + + done := false + if !done { + pk := new(secp256k1.PubKey) + any, _ := codectypes.NewAnyWithValue(pk) + if m.Unmarshal(strings.NewReader(string(bi.PubKey)), any) == nil { + acc.SetPubKey(pk) + done = true + } + } + if !done { + pk := new(ed25519.PubKey) + any, _ := codectypes.NewAnyWithValue(pk) + if m.Unmarshal(strings.NewReader(string(bi.PubKey)), any) == nil { + acc.SetPubKey(pk) + done = true + } + } + if !done { + pk := new(multisig.LegacyAminoPubKey) + any, _ := codectypes.NewAnyWithValue(pk) + if m.Unmarshal(strings.NewReader(string(bi.PubKey)), any) == nil { + acc.SetPubKey(pk) + } + } + return nil +} + +type ModuleAccountJSON struct { + BaseAccount json.RawMessage `json:"base_account"` + Name string `json:"name"` + Permissions []string `json:"permissions"` +} + +func (ma ModuleAccount) MarshalJSONPB(m *jsonpb.Marshaler) ([]byte, error) { + var mi ModuleAccountJSON + + bz, err := ma.BaseAccount.MarshalJSONPB(m) + if err != nil { + return nil, err + } + mi.BaseAccount = bz + mi.Name = ma.Name + mi.Permissions = ma.Permissions + + return json.Marshal(mi) +} + +func (ma *ModuleAccount) UnmarshalJSONPB(m *jsonpb.Unmarshaler, bz []byte) error { + var mi ModuleAccountJSON + + err := json.Unmarshal(bz, &mi) + if err != nil { + return err + } + + ma.Name = mi.Name + ma.Permissions = mi.Permissions + + ba := new(BaseAccount) + if err := m.Unmarshal(strings.NewReader(string(mi.BaseAccount)), ba); err != nil { + return err + } + ma.BaseAccount = ba + + return nil +} diff --git a/x/auth/types/auth.pb.go b/x/auth/types/auth.pb.go index 9cb7825633..c98e454f83 100644 --- a/x/auth/types/auth.pb.go +++ b/x/auth/types/auth.pb.go @@ -7,7 +7,9 @@ import ( fmt "fmt" _ "github.com/gogo/protobuf/gogoproto" proto "github.com/gogo/protobuf/proto" - types "github.com/line/lbm-sdk/codec/types" + ed25519 "github.com/line/lbm-sdk/crypto/keys/ed25519" + multisig "github.com/line/lbm-sdk/crypto/keys/multisig" + secp256k1 "github.com/line/lbm-sdk/crypto/keys/secp256k1" _ "github.com/regen-network/cosmos-proto" io "io" math "math" @@ -29,9 +31,11 @@ const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package // for basic account functionality. Any custom account type should extend this // type for additional functionality (e.g. vesting). type BaseAccount struct { - Address string `protobuf:"bytes,1,opt,name=address,proto3" json:"address,omitempty"` - PubKey *types.Any `protobuf:"bytes,2,opt,name=pub_key,json=pubKey,proto3" json:"public_key,omitempty" yaml:"public_key"` - Sequence uint64 `protobuf:"varint,3,opt,name=sequence,proto3" json:"sequence,omitempty"` + Address string `protobuf:"bytes,1,opt,name=address,proto3" json:"address,omitempty"` + Ed25519PubKey *ed25519.PubKey `protobuf:"bytes,2,opt,name=ed25519_pub_key,json=ed25519PubKey,proto3" json:"ed25519_public_key,omitempty" yaml:"ed25519_public_key"` + Secp256K1PubKey *secp256k1.PubKey `protobuf:"bytes,3,opt,name=secp256k1_pub_key,json=secp256k1PubKey,proto3" json:"secp256k1_public_key,omitempty" yaml:"secp256k1_public_key"` + MultisigPubKey *multisig.LegacyAminoPubKey `protobuf:"bytes,4,opt,name=multisig_pub_key,json=multisigPubKey,proto3" json:"multisig_public_key,omitempty" yaml:"multisig_public_key"` + Sequence uint64 `protobuf:"varint,5,opt,name=sequence,proto3" json:"sequence,omitempty"` } func (m *BaseAccount) Reset() { *m = BaseAccount{} } @@ -198,51 +202,58 @@ func init() { func init() { proto.RegisterFile("lbm/auth/v1beta1/auth.proto", fileDescriptor_023b8ec707b0f8f4) } var fileDescriptor_023b8ec707b0f8f4 = []byte{ - // 689 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x74, 0x54, 0x4d, 0x4f, 0xdb, 0x48, - 0x18, 0x8e, 0x97, 0x6c, 0x80, 0x09, 0xbb, 0x5a, 0x4c, 0x16, 0x4c, 0x58, 0xec, 0xac, 0xb5, 0x87, - 0x1c, 0x36, 0xb6, 0x92, 0x8a, 0x4a, 0xe4, 0x80, 0x84, 0x69, 0x0f, 0xa8, 0xa5, 0x42, 0x8e, 0xc4, - 0xa1, 0x6a, 0x65, 0x8d, 0x9d, 0xc1, 0x8c, 0xe2, 0xc9, 0x18, 0xcf, 0x18, 0xc5, 0xfc, 0x82, 0x1e, - 0x7b, 0xec, 0x91, 0x1f, 0x81, 0xd4, 0x43, 0x2f, 0x3d, 0xf6, 0x88, 0x38, 0xf5, 0x64, 0x55, 0xe1, - 0x52, 0xf5, 0x98, 0x5f, 0x50, 0x79, 0x9c, 0x84, 0x80, 0xd2, 0x9b, 0x9f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xb9, 0x53, 0x0b, 0x5f, - 0xef, 0xd4, 0xc2, 0xeb, 0xff, 0x7c, 0xcc, 0xcf, 0x62, 0xd7, 0xf0, 0x28, 0x31, 0x03, 0xdc, 0x47, - 0x66, 0xe0, 0x92, 0x06, 0xeb, 0xf6, 0xcc, 0x41, 0xfe, 0x97, 0xe1, 0x49, 0x88, 0x98, 0x5b, 0x12, - 0xdf, 0xed, 0x93, 0x9f, 0x01, 0x00, 0x00, 0xff, 0xff, 0x54, 0x4e, 0x42, 0x3b, 0x7e, 0x04, 0x00, - 0x00, + // 802 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x6c, 0x94, 0xbf, 0x6f, 0xe4, 0x44, + 0x14, 0xc7, 0xd7, 0xc4, 0x84, 0x64, 0xf6, 0x7e, 0xc5, 0x09, 0xb9, 0xcd, 0x26, 0xf1, 0x2c, 0x16, + 0x42, 0x29, 0x88, 0xad, 0x04, 0x05, 0xe9, 0x56, 0xe2, 0x50, 0x7c, 0x50, 0x9c, 0xb8, 0x43, 0x91, + 0x23, 0x5d, 0x81, 0x84, 0xac, 0xb1, 0x77, 0x70, 0x46, 0xeb, 0xd9, 0xf1, 0x79, 0xc6, 0xd1, 0xfa, + 0x3a, 0x44, 0x83, 0x44, 0x03, 0x1d, 0x65, 0xfe, 0x88, 0x93, 0x68, 0x29, 0x29, 0xa3, 0xab, 0xa8, + 0x2c, 0xb4, 0x69, 0x50, 0xca, 0xfd, 0x0b, 0x90, 0x67, 0xbc, 0xc6, 0x49, 0xdc, 0xf9, 0xbd, 0xf7, + 0x7d, 0x6f, 0x3e, 0x33, 0xfe, 0xce, 0x80, 0xed, 0x38, 0xa0, 0x0e, 0xca, 0xc4, 0x99, 0x73, 0x7e, + 0x10, 0x60, 0x81, 0x0e, 0x64, 0x60, 0x27, 0x29, 0x13, 0xcc, 0x78, 0x14, 0x07, 0xd4, 0x96, 0x71, + 0x55, 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e, 0x14, 0xf3, 0x02, 0x0e, 0xda, 0x97, 0xad, 0x87, 0x58, 0xde, 0x26, 0x6f, 0xed, 0x35, 0x5e, + 0x81, 0xcd, 0x73, 0x14, 0x93, 0x91, 0x3c, 0xe1, 0x20, 0x66, 0xe1, 0xb8, 0x3c, 0x1d, 0xc2, 0x46, + 0xbd, 0x65, 0xb9, 0xee, 0x47, 0xf3, 0x02, 0xee, 0xaa, 0xe9, 0xed, 0x3a, 0xcb, 0x5b, 0x97, 0x85, + 0x53, 0x12, 0xb9, 0x65, 0xfa, 0x44, 0x66, 0x87, 0x2b, 0xd5, 0x45, 0xd0, 0xdc, 0xa7, 0x7f, 0xcd, + 0x4c, 0xed, 0x72, 0x66, 0x6a, 0xff, 0xcc, 0x4c, 0xed, 0xd7, 0x2b, 0xb3, 0x73, 0x79, 0x65, 0x76, + 0xfe, 0xbe, 0x32, 0x3b, 0xdf, 0x7d, 0x1c, 0x11, 0x71, 0x96, 0x05, 0x76, 0xc8, 0xa8, 0x13, 0x93, + 0x09, 0x76, 0xe2, 0x80, 0xee, 0xf3, 0xd1, 0xd8, 0x99, 0xaa, 0x27, 0x5f, 0xe4, 0x09, 0xe6, 0xc1, + 0xb2, 0x7c, 0x49, 0x3f, 0xfb, 0x2f, 0x00, 0x00, 0xff, 0xff, 0x24, 0xbf, 0x78, 0x95, 0x0b, 0x06, + 0x00, 0x00, } func (this *Params) Equal(that interface{}) bool { @@ -307,11 +318,35 @@ func (m *BaseAccount) MarshalToSizedBuffer(dAtA []byte) (int, error) { if m.Sequence != 0 { i = encodeVarintAuth(dAtA, i, uint64(m.Sequence)) i-- - dAtA[i] = 0x18 + dAtA[i] = 0x28 + } + if m.MultisigPubKey != nil { + { + size, err := m.MultisigPubKey.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintAuth(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x22 } - if m.PubKey != nil { + if m.Secp256K1PubKey != nil { { - size, err := m.PubKey.MarshalToSizedBuffer(dAtA[:i]) + size, err := m.Secp256K1PubKey.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintAuth(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x1a + } + if m.Ed25519PubKey != nil { + { + size, err := m.Ed25519PubKey.MarshalToSizedBuffer(dAtA[:i]) if err != nil { return 0, err } @@ -456,8 +491,16 @@ func (m *BaseAccount) Size() (n int) { if l > 0 { n += 1 + l + sovAuth(uint64(l)) } - if m.PubKey != nil { - l = m.PubKey.Size() + if m.Ed25519PubKey != nil { + l = m.Ed25519PubKey.Size() + n += 1 + l + sovAuth(uint64(l)) + } + if m.Secp256K1PubKey != nil { + l = m.Secp256K1PubKey.Size() + n += 1 + l + sovAuth(uint64(l)) + } + if m.MultisigPubKey != nil { + l = m.MultisigPubKey.Size() n += 1 + l + sovAuth(uint64(l)) } if m.Sequence != 0 { @@ -585,7 +628,7 @@ func (m *BaseAccount) Unmarshal(dAtA []byte) error { iNdEx = postIndex case 2: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field PubKey", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Ed25519PubKey", wireType) } var msglen int for shift := uint(0); ; shift += 7 { @@ -612,14 +655,86 @@ func (m *BaseAccount) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - if m.PubKey == nil { - m.PubKey = &types.Any{} + if m.Ed25519PubKey == nil { + m.Ed25519PubKey = &ed25519.PubKey{} } - if err := m.PubKey.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + if err := m.Ed25519PubKey.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } iNdEx = postIndex case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Secp256K1PubKey", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowAuth + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthAuth + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthAuth + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Secp256K1PubKey == nil { + m.Secp256K1PubKey = &secp256k1.PubKey{} + } + if err := m.Secp256K1PubKey.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field MultisigPubKey", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowAuth + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthAuth + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthAuth + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.MultisigPubKey == nil { + m.MultisigPubKey = &multisig.LegacyAminoPubKey{} + } + if err := m.MultisigPubKey.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 5: if wireType != 0 { return fmt.Errorf("proto: wrong wireType = %d for field Sequence", wireType) } diff --git a/x/bank/exported/exported.go b/x/bank/exported/exported.go index 3fc0fcd61b..6ca372ac05 100644 --- a/x/bank/exported/exported.go +++ b/x/bank/exported/exported.go @@ -26,4 +26,6 @@ type SupplyI interface { String() string ValidateBasic() error + + MarshalX() ([]byte, error) } diff --git a/x/bank/keeper/keeper.go b/x/bank/keeper/keeper.go index 912add2e10..a638e3eaeb 100644 --- a/x/bank/keeper/keeper.go +++ b/x/bank/keeper/keeper.go @@ -190,7 +190,9 @@ func (k BaseKeeper) GetDenomMetaData(ctx sdk.Context, denom string) types.Metada } var metadata types.Metadata - k.cdc.MustUnmarshalBinaryBare(bz, &metadata) + if err := metadata.Unmarshal(bz); err != nil { + panic(err) + } return metadata } @@ -409,12 +411,11 @@ func (k BaseKeeper) trackUndelegation(ctx sdk.Context, addr sdk.AccAddress, amt // MarshalSupply protobuf serializes a Supply interface func (k BaseKeeper) MarshalSupply(supplyI exported.SupplyI) ([]byte, error) { - return k.cdc.MarshalInterface(supplyI) + return supplyI.MarshalX() } // UnmarshalSupply returns a Supply interface from raw encoded supply // bytes of a Proto-based Supply type func (k BaseKeeper) UnmarshalSupply(bz []byte) (exported.SupplyI, error) { - var evi exported.SupplyI - return evi, k.cdc.UnmarshalInterface(bz, &evi) + return types.UnmarshalSupplyX(bz) } diff --git a/x/bank/keeper/send.go b/x/bank/keeper/send.go index 363f27b96e..6ae9b14022 100644 --- a/x/bank/keeper/send.go +++ b/x/bank/keeper/send.go @@ -266,7 +266,10 @@ func (k BaseSendKeeper) SetBalance(ctx sdk.Context, addr sdk.AccAddress, balance balancesStore := prefix.NewStore(store, types.BalancesPrefix) accountStore := prefix.NewStore(balancesStore, AddressToPrefixKey(addr)) - bz := k.cdc.MustMarshalBinaryBare(&balance) + bz, err := balance.Marshal() + if err != nil { + return err + } accountStore.Set([]byte(balance.Denom), bz) return nil diff --git a/x/bank/keeper/view.go b/x/bank/keeper/view.go index 00afd202c8..bc646629d0 100644 --- a/x/bank/keeper/view.go +++ b/x/bank/keeper/view.go @@ -107,7 +107,9 @@ func (k BaseViewKeeper) GetBalance(ctx sdk.Context, addr sdk.AccAddress, denom s } var balance sdk.Coin - k.cdc.MustUnmarshalBinaryBare(bz, &balance) + if err := balance.Unmarshal(bz); err != nil { + panic(err) + } return balance } @@ -125,7 +127,9 @@ func (k BaseViewKeeper) IterateAccountBalances(ctx sdk.Context, addr sdk.AccAddr for ; iterator.Valid(); iterator.Next() { var balance sdk.Coin - k.cdc.MustUnmarshalBinaryBare(iterator.Value(), &balance) + if err := balance.Unmarshal(iterator.Value()); err != nil { + panic(err) + } if cb(balance) { break @@ -147,7 +151,9 @@ func (k BaseViewKeeper) IterateAllBalances(ctx sdk.Context, cb func(sdk.AccAddre address := types.AddressFromBalancesStore(iterator.Key()) var balance sdk.Coin - k.cdc.MustUnmarshalBinaryBare(iterator.Value(), &balance) + if err := balance.Unmarshal(iterator.Value()); err != nil { + panic(err) + } if cb(address, balance) { break diff --git a/x/bank/types/supply.go b/x/bank/types/supply.go index ea7015ddeb..a32020ca91 100644 --- a/x/bank/types/supply.go +++ b/x/bank/types/supply.go @@ -56,3 +56,16 @@ func (supply Supply) ValidateBasic() error { return nil } + +func (supply *Supply) MarshalX() ([]byte, error) { + return supply.Marshal() +} + +func UnmarshalSupplyX(bz []byte) (exported.SupplyI, error) { + var supply Supply + + if err := supply.Unmarshal(bz); err != nil { + return nil, err + } + return &supply, nil +} diff --git a/x/wasm/keeper/keeper_test.go b/x/wasm/keeper/keeper_test.go index e19f7a1ddd..3e19a2250c 100644 --- a/x/wasm/keeper/keeper_test.go +++ b/x/wasm/keeper/keeper_test.go @@ -287,7 +287,7 @@ func TestInstantiate(t *testing.T) { gasAfter := ctx.GasMeter().GasConsumed() if types.EnableGasVerification { - require.Equal(t, uint64(0x114c2), gasAfter-gasBefore) + require.Equal(t, uint64(0x1115c), gasAfter-gasBefore) } // ensure it is stored properly @@ -521,7 +521,7 @@ func TestExecute(t *testing.T) { // make sure gas is properly deducted from ctx gasAfter := ctx.GasMeter().GasConsumed() if types.EnableGasVerification { - require.Equal(t, uint64(0x10c22), gasAfter-gasBefore) + require.Equal(t, uint64(0x107b7), gasAfter-gasBefore) } // ensure bob now exists and got both payments released bobAcct = accKeeper.GetAccount(ctx, bob) diff --git a/x/wasm/keeper/submsg_test.go b/x/wasm/keeper/submsg_test.go index 03c0adc359..b21c80112e 100644 --- a/x/wasm/keeper/submsg_test.go +++ b/x/wasm/keeper/submsg_test.go @@ -262,7 +262,7 @@ func TestDispatchSubMsgErrorHandling(t *testing.T) { submsgID: 5, msg: validBankSend, // note we charge another 40k for the reply call - resultAssertions: []assertion{assertReturnedEvents(3), assertGasUsed(118000, 130000)}, + resultAssertions: []assertion{assertReturnedEvents(3), assertGasUsed(117000, 130000)}, }, "not enough tokens": { submsgID: 6, @@ -282,7 +282,7 @@ func TestDispatchSubMsgErrorHandling(t *testing.T) { msg: validBankSend, gasLimit: &subGasLimit, // uses same gas as call without limit - resultAssertions: []assertion{assertReturnedEvents(3), assertGasUsed(118000, 130000)}, + resultAssertions: []assertion{assertReturnedEvents(3), assertGasUsed(117000, 130000)}, }, "not enough tokens with limit": { submsgID: 16,