-
Notifications
You must be signed in to change notification settings - Fork 188
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
doc(katana): db table layout #1442
Conversation
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"
|
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #1442 +/- ##
=======================================
Coverage 67.62% 67.62%
=======================================
Files 218 218
Lines 21060 21060
=======================================
Hits 14242 14242
Misses 6818 6818 ☔ View full report in Codecov by Sentry. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for this effort, it gaves a good graphical overview of the work done on the database.
- I suggest to homogenize the entity names (and this tables name) at singular instead of plural.
- For the relationship same thing, ensuring we've a verb and consistent way to describe them. BlockHash to BlockNumber may be something like "Maps to" for instance.
The entity names are the actual table names. Unless you're suggesting that we should update the table names as well, I don't think the entity names should be different than what it's trying to represent as the diagram it just trying to explain logically how the table data are related. Lmk what you think on this.
Make sense. I had no idea what to put so just wrote |
Yep I'll be supportive of rewording yes, but that can be done in a code refacto in subsequent work as it's also code related as you mentioned. |
singularizing the table names would be sorta conflicting with some of the primitive types that are used as the tables' value (eg I think having plural name for db tables is a pretty common convention. It is also a convention used by |
Thanks for the feedback and context, good point. |
Initial effort in improving documentations for
katana
. This adds an ER diagram loosely representing the logical model ofkatana
's DB table schema using mermaid diagram so it can be easily embedded in markdown.Disclaimer: This is my first ERD in a long time, so I'm definitely not sure whether it is correctly visualizing the tables relations with one another.