Skip to content

Commit

Permalink
Block v3 builder boost factor (#5035)
Browse files Browse the repository at this point in the history
* builder boost factor

* default boost factor

* revert

* deprecate always_prefer_builder_payload, builder-profit-threshold, ignore_builder_override_suggestion_threshold and builder_comparison_factor flags

* revert

* set deprecated flags to no op, revert should_override_builder

* fix test, calc boosted relay value correctly, dont calculate if none

* Add deprecation warnings and restore CLI docs
  • Loading branch information
eserilev authored Jan 8, 2024
1 parent 0c97762 commit 9c1505d
Show file tree
Hide file tree
Showing 20 changed files with 194 additions and 430 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ cli:
docker run --rm --user=root \
-v ${PWD}:/home/runner/actions-runner/lighthouse sigmaprime/github-runner \
bash -c 'cd lighthouse && make && ./scripts/cli.sh'

# Runs the entire test suite, downloading test vectors if required.
test-full: cargo-fmt test-release test-debug test-ef test-exec-engine

Expand Down
7 changes: 7 additions & 0 deletions beacon_node/beacon_chain/src/beacon_chain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4021,6 +4021,7 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
slot: Slot,
validator_graffiti: Option<Graffiti>,
verification: ProduceBlockVerification,
builder_boost_factor: Option<u64>,
block_production_version: BlockProductionVersion,
) -> Result<BeaconBlockResponseWrapper<T::EthSpec>, BlockProductionError> {
metrics::inc_counter(&metrics::BLOCK_PRODUCTION_REQUESTS);
Expand Down Expand Up @@ -4049,6 +4050,7 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
randao_reveal,
validator_graffiti,
verification,
builder_boost_factor,
block_production_version,
)
.await
Expand Down Expand Up @@ -4652,6 +4654,7 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
randao_reveal: Signature,
validator_graffiti: Option<Graffiti>,
verification: ProduceBlockVerification,
builder_boost_factor: Option<u64>,
block_production_version: BlockProductionVersion,
) -> Result<BeaconBlockResponseWrapper<T::EthSpec>, BlockProductionError> {
// Part 1/3 (blocking)
Expand All @@ -4668,6 +4671,7 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
produce_at_slot,
randao_reveal,
validator_graffiti,
builder_boost_factor,
block_production_version,
)
},
Expand Down Expand Up @@ -4757,13 +4761,15 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
}
}

#[allow(clippy::too_many_arguments)]
fn produce_partial_beacon_block(
self: &Arc<Self>,
mut state: BeaconState<T::EthSpec>,
state_root_opt: Option<Hash256>,
produce_at_slot: Slot,
randao_reveal: Signature,
validator_graffiti: Option<Graffiti>,
builder_boost_factor: Option<u64>,
block_production_version: BlockProductionVersion,
) -> Result<PartialBeaconBlock<T::EthSpec>, BlockProductionError> {
let eth1_chain = self
Expand Down Expand Up @@ -4825,6 +4831,7 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
parent_root,
proposer_index,
builder_params,
builder_boost_factor,
block_production_version,
)?;
Some(prepare_payload_handle)
Expand Down
4 changes: 4 additions & 0 deletions beacon_node/beacon_chain/src/execution_payload.rs
Original file line number Diff line number Diff line change
Expand Up @@ -405,6 +405,7 @@ pub fn get_execution_payload<T: BeaconChainTypes>(
parent_block_root: Hash256,
proposer_index: u64,
builder_params: BuilderParams,
builder_boost_factor: Option<u64>,
block_production_version: BlockProductionVersion,
) -> Result<PreparePayloadHandle<T::EthSpec>, BlockProductionError> {
// Compute all required values from the `state` now to avoid needing to pass it into a spawned
Expand Down Expand Up @@ -449,6 +450,7 @@ pub fn get_execution_payload<T: BeaconChainTypes>(
builder_params,
withdrawals,
parent_beacon_block_root,
builder_boost_factor,
block_production_version,
)
.await
Expand Down Expand Up @@ -485,6 +487,7 @@ pub async fn prepare_execution_payload<T>(
builder_params: BuilderParams,
withdrawals: Option<Vec<Withdrawal>>,
parent_beacon_block_root: Option<Hash256>,
builder_boost_factor: Option<u64>,
block_production_version: BlockProductionVersion,
) -> Result<BlockProposalContentsType<T::EthSpec>, BlockProductionError>
where
Expand Down Expand Up @@ -575,6 +578,7 @@ where
builder_params,
fork,
&chain.spec,
builder_boost_factor,
block_production_version,
)
.await
Expand Down
9 changes: 4 additions & 5 deletions beacon_node/beacon_chain/src/test_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -464,14 +464,13 @@ where
}

pub fn mock_execution_layer(self) -> Self {
self.mock_execution_layer_with_config(None)
self.mock_execution_layer_with_config()
}

pub fn mock_execution_layer_with_config(mut self, builder_threshold: Option<u128>) -> Self {
pub fn mock_execution_layer_with_config(mut self) -> Self {
let mock = mock_execution_layer_from_parts::<E>(
self.spec.as_ref().expect("cannot build without spec"),
self.runtime.task_executor.clone(),
builder_threshold,
);
self.execution_layer = Some(mock.el.clone());
self.mock_execution_layer = Some(mock);
Expand Down Expand Up @@ -574,7 +573,6 @@ where
pub fn mock_execution_layer_from_parts<T: EthSpec>(
spec: &ChainSpec,
task_executor: TaskExecutor,
builder_threshold: Option<u128>,
) -> MockExecutionLayer<T> {
let shanghai_time = spec.capella_fork_epoch.map(|epoch| {
HARNESS_GENESIS_TIME + spec.seconds_per_slot * T::slots_per_epoch() * epoch.as_u64()
Expand All @@ -593,7 +591,6 @@ pub fn mock_execution_layer_from_parts<T: EthSpec>(
DEFAULT_TERMINAL_BLOCK,
shanghai_time,
cancun_time,
builder_threshold,
Some(JwtKey::from_slice(&DEFAULT_JWT_SECRET).unwrap()),
spec.clone(),
Some(kzg),
Expand Down Expand Up @@ -860,6 +857,7 @@ where
randao_reveal,
Some(graffiti),
ProduceBlockVerification::VerifyRandao,
None,
BlockProductionVersion::FullV2,
)
.await
Expand Down Expand Up @@ -921,6 +919,7 @@ where
randao_reveal,
Some(graffiti),
ProduceBlockVerification::VerifyRandao,
None,
BlockProductionVersion::FullV2,
)
.await
Expand Down
2 changes: 1 addition & 1 deletion beacon_node/beacon_chain/tests/store_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2421,7 +2421,7 @@ async fn weak_subjectivity_sync_test(slots: Vec<Slot>, checkpoint_slot: Slot) {
.unwrap();

let mock =
mock_execution_layer_from_parts(&harness.spec, harness.runtime.task_executor.clone(), None);
mock_execution_layer_from_parts(&harness.spec, harness.runtime.task_executor.clone());

// Initialise a new beacon chain from the finalized checkpoint.
// The slot clock must be set to a time ahead of the checkpoint state.
Expand Down
Loading

0 comments on commit 9c1505d

Please sign in to comment.