Skip to content

Commit

Permalink
Remove duplicate slot_clock method (#2842)
Browse files Browse the repository at this point in the history
  • Loading branch information
paulhauner committed Dec 1, 2021
1 parent 4760ffd commit 4f480ef
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 11 deletions.
3 changes: 2 additions & 1 deletion beacon_node/beacon_chain/src/execution_payload.rs
Expand Up @@ -168,7 +168,8 @@ pub fn validate_execution_payload_for_gossip<T: BeaconChainTypes>(
if is_merge_complete || execution_payload != &<_>::default() {
let expected_timestamp = chain
.slot_clock
.compute_timestamp_at_slot(block.slot())
.start_of(block.slot())
.map(|d| d.as_secs())
.ok_or(BlockError::BeaconChainError(
BeaconChainError::UnableToComputeTimeAtSlot,
))?;
Expand Down
10 changes: 0 additions & 10 deletions common/slot_clock/src/lib.rs
Expand Up @@ -102,14 +102,4 @@ pub trait SlotClock: Send + Sync + Sized + Clone {
fn sync_committee_contribution_production_delay(&self) -> Duration {
self.slot_duration() * 2 / 3
}

/// An implementation of the method described in the consensus spec here:
///
/// https://github.com/ethereum/consensus-specs/blob/dev/specs/merge/beacon-chain.md#compute_timestamp_at_slot
fn compute_timestamp_at_slot(&self, slot: Slot) -> Option<u64> {
let slots_since_genesis = slot.as_u64().checked_sub(self.genesis_slot().as_u64())?;
slots_since_genesis
.checked_mul(self.slot_duration().as_secs())
.and_then(|since_genesis| self.genesis_duration().as_secs().checked_add(since_genesis))
}
}

0 comments on commit 4f480ef

Please sign in to comment.