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

Darren/logdb remove leading zeros #865

Open
wants to merge 10 commits into
base: feat/db
Choose a base branch
from

Conversation

darrenvechain
Copy link
Member

@darrenvechain darrenvechain commented Oct 21, 2024

Description

This changes reduces the storage size for the LogDB by removing leading zeros from topics. Eg, instead of storing topic 1 equal to:

0000000000000000000000006d95e6dca01d109882fe1726a2fb9865fa41e7aa

We store:

6d95e6dca01d109882fe1726a2fb9865fa41e7aa

This saves over 0.5 GB of storage.

Type of change

Please delete options that are not relevant.

  • Breaking change - requires a full resync of the logDB

How Has This Been Tested?

Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also
list any relevant details for your test configuration

  • Unit tested
  • Performance tested - No change in query performance
  • Comparison tested - Mainnet against synced node with these changes. All API calls returned the same values for the same request

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • New and existing E2E tests pass locally with my changes
  • Any dependent changes have been merged and published in downstream modules
  • I have not added any vulnerable dependencies to my code

@darrenvechain darrenvechain requested a review from a team as a code owner October 21, 2024 08:53
@codecov-commenter
Copy link

Codecov Report

Attention: Patch coverage is 95.83333% with 1 line in your changes missing coverage. Please review.

Project coverage is 60.62%. Comparing base (175050c) to head (82b2a67).

Files with missing lines Patch % Lines
logdb/logdb.go 95.65% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #865      +/-   ##
==========================================
- Coverage   62.60%   60.62%   -1.99%     
==========================================
  Files         209      209              
  Lines       18946    22446    +3500     
==========================================
+ Hits        11862    13608    +1746     
- Misses       5983     7738    +1755     
+ Partials     1101     1100       -1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@darrenvechain darrenvechain changed the base branch from master to feat/db October 21, 2024 08:59
Copy link
Member

@paologalligit paologalligit left a comment

Choose a reason for hiding this comment

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

Looks good to me! Just a minor typo

logdb/logdb.go Outdated Show resolved Hide resolved
Co-authored-by: Paolo Galli <[email protected]>
logdb/logdb.go Outdated
}
bytes = bytes[i:]
// ensure at least 1 byte
if len(bytes) == 0 {
Copy link
Member

Choose a reason for hiding this comment

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

Any particular reason for this?

Copy link
Member

Choose a reason for hiding this comment

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

NVM, I got that.

Copy link
Member

Choose a reason for hiding this comment

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

How about

   if i== 31{
        return []byte{0}
   }
   return bytes[i:]

Copy link
Member Author

Choose a reason for hiding this comment

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

Pushed this change a change for:

if i == len(bytes) {
	return []byte{0}
}

because the unit test was failing when you pass in a number of bytes not equal to 32

logdb/logdb.go Outdated
@@ -474,14 +487,20 @@ func (w *Writer) Write(b *block.Block, receipts tx.Receipts) error {

for clauseIndex, output := range r.Outputs {
for _, ev := range output.Events {
t0Val := topicValue(ev.Topics, 0)
Copy link
Member

@libotony libotony Oct 22, 2024

Choose a reason for hiding this comment

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

Looks the same as changing before. Any benefits here?

Copy link
Member Author

Choose a reason for hiding this comment

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

Apologies, this was me debugging I think, I'll revert

@qianbin
Copy link
Member

qianbin commented Oct 24, 2024

It seems not very useful on reducing the size of logdb, And it's not worth it.

@darrenvechain
Copy link
Member Author

It seems not very useful on reducing the size of logdb, And it's not worth it.

@qianbin the idea is to put it with mainDB v4 changes, as a full sync is required. There's not really any negatives to include it there.

@qianbin
Copy link
Member

qianbin commented Oct 24, 2024

It seems not very useful on reducing the size of logdb, And it's not worth it.

@qianbin the idea is to put it with mainDB v4 changes, as a full sync is required. There's not really any negatives to include it there.

It'll be good if so.

However, I think the compressed(zstd ? gzip?) VFS of sqlite might be the more advanced solution.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants