Storage Layout of zkBNB
Table
Account
: record account related informationAccount History
: record the historical change information of the accountAsset
: record Asset related informationBlock Witness
: record the information about the generated WitnessL1 Rollup Tx
: record transaction information from L1L1 Synced Block
: record block information from L1Compressed Block
: record other information of L2 blockBlock
: record L2 block informationPool Tx
: record pending and executed but not packed Tx messagesL2 NFT
: record NFT related informationL2 NFT History
: record the historical status change information of NFTPriority Request
: record Priority Request information from L1Proof
: record the Proof information generated by the circuitSys Config
: store system variablesTx
: record transaction information on L2Tx Detail
: record detailed transaction information on L2
Tree
There are 4 types of trees in the system.
- Account Tree
- Account Asset Tree
- NFT Tree
Account Tree
The AccountNameHash
, PublicKey
, Nonce
, CollectionNonce
, AccountAssetTree.Root()
of each Account will be calculated as a hash and written into the tree corresponding to the AccountID
.
Used to record and save account status under each block height.
Account Asset Tree
Each Account will maintain an Asset tree, the Balance
, LpAmount
, and OfferCanceledOrFinalized
of each Asset will be calculated as a hash and written into the tree corresponding to the AssetID
.
NFT Tree
The CreatorAccountIndex
, OwnerAccountIndex
, NftContentHash
, NftL1Address
, NftL1TokenId
, CreatorTreasuryRate
, and CollectionId
of each nft resource will be calculated as a hash and written into the tree corresponding to the NftIndex
.
Used to record and save nft status under each block height.
Physical Storage
The Tree in ZkBNB
uses the Sparse Merkle Tree (SMT) structure. In order to optimize the storage space as much as possible, we have implemented a SMT library, compressing the four-layer tree structure into one layer, reducing the depth of the tree and achieving a higher level. storage space usage.
Find More: https://github.com/bnb-chain/zkbnb-smt/blob/master/docs/design.md