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

perf: internal objects optimization #281

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
122 changes: 61 additions & 61 deletions docs/core/proto-docs.md
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,10 @@
- [Header](#ibc.lightclients.tendermint.v1.Header)
- [Misbehaviour](#ibc.lightclients.tendermint.v1.Misbehaviour)

- [lfb/crypto/secp256k1/keys.proto](#lfb/crypto/secp256k1/keys.proto)
- [PrivKey](#lfb.crypto.secp256k1.PrivKey)
- [PubKey](#lfb.crypto.secp256k1.PubKey)

- [lfb/auth/v1beta1/auth.proto](#lfb/auth/v1beta1/auth.proto)
- [BaseAccount](#lfb.auth.v1beta1.BaseAccount)
- [ModuleAccount](#lfb.auth.v1beta1.ModuleAccount)
Expand Down Expand Up @@ -371,10 +375,6 @@
- [CompactBitArray](#lfb.crypto.multisig.v1beta1.CompactBitArray)
- [MultiSignature](#lfb.crypto.multisig.v1beta1.MultiSignature)

- [lfb/crypto/secp256k1/keys.proto](#lfb/crypto/secp256k1/keys.proto)
- [PrivKey](#lfb.crypto.secp256k1.PrivKey)
- [PubKey](#lfb.crypto.secp256k1.PubKey)

- [lfb/distribution/v1beta1/distribution.proto](#lfb/distribution/v1beta1/distribution.proto)
- [CommunityPoolSpendProposal](#lfb.distribution.v1beta1.CommunityPoolSpendProposal)
- [CommunityPoolSpendProposalWithDeposit](#lfb.distribution.v1beta1.CommunityPoolSpendProposalWithDeposit)
Expand Down Expand Up @@ -3828,6 +3828,56 @@ that implements Misbehaviour interface expected by ICS-02



<!-- end messages -->

<!-- end enums -->

<!-- end HasExtensions -->

<!-- end services -->



<a name="lfb/crypto/secp256k1/keys.proto"></a>
<p align="right"><a href="#top">Top</a></p>

## lfb/crypto/secp256k1/keys.proto



<a name="lfb.crypto.secp256k1.PrivKey"></a>

### PrivKey
PrivKey defines a secp256k1 private key.


| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| `key` | [bytes](#bytes) | | |






<a name="lfb.crypto.secp256k1.PubKey"></a>

### 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) | | |





<!-- end messages -->

<!-- end enums -->
Expand Down Expand Up @@ -3855,8 +3905,8 @@ type for additional functionality (e.g. vesting).

| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| `address` | [string](#string) | | |
| `pub_key` | [google.protobuf.Any](#google.protobuf.Any) | | |
| `address` | [bytes](#bytes) | | |
| `pub_key` | [lfb.crypto.secp256k1.PubKey](#lfb.crypto.secp256k1.PubKey) | | |
| `account_number` | [uint64](#uint64) | | |
| `sequence` | [uint64](#uint64) | | |

Expand Down Expand Up @@ -4108,7 +4158,7 @@ Input models transaction input.

| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| `address` | [string](#string) | | |
| `address` | [bytes](#bytes) | | |
| `coins` | [lfb.base.v1beta1.Coin](#lfb.base.v1beta1.Coin) | repeated | |


Expand Down Expand Up @@ -4143,7 +4193,7 @@ Output models transaction outputs.

| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| `address` | [string](#string) | | |
| `address` | [bytes](#bytes) | | |
| `coins` | [lfb.base.v1beta1.Coin](#lfb.base.v1beta1.Coin) | repeated | |


Expand Down Expand Up @@ -4225,7 +4275,7 @@ genesis state.

| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| `address` | [string](#string) | | address is the address of the balance holder. |
| `address` | [bytes](#bytes) | | address is the address of the balance holder. |
| `coins` | [lfb.base.v1beta1.Coin](#lfb.base.v1beta1.Coin) | repeated | coins defines the different coins this balance holds. |


Expand Down Expand Up @@ -4542,8 +4592,8 @@ MsgSend represents a message to send coins from one account to another.

| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| `from_address` | [string](#string) | | |
| `to_address` | [string](#string) | | |
| `from_address` | [bytes](#bytes) | | |
| `to_address` | [bytes](#bytes) | | |
| `amount` | [lfb.base.v1beta1.Coin](#lfb.base.v1beta1.Coin) | repeated | |


Expand Down Expand Up @@ -5674,56 +5724,6 @@ signed and with which modes.



<!-- end messages -->

<!-- end enums -->

<!-- end HasExtensions -->

<!-- end services -->



<a name="lfb/crypto/secp256k1/keys.proto"></a>
<p align="right"><a href="#top">Top</a></p>

## lfb/crypto/secp256k1/keys.proto



<a name="lfb.crypto.secp256k1.PrivKey"></a>

### PrivKey
PrivKey defines a secp256k1 private key.


| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| `key` | [bytes](#bytes) | | |






<a name="lfb.crypto.secp256k1.PubKey"></a>

### 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) | | |





<!-- end messages -->

<!-- end enums -->
Expand Down
5 changes: 3 additions & 2 deletions proto/lfb/auth/v1beta1/auth.proto
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
syntax = "proto3";
package lfb.auth.v1beta1;

import "lfb/crypto/secp256k1/keys.proto";
import "cosmos_proto/cosmos.proto";
import "gogoproto/gogo.proto";
import "google/protobuf/any.proto";
Expand All @@ -17,8 +18,8 @@ message BaseAccount {

option (cosmos_proto.implements_interface) = "AccountI";

string address = 1;
google.protobuf.Any pub_key = 2
bytes address = 1;
lfb.crypto.secp256k1.PubKey pub_key = 2
[(gogoproto.jsontag) = "public_key,omitempty", (gogoproto.moretags) = "yaml:\"public_key\""];
uint64 account_number = 3 [(gogoproto.moretags) = "yaml:\"account_number\""];
uint64 sequence = 4;
Expand Down
4 changes: 2 additions & 2 deletions proto/lfb/bank/v1beta1/bank.proto
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ message Input {
option (gogoproto.equal) = false;
option (gogoproto.goproto_getters) = false;

string address = 1;
bytes address = 1;
repeated lfb.base.v1beta1.Coin coins = 2
[(gogoproto.nullable) = false, (gogoproto.castrepeated) = "github.com/line/lfb-sdk/types.Coins"];
}
Expand All @@ -38,7 +38,7 @@ message Output {
option (gogoproto.equal) = false;
option (gogoproto.goproto_getters) = false;

string address = 1;
bytes address = 1;
repeated lfb.base.v1beta1.Coin coins = 2
[(gogoproto.nullable) = false, (gogoproto.castrepeated) = "github.com/line/lfb-sdk/types.Coins"];
}
Expand Down
2 changes: 1 addition & 1 deletion proto/lfb/bank/v1beta1/genesis.proto
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ message Balance {
option (gogoproto.goproto_getters) = false;

// address is the address of the balance holder.
string address = 1;
bytes address = 1;

// coins defines the different coins this balance holds.
repeated lfb.base.v1beta1.Coin coins = 2
Expand Down
4 changes: 2 additions & 2 deletions proto/lfb/bank/v1beta1/tx.proto
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ message MsgSend {
option (gogoproto.equal) = false;
option (gogoproto.goproto_getters) = false;

string from_address = 1 [(gogoproto.moretags) = "yaml:\"from_address\""];
string to_address = 2 [(gogoproto.moretags) = "yaml:\"to_address\""];
bytes from_address = 1 [(gogoproto.moretags) = "yaml:\"from_address\""];
bytes to_address = 2 [(gogoproto.moretags) = "yaml:\"to_address\""];
repeated lfb.base.v1beta1.Coin amount = 3
[(gogoproto.nullable) = false, (gogoproto.castrepeated) = "github.com/line/lfb-sdk/types.Coins"];
}
Expand Down
6 changes: 3 additions & 3 deletions proto/lfb/gov/v1beta1/gov.proto
Original file line number Diff line number Diff line change
Expand Up @@ -103,9 +103,9 @@ enum ProposalStatus {
message TallyResult {
option (gogoproto.equal) = true;

string yes = 1 [(gogoproto.customtype) = "github.com/line/lfb-sdk/types.Int", (gogoproto.nullable) = false];
string abstain = 2 [(gogoproto.customtype) = "github.com/line/lfb-sdk/types.Int", (gogoproto.nullable) = false];
string no = 3 [(gogoproto.customtype) = "github.com/line/lfb-sdk/types.Int", (gogoproto.nullable) = false];
string yes = 1 [(gogoproto.customtype) = "github.com/line/lfb-sdk/types.Int", (gogoproto.nullable) = false];
string abstain = 2 [(gogoproto.customtype) = "github.com/line/lfb-sdk/types.Int", (gogoproto.nullable) = false];
string no = 3 [(gogoproto.customtype) = "github.com/line/lfb-sdk/types.Int", (gogoproto.nullable) = false];
string no_with_veto = 4 [
(gogoproto.customtype) = "github.com/line/lfb-sdk/types.Int",
(gogoproto.nullable) = false,
Expand Down
6 changes: 2 additions & 4 deletions proto/lfb/staking/v1beta1/tx.proto
Original file line number Diff line number Diff line change
Expand Up @@ -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/lfb-sdk/types.Dec",
(gogoproto.moretags) = "yaml:\"commission_rate\""
];
string commission_rate = 3
[(gogoproto.customtype) = "github.com/line/lfb-sdk/types.Dec", (gogoproto.moretags) = "yaml:\"commission_rate\""];
string min_self_delegation = 4 [
(gogoproto.customtype) = "github.com/line/lfb-sdk/types.Int",
(gogoproto.moretags) = "yaml:\"min_self_delegation\""
Expand Down
2 changes: 1 addition & 1 deletion simapp/simd/cmd/genaccounts.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ contain valid denominations. Accounts may optionally be supplied with vesting pa
// create concrete account type based on input parameters
var genAccount authtypes.GenesisAccount

balances := banktypes.Balance{Address: addr.String(), Coins: coins.Sort()}
balances := banktypes.Balance{Address: addr, Coins: coins.Sort()}
baseAccount := authtypes.NewBaseAccount(addr, nil, 0, 0)

if !vestingAmt.IsZero() {
Expand Down
2 changes: 1 addition & 1 deletion simapp/simd/cmd/testnet.go
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ func InitTestnet(
sdk.NewCoin(sdk.DefaultBondDenom, accStakingTokens),
}

genBalances = append(genBalances, banktypes.Balance{Address: addr.String(), Coins: coins.Sort()})
genBalances = append(genBalances, banktypes.Balance{Address: addr, Coins: coins.Sort()})
genAccounts = append(genAccounts, authtypes.NewBaseAccount(addr, nil, 0, 0))

valTokens := sdk.TokensFromConsensusPower(100)
Expand Down
5 changes: 2 additions & 3 deletions x/auth/keeper/keeper.go
Original file line number Diff line number Diff line change
Expand Up @@ -217,14 +217,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 accountI.MarshalX()
}

// 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(bz)
}

// GetCodec return codec.Marshaler object used by the keeper
Expand Down
Loading