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

clean up / document init #3387

Merged
merged 2 commits into from
Feb 16, 2022
Merged

clean up / document init #3387

merged 2 commits into from
Feb 16, 2022

Conversation

arnetheduck
Copy link
Member

  • drop immutable_validators data (pre-altair)
  • document versions where data is first added
  • avoid needlessly loading genesis block data on startup
  • add a few more internal database consistency checks
  • remove duplicate state root lookup on state load

* drop `immutable_validators` data (pre-altair)
* document versions where data is first added
* avoid needlessly loading genesis block data on startup
* add a few more internal database consistency checks
* remove duplicate state root lookup on state load
# should not be removed until after altair, to permit downgrades.
# uncompressed keys instead. We still support upgrading a database from the
# old format, but don't need to support downgrading, and therefore safely can
# remove the keys
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't remember having a bench for this.
I only bench compressed key deserialization: https://github.com/status-im/nim-blscurve/blob/0237e4e/benchmarks/bls_signature.nim#L37-L43

Though it makes sense, decompression involves modular square root, which is over 400x more expensive than other operations:
image

https://github.com/supranational/blst/blob/eb6151961c133a930420e844e1a84708fbb4f6a4/src/e1.c#L236-L259

image

The tradeoff is 2x the size.
Assuming 300k validators that's 48 bytes (381-bit.nextPowerOfTwo() / 8) x 2 x 300k = 28.8MB (instead of 14.4)

Copy link
Member Author

Choose a reason for hiding this comment

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

indeed, this was benchmarked at the time it was introduced and the difference was significant - you can still see it today: the time to write a checkpoint state from SSZ to the database on first startup is dominated by the time it takes to convert the keys from compressed to uncompressed

@@ -446,6 +449,10 @@ proc new*(T: type BeaconChainDB,
))
immutableValidatorsDb1.close()

# Safe because nobody will be downgrading to pre-altair versions
# TODO: drop table maybe? that would require not creating the table just above
discard db.exec("DELETE FROM immutable_validators;")
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we need to drop the table. And I should do the same with the old slashing DB.

Copy link
Member Author

@arnetheduck arnetheduck Feb 14, 2022

Choose a reason for hiding this comment

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

as the comment says, the check above recreates the table - this would need more surgery on the codebase

@github-actions
Copy link

github-actions bot commented Feb 14, 2022

Unit Test Results

     12 files  ±0     821 suites  ±0   33m 36s ⏱️ +42s
1 671 tests ±0  1 625 ✔️ ±0    46 💤 ±0  0 ±0 
9 755 runs  ±0  9 655 ✔️ ±0  100 💤 ±0  0 ±0 

Results for commit 3d6d0b9. ± Comparison against base commit 873a8ec.

♻️ This comment has been updated with latest results.

Base automatically changed from unstable to stable February 15, 2022 20:57
@zah zah changed the base branch from stable to unstable February 15, 2022 22:07
@arnetheduck arnetheduck merged commit 7db5647 into unstable Feb 16, 2022
@arnetheduck arnetheduck deleted the chaindag-init branch February 16, 2022 15:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants