diff --git a/beacon_node/execution_layer/src/test_utils/mock_builder.rs b/beacon_node/execution_layer/src/test_utils/mock_builder.rs index 4d06b15033..420ceea87e 100644 --- a/beacon_node/execution_layer/src/test_utils/mock_builder.rs +++ b/beacon_node/execution_layer/src/test_utils/mock_builder.rs @@ -272,6 +272,8 @@ pub struct MockBuilder { /// a valid block. apply_operations: bool, payload_id_cache: Arc>>, + /// If set to `true`, sets the bid returned by `get_header` to Uint256::MAX + max_bid: bool, /// A cache that stores the proposers index for a given epoch proposers_cache: Arc>>>, log: Logger, @@ -304,6 +306,7 @@ impl MockBuilder { BeaconNodeHttpClient::new(beacon_url, Timeouts::set_all(Duration::from_secs(1))), true, true, + false, spec, executor.log().clone(), ); @@ -318,6 +321,7 @@ impl MockBuilder { beacon_client: BeaconNodeHttpClient, validate_pubkey: bool, apply_operations: bool, + max_bid: bool, spec: Arc, log: Logger, ) -> Self { @@ -335,6 +339,7 @@ impl MockBuilder { payload_id_cache: Arc::new(RwLock::new(HashMap::new())), proposers_cache: Arc::new(RwLock::new(HashMap::new())), apply_operations, + max_bid, genesis_time: None, log, } @@ -496,11 +501,7 @@ impl MockBuilder { blob_kzg_commitments: maybe_blobs_bundle .map(|b| b.commitments) .unwrap_or_default(), - value: if !self.apply_operations { - value - } else { - Uint256::from(DEFAULT_BUILDER_PAYLOAD_VALUE_WEI) - }, + value: self.get_bid_value(value), pubkey: self.builder_sk.public_key().compress(), execution_requests: maybe_requests.unwrap_or_default(), }), @@ -512,11 +513,7 @@ impl MockBuilder { blob_kzg_commitments: maybe_blobs_bundle .map(|b| b.commitments) .unwrap_or_default(), - value: if !self.apply_operations { - value - } else { - Uint256::from(DEFAULT_BUILDER_PAYLOAD_VALUE_WEI) - }, + value: self.get_bid_value(value), pubkey: self.builder_sk.public_key().compress(), }), ForkName::Capella => BuilderBid::Capella(BuilderBidCapella { @@ -524,11 +521,7 @@ impl MockBuilder { .as_capella() .map_err(|_| "incorrect payload variant".to_string())? .into(), - value: if !self.apply_operations { - value - } else { - Uint256::from(DEFAULT_BUILDER_PAYLOAD_VALUE_WEI) - }, + value: self.get_bid_value(value), pubkey: self.builder_sk.public_key().compress(), }), ForkName::Bellatrix => BuilderBid::Bellatrix(BuilderBidBellatrix { @@ -536,11 +529,7 @@ impl MockBuilder { .as_bellatrix() .map_err(|_| "incorrect payload variant".to_string())? .into(), - value: if !self.apply_operations { - value - } else { - Uint256::from(DEFAULT_BUILDER_PAYLOAD_VALUE_WEI) - }, + value: self.get_bid_value(value), pubkey: self.builder_sk.public_key().compress(), }), ForkName::Base | ForkName::Altair => return Err("invalid fork".to_string()), @@ -566,6 +555,16 @@ impl MockBuilder { self.spec.fork_name_at_slot::(slot) } + fn get_bid_value(&self, value: Uint256) -> Uint256 { + if self.max_bid { + Uint256::MAX + } else if !self.apply_operations { + value + } else { + Uint256::from(DEFAULT_BUILDER_PAYLOAD_VALUE_WEI) + } + } + /// Prepare the execution layer for payload creation every slot for the correct /// proposer index pub async fn prepare_execution_layer(&self) -> Result<(), String> {