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

catchup: state-proof-based catchup #5720

Draft
wants to merge 6 commits into
base: nickolai/state-proof-catchup-base
Choose a base branch
from

Conversation

zeldovich
Copy link
Contributor

Add support for catchup to use state proofs to validate new blocks.

The main changes are:

  • The catchup service now has a state proof fetcher, whose job is to retrieve state proofs for rounds beyond the current ledger state. These state proofs are stored in an sqlite DB, since there might be many state proofs that we need to fetch.

  • The catchup service exposes a way to set trusted "renaissance" parameters for authenticating the initial state proofs, for cases when we can't use state proofs from the genesis block (like the situation we have on mainnet now).

  • The BlockService HTTP interface adds support for retrieving a state proof, and for getting a light block header proof instead of a cert when retrieving a block.

  • The catchup service uses state proofs, if possible, to authenticate new blocks, in lieu of agreement certificates. The catchup service is backwards-compatible: if it requests a state proof from the BlockService, but receives an agreement certificate instead (e.g., because the BlockService has not been upgraded with the above changes), the catchup service will validate the certificate instead.

  • The config file has additional fields to optionally specify the renaissance catchup parameters, to allow catchup to start validating state proofs from some (trusted through out-of-band channels) block.

It may be a good idea, for performance, to pre-compute the state proofs and distribute them in a single file, rather than asking many relays to find the state proofs on-demand. This is not done yet, because it largely depends on how we would want to distribute these bundled state proofs. It should be reasonably straightforward to feed a bundle of state proofs into the stateProofFetcher.

This is a somewhat large PR; I tried to factor out some independent pieces from it (the still-open ones are PRs #5663, #5703, #5718), but unfortunately I couldn't find other substantial pieces to meaningfully split out on their own. This PR is against a temporary branch (nickolai/state-proof-catchup-base) that already has the above PRs applied, so that they don't show up in the code diff for this PR.

Add support for catchup to use state proofs to validate new blocks.

The main changes are:

- The catchup service now has a state proof fetcher, whose job is to
  retrieve state proofs for rounds beyond the current ledger state.
  These state proofs are stored in an sqlite DB, since there might be
  many state proofs that we need to fetch.

- The catchup service exposes a way to set trusted "renaissance"
  parameters for authenticating the initial state proofs, for cases
  when we can't use state proofs from the genesis block (like the
  situation we have on mainnet now).

- The BlockService HTTP interface adds support for retrieving a
  state proof, and for getting a light block header proof instead
  of a cert when retrieving a block.

- The catchup service uses state proofs, if possible, to authenticate
  new blocks, in lieu of agreement certificates.  The catchup service
  is backwards-compatible: if it requests a state proof from the
  BlockService, but receives an agreement certificate instead (e.g.,
  because the BlockService has not been upgraded with the above
  changes), the catchup service will validate the certificate instead.

- The config file has additional fields to optionally specify the
  renaissance catchup parameters, to allow catchup to start validating
  state proofs from some (trusted through out-of-band channels) block.

It may be a good idea, for performance, to pre-compute the state proofs
and distribute them in a single file, rather than asking many relays to
find the state proofs on-demand.  This is not done yet, because it largely
depends on how we would want to distribute these bundled state proofs.
It should be reasonably straightforward to feed a bundle of state proofs
into the stateProofFetcher.
Copy link

codecov bot commented Nov 24, 2024

Codecov Report

Attention: Patch coverage is 44.40433% with 308 lines in your changes missing coverage. Please review.

Project coverage is 53.33%. Comparing base (f73f00f) to head (87cfe4f).

Files with missing lines Patch % Lines
rpcs/blockService.go 0.66% 149 Missing ⚠️
catchup/stateproof.go 54.05% 107 Missing and 12 partials ⚠️
catchup/universalFetcher.go 84.00% 8 Missing and 4 partials ⚠️
catchup/service.go 71.79% 9 Missing and 2 partials ⚠️
daemon/algod/api/server/v2/handlers.go 0.00% 7 Missing ⚠️
config/localTemplate.go 57.14% 2 Missing and 1 partial ⚠️
node/follower_node.go 57.14% 2 Missing and 1 partial ⚠️
node/node.go 57.14% 2 Missing and 1 partial ⚠️
catchup/catchpointService.go 0.00% 1 Missing ⚠️
Additional details and impacted files
@@                          Coverage Diff                          @@
##           nickolai/state-proof-catchup-base    #5720      +/-   ##
=====================================================================
+ Coverage                              46.15%   53.33%   +7.17%     
=====================================================================
  Files                                    473      474       +1     
  Lines                                  66330    66815     +485     
=====================================================================
+ Hits                                   30616    35635    +5019     
+ Misses                                 33095    28639    -4456     
+ Partials                                2619     2541      -78     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.


🚨 Try these New Features:

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.

1 participant