Add a flag to always use payloads from builders (#4052)

## Issue Addressed

#4040 

## Proposed Changes

- Add the `always_prefer_builder_payload`  field to `Config` in `beacon_node/client/src/config.rs`.
- Add that same field to `Inner` in `beacon_node/execution_layer/src/lib.rs`
- Modify the logic for picking the payload in `beacon_node/execution_layer/src/lib.rs`
- Add the `always-prefer-builder-payload` flag to the beacon node CLI
- Test the new flags in `lighthouse/tests/beacon_node.rs`

Co-authored-by: Paul Hauner <paul@paulhauner.com>
This commit is contained in:
Daniel Ramirez Chiquillo
2023-03-07 05:37:28 +00:00
parent 5bb635d17f
commit 4c109115ca
6 changed files with 39 additions and 2 deletions

View File

@@ -219,6 +219,7 @@ struct Inner<E: EthSpec> {
payload_cache: PayloadCache<E>,
builder_profit_threshold: Uint256,
log: Logger,
always_prefer_builder_payload: bool,
}
#[derive(Debug, Default, Clone, Serialize, Deserialize)]
@@ -241,6 +242,7 @@ pub struct Config {
/// The minimum value of an external payload for it to be considered in a proposal.
pub builder_profit_threshold: u128,
pub execution_timeout_multiplier: Option<u32>,
pub always_prefer_builder_payload: bool,
}
/// Provides access to one execution engine and provides a neat interface for consumption by the
@@ -263,6 +265,7 @@ impl<T: EthSpec> ExecutionLayer<T> {
default_datadir,
builder_profit_threshold,
execution_timeout_multiplier,
always_prefer_builder_payload,
} = config;
if urls.len() > 1 {
@@ -335,6 +338,7 @@ impl<T: EthSpec> ExecutionLayer<T> {
payload_cache: PayloadCache::default(),
builder_profit_threshold: Uint256::from(builder_profit_threshold),
log,
always_prefer_builder_payload,
};
Ok(Self {
@@ -796,7 +800,9 @@ impl<T: EthSpec> ExecutionLayer<T> {
let relay_value = relay.data.message.value;
let local_value = *local.block_value();
if local_value >= relay_value {
if !self.inner.always_prefer_builder_payload
&& local_value >= relay_value
{
info!(
self.log(),
"Local block is more profitable than relay block";