Skip to content

Commit e270c61

Browse files
committed
Merge branch 'unstable' of https://github.com/sigp/lighthouse into prepare-proposer
� Conflicts: � Cargo.lock � beacon_node/execution_layer/Cargo.toml
2 parents c86ada0 + 381d0ec commit e270c61

19 files changed

Lines changed: 861 additions & 84 deletions

File tree

Cargo.lock

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

beacon_node/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ environment = { path = "../lighthouse/environment" }
2929
task_executor = { path = "../common/task_executor" }
3030
genesis = { path = "genesis" }
3131
eth2_network_config = { path = "../common/eth2_network_config" }
32+
execution_layer = { path = "execution_layer" }
3233
lighthouse_network = { path = "./lighthouse_network" }
3334
serde = "1.0.116"
3435
clap_utils = { path = "../common/clap_utils" }

beacon_node/beacon_chain/src/test_utils.rs

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -337,14 +337,20 @@ where
337337

338338
let el_runtime = ExecutionLayerRuntime::default();
339339

340-
let urls = urls
340+
let urls: Vec<SensitiveUrl> = urls
341341
.iter()
342342
.map(|s| SensitiveUrl::parse(*s))
343343
.collect::<Result<_, _>>()
344344
.unwrap();
345-
let execution_layer = ExecutionLayer::from_urls(
346-
urls,
347-
Some(Address::repeat_byte(42)),
345+
346+
let config = execution_layer::Config {
347+
execution_endpoints: urls,
348+
secret_files: vec![],
349+
suggested_fee_recipient: Some(Address::repeat_byte(42)),
350+
..Default::default()
351+
};
352+
let execution_layer = ExecutionLayer::from_config(
353+
config,
348354
el_runtime.task_executor.clone(),
349355
el_runtime.log.clone(),
350356
)

beacon_node/client/src/builder.rs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -150,11 +150,10 @@ where
150150
None
151151
};
152152

