Block v3 builder boost factor (#5035)

* 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
This commit is contained in:
Eitan Seri-Levi
2024-01-08 02:10:32 +02:00
committed by GitHub
parent 0c97762032
commit 9c1505d082
20 changed files with 201 additions and 437 deletions

View File

@@ -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);
@@ -4049,6 +4050,7 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
randao_reveal,
validator_graffiti,
verification,
builder_boost_factor,
block_production_version,
)
.await
@@ -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)
@@ -4668,6 +4671,7 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
produce_at_slot,
randao_reveal,
validator_graffiti,
builder_boost_factor,
block_production_version,
)
},
@@ -4757,6 +4761,7 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
}
}
#[allow(clippy::too_many_arguments)]
fn produce_partial_beacon_block(
self: &Arc<Self>,
mut state: BeaconState<T::EthSpec>,
@@ -4764,6 +4769,7 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
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
@@ -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)

View File

@@ -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
@@ -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
@@ -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
@@ -575,6 +578,7 @@ where
builder_params,
fork,
&chain.spec,
builder_boost_factor,
block_production_version,
)
.await

View File

@@ -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);
@@ -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()
@@ -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),
@@ -860,6 +857,7 @@ where
randao_reveal,
Some(graffiti),
ProduceBlockVerification::VerifyRandao,
None,
BlockProductionVersion::FullV2,
)
.await
@@ -921,6 +919,7 @@ where
randao_reveal,
Some(graffiti),
ProduceBlockVerification::VerifyRandao,
None,
BlockProductionVersion::FullV2,
)
.await

View File

@@ -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.