8fa032c8ae
## Issue Addressed Upcoming spec change https://github.com/ethereum/consensus-specs/pull/2878 ## Proposed Changes 1. Run fork choice at the start of every slot, and wait for this run to complete before proposing a block. 2. As an optimisation, also run fork choice 3/4 of the way through the slot (at 9s), _dequeueing attestations for the next slot_. 3. Remove the fork choice run from the state advance timer that occurred before advancing the state. ## Additional Info ### Block Proposal Accuracy This change makes us more likely to propose on top of the correct head in the presence of re-orgs with proposer boost in play. The main scenario that this change is designed to address is described in the linked spec issue. ### Attestation Accuracy This change _also_ makes us more likely to attest to the correct head. Currently in the case of a skipped slot at `slot` we only run fork choice 9s into `slot - 1`. This means the attestations from `slot - 1` aren't taken into consideration, and any boost applied to the block from `slot - 1` is not removed (it should be). In the language of the linked spec issue, this means we are liable to attest to C, even when the majority voting weight has already caused a re-org to B. ### Why remove the call before the state advance? If we've run fork choice at the start of the slot then it has already dequeued all the attestations from the previous slot, which are the only ones eligible to influence the head in the current slot. Running fork choice again is unnecessary (unless we run it for the next slot and try to pre-empt a re-org, but I don't currently think this is a great idea). ### Performance Based on Prater testing this adds about 5-25ms of runtime to block proposal times, which are 500-1000ms on average (and spike to 5s+ sometimes due to state handling issues 😢 ). I believe this is a small enough penalty to enable it by default, with the option to disable it via the new flag `--fork-choice-before-proposal-timeout 0`. Upcoming work on block packing and state representation will also reduce block production times in general, while removing the spikes. ### Implementation Fork choice gets invoked at the start of the slot via the `per_slot_task` function called from the slot timer. It then uses a condition variable to signal to block production that fork choice has been updated. This is a bit funky, but it seems to work. One downside of the timer-based approach is that it doesn't happen automatically in most of the tests. The test added by this PR has to trigger the run manually.
46 lines
1.5 KiB
TOML
46 lines
1.5 KiB
TOML
[package]
|
|
name = "http_api"
|
|
version = "0.1.0"
|
|
authors = ["Paul Hauner <paul@paulhauner.com>"]
|
|
edition = "2021"
|
|
autotests = false # using a single test binary compiles faster
|
|
|
|
[dependencies]
|
|
warp = { version = "0.3.2", features = ["tls"] }
|
|
serde = { version = "1.0.116", features = ["derive"] }
|
|
tokio = { version = "1.14.0", features = ["macros","sync"] }
|
|
tokio-stream = { version = "0.1.3", features = ["sync"] }
|
|
types = { path = "../../consensus/types" }
|
|
hex = "0.4.2"
|
|
beacon_chain = { path = "../beacon_chain" }
|
|
eth2 = { path = "../../common/eth2", features = ["lighthouse"] }
|
|
slog = "2.5.2"
|
|
network = { path = "../network" }
|
|
lighthouse_network = { path = "../lighthouse_network" }
|
|
eth1 = { path = "../eth1" }
|
|
state_processing = { path = "../../consensus/state_processing" }
|
|
lighthouse_version = { path = "../../common/lighthouse_version" }
|
|
lighthouse_metrics = { path = "../../common/lighthouse_metrics" }
|
|
lazy_static = "1.4.0"
|
|
warp_utils = { path = "../../common/warp_utils" }
|
|
slot_clock = { path = "../../common/slot_clock" }
|
|
eth2_ssz = "0.4.1"
|
|
bs58 = "0.4.0"
|
|
futures = "0.3.8"
|
|
execution_layer = {path = "../execution_layer"}
|
|
parking_lot = "0.12.0"
|
|
safe_arith = {path = "../../consensus/safe_arith"}
|
|
task_executor = { path = "../../common/task_executor" }
|
|
|
|
|
|
[dev-dependencies]
|
|
store = { path = "../store" }
|
|
environment = { path = "../../lighthouse/environment" }
|
|
tree_hash = "0.4.1"
|
|
sensitive_url = { path = "../../common/sensitive_url" }
|
|
logging = { path = "../../common/logging" }
|
|
|
|
[[test]]
|
|
name = "bn_http_api_tests"
|
|
path = "tests/main.rs"
|