diff --git a/design/architecture/db_schema.png b/design/architecture/db_schema.png index d0e162451e..9f53639295 100644 Binary files a/design/architecture/db_schema.png and b/design/architecture/db_schema.png differ diff --git a/design/architecture/db_schema.puml b/design/architecture/db_schema.puml index 9266d65f93..86f20a273f 100644 --- a/design/architecture/db_schema.puml +++ b/design/architecture/db_schema.puml @@ -1,175 +1,112 @@ @startuml -' avoid problems with angled crows feet -skinparam linetype ortho - -package "Batch Execution" as BE #LightYellow{ - -note as N0 - This section is populated - when a batch is processed. -end note - -note as N1 - There can be multiple - sibling batches, but - they will always - share a body. -end note -note as N2 - The same transaction can be part - of multiple reorged sibling batches, - and generate different receipts and events. -end note - -note as N3 - Transactions can be bound - to a batch body only. -end note +!theme plain +top to bottom direction +skinparam linetype ortho +class attestation_key { + party: binary(20) + ky: binary(33) } - -package "Block Submission" as BS #LightBlue{ -note as N4 - This section is populated - when an L1 block is processed. - The logic will store the rollups - and the cross chain messages. - It will also mark "is_canonical" - when there are reorgs. -end note - -note as N6 -Add constraint on -block(is_canonical, height) -end note - +class batch { + converted_hash: binary(32) + hash: binary(32) + height: int + is_canonical: boolean + header: blob + l1_proof_hash: binary(32) + l1_proof: integer + is_executed: boolean + sequence: int } - -package "Config" as C #LightGreen{ -note as N5 - This table contains general - information like the shared secret, - the attestation, etc. -end note - +class block { + hash: binary(32) + is_canonical: boolean + header: blob + height: int + id: integer } - -package "Key Value" as KV { -note as N7 -This is where the stateDB lives. -Maybe some stuff needed by the embedded geth. -end note +class config { + val: mediumblob + ky: varchar(64) } - -entity "Batch" as BE.batch { - *batchHash : binary(32) - -- - sequence : int - height : int - is_canonical : boolean - source : P2P/ROLLUP - header : string - *l1Proof : binary(32) <> - *bodyHash : binary(32) <> - *parentHash : binary(32) <> +class contract { + address: binary(20) + owner: int + id: integer } - -entity "Batch Body" as BE.batch_body { - *bodyHash : binary(32) - -- - content : mediumblob +class event_log { + event_type: integer + topic1: integer + topic2: integer + topic3: integer + datablob: mediumblob + log_idx: integer + receipt: integer + id: integer } - -entity "Transaction" as BE.tx { - *txHash : binary(32) - -- - content : binary - senderAddress : binary(20) - nonce : int - idx : int - *bodyHash : binary(32) <> +class event_topic { + topic: binary(32) + rel_address: integer + id: integer } - -entity "Executed Transaction" as BE.exec_tx { - *execTxId : number <> - -- - createdContractAddress : binary(32) - receipt : mediumblob - *txHash : binary(32) <> - *batchHash : binary(32) <> +class event_type { + contract: integer + event_sig: binary(32) + lifecycle_event: boolean + id: integer } - -entity "Event" as BE.event { - -- - topic0 : binary(32) - topic1 : binary(32) - topic2 : binary(32) - topic3 : binary(32) - topic4 : binary(32) - datablob : mediumblob - logIdx : int - address : binary(32) - lifecycleEvent : boolean - relAddress1 : binary(20) - relAddress2 : binary(20) - relAddress3 : binary(20) - relAddress4 : binary(20) - *execTxId : number <> +class externally_owned_account { + address: binary(20) + id: integer } - -entity "Block" as BS.block { - *blockHash : binary(32) - -- - *parentHash : binary(32) <> - is_canonical : boolean - height : int - header : string +class keyvalue { + ky: varbinary(64) + val: mediumblob + id: integer } - -entity "L1 Message" as BS.l1_msg{ - __ - message : mediumblob - *blockHash : binary(32) <> +class l1_msg { + message: varbinary(1024) + block: integer + is_transfer: boolean + id: integer } - -entity "Rollup" as BS.rollup { - *rollupHash : binary(32) - -- - start_seq : int - end_seq : int - *blockHash : binary(32) <> +class receipt { + content: mediumblob + tx: integer + batch: integer + id: integer } - -entity "Config" as C.cfg{ - *key : string - -- - value : binary +class rollup { + hash: binary(32) + start_seq: int + end_seq: int + time_stamp: int + header: blob + compression_block: integer + id: integer } - -entity "KeyValue" as KV.kv{ - *key : binary - -- - value : binary +class tx { + hash: binary(32) + content: mediumblob + sender_address: int + idx: int + batch_height: int + id: integer } - - -batch_body ||..o{ tx : included in -batch_body ||..|{ batch -block ||..|{ batch : L1 proof -block ||..|{ rollup : Published in -exec_tx ||..|{ event -batch ||..|{ exec_tx -tx ||..|{ exec_tx -block ||..o{ l1_msg -block ||..|{ block -batch ||..|{ batch - - -batch_body .. N1 -exec_tx .. N2 -tx .. N3 -block .. N6 - -@enduml \ No newline at end of file +batch -[#595959,plain]-^ block : "l1_proof:id" +contract -[#595959,plain]-^ externally_owned_account : "owner:id" +event_log -[#595959,plain]-^ event_topic : "topic2:id" +event_log -[#595959,plain]-^ event_topic : "topic1:id" +event_log -[#595959,plain]-^ event_topic : "topic3:id" +event_log -[#595959,plain]-^ event_type : "event_type:id" +event_log -[#595959,plain]-^ receipt : "receipt:id" +event_topic -[#595959,plain]-^ externally_owned_account : "rel_address:id" +event_type -[#595959,plain]-^ contract : "contract:id" +l1_msg -[#595959,plain]-^ block : "block:id" +receipt -[#595959,plain]-^ batch : "batch:sequence" +receipt -[#595959,plain]-^ tx : "tx:id" +rollup -[#595959,plain]-^ block : "compression_block:id" +tx -[#595959,plain]-^ externally_owned_account : "sender_address:id" +@enduml