-
Notifications
You must be signed in to change notification settings - Fork 182
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
doc(katana): db table layout (#1442)
Initial effort in improving documentations for katana. This adds an ER diagram loosely representing the logical model of katana's DB table schema using mermaid diagram so it can be easily embedded in markdown.
- Loading branch information
Showing
1 changed file
with
153 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,153 @@ | ||
# Database | ||
|
||
## Table layout | ||
|
||
```mermaid | ||
erDiagram | ||
Headers { | ||
KEY BlockNumber | ||
VALUE Header | ||
} | ||
BlockHashes { | ||
KEY BlockNumber | ||
VALUE BlockHash | ||
} | ||
BlockNumbers { | ||
KEY BlockHash | ||
VALUE BlockNumber | ||
} | ||
BlockStatusses { | ||
KEY BlockNumber | ||
VALUE FinalityStatus | ||
} | ||
BlockBodyIndices { | ||
KEY BlockNumber | ||
VALUE StoredBlockBodyIndices | ||
} | ||
TxNumbers { | ||
KEY TxHash | ||
VALUE TxNumber | ||
} | ||
TxHashes { | ||
KEY TxNumber | ||
VALUE TxHash | ||
} | ||
Transactions { | ||
KEY TxNumber | ||
VALUE Tx | ||
} | ||
TxBlocks { | ||
KEY TxNumber | ||
VALUE BlockNumber | ||
} | ||
Receipts { | ||
KEY TxNumber | ||
VALUE Receipt | ||
} | ||
CompiledClassHashes { | ||
KEY ClassHash | ||
VALUE CompiledClassHash | ||
} | ||
CompiledContractClasses { | ||
KEY ClassHash | ||
VALUE StoredContractClass | ||
} | ||
SierraClasses { | ||
KEY ClassHash | ||
VALUE FlattenedSierraClass | ||
} | ||
ContractInfo { | ||
KEY ContractAddress | ||
VALUE GenericContractInfo | ||
} | ||
ContractStorage { | ||
KEY ContractAddress | ||
DUP_KEY StorageKey | ||
VALUE StorageEntry | ||
} | ||
ClassDeclarationBlock { | ||
KEY ClassHash | ||
VALUE BlockNumber | ||
} | ||
ClassDeclarations { | ||
KEY BlockNumber | ||
DUP_KEY ClassHash | ||
VALUE ClassHash | ||
} | ||
ContractInfoChangeSet { | ||
KEY ContractAddress | ||
VALUE ContractInfoChangeList | ||
} | ||
NonceChanges { | ||
KEY BlockNumber | ||
DUP_KEY ContractAddress | ||
VALUE ContractNonceChange | ||
} | ||
ContractClassChanges { | ||
KEY BlockNumber | ||
DUP_KEY ContractAddress | ||
VALUE ContractClassChange | ||
} | ||
StorageChangeSet { | ||
KEY ContractAddress | ||
DUP_KEY StorageKey | ||
VALUE StorageEntryChangeList | ||
} | ||
StorageChanges { | ||
KEY BlockNumber | ||
DUP_KEY ContractStorageKey | ||
VALUE ContractStorageEntry | ||
} | ||
BlockHashes ||--|| BlockNumbers : "block id" | ||
BlockNumbers ||--|| BlockBodyIndices : "has" | ||
BlockNumbers ||--|| Headers : "has" | ||
BlockNumbers ||--|| BlockStatusses : "has" | ||
BlockBodyIndices ||--o{ Transactions : "block txs" | ||
TxHashes ||--|| TxNumbers : "tx id" | ||
TxNumbers ||--|| Transactions : "has" | ||
TxBlocks ||--|{ Transactions : "tx block" | ||
Transactions ||--|| Receipts : "each tx must have a receipt" | ||
CompiledClassHashes ||--|| CompiledContractClasses : "has" | ||
CompiledClassHashes ||--|| SierraClasses : "has" | ||
SierraClasses |o--|| CompiledContractClasses : "has" | ||
ContractInfo ||--o{ ContractStorage : "a contract storage slots" | ||
ContractInfo ||--|| CompiledClassHashes : "has" | ||
ContractInfo }|--|{ ContractInfoChangeSet : "has" | ||
ContractStorage }|--|{ StorageChangeSet : "has" | ||
ContractInfoChangeSet }|--|{ NonceChanges : "has" | ||
ContractInfoChangeSet }|--|{ ContractClassChanges : "has" | ||
CompiledClassHashes ||--|| ClassDeclarationBlock : "has" | ||
ClassDeclarationBlock ||--|| ClassDeclarations : "has" | ||
BlockNumbers ||--|| ClassDeclarations : "" | ||
StorageChangeSet }|--|{ StorageChanges : "has" | ||
``` |