Skip to content

[ADR - 42] State-sync#3769

Merged
tac0turtle merged 14 commits intomasterfrom
bucky/state-sync
Aug 6, 2019
Merged

[ADR - 42] State-sync#3769
tac0turtle merged 14 commits intomasterfrom
bucky/state-sync

Conversation

@tac0turtle
Copy link
Contributor

Initial State-sync discussions to be held in this PR. This is not the final stage of the PR.

  • Referenced an issue explaining the need for the change
  • Updated all relevant documentation in docs
  • Updated all code comments where relevant
  • Wrote tests
  • Updated CHANGELOG_PENDING.md

@AdityaSripal
Copy link
Contributor

Would be useful to have a Security Models section that compares the Warp-Sync security model with a standard light-client security model. Discussion on how choosing one security model or the other also has trade-offs in performance/simplicity/etc. would be helpful

@codecov-io
Copy link

codecov-io commented Jul 4, 2019

Codecov Report

Merging #3769 into master will decrease coverage by 0.1%.
The diff coverage is n/a.

@@            Coverage Diff             @@
##           master    #3769      +/-   ##
==========================================
- Coverage   64.98%   64.87%   -0.11%     
==========================================
  Files         217      217              
  Lines       18211    18189      -22     
==========================================
- Hits        11835    11801      -34     
- Misses       5458     5470      +12     
  Partials      918      918
Impacted Files Coverage Δ
blockchain/v0/reactor.go 73.11% <0%> (-6.14%) ⬇️
consensus/reactor.go 71.04% <0%> (-1.06%) ⬇️
blockchain/v0/pool.go 80.65% <0%> (-0.99%) ⬇️
consensus/state.go 79.95% <0%> (-0.12%) ⬇️
p2p/pex/pex_reactor.go 83.18% <0%> (+1.15%) ⬆️
privval/signer_listener_endpoint.go 89.13% <0%> (+2.17%) ⬆️
privval/socket_listeners.go 88.88% <0%> (+2.68%) ⬆️
privval/signer_endpoint.go 84% <0%> (+5.33%) ⬆️

Copy link
Contributor

@ebuchman ebuchman left a comment

Choose a reason for hiding this comment

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

Wow this is so much clearer, thank you @brapse !

