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

Use Epoch boundary cache to retrieve balances #12083

Merged
merged 6 commits into from
Mar 6, 2023

Conversation

potuz
Copy link
Contributor

@potuz potuz commented Mar 6, 2023

When retrieving balances by Root for forkchoice, use the epoch boundary cache to retrieve the justified checkpoint balances

@potuz potuz added Ready For Review A pull request ready for code review OK to merge labels Mar 6, 2023
@potuz potuz requested a review from a team as a code owner March 6, 2023 14:03
@potuz potuz force-pushed the use_epoch_boundary_cache_to_get_balances branch from db1d346 to 01aa9d4 Compare March 6, 2023 14:37
terencechain
terencechain previously approved these changes Mar 6, 2023
Copy link
Member

@terencechain terencechain left a comment

Choose a reason for hiding this comment

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

Adding some rationale to this. Given fork choice store needs the balances for the justified checkpoint. Prysm uses StateByRoot and we want the state to be in the epoch boundary cache as often as we can for a better hit ratio.
This PR accomplishes the following

  • uses epoch boundary cache inStateByRoot
  • saves the states on batches before sending them to fork choices store

if err := s.cfg.StateGen.SaveState(ctx, r, st); err != nil {
return err
}
}
// Also saves the last post state which to be used as pre state for the next batch.
lastB := blks[len(blks)-1]
if err := s.cfg.StateGen.SaveState(ctx, lastBR, preState); err != nil {
Copy link
Member

Choose a reason for hiding this comment

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

You can shift this up too

nisdas
nisdas previously approved these changes Mar 6, 2023
@prylabs-bulldozer prylabs-bulldozer bot merged commit bb95d95 into develop Mar 6, 2023
@delete-merged-branch delete-merged-branch bot deleted the use_epoch_boundary_cache_to_get_balances branch March 6, 2023 21:42
terencechain pushed a commit that referenced this pull request Mar 6, 2023
* Use Epoch boundary cache to retrieve balances

* save boundary states before inserting to forkchoice

* move up last block save

* remove boundary checks on balances

* fix ordering

---------

Co-authored-by: prylabs-bulldozer[bot] <58059840+prylabs-bulldozer[bot]@users.noreply.github.com>
terencechain pushed a commit that referenced this pull request Mar 6, 2023
* Use Epoch boundary cache to retrieve balances

* save boundary states before inserting to forkchoice

* move up last block save

* remove boundary checks on balances

* fix ordering

---------

Co-authored-by: prylabs-bulldozer[bot] <58059840+prylabs-bulldozer[bot]@users.noreply.github.com>
Taranpreet26311 pushed a commit that referenced this pull request Mar 7, 2023
* Use Epoch boundary cache to retrieve balances

* save boundary states before inserting to forkchoice

* move up last block save

* remove boundary checks on balances

* fix ordering

---------

Co-authored-by: prylabs-bulldozer[bot] <58059840+prylabs-bulldozer[bot]@users.noreply.github.com>
github-merge-queue bot pushed a commit that referenced this pull request Mar 22, 2024
…12675)

* Remove Feature Flag From Prater (#12082)

* Use Epoch boundary cache to retrieve balances (#12083)

* Use Epoch boundary cache to retrieve balances

* save boundary states before inserting to forkchoice

* move up last block save

* remove boundary checks on balances

* fix ordering

---------

Co-authored-by: prylabs-bulldozer[bot] <58059840+prylabs-bulldozer[bot]@users.noreply.github.com>

* create the log file along with its parent directory if not present

* only give ReadWritePermissions to the log file

* use io/file package to create the parent directories

* fix ci related issues

* add regression tests

* run gazelle

* fix tests

* remove print statements

* gazelle

* Remove failing test for MkdirAll, this failure is not expected

---------

Co-authored-by: Nishant Das <nishdas93@gmail.com>
Co-authored-by: Potuz <potuz@prysmaticlabs.com>
Co-authored-by: prylabs-bulldozer[bot] <58059840+prylabs-bulldozer[bot]@users.noreply.github.com>
Co-authored-by: Preston Van Loon <pvanloon@offchainlabs.com>
github-merge-queue bot pushed a commit that referenced this pull request Jul 31, 2024
* Remove Feature Flag From Prater (#12082)

* Use Epoch boundary cache to retrieve balances (#12083)

* Use Epoch boundary cache to retrieve balances

* save boundary states before inserting to forkchoice

* move up last block save

* remove boundary checks on balances

* fix ordering

---------

Co-authored-by: prylabs-bulldozer[bot] <58059840+prylabs-bulldozer[bot]@users.noreply.github.com>

* chore: fix unfound image

* fix link

---------

Co-authored-by: Nishant Das <nishdas93@gmail.com>
Co-authored-by: Potuz <potuz@prysmaticlabs.com>
Co-authored-by: prylabs-bulldozer[bot] <58059840+prylabs-bulldozer[bot]@users.noreply.github.com>
Co-authored-by: Preston Van Loon <pvanloon@offchainlabs.com>
Co-authored-by: Radosław Kapka <rkapka@wp.pl>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Ready For Review A pull request ready for code review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants