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

refactor: improve snapshot generation performance #251

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

seanmcgary
Copy link
Member

Makes all snapshot tables long-lived with proper unique constraints.

Previously, snapshot tables were dropped (if they existed) and re-generated for a given snapshot date. This results in a lot of data being generated and thrown out for no reason. It also meant that we couldnt put proper indexes on these tables since they would disappear when the table was dropped and re-created.

@seanmcgary seanmcgary requested a review from a team as a code owner February 18, 2025 20:25
@seanmcgary seanmcgary force-pushed the sm-performance branch 2 times, most recently from bd1028a to a79d1e6 Compare February 18, 2025 20:51
Makes all snapshot tables long-lived with proper unique constraints.

Previously, snapshot tables were dropped (if they existed) and
re-generated for a given snapshot date. This results in a lot of
data being generated and thrown out for no reason. It also meant
that we couldnt put proper indexes on these tables since they would
disappear when the table was dropped and re-created.
Copy link
Contributor

@jbrower95 jbrower95 left a comment

Choose a reason for hiding this comment

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

generally looks good. I need to spend some more time reading up on the sidecar for further reviews.

@jbrower95
Copy link
Contributor

Since you're changing queries, or insert logic -- will this be re-audited?

@seanmcgary
Copy link
Member Author

@jbrower95

Since you're changing queries, or insert logic -- will this be re-audited?

functionally it should behave exactly the same (in fact, this is actually much safer than how it is now since it has proper unique constraints in place...). Im going to regression test it with a full mainnet sync to ensure thats the case before merging it. If it can sync from scratch and reconstitute every root, that's good enough for me.

@anupsv thoughts on this?

@anupsv
Copy link
Contributor

anupsv commented Feb 20, 2025

net sync to ensure thats the case before merging it. If it can sync from scratch and reconstitute every root, that's good enough for me.

I was thinking if we could include this small change in the rewards 2.1 audit thats going on to be on the safer side. But yes, we definitely need (if we don't have) tests to cover the invariants that should hold for this table. Since a regression test is being done its good. But also @seanmcgary do we have an e2e test where it tries to ingest the latest database and see if all the roots match up ?

@seanmcgary
Copy link
Member Author

Yeah I can see if the OpenBlocks guys can take a pass at this particular change as a sanity check.

do we have an e2e test where it tries to ingest the latest database and see if all the roots match up ?

Not an automated one yet (it's on my list to do...). For large-ish changes like this I just manually start up a new mainnet sidecar and sync from EL genesis. We do have a test suite for rewards generation that you can run locally, but it only does the first like 5 roots from mainnet, so its decent as a sanity check, but not 100% comprehensive like re-syncing from scratch.

@anupsv
Copy link
Contributor

anupsv commented Feb 20, 2025

Yeah I can see if the OpenBlocks guys can take a pass at this particular change as a sanity check.

do we have an e2e test where it tries to ingest the latest database and see if all the roots match up ?

Not an automated one yet (it's on my list to do...). For large-ish changes like this I just manually start up a new mainnet sidecar and sync from EL genesis. We do have a test suite for rewards generation that you can run locally, but it only does the first like 5 roots from mainnet, so its decent as a sanity check, but not 100% comprehensive like re-syncing from scratch.

I see. Can we add the automated test in like the next PR or so? With more changes coming in, it'll be really helpful in getting confidence that the changes didn't brick things.

@seanmcgary
Copy link
Member Author

Id like to get it in before the slashing release...Im like halfway through setting up self-hosted github runners to handle it (more horsepower & flexibility with creating the correct test environment).

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