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

Revert BaseAccount back to cosmos-sdk #588

Merged

Conversation

torao
Copy link
Contributor

@torao torao commented Jul 11, 2022

Description

This PR brings the performance fixes mainly done in 39afd48 back into the cosmos-sdk implementation based on the results of the performance comparison in #549.

  • PubKey Fields: Make the BaseAccount Protocol Buffers definition have a single field for each type of public-key present.
  • JSON/JSONPB: Drop the JSON and JSONPB marshaling implementation of BaseAccount and revert to using ProtocolBuffers for serialization.
  • Gas Calculation: Gas consumption is affected since there is a change in the byte size input/output to/from KVS.

closes: #549

@torao torao added the A: improvement Changes in existing functionality label Jul 11, 2022
@torao torao self-assigned this Jul 11, 2022
@CLAassistant
Copy link

CLAassistant commented Jul 11, 2022

CLA assistant check
All committers have signed the CLA.

@torao torao force-pushed the feature/revert-pubkey-fields-back-to-cosmos-style branch from ecd4482 to 8bbec1e Compare July 11, 2022 06:34
@codecov
Copy link

codecov bot commented Jul 11, 2022

Codecov Report

Merging #588 (39ec0f9) into main (fa0dc25) will decrease coverage by 0.01%.
The diff coverage is 88.88%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #588      +/-   ##
==========================================
- Coverage   57.55%   57.53%   -0.02%     
==========================================
  Files         796      796              
  Lines       87814    87526     -288     
==========================================
- Hits        50543    50361     -182     
+ Misses      34100    34026      -74     
+ Partials     3171     3139      -32     
Impacted Files Coverage Δ
x/auth/vesting/types/vesting_account.go 89.87% <ø> (+1.54%) ⬆️
x/auth/types/account.go 77.24% <84.21%> (+15.53%) ⬆️
x/auth/keeper/keeper.go 51.48% <100.00%> (+0.48%) ⬆️
x/bank/keeper/keeper.go 69.63% <100.00%> (+0.66%) ⬆️
x/bank/keeper/send.go 76.71% <100.00%> (+1.32%) ⬆️
x/bank/keeper/view.go 65.83% <100.00%> (+3.72%) ⬆️
crypto/keys/internal/ecdsa/privkey.go 82.45% <0.00%> (-1.76%) ⬇️
store/rootmulti/store.go 70.06% <0.00%> (-1.09%) ⬇️
... and 3 more

@torao torao marked this pull request as ready for review July 11, 2022 07:23
@torao torao requested review from zemyblue and tnasu July 11, 2022 07:23
Copy link
Member

@tnasu tnasu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@@ -124,7 +124,7 @@ func TestBaseApp_BlockGas(t *testing.T) {
require.Equal(t, []byte("ok"), okValue)
}
// check block gas is always consumed
baseGas := uint64(35030) // baseGas is the gas consumed before tx msg
baseGas := uint64(40043) // baseGas is the gas consumed before tx msg
Copy link
Member

@tnasu tnasu Jul 11, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@@ -198,54 +196,6 @@ func (bva BaseVestingAccount) MarshalYAML() (interface{}, error) {
return marshalYaml(out)
}

type vestingAccountJSON struct {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I left a few of these test cases because I thought it would be less likely to cause conflicts if only they were only test cases like this, but well, I'll remove them.

@@ -804,87 +803,21 @@ func TestPermanentLockedAccountMarshal(t *testing.T) {
require.NotNil(t, err)
}

func TestBaseVestingAccountMarshalJSONPB(t *testing.T) {
func TestBaseVestingAccountMarshal(t *testing.T) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto

@dudong2
Copy link
Contributor

dudong2 commented Jul 11, 2022

I think the gas consumption would have been reduced because 4 fields were merged into 1. Please check the gas comsumption value in the test codes.

@torao
Copy link
Contributor Author

torao commented Jul 12, 2022

@tnasu All formatting differences from cosmos-sdk v0.45.1 in files under proto/ have been fixed.

@dudong2 Based on preliminary findings, the Marshal Size in one field has increased by 35B (see also #549 (comment)). Perhaps the 4-fields version is stored in binary, whereas the 1-field version is stored in types.Any with the relevant information. The gas consumption is calculated at 30 gas per 1 byte and is therefore considered to be increasing.

@torao torao requested a review from tnasu July 12, 2022 02:41
@tnasu
Copy link
Member

tnasu commented Jul 12, 2022

@torao I've confirmed x/bank/ module changes, would you revert them? See the PRs:

All formatting differences from cosmos-sdk v0.45.1 in files under proto/ have been fixed.

Got it.

@torao
Copy link
Contributor Author

torao commented Jul 12, 2022

@tnasu I've made the changed files contained in those two PRs identical to the cosmos-sdk as much as possible within the scope of this issue.

@torao torao merged commit 728aea5 into Finschia:main Jul 12, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A: improvement Changes in existing functionality
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Reduce the difference between lbm-sdk and cosmos-sdk
5 participants