mirror of
https://github.com/sigp/lighthouse.git
synced 2026-05-08 09:16:00 +00:00
Ensure harness produces block before attestations.
This commit is contained in:
@@ -97,7 +97,9 @@ impl BeaconChainHarness {
|
|||||||
/// Move the `slot_clock` for the `BeaconChain` forward one slot.
|
/// Move the `slot_clock` for the `BeaconChain` forward one slot.
|
||||||
///
|
///
|
||||||
/// This is the equivalent of advancing a system clock forward one `SLOT_DURATION`.
|
/// This is the equivalent of advancing a system clock forward one `SLOT_DURATION`.
|
||||||
pub fn increment_beacon_chain_slot(&mut self) {
|
///
|
||||||
|
/// Returns the new slot.
|
||||||
|
pub fn increment_beacon_chain_slot(&mut self) -> u64 {
|
||||||
let slot = self
|
let slot = self
|
||||||
.beacon_chain
|
.beacon_chain
|
||||||
.present_slot()
|
.present_slot()
|
||||||
@@ -107,6 +109,7 @@ impl BeaconChainHarness {
|
|||||||
debug!("Incrementing BeaconChain slot to {}.", slot);
|
debug!("Incrementing BeaconChain slot to {}.", slot);
|
||||||
|
|
||||||
self.beacon_chain.slot_clock.set_slot(slot);
|
self.beacon_chain.slot_clock.set_slot(slot);
|
||||||
|
slot
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Gather the `FreeAttestation`s from the valiators.
|
/// Gather the `FreeAttestation`s from the valiators.
|
||||||
@@ -151,6 +154,8 @@ impl BeaconChainHarness {
|
|||||||
proposer, present_slot
|
proposer, present_slot
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// Ensure the validators slot clock is accurate.
|
||||||
|
self.validators[proposer].set_slot(present_slot);
|
||||||
self.validators[proposer].produce_block().unwrap()
|
self.validators[proposer].produce_block().unwrap()
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -160,16 +165,20 @@ impl BeaconChainHarness {
|
|||||||
/// validators.
|
/// validators.
|
||||||
pub fn advance_chain_with_block(&mut self) {
|
pub fn advance_chain_with_block(&mut self) {
|
||||||
self.increment_beacon_chain_slot();
|
self.increment_beacon_chain_slot();
|
||||||
let free_attestations = self.gather_free_attesations();
|
|
||||||
for free_attestation in free_attestations {
|
// Produce a new block.
|
||||||
self.beacon_chain
|
|
||||||
.process_free_attestation(free_attestation.clone())
|
|
||||||
.unwrap();
|
|
||||||
}
|
|
||||||
let block = self.produce_block();
|
let block = self.produce_block();
|
||||||
debug!("Submitting block for processing...");
|
debug!("Submitting block for processing...");
|
||||||
self.beacon_chain.process_block(block).unwrap();
|
self.beacon_chain.process_block(block).unwrap();
|
||||||
debug!("...block processed by BeaconChain.");
|
debug!("...block processed by BeaconChain.");
|
||||||
|
|
||||||
|
// Produce new attestations.
|
||||||
|
let free_attestations = self.gather_free_attesations();
|
||||||
|
for free_attestation in free_attestations {
|
||||||
|
self.beacon_chain
|
||||||
|
.process_free_attestation(free_attestation)
|
||||||
|
.unwrap();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn chain_dump(&self) -> Result<Vec<SlotDump>, DumpError> {
|
pub fn chain_dump(&self) -> Result<Vec<SlotDump>, DumpError> {
|
||||||
|
|||||||
Reference in New Issue
Block a user