lighthouse/consensus/types/Cargo.toml

71 lines
2.5 KiB
TOML
Raw Normal View History

[package]
name = "types"
Deposit Cache Finalization & Fast WS Sync (#2915) ## Summary The deposit cache now has the ability to finalize deposits. This will cause it to drop unneeded deposit logs and hashes in the deposit Merkle tree that are no longer required to construct deposit proofs. The cache is finalized whenever the latest finalized checkpoint has a new `Eth1Data` with all deposits imported. This has three benefits: 1. Improves the speed of constructing Merkle proofs for deposits as we can just replay deposits since the last finalized checkpoint instead of all historical deposits when re-constructing the Merkle tree. 2. Significantly faster weak subjectivity sync as the deposit cache can be transferred to the newly syncing node in compressed form. The Merkle tree that stores `N` finalized deposits requires a maximum of `log2(N)` hashes. The newly syncing node then only needs to download deposits since the last finalized checkpoint to have a full tree. 3. Future proofing in preparation for [EIP-4444](https://eips.ethereum.org/EIPS/eip-4444) as execution nodes will no longer be required to store logs permanently so we won't always have all historical logs available to us. ## More Details Image to illustrate how the deposit contract merkle tree evolves and finalizes along with the resulting `DepositTreeSnapshot` ![image](https://user-images.githubusercontent.com/37123614/151465302-5fc56284-8a69-4998-b20e-45db3934ac70.png) ## Other Considerations I've changed the structure of the `SszDepositCache` so once you load & save your database from this version of lighthouse, you will no longer be able to load it from older versions. Co-authored-by: ethDreamer <37123614+ethDreamer@users.noreply.github.com>
2022-10-30 04:04:24 +00:00
version = "0.2.1"
2019-02-14 05:46:33 +00:00
authors = ["Paul Hauner <paul@paulhauner.com>", "Age Manning <Age@AgeManning.com>"]
edition = { workspace = true }
[[bench]]
name = "benches"
harness = false
[dependencies]
merkle_proof = { workspace = true }
bls = { workspace = true, features = ["arbitrary"] }
kzg = { workspace = true }
compare_fields = { workspace = true }
compare_fields_derive = { workspace = true }
eth2_interop_keypairs = { path = "../../common/eth2_interop_keypairs" }
ethereum-types = { workspace = true, features = ["arbitrary"] }
ethereum_hashing = { workspace = true }
hex = { workspace = true }
int_to_bytes = { workspace = true }
log = { workspace = true }
rayon = { workspace = true }
rand = { workspace = true }
safe_arith = { workspace = true }
serde = { workspace = true, features = ["rc"] }
slog = { workspace = true }
ethereum_ssz = { workspace = true, features = ["arbitrary"] }
ethereum_ssz_derive = { workspace = true }
ssz_types = { workspace = true, features = ["arbitrary"] }
swap_or_not_shuffle = { workspace = true, features = ["arbitrary"] }
test_random_derive = { path = "../../common/test_random_derive" }
tree_hash = { workspace = true, features = ["arbitrary"] }
tree_hash_derive = { workspace = true }
rand_xorshift = "0.3.0"
cached_tree_hash = { workspace = true }
serde_yaml = { workspace = true }
tempfile = { workspace = true }
derivative = { workspace = true }
rusqlite = { workspace = true }
# The arbitrary dependency is enabled by default since Capella to avoid complexity introduced by
# `AbstractExecPayload`
arbitrary = { workspace = true, features = ["derive"] }
ethereum_serde_utils = { workspace = true }
regex = { workspace = true }
lazy_static = { workspace = true }
parking_lot = { workspace = true }
itertools = { workspace = true }
superstruct = { workspace = true }
Verify execution block hashes during finalized sync (#3794) ## Issue Addressed Recent discussions with other client devs about optimistic sync have revealed a conceptual issue with the optimisation implemented in #3738. In designing that feature I failed to consider that the execution node checks the `blockHash` of the execution payload before responding with `SYNCING`, and that omitting this check entirely results in a degradation of the full node's validation. A node omitting the `blockHash` checks could be tricked by a supermajority of validators into following an invalid chain, something which is ordinarily impossible. ## Proposed Changes I've added verification of the `payload.block_hash` in Lighthouse. In case of failure we log a warning and fall back to verifying the payload with the execution client. I've used our existing dependency on `ethers_core` for RLP support, and a new dependency on Parity's `triehash` crate for the Merkle patricia trie. Although the `triehash` crate is currently unmaintained it seems like our best option at the moment (it is also used by Reth, and requires vastly less boilerplate than Parity's generic `trie-root` library). Block hash verification is pretty quick, about 500us per block on my machine (mainnet). The optimistic finalized sync feature can be disabled using `--disable-optimistic-finalized-sync` which forces full verification with the EL. ## Additional Info This PR also introduces a new dependency on our [`metastruct`](https://github.com/sigp/metastruct) library, which was perfectly suited to the RLP serialization method. There will likely be changes as `metastruct` grows, but I think this is a good way to start dogfooding it. I took inspiration from some Parity and Reth code while writing this, and have preserved the relevant license headers on the files containing code that was copied and modified.
2023-01-09 03:11:59 +00:00
metastruct = "0.1.0"
serde_json = { workspace = true }
smallvec = { workspace = true }
maplit = { workspace = true }
strum = { workspace = true }
[dev-dependencies]
criterion = { workspace = true }
beacon_chain = { workspace = true }
state_processing = { workspace = true }
tokio = { workspace = true }
paste = { workspace = true }
[features]
default = ["sqlite", "legacy-arith"]
# Allow saturating arithmetic on slots and epochs. Enabled by default, but deprecated.
legacy-arith = []
sqlite = []
# The `arbitrary-fuzz` feature is a no-op provided for backwards compatibility.
# For simplicity `Arbitrary` is now derived regardless of the feature's presence.
arbitrary-fuzz = []