Skip to content

Commit

Permalink
Improve ledger header diagram, minimize discussion of skiplist which …
Browse files Browse the repository at this point in the history
…is unused (and broken)
  • Loading branch information
graydon committed Dec 20, 2024
1 parent 9d3ed91 commit bc26526
Showing 1 changed file with 40 additions and 8 deletions.
48 changes: 40 additions & 8 deletions docs/learn/encyclopedia/network-configuration/ledger-headers.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,49 @@ title: Ledger Headers
sidebar_position: 30
---

Every ledger has a header that references the data in that ledger and the previous ledger. These references are cryptographic hashes of the content which behave like pointers in typical data structures but with added security guarantees. Think of a historical ledger chain as a linked list of ledger headers:
Every ledger has a header that references the data in that ledger and the previous ledger.
These references are cryptographic hashes of the content which behave like pointers in typical data structures but with added security guarantees.
Think of a historical ledger chain as a linked list of ledger headers.
Time flows forward from left to right, hashes point backwards in time, from right to left.
Each hash in the chain links a ledger to its previous ledger, which authenticates the entire history of ledgers in its past:

```mermaid
stateDiagram
direction LR
Genesis --> LedgerHeader_1
LedgerHeader_1 --> ...
... --> LedgerHeader_n
flowchart RL
subgraph genesis["Genesis"]
direction LR
prev1["Prev: none"]
state1["Genesis state"]
end
subgraph block2["Ledger 2"]
prev2["Prev: hash(Genesis)"]
state2["Ledger 2<br/>transactions<br/>and state"]
end
subgraph block3["Ledger 3"]
prev3["Prev: hash(Ledger 2)"]
state3["Ledger 3<br/>transactions<br/>and state"]
end
subgraph dotdot["..."]
end
subgraph blockn["Ledger N"]
prevn["Prev: hash(Ledger N-1)"]
staten["Ledger N<br/>transactions<br/>and state"]
end
genesis ~~~ block2 ~~~ block3 ~~~ dotdot ~~~ blockn
prev2 --> genesis
prev3 --> block2
dotdot --> block3
prevn --> dotdot
```

The genesis ledger has a sequence number of 1. The ledger directly following a ledger with sequence number n has a sequence number of n+1.
The genesis ledger has a sequence number of 1. The ledger directly following a ledger with sequence number `N` has a sequence number of `N+1`.
Ledger `N+1` contains a hash of ledger `N` in its previous ledger field.

## Ledger header fields

Expand Down Expand Up @@ -83,4 +115,4 @@ The reserve the network uses when calculating an account’s minimum balance.

### Skip list

Hashes of ledgers in the past. Allows you to jump back in time in the ledger chain without walking back ledger by ledger. There are four ledger hashes stored in the skip list. Each slot contains the oldest ledger that is mod of either 50 5000 50000 or 500000 depending on index skipList[0] mod(50), skipList[1] mod(5000), etc.
Hashes of ledgers in the past. Intended to accelerate access to past ledgers without walking back ledger by ledger. Currently unused.

0 comments on commit bc26526

Please sign in to comment.