forked from sigp/lighthouse
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move the
BeaconProcessor
into a new crate (sigp#4435)
*Replaces sigp#4434. It is identical, but this PR has a smaller diff due to a curated commit history.* NA This PR moves the scheduling logic for the `BeaconProcessor` into a new crate in `beacon_node/beacon_processor`. Previously it existed in the `beacon_node/network` crate. This addresses a circular-dependency problem where it's not possible to use the `BeaconProcessor` from the `beacon_chain` crate. The `network` crate depends on the `beacon_chain` crate (`network -> beacon_chain`), but importing the `BeaconProcessor` into the `beacon_chain` crate would create a circular dependancy of `beacon_chain -> network`. The `BeaconProcessor` was designed to provide queuing and prioritized scheduling for messages from the network. It has proven to be quite valuable and I believe we'd make Lighthouse more stable and effective by using it elsewhere. In particular, I think we should use the `BeaconProcessor` for: 1. HTTP API requests. 1. Scheduled tasks in the `BeaconChain` (e.g., state advance). Using the `BeaconProcessor` for these tasks would help prevent the BN from becoming overwhelmed and would also help it to prioritize operations (e.g., choosing to process blocks from gossip before responding to low-priority HTTP API requests). This PR is intended to have zero impact on runtime behaviour. It aims to simply separate the *scheduling* code (i.e., the `BeaconProcessor`) from the *business logic* in the `network` crate (i.e., the `Worker` impls). Future PRs (see sigp#4462) can build upon these works to actually use the `BeaconProcessor` for more operations. I've gone to some effort to use `git mv` to make the diff look more like "file was moved and modified" rather than "file was deleted and a new one added". This should reduce review burden and help maintain commit attribution.
- Loading branch information
1 parent
aff4cba
commit 1c4ee78
Showing
18 changed files
with
836 additions
and
171 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
[package] | ||
name = "beacon_processor" | ||
version = "0.1.0" | ||
edition = "2021" | ||
|
||
[dependencies] | ||
slog = { version = "2.5.2", features = ["max_level_trace"] } | ||
itertools = "0.10.0" | ||
logging = { path = "../../common/logging" } | ||
tokio = { version = "1.14.0", features = ["full"] } | ||
tokio-util = { version = "0.6.3", features = ["time"] } | ||
futures = "0.3.7" | ||
fnv = "1.0.7" | ||
strum = "0.24.0" | ||
task_executor = { path = "../../common/task_executor" } | ||
slot_clock = { path = "../../common/slot_clock" } | ||
lighthouse_network = { path = "../lighthouse_network" } | ||
hex = "0.4.2" | ||
derivative = "2.2.0" | ||
types = { path = "../../consensus/types" } | ||
ethereum_ssz = "0.5.0" | ||
lazy_static = "1.4.0" | ||
lighthouse_metrics = { path = "../../common/lighthouse_metrics" } | ||
parking_lot = "0.12.0" |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,141 @@ | ||
pub use lighthouse_metrics::*; | ||
|
||
lazy_static::lazy_static! { | ||
|
||
/* | ||
* Gossip processor | ||
*/ | ||
pub static ref BEACON_PROCESSOR_WORK_EVENTS_RX_COUNT: Result<IntCounterVec> = try_create_int_counter_vec( | ||
"beacon_processor_work_events_rx_count", | ||
"Count of work events received (but not necessarily processed)", | ||
&["type"] | ||
); | ||
pub static ref BEACON_PROCESSOR_WORK_EVENTS_IGNORED_COUNT: Result<IntCounterVec> = try_create_int_counter_vec( | ||
"beacon_processor_work_events_ignored_count", | ||
"Count of work events purposefully ignored", | ||
&["type"] | ||
); | ||
pub static ref BEACON_PROCESSOR_WORK_EVENTS_STARTED_COUNT: Result<IntCounterVec> = try_create_int_counter_vec( | ||
"beacon_processor_work_events_started_count", | ||
"Count of work events which have been started by a worker", | ||
&["type"] | ||
); | ||
pub static ref BEACON_PROCESSOR_WORKER_TIME: Result<HistogramVec> = try_create_histogram_vec( | ||
"beacon_processor_worker_time", | ||
"Time taken for a worker to fully process some parcel of work.", | ||
&["type"] | ||
); | ||
pub static ref BEACON_PROCESSOR_WORKERS_SPAWNED_TOTAL: Result<IntCounter> = try_create_int_counter( | ||
"beacon_processor_workers_spawned_total", | ||
"The number of workers ever spawned by the gossip processing pool." | ||
); | ||
pub static ref BEACON_PROCESSOR_WORKERS_ACTIVE_TOTAL: Result<IntGauge> = try_create_int_gauge( | ||
"beacon_processor_workers_active_total", | ||
"Count of active workers in the gossip processing pool." | ||
); | ||
pub static ref BEACON_PROCESSOR_IDLE_EVENTS_TOTAL: Result<IntCounter> = try_create_int_counter( | ||
"beacon_processor_idle_events_total", | ||
"Count of idle events processed by the gossip processor manager." | ||
); | ||
pub static ref BEACON_PROCESSOR_EVENT_HANDLING_SECONDS: Result<Histogram> = try_create_histogram( | ||
"beacon_processor_event_handling_seconds", | ||
"Time spent handling a new message and allocating it to a queue or worker." | ||
); | ||
// Gossip blocks. | ||
pub static ref BEACON_PROCESSOR_GOSSIP_BLOCK_QUEUE_TOTAL: Result<IntGauge> = try_create_int_gauge( | ||
"beacon_processor_gossip_block_queue_total", | ||
"Count of blocks from gossip waiting to be verified." | ||
); | ||
// Gossip Exits. | ||
pub static ref BEACON_PROCESSOR_EXIT_QUEUE_TOTAL: Result<IntGauge> = try_create_int_gauge( | ||
"beacon_processor_exit_queue_total", | ||
"Count of exits from gossip waiting to be verified." | ||
); | ||
// Gossip proposer slashings. | ||
pub static ref BEACON_PROCESSOR_PROPOSER_SLASHING_QUEUE_TOTAL: Result<IntGauge> = try_create_int_gauge( | ||
"beacon_processor_proposer_slashing_queue_total", | ||
"Count of proposer slashings from gossip waiting to be verified." | ||
); | ||
// Gossip attester slashings. | ||
pub static ref BEACON_PROCESSOR_ATTESTER_SLASHING_QUEUE_TOTAL: Result<IntGauge> = try_create_int_gauge( | ||
"beacon_processor_attester_slashing_queue_total", | ||
"Count of attester slashings from gossip waiting to be verified." | ||
); | ||
// Gossip BLS to execution changes. | ||
pub static ref BEACON_PROCESSOR_BLS_TO_EXECUTION_CHANGE_QUEUE_TOTAL: Result<IntGauge> = try_create_int_gauge( | ||
"beacon_processor_bls_to_execution_change_queue_total", | ||
"Count of address changes from gossip waiting to be verified." | ||
); | ||
// Rpc blocks. | ||
pub static ref BEACON_PROCESSOR_RPC_BLOCK_QUEUE_TOTAL: Result<IntGauge> = try_create_int_gauge( | ||
"beacon_processor_rpc_block_queue_total", | ||
"Count of blocks from the rpc waiting to be verified." | ||
); | ||
// Chain segments. | ||
pub static ref BEACON_PROCESSOR_CHAIN_SEGMENT_QUEUE_TOTAL: Result<IntGauge> = try_create_int_gauge( | ||
"beacon_processor_chain_segment_queue_total", | ||
"Count of chain segments from the rpc waiting to be verified." | ||
); | ||
pub static ref BEACON_PROCESSOR_BACKFILL_CHAIN_SEGMENT_QUEUE_TOTAL: Result<IntGauge> = try_create_int_gauge( | ||
"beacon_processor_backfill_chain_segment_queue_total", | ||
"Count of backfill chain segments from the rpc waiting to be verified." | ||
); | ||
// Unaggregated attestations. | ||
pub static ref BEACON_PROCESSOR_UNAGGREGATED_ATTESTATION_QUEUE_TOTAL: Result<IntGauge> = try_create_int_gauge( | ||
"beacon_processor_unaggregated_attestation_queue_total", | ||
"Count of unagg. attestations waiting to be processed." | ||
); | ||
// Aggregated attestations. | ||
pub static ref BEACON_PROCESSOR_AGGREGATED_ATTESTATION_QUEUE_TOTAL: Result<IntGauge> = try_create_int_gauge( | ||
"beacon_processor_aggregated_attestation_queue_total", | ||
"Count of agg. attestations waiting to be processed." | ||
); | ||
// Sync committee messages. | ||
pub static ref BEACON_PROCESSOR_SYNC_MESSAGE_QUEUE_TOTAL: Result<IntGauge> = try_create_int_gauge( | ||
"beacon_processor_sync_message_queue_total", | ||
"Count of sync committee messages waiting to be processed." | ||
); | ||
// Sync contribution. | ||
pub static ref BEACON_PROCESSOR_SYNC_CONTRIBUTION_QUEUE_TOTAL: Result<IntGauge> = try_create_int_gauge( | ||
"beacon_processor_sync_contribution_queue_total", | ||
"Count of sync committee contributions waiting to be processed." | ||
); | ||
|
||
/* | ||
* Attestation reprocessing queue metrics. | ||
*/ | ||
pub static ref BEACON_PROCESSOR_REPROCESSING_QUEUE_TOTAL: Result<IntGaugeVec> = | ||
try_create_int_gauge_vec( | ||
"beacon_processor_reprocessing_queue_total", | ||
"Count of items in a reprocessing queue.", | ||
&["type"] | ||
); | ||
pub static ref BEACON_PROCESSOR_REPROCESSING_QUEUE_EXPIRED_ATTESTATIONS: Result<IntCounter> = try_create_int_counter( | ||
"beacon_processor_reprocessing_queue_expired_attestations", | ||
"Number of queued attestations which have expired before a matching block has been found." | ||
); | ||
pub static ref BEACON_PROCESSOR_REPROCESSING_QUEUE_MATCHED_ATTESTATIONS: Result<IntCounter> = try_create_int_counter( | ||
"beacon_processor_reprocessing_queue_matched_attestations", | ||
"Number of queued attestations where as matching block has been imported." | ||
); | ||
|
||
/* | ||
* Light client update reprocessing queue metrics. | ||
*/ | ||
pub static ref BEACON_PROCESSOR_REPROCESSING_QUEUE_EXPIRED_OPTIMISTIC_UPDATES: Result<IntCounter> = try_create_int_counter( | ||
"beacon_processor_reprocessing_queue_expired_optimistic_updates", | ||
"Number of queued light client optimistic updates which have expired before a matching block has been found." | ||
); | ||
pub static ref BEACON_PROCESSOR_REPROCESSING_QUEUE_MATCHED_OPTIMISTIC_UPDATES: Result<IntCounter> = try_create_int_counter( | ||
"beacon_processor_reprocessing_queue_matched_optimistic_updates", | ||
"Number of queued light client optimistic updates where as matching block has been imported." | ||
); | ||
|
||
/// Errors and Debugging Stats | ||
pub static ref BEACON_PROCESSOR_SEND_ERROR_PER_WORK_TYPE: Result<IntCounterVec> = | ||
try_create_int_counter_vec( | ||
"beacon_processor_send_error_per_work_type", | ||
"Total number of beacon processor send error per work type", | ||
&["type"] | ||
); | ||
} |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.