Skip to content

Commit

Permalink
Add Genesis Slot to timestamp-slot conversion
Browse files Browse the repository at this point in the history
  • Loading branch information
PhilippGackstatter committed Nov 29, 2023
1 parent 97405b8 commit 65a3cc5
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions tips/TIP-0046/tip-0046.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,14 +67,14 @@ slots and each slot is `Slot Duration In Seconds` seconds in length.
### Slot Index

Each slot has a corresponding slot index, which is a `uint32`. To calculate the slot index of a timestamp, the protocol
parameters `Genesis Unix Timestamp` and `Slot Duration In Seconds` are used. The slot index of a Unix timestamp
`Unix Timestamp` (in seconds) is calculated as follows:
parameters `Genesis Slot`, `Genesis Unix Timestamp` and `Slot Duration In Seconds` are used. The slot index of a Unix
timestamp `Unix Timestamp` (in seconds) is calculated as follows:

- Compute `Elapsed Time` as `Unix Timestamp - Genesis Unix Timestamp`.
- If `Elapsed Time < 0`, the slot index is `0`.
- Otherwise the slot index is `Elapsed Time/Slot Duration In Seconds + 1`.
- Note: The `+ 1` is required because slots are counted starting from `1` with `0` being reserved for times before the
genesis, which has to be addressable as its own slot.
- If `Elapsed Time < 0`, the slot index is `Genesis Slot`.
- Otherwise the slot index is `Genesis Slot + Elapsed Time/Slot Duration In Seconds + 1`.
- Note: The `+ 1` is required because slots are counted starting from `1`. `0` is reserved for times before the
genesis (if `Genesis Slot = 0`), which has to be addressable as its own slot.

### Epoch Index

Expand Down

0 comments on commit 65a3cc5

Please sign in to comment.