I've seen a few discussions pointing out that in a year Solana's ledger grows up by ~2Tb.
However, Solana produces ~2 blocks per second with an average size of 1.5Mb (taken from getBlock
RPC request), resulting in whooping 100Tb per year. So I assume that ledger stores state differently? And, if so, how can I get a complete ledger history and its current size.
1 Answer
This depends on your definition of what data is part of the blockchain and on your method to calculate that size.
Data Categories
- Accounts, persistent data entries that programs own and access. Every full node keeps a copy of the latest versions of all accounts.
- Entries (transaction or wall clock tick); These determine the blockhash and are most likely what you are looking for.
- Transaction receipts which include detailed information about transaction executions (logs, CPIs, compute units spent, etc).
Common data stores
As of now, this data is stored in a few ways. Each database/file format requires different amounts of space to store the same data.
- Full/validator nodes store the latest accounts in a custom AppendVec files; and recent transactions and receipts in the blockstore RocksDB database.
- Various Bigtable databases store all transactions and all receipts in the bincode or solana-storage-proto Protobuf formats
- Custom specialized databases (e.g. explorers) may store historical versions of accounts
Accurate solution
If we define "blockchain size" as "the size of all transactions in bincode-encoding", which is the encoding used for consensus (PoH). Here is a possible way to create an accurate calculation:
- For every slot number:
- Use the
getBlock()
RPC to retrieve all transactions at that slot - Convert each transaction to a
VersionedTransaction
- Serialize transaction using
bincode::serialize
- Count bytes
- Use the
Estimates
Some simpler ways to estimate blockchain data is to look at the sizes of data stores. Estimates as of 2022-07:
- Recent account snapshot (compressed): ~30 GB
- Recent account snapshot (uncompressed): ~100 GB
- All transactions: tens of TB
- All historical account versions (corresponds to an Ethereum archive node): hundreds of TB
-
Where can I look up the sizes of current data stores? Also how much space it would require to store all data from the genesis block to be used by RPC Server? As a server seems to store both receipts and entries while ignoring historical account versions, so it doesn't seem to fit any of the given estimates (first + third?). Commented Jul 27, 2022 at 23:40
-
I'm not sure that it's possible to store all transactions on an RPC node. The blockstore database was not designed for such an amount of data.– terorieCommented Jul 28, 2022 at 10:22
-
1yes, then you can use Google Cloud APIs to get an estimate for the BigTable database size. As mentioned, this number is not the true size of the blockchain. You can either create your own Bigtable database or seek access from entities that host a full copy (Solana Foundation, Triton One)– terorieCommented Jul 28, 2022 at 10:28
-
1I see, thank you! There is also one tangential question of whether HDD write speed is enough for storing all new ledger data, generated by Solana Commented Jul 28, 2022 at 10:55
-
1@RowanStone When just logging transactions in a serial manner, HDDs will be performant enough to keep up. Anything that requires random write (e.g. indexing by signature), probably not.– terorieCommented Jul 28, 2022 at 10:57