mirror of
https://github.com/sigp/lighthouse.git
synced 2026-03-23 06:44:35 +00:00
Fix http api tests ci (#7943)
Co-Authored-By: Jimmy Chen <jchen.tc@gmail.com> Co-Authored-By: Michael Sproul <micsproul@gmail.com> Co-Authored-By: Michael Sproul <michael@sigmaprime.io> Co-Authored-By: hopinheimer <knmanas6@gmail.com>
This commit is contained in:
@@ -715,7 +715,10 @@ where
|
||||
pub fn set_mock_builder(
|
||||
&mut self,
|
||||
beacon_url: SensitiveUrl,
|
||||
) -> impl futures::Future<Output = ()> + 'static {
|
||||
strict_registrations: bool,
|
||||
apply_operations: bool,
|
||||
broadcast_to_bn: bool,
|
||||
) -> impl futures::Future<Output = ()> + use<E, Hot, Cold> {
|
||||
let mock_el = self
|
||||
.mock_execution_layer
|
||||
.as_ref()
|
||||
@@ -727,6 +730,9 @@ where
|
||||
let (mock_builder, (addr, mock_builder_server)) = MockBuilder::new_for_testing(
|
||||
mock_el_url,
|
||||
beacon_url,
|
||||
strict_registrations,
|
||||
apply_operations,
|
||||
broadcast_to_bn,
|
||||
self.spec.clone(),
|
||||
self.runtime.task_executor.clone(),
|
||||
);
|
||||
@@ -903,8 +909,65 @@ where
|
||||
state: BeaconState<E>,
|
||||
slot: Slot,
|
||||
) -> (SignedBlindedBeaconBlock<E>, BeaconState<E>) {
|
||||
let (unblinded, new_state) = self.make_block(state, slot).await;
|
||||
((*unblinded.0).clone().into(), new_state)
|
||||
self.make_blinded_block_with_modifier(state, slot, |_| {})
|
||||
.await
|
||||
}
|
||||
|
||||
pub async fn make_blinded_block_with_modifier(
|
||||
&self,
|
||||
mut state: BeaconState<E>,
|
||||
slot: Slot,
|
||||
block_modifier: impl FnOnce(&mut BlindedBeaconBlock<E>),
|
||||
) -> (SignedBlindedBeaconBlock<E>, BeaconState<E>) {
|
||||
assert_ne!(slot, 0, "can't produce a block at slot 0");
|
||||
assert!(slot >= state.slot());
|
||||
|
||||
complete_state_advance(&mut state, None, slot, &self.spec)
|
||||
.expect("should be able to advance state to slot");
|
||||
|
||||
state.build_caches(&self.spec).expect("should build caches");
|
||||
|
||||
let proposer_index = state.get_beacon_proposer_index(slot, &self.spec).unwrap();
|
||||
|
||||
// If we produce two blocks for the same slot, they hash up to the same value and
|
||||
// BeaconChain errors out with `DuplicateFullyImported`. Vary the graffiti so that we produce
|
||||
// different blocks each time.
|
||||
let graffiti = Graffiti::from(self.rng.lock().random::<[u8; 32]>());
|
||||
|
||||
let randao_reveal = self.sign_randao_reveal(&state, proposer_index, slot);
|
||||
|
||||
// Always use the builder, so that we produce a "real" blinded payload.
|
||||
let builder_boost_factor = Some(u64::MAX);
|
||||
|
||||
let BeaconBlockResponseWrapper::Blinded(block_response) = self
|
||||
.chain
|
||||
.produce_block_on_state(
|
||||
state,
|
||||
None,
|
||||
slot,
|
||||
randao_reveal,
|
||||
Some(graffiti),
|
||||
ProduceBlockVerification::VerifyRandao,
|
||||
builder_boost_factor,
|
||||
BlockProductionVersion::V3,
|
||||
)
|
||||
.await
|
||||
.unwrap()
|
||||
else {
|
||||
panic!("Should always be a blinded payload response");
|
||||
};
|
||||
|
||||
let mut block = block_response.block;
|
||||
block_modifier(&mut block);
|
||||
|
||||
let signed_block = block.sign(
|
||||
&self.validator_keypairs[proposer_index].sk,
|
||||
&block_response.state.fork(),
|
||||
block_response.state.genesis_validators_root(),
|
||||
&self.spec,
|
||||
);
|
||||
|
||||
(signed_block, block_response.state)
|
||||
}
|
||||
|
||||
/// Returns a newly created block, signed by the proposer for the given slot.
|
||||
|
||||
Reference in New Issue
Block a user