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

[Merged by Bors] - recover only N latest layers required for correct ballots decoding #5109

Closed
wants to merge 15 commits into from

Conversation

dshulyak
Copy link
Contributor

@dshulyak dshulyak commented Sep 28, 2023

closes: #3006

tortoise recovers state to decode votes (that are encoded as base ballot + delta) and verify that signed opinion is available locally. when we are accepting votes from network we need to verify those two things. you can see how this recursiveness goes back to genesis. current code reloads ballots from genesis as it is the most fail safe approach. but this have a downside that overtime we will have to load unbounded amount of data, which is not practical.

in this change tortoise loads ballots that are useful only for next ballots that we expect to receive from the network. the algorithm looks up latest applied layer, subtracts number of layers which are set as tortoise window (10 000), and finds the first layer of that epoch.

@dshulyak dshulyak changed the title recovery only N latest layers required for correct ballots decoding recover only N latest layers required for correct ballots decoding Sep 28, 2023
@codecov
Copy link

codecov bot commented Sep 28, 2023

Codecov Report

Merging #5109 (db032d6) into develop (cb9c70f) will decrease coverage by 0.2%.
Report is 1 commits behind head on develop.
The diff coverage is 55.5%.

@@            Coverage Diff            @@
##           develop   #5109     +/-   ##
=========================================
- Coverage     77.2%   77.1%   -0.2%     
=========================================
  Files          257     257             
  Lines        30278   30314     +36     
=========================================
- Hits         23378   23373      -5     
- Misses        5378    5410     +32     
- Partials      1522    1531      +9     
Files Coverage Δ
node/node.go 63.7% <100.0%> (ø)
tortoise/sim/layer.go 88.9% <100.0%> (ø)
tortoise/sim/utils.go 70.5% <ø> (+2.0%) ⬆️
tortoise/state.go 97.4% <100.0%> (-0.1%) ⬇️
tortoise/model/core.go 81.2% <90.9%> (+0.6%) ⬆️
tortoise/sim/state.go 51.3% <40.0%> (-7.0%) ⬇️
tortoise/tortoise.go 88.7% <72.4%> (-0.9%) ⬇️
tortoise/algorithm.go 73.5% <26.6%> (-4.2%) ⬇️
tortoise/recover.go 47.7% <53.1%> (-3.2%) ⬇️

... and 2 files with indirect coverage changes

@dshulyak
Copy link
Contributor Author

dshulyak commented Oct 4, 2023

bors try

bors bot added a commit that referenced this pull request Oct 4, 2023
@bors
Copy link

bors bot commented Oct 4, 2023

try

Build failed:

@dshulyak dshulyak marked this pull request as ready for review October 4, 2023 10:20
tortoise/recover.go Outdated Show resolved Hide resolved
tortoise/recover.go Outdated Show resolved Hide resolved
tortoise/state.go Show resolved Hide resolved
@dshulyak
Copy link
Contributor Author

dshulyak commented Oct 6, 2023

bors merge

bors bot pushed a commit that referenced this pull request Oct 6, 2023
…5109)

closes: #3006

tortoise recovers state to decode votes (that are encoded as base ballot + delta) and verify that signed opinion is available locally. when we are accepting votes from network we need to verify those two things. you can see how this recursiveness goes back to genesis. current code reloads ballots from genesis as it is the most fail safe approach. but this have a downside that overtime we will have to load unbounded amount of data, which is not practical. 

in this change tortoise loads ballots that are useful only for next ballots that we expect to receive from the network. the algorithm looks up latest applied layer, subtracts number of layers which are set as tortoise window (10 000), and finds the first layer of that epoch.
@bors
Copy link

bors bot commented Oct 6, 2023

Pull request successfully merged into develop.

Build succeeded!

The publicly hosted instance of bors-ng is deprecated and will go away soon.

If you want to self-host your own instance, instructions are here.
For more help, visit the forum.

If you want to switch to GitHub's built-in merge queue, visit their help page.

@bors bors bot changed the title recover only N latest layers required for correct ballots decoding [Merged by Bors] - recover only N latest layers required for correct ballots decoding Oct 6, 2023
@bors bors bot closed this Oct 6, 2023
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.

tortoise: tortoise state loading will be growing in time
2 participants