Set BeaconChain present_slot
to read from state.
It used to read from the slot_clock, that has been replaced with `read_slot_clock`.
This commit is contained in:
parent
92753fa24e
commit
d50a8b03f8
@ -29,7 +29,6 @@ pub enum Outcome {
|
||||
pub enum Error {
|
||||
DBError(String),
|
||||
UnableToDecodeBlock,
|
||||
PresentSlotIsNone,
|
||||
SlotClockError(SystemTimeSlotClockError),
|
||||
MissingParentState(Hash256),
|
||||
InvalidParentState(Hash256),
|
||||
@ -57,25 +56,19 @@ where
|
||||
.ok_or(Error::UnableToDecodeBlock)?;
|
||||
let block_root = block.canonical_root();
|
||||
|
||||
let present_slot = self
|
||||
.slot_clock
|
||||
.present_slot()?
|
||||
.ok_or(Error::PresentSlotIsNone)?;
|
||||
let present_slot = self.present_slot();
|
||||
|
||||
// Block from future slots (i.e., greater than the present slot) should not be processed.
|
||||
if block.slot() > present_slot {
|
||||
return Ok(Outcome::InvalidBlock(InvalidBlock::FutureSlot));
|
||||
}
|
||||
|
||||
let parent_block_root = block.parent_root();
|
||||
|
||||
let parent_block = self
|
||||
.block_store
|
||||
.get_reader(&parent_block_root)?
|
||||
.ok_or(Error::MissingParentBlock(parent_block_root))?;
|
||||
|
||||
let parent_state_root = parent_block.state_root();
|
||||
|
||||
let parent_state = self
|
||||
.state_store
|
||||
.get_reader(&parent_state_root)?
|
||||
|
@ -35,13 +35,17 @@ where
|
||||
}
|
||||
}
|
||||
|
||||
pub fn present_slot(&self) -> Option<u64> {
|
||||
pub fn read_slot_clock(&self) -> Option<u64> {
|
||||
match self.slot_clock.present_slot() {
|
||||
Ok(some_slot) => some_slot,
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn present_slot(&self) -> u64 {
|
||||
self.state.read().slot
|
||||
}
|
||||
|
||||
pub fn block_proposer(&self, slot: u64) -> Result<usize, CommitteesError> {
|
||||
let index = self
|
||||
.state
|
||||
|
@ -104,11 +104,7 @@ impl BeaconChainHarness {
|
||||
///
|
||||
/// Returns the new slot.
|
||||
pub fn increment_beacon_chain_slot(&mut self) -> u64 {
|
||||
let slot = self
|
||||
.beacon_chain
|
||||
.present_slot()
|
||||
.expect("Unable to determine slot.")
|
||||
+ 1;
|
||||
let slot = self.beacon_chain.present_slot() + 1;
|
||||
|
||||
debug!("Incrementing BeaconChain slot to {}.", slot);
|
||||
|
||||
@ -122,7 +118,7 @@ impl BeaconChainHarness {
|
||||
/// Note: validators will only produce attestations _once per slot_. So, if you call this twice
|
||||
/// you'll only get attestations on the first run.
|
||||
pub fn gather_free_attesations(&mut self) -> Vec<FreeAttestation> {
|
||||
let present_slot = self.beacon_chain.present_slot().unwrap();
|
||||
let present_slot = self.beacon_chain.present_slot();
|
||||
|
||||
let attesting_validators = self
|
||||
.beacon_chain
|
||||
@ -169,7 +165,7 @@ impl BeaconChainHarness {
|
||||
/// Note: the validator will only produce it _once per slot_. So, if you call this twice you'll
|
||||
/// only get a block once.
|
||||
pub fn produce_block(&mut self) -> BeaconBlock {
|
||||
let present_slot = self.beacon_chain.present_slot().unwrap();
|
||||
let present_slot = self.beacon_chain.present_slot();
|
||||
|
||||
let proposer = self.beacon_chain.block_proposer(present_slot).unwrap();
|
||||
|
||||
@ -210,13 +206,6 @@ impl BeaconChainHarness {
|
||||
});
|
||||
|
||||
debug!("Free attestations processed.");
|
||||
/*
|
||||
for free_attestation in free_attestations {
|
||||
self.beacon_chain
|
||||
.process_free_attestation(free_attestation)
|
||||
.unwrap();
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
pub fn chain_dump(&self) -> Result<Vec<SlotDump>, DumpError> {
|
||||
|
Loading…
Reference in New Issue
Block a user