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

Bids 2379/new bigtable cl schema #2490

Merged
merged 109 commits into from
Sep 12, 2023
Merged

Conversation

peterbitfly
Copy link
Collaborator

@peterbitfly peterbitfly commented Aug 21, 2023

This PR implements a new bigtable cl schema that eliminates performance issues with the current schema.

Currenlty we store that data in one large table with the epoch and block number as row key and all validator specific data in columns.
This causes the column size to grow together with the validator set size. As for certain networks the validator set size is quite large we will ultimately run into performance issues.

New schema:

-) Create a new bigtable table that contains the validator history (proposals, balances, attestations, sync_committees, reward_details)
-) Row key is in the format <chain_id><reversed_validator_index><history_type><reversed_epoch/slot> where we use epoch if its just one entry per epoch and slot if there are multiple entries per epoch. reversed_validator_index is the reverse notation of the validator index so 1234 becomes 4321. reversed_epoch remains as max_uint64 - epoch

The new schema will be slower on writes than the current one but significant faster on reads if they only concern a few validators (validator view & dashboard view). It will be slower for reads over the whole validator set which are needed for the statistics process. If the slowness in regards to writes & statistics is tolerable needs to be tried using real data. Nevertheless bigtable scaling should be able to accommodate with the new schema as the reversed validator index will allow a very efficient table partitioning.

Prior to merging & deploying the PR a full data migration from the old to the new schema is required.

🤖 Generated by Copilot at f0364c5

This pull request optimizes various database queries and functions that fetch validator data from Bigtable, by passing a list of validator indices instead of querying all validators. It also adds a new function to reverse strings and fixes a bug in the burn page data query. The affected files are db/statistics.go, handlers/validator.go, services/charts_updater.go, db/db.go, services/notifications.go, services/services.go, and utils/utils.go.

@peterbitfly peterbitfly requested review from D13ce and manuelsc August 21, 2023 09:23
@peterbitfly peterbitfly marked this pull request as ready for review September 11, 2023 11:01
db/db.go Show resolved Hide resolved
@peterbitfly peterbitfly requested a review from D13ce September 11, 2023 11:39
db/bigtable.go Outdated Show resolved Hide resolved
db/bigtable.go Outdated Show resolved Hide resolved
db/bigtable.go Outdated Show resolved Hide resolved
db/db.go Show resolved Hide resolved
Copy link
Contributor

@D13ce D13ce left a comment

Choose a reason for hiding this comment

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

utACK 🎉

@peterbitfly peterbitfly merged commit 04df8ea into master Sep 12, 2023
3 checks passed
@recy21 recy21 deleted the BIDS-2379/new_bigtable_cl_schema branch October 1, 2023 07:54
@recy21 recy21 restored the BIDS-2379/new_bigtable_cl_schema branch October 1, 2023 07:54
@recy21 recy21 deleted the BIDS-2379/new_bigtable_cl_schema branch October 1, 2023 07:54
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.

3 participants