Skip to content

Commit 8630ddf

Browse files
committed
Add beacon.watch (#3362)
> This is currently a WIP and all features are subject to alteration or removal at any time. ## Overview The successor to #2873. Contains the backbone of `beacon.watch` including syncing code, the initial API, and several core database tables. See `watch/README.md` for more information, requirements and usage.
1 parent 1e029ce commit 8630ddf

File tree

80 files changed

+7662
-235
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

80 files changed

+7662
-235
lines changed

Cargo.lock

Lines changed: 478 additions & 219 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,8 @@ members = [
8787

8888
"validator_client",
8989
"validator_client/slashing_protection",
90+
91+
"watch",
9092
]
9193
resolver = "2"
9294

beacon_node/http_api/Cargo.toml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,15 +38,15 @@ system_health = { path = "../../common/system_health" }
3838
directory = { path = "../../common/directory" }
3939
eth2_serde_utils = "0.1.1"
4040
operation_pool = { path = "../operation_pool" }
41+
sensitive_url = { path = "../../common/sensitive_url" }
42+
unused_port = {path = "../../common/unused_port"}
43+
logging = { path = "../../common/logging" }
44+
store = { path = "../store" }
4145

4246
[dev-dependencies]
43-
store = { path = "../store" }
4447
environment = { path = "../../lighthouse/environment" }
45-
sensitive_url = { path = "../../common/sensitive_url" }
46-
logging = { path = "../../common/logging" }
4748
serde_json = "1.0.58"
4849
proto_array = { path = "../../consensus/proto_array" }
49-
unused_port = {path = "../../common/unused_port"}
5050
genesis = { path = "../genesis" }
5151

5252
[[test]]

beacon_node/http_api/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ mod standard_block_rewards;
1818
mod state_id;
1919
mod sync_committee_rewards;
2020
mod sync_committees;
21+
pub mod test_utils;
2122
mod ui;
2223
mod validator_inclusion;
2324
mod version;

beacon_node/http_api/tests/common.rs renamed to beacon_node/http_api/src/test_utils.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
use crate::{Config, Context};
12
use beacon_chain::{
23
test_utils::{
34
BeaconChainHarness, BoxedMutator, Builder as HarnessBuilder, EphemeralHarnessType,
@@ -6,7 +7,6 @@ use beacon_chain::{
67
};
78
use directory::DEFAULT_ROOT_DIR;
89
use eth2::{BeaconNodeHttpClient, Timeouts};
9-
use http_api::{Config, Context};
1010
use lighthouse_network::{
1111
discv5::enr::{CombinedKey, EnrBuilder},
1212
libp2p::{
@@ -182,7 +182,7 @@ pub async fn create_api_server_on_port<T: BeaconChainTypes>(
182182
let eth1_service =
183183
eth1::Service::new(eth1::Config::default(), log.clone(), chain.spec.clone()).unwrap();
184184

185-
let context = Arc::new(Context {
185+
let ctx = Arc::new(Context {
186186
config: Config {
187187
enabled: true,
188188
listen_addr: IpAddr::V4(Ipv4Addr::new(127, 0, 0, 1)),
@@ -193,19 +193,19 @@ pub async fn create_api_server_on_port<T: BeaconChainTypes>(
193193
data_dir: std::path::PathBuf::from(DEFAULT_ROOT_DIR),
194194
spec_fork_name: None,
195195
},
196-
chain: Some(chain.clone()),
196+
chain: Some(chain),
197197
network_senders: Some(network_senders),
198198
network_globals: Some(network_globals),
199199
eth1_service: Some(eth1_service),
200200
log,
201201
});
202-
let ctx = context.clone();
202+
203203
let (shutdown_tx, shutdown_rx) = oneshot::channel();
204204
let server_shutdown = async {
205205
// It's not really interesting why this triggered, just that it happened.
206206
let _ = shutdown_rx.await;
207207
};
208-
let (listening_socket, server) = http_api::serve(ctx, server_shutdown).unwrap();
208+
let (listening_socket, server) = crate::serve(ctx, server_shutdown).unwrap();
209209

210210
ApiServer {
211211
server,

beacon_node/http_api/tests/fork_tests.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
//! Tests for API behaviour across fork boundaries.
2-
use crate::common::*;
32
use beacon_chain::{
43
test_utils::{RelativeSyncCommittee, DEFAULT_ETH1_BLOCK_HASH, HARNESS_GENESIS_TIME},
54
StateSkipConfig,
65
};
76
use eth2::types::{IndexedErrorMessage, StateId, SyncSubcommittee};
87
use genesis::{bls_withdrawal_credentials, interop_genesis_state_with_withdrawal_credentials};
8+
use http_api::test_utils::*;
99
use std::collections::HashSet;
1010
use types::{
1111
test_utils::{generate_deterministic_keypair, generate_deterministic_keypairs},

beacon_node/http_api/tests/interactive_tests.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
//! Generic tests that make use of the (newer) `InteractiveApiTester`
2-
use crate::common::*;
32
use beacon_chain::{
43
chain_config::ReOrgThreshold,
54
test_utils::{AttestationStrategy, BlockStrategy, SyncCommitteeStrategy},
65
};
76
use eth2::types::DepositContractData;
87
use execution_layer::{ForkchoiceState, PayloadAttributes};
8+
use http_api::test_utils::InteractiveTester;
99
use parking_lot::Mutex;
1010
use slot_clock::SlotClock;
1111
use state_processing::{

beacon_node/http_api/tests/main.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
#![cfg(not(debug_assertions))] // Tests are too slow in debug.
22

3-
pub mod common;
43
pub mod fork_tests;
54
pub mod interactive_tests;
65
pub mod tests;

beacon_node/http_api/tests/tests.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
use crate::common::{create_api_server, create_api_server_on_port, ApiServer};
21
use beacon_chain::test_utils::RelativeSyncCommittee;
32
use beacon_chain::{
43
test_utils::{AttestationStrategy, BeaconChainHarness, BlockStrategy, EphemeralHarnessType},
@@ -18,7 +17,10 @@ use execution_layer::test_utils::{
1817
};
1918
use futures::stream::{Stream, StreamExt};
2019
use futures::FutureExt;
21-
use http_api::{BlockId, StateId};
20+
use http_api::{
21+
test_utils::{create_api_server, create_api_server_on_port, ApiServer},
22+
BlockId, StateId,
23+
};
2224
use lighthouse_network::{Enr, EnrExt, PeerId};
2325
use network::NetworkReceivers;
2426
use proto_array::ExecutionStatus;

common/eth2/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ use lighthouse_network::PeerId;
2222
pub use reqwest;
2323
use reqwest::{IntoUrl, RequestBuilder, Response};
2424
pub use reqwest::{StatusCode, Url};
25-
pub use sensitive_url::SensitiveUrl;
25+
pub use sensitive_url::{SensitiveError, SensitiveUrl};
2626
use serde::{de::DeserializeOwned, Serialize};
2727
use std::convert::TryFrom;
2828
use std::fmt;

0 commit comments

Comments
 (0)