153-
let execution_layer = if let Some(execution_endpoints) = config.execution_endpoints {
153+
let execution_layer = if let Some(config) = config.execution_layer {
154154
let context = runtime_context.service_context("exec".into());
155-
let execution_layer = ExecutionLayer::from_urls(
156-
execution_endpoints,
157-
config.suggested_fee_recipient,
155+
let execution_layer = ExecutionLayer::from_config(
156+
config,
158157
context.executor.clone(),
159158
context.log().clone(),
160159
)
@@ -710,6 +709,9 @@ where
710709
execution_layer.spawn_clean_proposer_preparation_routine::<TSlotClock, TEthSpec>(
711710
beacon_chain.slot_clock.clone(),
712711
);
712+
713+
// Spawns a routine that polls the `exchange_transition_configuration` endpoint.
714+
execution_layer.spawn_transition_configuration_poll(beacon_chain.spec.clone());
713715
}
714716

715717
start_proposer_prep_service(runtime_context.executor.clone(), beacon_chain.clone());

beacon_node/client/src/config.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use sensitive_url::SensitiveUrl;
44
use serde_derive::{Deserialize, Serialize};
55
use std::fs;
66
use std::path::PathBuf;
7-
use types::{Address, Graffiti, PublicKeyBytes};
7+
use types::{Graffiti, PublicKeyBytes};
88

99
/// Default directory name for the freezer database under the top-level data dir.
1010
const DEFAULT_FREEZER_DB_DIR: &str = "freezer_db";
@@ -72,8 +72,7 @@ pub struct Config {
7272
pub network: network::NetworkConfig,
7373
pub chain: beacon_chain::ChainConfig,
7474
pub eth1: eth1::Config,
75-
pub execution_endpoints: Option<Vec<SensitiveUrl>>,
76-
pub suggested_fee_recipient: Option<Address>,
75+
pub execution_layer: Option<execution_layer::Config>,
7776
pub http_api: http_api::Config,
7877
pub http_metrics: http_metrics::Config,
7978
pub monitoring_api: Option<monitoring_api::Config>,
@@ -94,8 +93,7 @@ impl Default for Config {
9493
dummy_eth1_backend: false,
9594
sync_eth1_chain: false,
9695
eth1: <_>::default(),
97-
execution_endpoints: None,
98-
suggested_fee_recipient: None,
96+
execution_layer: None,
9997
graffiti: Graffiti::default(),
10098
http_api: <_>::default(),
10199
http_metrics: <_>::default(),

beacon_node/execution_layer/Cargo.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ serde_json = "1.0.58"
1818
serde = { version = "1.0.116", features = ["derive"] }
1919
eth1 = { path = "../eth1" }
2020
warp = { git = "https://github.com/macladson/warp", rev ="dfa259e", features = ["tls"] }
21+
jsonwebtoken = "8"
2122
environment = { path = "../../lighthouse/environment" }
2223
bytes = "1.1.0"
2324
task_executor = { path = "../../common/task_executor" }
@@ -33,4 +34,4 @@ tempfile = "3.1.0"
3334
rand = "0.7.3"
3435
zeroize = { version = "1.4.2", features = ["zeroize_derive"] }
3536
lighthouse_metrics = { path = "../../common/lighthouse_metrics" }
36-
lazy_static = "1.4.0"
37+
lazy_static = "1.4.0"

beacon_node/execution_layer/src/engine_api.rs

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
11
use async_trait::async_trait;
22
use eth1::http::RpcError;
3+
use reqwest::StatusCode;
34
use serde::{Deserialize, Serialize};
45

56
pub const LATEST_TAG: &str = "latest";
67

78
use crate::engines::ForkChoiceState;
9+
pub use json_structures::TransitionConfigurationV1;
810
pub use types::{Address, EthSpec, ExecutionBlockHash, ExecutionPayload, Hash256, Uint256};
911

12+
pub mod auth;
1013
pub mod http;
1114
pub mod json_structures;
1215

@@ -15,6 +18,7 @@ pub type PayloadId = [u8; 8];
1518
#[derive(Debug)]
1619
pub enum Error {
1720
Reqwest(reqwest::Error),
21+
Auth(auth::Error),
1822
BadResponse(String),
1923
RequestFailed(String),
2024
InvalidExecutePayloadResponse(&'static str),
@@ -27,11 +31,19 @@ pub enum Error {
2731
ExecutionHeadBlockNotFound,
2832
ParentHashEqualsBlockHash(ExecutionBlockHash),
2933
PayloadIdUnavailable,
34+
TransitionConfigurationMismatch,
3035
}
3136

3237
impl From<reqwest::Error> for Error {
3338
fn from(e: reqwest::Error) -> Self {
34-
Error::Reqwest(e)
39+
if matches!(
40+
e.status(),
41+
Some(StatusCode::UNAUTHORIZED) | Some(StatusCode::FORBIDDEN)
42+
) {
43+
Error::Auth(auth::Error::InvalidToken)
44+
} else {
45+
Error::Reqwest(e)
46+
}
3547
}
3648
}
3749

@@ -41,6 +53,12 @@ impl From<serde_json::Error> for Error {
4153
}
4254
}
4355

56+
impl From<auth::Error> for Error {
57+
fn from(e: auth::Error) -> Self {
58+
Error::Auth(e)
59+
}
60+
}
61+
4462
/// A generic interface for an execution engine API.
4563
#[async_trait]
4664
pub trait EngineApi {
@@ -71,6 +89,11 @@ pub trait EngineApi {
7189
forkchoice_state: ForkChoiceState,
7290
payload_attributes: Option<PayloadAttributes>,
7391
) -> Result<ForkchoiceUpdatedResponse, Error>;
92+
93+
async fn exchange_transition_configuration_v1(
94+
&self,
95+
transition_configuration: TransitionConfigurationV1,
96+
) -> Result<TransitionConfigurationV1, Error>;
7497
}
7598

7699
#[derive(Clone, Copy, Debug, PartialEq)]

0 commit comments

Comments
 (0)