Skip to main content

Persistent States

Nodes store snapshots of states of the blockchain periodically. Each state is created at some masterchain block and has some TTL. The block and TTL are chosen using the following algorithm:

Only key blocks can be chosen. A block has some timestamp ts. There are periods of time of length 2^17 seconds (approximately up to 1.5 days). The period of a block with timestamp ts is x = floor(ts / 2^17). The first key block from each period is chosen to create a persistent state.

TTL of a state from period x is equal to 2^(18 + ctz(x)), where ctz(x) is the number of trailing zeroes in the binary representation of x (i.e. the largest y such that x is divisible by 2^y).

That means that persistent states are created every 1.5 days, half of them have TTL of 2^18 seconds (3 days), half of the remaining states have TTL of 2^19 seconds (6 days) and so on.

In 2022 there is the following long-term (at least 3 months) persistent states (times in the future are approximate):

Block seqnoBlock timeTTLExpires at
181553292022-02-07 01:31:53777 days2024-03-24 18:52:57
193654222022-03-27 14:36:5897 days2022-07-02 16:47:06
2022-05-14 20:00:00194 days2022-11-24 23:00:00
2022-07-02 09:00:0097 days2022-10-07 10:00:00
2022-08-19 22:00:00388 days2023-09-12 06:00:00
2022-10-07 11:00:0097 days2023-01-12 12:00:00
2022-11-25 00:00:00194 days2023-06-07 03:00:00
2022-11-25 00:00:00194 days2023-06-07 03:00:00
277470862022-03-02 05:08:111553 days2027-06-02 18:50:19

When the node starts for the first time, it has to download a persistent state. This is implemented in validator/manager-init.cpp.

Starting from the init block, the node downloads all newer key blocks. It selects the most recent key block with a persistent state which still exists (using the formula above), and then downloads the corresponding masterchain state and states for all shards (or only the shards that are required for this node).