Skip to content

Commit

Permalink
real slot begin timestamp
Browse files Browse the repository at this point in the history
  • Loading branch information
mskrzypkows committed Oct 2, 2024
1 parent 5b0f1af commit 2ac45f1
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
6 changes: 6 additions & 0 deletions Node/src/ethereum_l1/slot_clock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,12 @@ impl SlotClock {
Ok(start_of_slot.as_secs())
}

// returns real timestamp, the shift is reduced
pub fn get_real_slot_begin_timestamp_for_contract(&self, slot: Slot) -> Result<u64, Error> {
let start_of_slot = self.start_of(slot)? + self.slot_duration;
Ok(start_of_slot.as_secs())
}

pub fn get_epoch_for_timestamp(&self, timestamp: u64) -> Result<Epoch, Error> {
let slot = self.slot_of(Duration::from_secs(timestamp))?;
Ok(slot / self.slots_per_epoch)
Expand Down
5 changes: 4 additions & 1 deletion Node/src/node/operator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,10 @@ impl Operator {
}

pub fn get_lookahead_pointer(&mut self, slot: Slot) -> Result<u64, Error> {
let slot_begin_timestamp = self.ethereum_l1.slot_clock.start_of(slot)?.as_secs();
let slot_begin_timestamp = self
.ethereum_l1
.slot_clock
.get_real_slot_begin_timestamp_for_contract(slot)?;

let lookahead_pointer = self
.lookahead_preconfer_buffer
Expand Down

0 comments on commit 2ac45f1

Please sign in to comment.