nimbus-eth2/docs
Jacek Sieka 4207b127f9
era: load blocks and states (#3394)
* era: load blocks and states

Era files contain finalized history and can be thought of as an
alternative source for block and state data that allows clients to avoid
syncing this information from the P2P network - the P2P network is then
used to "top up" the client with the most recent data. They can be
freely shared in the community via whatever means (http, torrent, etc)
and serve as a permanent cold store of consensus data (and, after the
merge, execution data) for history buffs and bean counters alike.

This PR gently introduces support for loading blocks and states in two
cases: block requests from rest/p2p and frontfilling when doing
checkpoint sync.

The era files are used as a secondary source if the information is not
found in the database - compared to the database, there are a few key
differences:

* the database stores the block indexed by block root while the era file
indexes by slot - the former is used only in rest, while the latter is
used both by p2p and rest.
* when loading blocks from era files, the root is no longer trivially
available - if it is needed, it must either be computed (slow) or cached
(messy) - the good news is that for p2p requests, it is not needed
* in era files, "framed" snappy encoding is used while in the database
we store unframed snappy - for p2p2 requests, the latter requires
recompression while the former could avoid it
* front-filling is the process of using era files to replace backfilling
- in theory this front-filling could happen from any block and
front-fills with gaps could also be entertained, but our backfilling
algorithm cannot take advantage of this because there's no (simple) way
to tell it to "skip" a range.
* front-filling, as implemented, is a bit slow (10s to load mainnet): we
load the full BeaconState for every era to grab the roots of the blocks
- it would be better to partially load the state - as such, it would
also be good to be able to partially decompress snappy blobs
* lookups from REST via root are served by first looking up a block
summary in the database, then using the slot to load the block data from
the era file - however, there needs to be an option to create the
summary table from era files to fully support historical queries

To test this, `ncli_db` has an era file exporter: the files it creates
should be placed in an `era` folder next to `db` in the data directory.
What's interesting in particular about this setup is that `db` remains
as the source of truth for security purposes - it stores the latest
synced head root which in turn determines where a node "starts" its
consensus participation - the era directory however can be freely shared
between nodes / people without any (significant) security implications,
assuming the era files are consistent / not broken.

There's lots of future improvements to be had:

* we can drop the in-memory `BlockRef` index almost entirely - at this
point, resident memory usage of Nimbus should drop to a cool 500-600 mb
* we could serve era files via REST trivially: this would drop backfill
times to whatever time it takes to download the files - unlike the
current implementation that downloads block by block, downloading an era
at a time almost entirely cuts out request overhead
* we can "reasonably" recreate detailed state history from almost any
point in time, turning an O(slot) process into O(1) effectively - we'll
still need caches and indices to do this with sufficient efficiency for
the rest api, but at least it cuts the whole process down to minutes
instead of hours, for arbitrary points in time

* CI: ignore failures with Nim-1.6 (temporary)

* test fixes

Co-authored-by: Ștefan Talpalaru <stefantalpalaru@yahoo.com>
2022-03-23 09:58:17 +01:00
..
nbc_audit_2020 Consensus object pools [reorg 4/5] (#2374) 2021-03-04 10:13:44 +01:00
the_auditors_handbook update spec references from eth2.0-specs to consensus-specs and to v1.1.0-beta.2 (#2822) 2021-08-26 10:21:52 +02:00
the_nimbus_book enable multithreading by default (10-20% faster sync) (#3493) 2022-03-19 08:59:10 +01:00
README.md bin dist related docs (#2684) 2021-07-05 12:31:25 +02:00
attestation_flow.dot [RFC - Doc] State of Nimbus block & attestation flows (#2351) 2021-03-01 11:22:16 +01:00
attestation_flow.md update unchanged specs/phase0/p2p-interface.md URL references from v1.1.9 to v1.1.10 (#3510) 2022-03-16 10:40:35 +00:00
attestation_flow.png [RFC - Doc] State of Nimbus block & attestation flows (#2351) 2021-03-01 11:22:16 +01:00
block_flow.dot Backward sync support for SyncManager. (#3131) 2021-12-08 22:15:29 +01:00
block_flow.md update unchanged specs/phase0/p2p-interface.md URL references from v1.1.9 to v1.1.10 (#3510) 2022-03-16 10:40:35 +00:00
block_flow.png [RFC - Doc] State of Nimbus block & attestation flows (#2351) 2021-03-01 11:22:16 +01:00
cpu_features.md Cpu architecture optimization documentation (#2483) 2021-04-08 15:48:43 +02:00
e2store.md era: load blocks and states (#3394) 2022-03-23 09:58:17 +01:00
kiln_geth_local_testnet.md kiln v2 documentation and testing (#3446) 2022-03-05 16:40:58 +02:00
kiln_geth_logs.png update docs for geth/kiln 2022-02-11 20:06:06 +00:00
kintsugi_nethermind_logs.png document how to run merge local testnet with Nethermind (#3110) 2021-11-17 20:45:39 +01:00
logging.md
mev_boost.md add mev-boost RPC test, with docs (#3430) 2022-02-24 14:38:31 +01:00
neth-m2-nimbus.md add mev-boost RPC test, with docs (#3430) 2022-02-24 14:38:31 +01:00
nimbus_localhost_run.png update docs for geth/kiln 2022-02-11 20:06:06 +00:00
running_nimbus_on_kiln.md running Nimbus on Kiln 2022-03-13 19:39:11 +00:00

README.md

The books in this folder were produced using mdBook - see installation guide.

Some books also use mdbook-toc for tables of contents.

# Install or update tooling (make sure you add "~/.cargo/bin" to PATH):
cargo install mdbook mdbook-toc mdbook-open-on-gh

# Work on the book locally - open "http://localhost:4000" for live version
cd docs/the_nimbus_book
mdbook serve -p 4000

# Publish book using makefile (in the top-level dir)
make publish-book