3

Approximately, what is the size of the state trie (in example on Polkadot for a recent block)?

For example how many nodes are in the trie? Even better would be the total bytes of node partial keys, and total bytes of node subvalues.

It might be possible to do this by inspecting the disk storage of substrate, but I thought someone could enlighten me with rough/approximate numbers, which could be useful to others.

Thanks!!

1

2 Answers 2

2

There is a pr open for sub-du. This will be able to output the size of the state. In the issue for this feature you see an example output of 2020:

60  M ├─┬ polkadot
55  M │ │─┬ Staking
28  M │ │ │─ ErasStakers => Map(29,915,344 bytes, 17691 keys)
20  M │ │ │─ ErasStakersClipped => Map(21,571,602 bytes, 17691 keys)
3   M │ │ │─ Ledger => Map(3,830,167 bytes, 10881 keys)
2   M │ │ │─ Nominators => Map(2,235,784 bytes, 8476 keys)
622 K │ │ │─ ErasRewardPoints => Map(637,242 bytes, 85 keys)
340 K │ │ │─ Bonded => Map(348,192 bytes, 10881 keys)
65  K │ │ │─ ErasValidatorPrefs => Map(67,533 bytes, 17691 keys)
17  K │ │ │─ Payee => Map(18,177 bytes, 10881 keys)
2   K │ │ │─ SpanSlash => Map(2,688 bytes, 84 keys)
2   K │ │ │─ Validators => Map(2,173 bytes, 580 keys)
1   K │ │ │─ SlashingSpans => Map(1,795 bytes, 103 keys)
1   K │ │ │─ ErasTotalStake => Map(1,360 bytes, 85 keys)
1   K │ │ │─ ErasValidatorReward => Map(1,344 bytes, 84 keys)
340 B │ │ │─ ErasStartSessionIndex => Map(340 bytes, 85 keys)
233 B │ │ │─ BondedEras => Value(233 bytes)
16  B │ │ │─ CanceledSlashPayout => Value(16 bytes)
13  B │ │ │─ ActiveEra => Value(13 bytes)
4   B │ │ │─ EarliestUnappliedSlash => Value(4 bytes)
4   B │ │ │─ SlashRewardFraction => Value(4 bytes)\
..
0

Not replying (I had the number last year while testing trie migration, but would not want to give a wrong one), but modifying https://github.com/paritytech/substrate/blob/master/utils/frame/rpc/state-trie-migration-rpc/src/lib.rs#L48 may be suited to count it (the whole trie state is iterated at node level but only count value items). related: https://github.com/paritytech/cumulus/pull/1424

I remember we also did export the whole state at a given block with try_runtime (querying rpc) but it can take a while.

Last idea to get a very rough number is to do a warpsync so only the state at the head of the chain will be in db (then looking at the size of the STATE column), note that the total size downloaded displayed while doing warpsync can be a little bigger than the size of the state because it dowloads chunks of proof size (so there is a small redundancy in node content between chunks).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.