Skip to content

Commit

Permalink
perf: internal objects optimization (BaseAccount, Balance & Supply) (#…
Browse files Browse the repository at this point in the history
…320)

* perf: internal objects optimization (BaseAccount, Balance & Supply)

* replaced cdc.(Un)MarshalInterface() with protobuf (Un)Marshal for
  internal objects: BaseAccount, Balance & Supply
* PubKey in BaseAccount has three seperate entries for publick keys to
  avoid MarshalInterface.
* custom json marshaler for BaseAccount to show a single pub key for
  json compatibility

* feat: integrate ostracon (#317)

* fix: treat addresses as strings

* fix: compile errors, test failures

* fix: works-1

* feat: integrate ostracon

* fix: bump up ostracon

* fix: lint error

* fix: bump up ostracon

* fix: self review

* fix: modify changelog

* fix: disable arm building

* fix: bls build failure on arm

* fix: bls build failure on arm

* fix: bls build failure on arm

* docs: modify changelog

* fix: apply comment

Co-authored-by: Woosang Son <woosang.son@linecorp.com>
  • Loading branch information
iproudhon and Woosang Son committed Sep 10, 2021
1 parent a18b7c8 commit 39afd48
Show file tree
Hide file tree
Showing 15 changed files with 584 additions and 250 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
294 changes: 148 additions & 146 deletions docs/core/proto-docs.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -5039,6 +5039,140 @@ data sign byte encodings.



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

## lbm/crypto/ed25519/keys.proto



<a name="lbm.crypto.ed25519.PrivKey"></a>

### PrivKey
PrivKey defines a ed25519 private key.


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






<a name="lbm.crypto.ed25519.PubKey"></a>

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





<!-- end messages -->

<!-- end enums -->

<!-- end HasExtensions -->

<!-- end services -->



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

## lbm/crypto/multisig/keys.proto



<a name="lbm.crypto.multisig.LegacyAminoPubKey"></a>

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





<!-- end messages -->

<!-- end enums -->

<!-- end HasExtensions -->

<!-- end services -->



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

## lbm/crypto/secp256k1/keys.proto



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

### PrivKey
PrivKey defines a secp256k1 private key.


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






<a name="lbm.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 -->

<!-- end HasExtensions -->

<!-- end services -->



<a name="lbm/auth/v1beta1/auth.proto"></a>
<p align="right"><a href="#top">Top</a></p>

Expand All @@ -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) | | |


Expand Down Expand Up @@ -6815,90 +6951,6 @@ Msg defines the bank Msg service.



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

## lbm/crypto/ed25519/keys.proto



<a name="lbm.crypto.ed25519.PrivKey"></a>

### PrivKey
PrivKey defines a ed25519 private key.


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






<a name="lbm.crypto.ed25519.PubKey"></a>

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





<!-- end messages -->

<!-- end enums -->

<!-- end HasExtensions -->

<!-- end services -->



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

## lbm/crypto/multisig/keys.proto



<a name="lbm.crypto.multisig.LegacyAminoPubKey"></a>

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





<!-- end messages -->

<!-- end enums -->

<!-- end HasExtensions -->

<!-- end services -->



<a name="lbm/crypto/multisig/v1beta1/multisig.proto"></a>
<p align="right"><a href="#top">Top</a></p>

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



<!-- end messages -->

<!-- end enums -->

<!-- end HasExtensions -->

<!-- end services -->



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

## lbm/crypto/secp256k1/keys.proto



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

### PrivKey
PrivKey defines a secp256k1 private key.


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






<a name="lbm.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
16 changes: 11 additions & 5 deletions proto/lbm/auth/v1beta1/auth.proto
Original file line number Diff line number Diff line change
@@ -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";

Expand All @@ -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.
Expand Down
6 changes: 3 additions & 3 deletions proto/lbm/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/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,
Expand Down
Loading

0 comments on commit 39afd48

Please sign in to comment.