Skip to content

Commit a7da067

Browse files
committedJul 1, 2022
Remove builder redundancy (sigp#3294)
## Issue Addressed This PR is a subset of the changes in sigp#3134. Unstable will still not function correctly with the new builder spec once this is merged, sigp#3134 should be used on testnets ## Proposed Changes - Removes redundancy in "builders" (servers implementing the builder spec) - Renames `payload-builder` flag to `builder` - Moves from old builder RPC API to new HTTP API, but does not implement the validator registration API (implemented in sigp#3194) Co-authored-by: sean <[email protected]> Co-authored-by: realbigsean <[email protected]>
1 parent d40c76e commit a7da067

File tree

25 files changed

+564
-374
lines changed

25 files changed

+564
-374
lines changed
 

‎Cargo.lock

+35
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎Cargo.toml

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ members = [
44

55
"beacon_node",
66
"beacon_node/beacon_chain",
7+
"beacon_node/builder_client",
78
"beacon_node/client",
89
"beacon_node/eth1",
910
"beacon_node/lighthouse_network",

‎beacon_node/beacon_chain/src/beacon_chain.rs

+7-2
Original file line numberDiff line numberDiff line change
@@ -334,7 +334,7 @@ pub struct BeaconChain<T: BeaconChainTypes> {
334334
/// Provides information from the Ethereum 1 (PoW) chain.
335335
pub eth1_chain: Option<Eth1Chain<T::Eth1Chain, T::EthSpec>>,
336336
/// Interfaces with the execution client.
337-
pub execution_layer: Option<ExecutionLayer>,
337+
pub execution_layer: Option<ExecutionLayer<T::EthSpec>>,
338338
/// Stores a "snapshot" of the chain at the time the head-of-the-chain block was received.
339339
pub(crate) canonical_head: TimeoutRwLock<BeaconSnapshot<T::EthSpec>>,
340340
/// The root of the genesis block.
@@ -3216,6 +3216,11 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
32163216
let slot = state.slot();
32173217
let proposer_index = state.get_beacon_proposer_index(state.slot(), &self.spec)? as u64;
32183218

3219+
let pubkey_opt = state
3220+
.validators()
3221+
.get(proposer_index as usize)
3222+
.map(|v| v.pubkey);
3223+
32193224
// Closure to fetch a sync aggregate in cases where it is required.
32203225
let get_sync_aggregate = || -> Result<SyncAggregate<_>, BlockProductionError> {
32213226
Ok(self
@@ -3274,7 +3279,7 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
32743279
BeaconState::Merge(_) => {
32753280
let sync_aggregate = get_sync_aggregate()?;
32763281
let execution_payload =
3277-
get_execution_payload::<T, Payload>(self, &state, proposer_index)?;
3282+
get_execution_payload::<T, Payload>(self, &state, proposer_index, pubkey_opt)?;
32783283
BeaconBlock::Merge(BeaconBlockMerge {
32793284
slot,
32803285
proposer_index,

‎beacon_node/beacon_chain/src/builder.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ pub struct BeaconChainBuilder<T: BeaconChainTypes> {
7777
>,
7878
op_pool: Option<OperationPool<T::EthSpec>>,
7979
eth1_chain: Option<Eth1Chain<T::Eth1Chain, T::EthSpec>>,
80-
execution_layer: Option<ExecutionLayer>,
80+
execution_layer: Option<ExecutionLayer<T::EthSpec>>,
8181
event_handler: Option<ServerSentEventHandler<T::EthSpec>>,
8282
slot_clock: Option<T::SlotClock>,
8383
shutdown_sender: Option<Sender<ShutdownReason>>,
@@ -481,7 +481,7 @@ where
481481
}
482482

483483
/// Sets the `BeaconChain` execution layer.
484-
pub fn execution_layer(mut self, execution_layer: Option<ExecutionLayer>) -> Self {
484+
pub fn execution_layer(mut self, execution_layer: Option<ExecutionLayer<TEthSpec>>) -> Self {
485485
self.execution_layer = execution_layer;
486486
self
487487
}

‎beacon_node/beacon_chain/src/execution_payload.rs

+8-3
Original file line numberDiff line numberDiff line change
@@ -247,9 +247,10 @@ pub fn get_execution_payload<T: BeaconChainTypes, Payload: ExecPayload<T::EthSpe
247247
chain: &BeaconChain<T>,
248248
state: &BeaconState<T::EthSpec>,
249249
proposer_index: u64,
250+
pubkey: Option<PublicKeyBytes>,
250251
) -> Result<Payload, BlockProductionError> {
251252
Ok(
252-
prepare_execution_payload_blocking::<T, Payload>(chain, state, proposer_index)?
253+
prepare_execution_payload_blocking::<T, Payload>(chain, state, proposer_index, pubkey)?
253254
.unwrap_or_default(),
254255
)
255256
}
@@ -259,6 +260,7 @@ pub fn prepare_execution_payload_blocking<T: BeaconChainTypes, Payload: ExecPayl
259260
chain: &BeaconChain<T>,
260261
state: &BeaconState<T::EthSpec>,
261262
proposer_index: u64,
263+
pubkey: Option<PublicKeyBytes>,
262264
) -> Result<Option<Payload>, BlockProductionError> {
263265
let execution_layer = chain
264266
.execution_layer
@@ -267,7 +269,7 @@ pub fn prepare_execution_payload_blocking<T: BeaconChainTypes, Payload: ExecPayl
267269

268270
execution_layer
269271
.block_on_generic(|_| async {
270-
prepare_execution_payload::<T, Payload>(chain, state, proposer_index).await
272+
prepare_execution_payload::<T, Payload>(chain, state, proposer_index, pubkey).await
271273
})
272274
.map_err(BlockProductionError::BlockingFailed)?
273275
}
@@ -290,6 +292,7 @@ pub async fn prepare_execution_payload<T: BeaconChainTypes, Payload: ExecPayload
290292
chain: &BeaconChain<T>,
291293
state: &BeaconState<T::EthSpec>,
292294
proposer_index: u64,
295+
pubkey: Option<PublicKeyBytes>,
293296
) -> Result<Option<Payload>, BlockProductionError> {
294297
let spec = &chain.spec;
295298
let execution_layer = chain
@@ -345,12 +348,14 @@ pub async fn prepare_execution_payload<T: BeaconChainTypes, Payload: ExecPayload
345348

346349
// Note: the suggested_fee_recipient is stored in the `execution_layer`, it will add this parameter.
347350
let execution_payload = execution_layer
348-
.get_payload::<T::EthSpec, Payload>(
351+
.get_payload::<Payload>(
349352
parent_hash,
350353
timestamp,
351354
random,
352355
finalized_block_hash.unwrap_or_else(ExecutionBlockHash::zero),
353356
proposer_index,
357+
pubkey,
358+
state.slot(),
354359
)
355360
.await
356361
.map_err(BlockProductionError::GetPayloadFailed)?;

‎beacon_node/beacon_chain/src/test_utils.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ pub struct Builder<T: BeaconChainTypes> {
147147
store: Option<Arc<HotColdDB<T::EthSpec, T::HotStore, T::ColdStore>>>,
148148
initial_mutator: Option<BoxedMutator<T::EthSpec, T::HotStore, T::ColdStore>>,
149149
store_mutator: Option<BoxedMutator<T::EthSpec, T::HotStore, T::ColdStore>>,
150-
execution_layer: Option<ExecutionLayer>,
150+
execution_layer: Option<ExecutionLayer<T::EthSpec>>,
151151
mock_execution_layer: Option<MockExecutionLayer<T::EthSpec>>,
152152
runtime: TestRuntime,
153153
log: Logger,
@@ -361,6 +361,7 @@ where
361361
DEFAULT_TERMINAL_BLOCK,
362362
spec.terminal_block_hash,
363363
spec.terminal_block_hash_activation_epoch,
364+
None,
364365
);
365366
self.execution_layer = Some(mock.el.clone());
366367
self.mock_execution_layer = Some(mock);

‎beacon_node/beacon_chain/tests/payload_invalidation.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ impl InvalidPayloadRig {
6464
self
6565
}
6666

67-
fn execution_layer(&self) -> ExecutionLayer {
67+
fn execution_layer(&self) -> ExecutionLayer<E> {
6868
self.harness.chain.execution_layer.clone().unwrap()
6969
}
7070

‎beacon_node/builder_client/Cargo.toml

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
[package]
2+
name = "builder_client"
3+
version = "0.1.0"
4+
edition = "2021"
5+
authors = ["Sean Anderson <sean@sigmaprime.io>"]
6+
7+
[dependencies]
8+
reqwest = { version = "0.11.0", features = ["json","stream"] }
9+
sensitive_url = { path = "../../common/sensitive_url" }
10+
eth2 = { path = "../../common/eth2" }
11+
serde = { version = "1.0.116", features = ["derive"] }
12+
serde_json = "1.0.58"

0 commit comments

Comments
 (0)