[tendermint state sync proposal 2](https://docs.google.com/document/d/1npGTAa1qxe8EQZ1wG0a0Sip9t5oX2vYZNUDwr_LVRR4/edit) - ackratos proposal
[proposal 2 implementation](https://github.com/tendermint/tendermint/pull/3243) - ackratos implementation
[WIP General/Lazy State-Sync pseudo-spec](https://github.com/tendermint/tendermint/issues/3639) - Jae Proposal
[Warp Sync Implementation](https://github.com/tendermint/tendermint/pull/3594) - ackratos
Copy link
Contributor

Choose a reason for hiding this comment

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

we have some more stuff:

  1. document for this enhancement: [R4R] BEP-18: for state sync enhancement bnb-chain/BEPs#18, included more chunking strategy we adopted
  2. to try out state sync in binance chain prod and testnet: https://github.com/binance-chain/docs-site/blob/master/docs/fullnode.md#state-sync

[#3639](https://github.com/tendermint/tendermint/issues/3639) where chunking
happens lazily and in a dynamic way: nodes request key ranges from their peers,
and peers respond with some subset of the
requested range and with notes on how to request the rest in parallel from other
Copy link
Contributor

Choose a reason for hiding this comment

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

This part of this design is super tricky to implement correctly in my view as we ask set of peers and each of them come back with notes how to download rest.

@brapse
Copy link
Contributor

brapse commented Jul 5, 2019

Would be useful to have a Security Models section that compares the Warp-Sync security model with a standard light-client security model. Discussion on how choosing one security model or the other also has trade-offs in performance/simplicity/etc. would be helpful

https://github.com/tendermint/tendermint/blob/834ecd53da78433dd4e0a6a30944d7b964ae0444/docs/architecture/adr-042-state-sync.md#compairing-security-models

Is this what you had in mind @AdityaSripal ?

WarpSync with per chunk light client validation might get the optimal
performance and safety.

## Decision: Eager StateSync With Per Chunk Light Client Validation
Copy link
Contributor

Choose a reason for hiding this comment

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

Would this require bringing manifest hash into consensus?

Copy link
Contributor

Choose a reason for hiding this comment

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

Will we only require validator nodes to compute and validate this hash?

Copy link
Contributor

Choose a reason for hiding this comment

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

No it would not, the application state would be validated against the merkle root produced from light client sync.

Co-Authored-By: Aditya <adityasripal@gmail.com>
@tac0turtle tac0turtle mentioned this pull request Jul 6, 2019
4 tasks
@tac0turtle tac0turtle changed the title State-sync discussions [ADR - 42] State-sync Jul 6, 2019
* Speed: Expected throughput of producing and consuming snapshots
* Safety: Cost of pushing invalid snapshots to a node
* Liveness: Cost of preventing a node from receiving/constructing a snapshot
* Effort: How much effort does an implementation require
Copy link
Contributor

Choose a reason for hiding this comment

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

Also versatility - whether any additional requirements are imposed upon the ABCI application about e.g. storage layout.

Copy link
Contributor

Choose a reason for hiding this comment

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

Would you say that could somehow be captured by engineering effort or should it be a distinct dimension?

* Complete snapshot
* Ordered IAVL key ranges
* Compressed individually chunks which can be validated
* How is data validated
Copy link
Contributor

Choose a reason for hiding this comment

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

Are these intended to be mutually exclusive? There's a continuum w.r.t. validation of subcomponents of state, e.g. after receiving a few chunks, validate one at random & ban the peer if invalid, etc.

Copy link
Contributor

Choose a reason for hiding this comment

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

Not at all. exactly as you state, the chunking scheme will have some impact on how soon data can be validated and peers banned.

["Warp Sync"](https://wiki.parity.io/Warp-Sync-Snapshot-Format.html) to rapidly
download both blocks and state snapshots from peers. Data is carved into ~4MB
chunks and snappy compressed. Hashes of snappy compressed chunks are stored in a
manifest file which co-ordinates the state-sync. Obtaining a correct manifest
Copy link
Contributor

Choose a reason for hiding this comment

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

That's lame. We should be able to verify random subsets of the state (random keys) pretty cheaply by keeping light client headers and requesting Merkle proofs occasionally, then ban any peer which sends invalid state, and recheck the whole state at the end.

Copy link
Contributor

Choose a reason for hiding this comment

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

Does Parity use this manifest file instead of a SPV Ethereum client?

Copy link
Contributor

Choose a reason for hiding this comment

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

Parity sync module takes a hybrid approach which will block header verification at the end but will sync intermediate state from snapshots first if WarpSync is enabled.

The general strategy is outlined here:
https://github.com/paritytech/parity-ethereum/blob/master/ethcore/sync/src/chain/mod.rs#L21-L34

Snapshots are vetted by rules and then taken from majority of peers here:
https://github.com/paritytech/parity-ethereum/blob/master/ethcore/sync/src/chain/mod.rs#L800-L828

@brapse brapse marked this pull request as ready for review July 24, 2019 16:11
@brapse brapse requested a review from xla as a code owner July 24, 2019 16:11
Copy link
Contributor

@brapse brapse left a comment

Choose a reason for hiding this comment

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

No new question in a little while, LGTM 👍

@jackzampolin jackzampolin dismissed AdityaSripal’s stale review August 5, 2019 19:14

comments addressed.

Co-Authored-By: Anton Kaliaev <anton.kalyaev@gmail.com>
@tac0turtle tac0turtle merged commit d70135e into master Aug 6, 2019
@tac0turtle tac0turtle deleted the bucky/state-sync branch August 6, 2019 08:25
cboh4 pushed a commit to scrtlabs/tendermint that referenced this pull request Apr 7, 2025
<!--

Please add a reference to the issue that this PR addresses and indicate
which
files are most critical to review. If it fully addresses a particular
issue,
please include "Closes #XXX" (where "XXX" is the issue number).

If this PR is non-trivial/large/complex, please ensure that you have
either
created an issue that the team's had a chance to respond to, or had some
discussion with the team prior to submitting substantial pull requests.
The team
can be reached via GitHub Discussions or the Cosmos Network Discord
server in
the #cometbft channel. GitHub Discussions is preferred over Discord as
it
allows us to keep track of conversations topically.
https://github.com/cometbft/cometbft/discussions

If the work in this PR is not aligned with the team's current
priorities, please
be advised that it may take some time before it is merged - especially
if it has
not yet been discussed with the team.

See the project board for the team's current priorities:
https://github.com/orgs/cometbft/projects/1

-->

---

#### PR checklist

- [ ] Tests written/updated
- [ ] Changelog entry added in `.changelog` (we use
[unclog](https://github.com/informalsystems/unclog) to manage our
changelog)
- [ ] Updated relevant documentation (`docs/` or `spec/`) and code
comments
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.