# 0. JAM diagram **Reference: https://hackmd.io/@xlc/HydGnfZ8C** --- Alice send 10 DOT to Bob using Asset Hub parachain ```mermaid sequenceDiagram Alice ->> dApp: Sign & send tx balances.transfer(10 DOT, Bob) dApp ->> Asset Hub parachain: submit transaction Asset Hub parachain ->> Asset Hub parachain: produce block Asset Hub parachain ->> JAM chain: submit work JAM chain ->> Asset Hub parachain: para block validated Asset Hub parachain ->> dApp: tx confirmed JAM chain ->> Asset Hub parachain: para block finalized Asset Hub parachain ->> dApp: tx finalized dApp ->> Alice: done ``` ```mermaid sequenceDiagram box AssetHub participant RPC node/Light Client participant Collator node end box JAM chain participant Proxy node participant Validator node end RPC node/Light Client ->> Collator node: submit transaction Collator node ->> Collator node: produce block Collator node ->> RPC node/Light Client: new unconfirmed block Collator node ->> Validator node: submit work package Validator node ->> Validator node: produce work report (incore) Validator node ->> Validator node: accumlate work and produce new block (onchain) Validator node ->> Proxy node: notify new block Proxy node ->> Collator node: notify new JAM block Proxy node ->> RPC node/Light Client: notify new JAM block Collator node ->> Collator node: confirm block RPC node/Light Client ->> RPC node/Light Client: confirm block Validator node ->> Validator node: audit work Validator node ->> Validator node: finalize block Validator node ->> Proxy node: notify new finalized block Proxy node ->> Collator node: notify new finalized JAM block Proxy node ->> RPC node/Light Client: notify new finalized JAM block Collator node ->> Collator node: finalize block RPC node/Light Client ->> RPC node/Light Client: finalize block ``` ```mermaid sequenceDiagram participant Parachain A participant Parachain B Parachain A ->> Shared Collator: pending transactions Parachain B ->> Shared Collator: pending transactions Shared Collator ->> Shared Collator: PoV block for chain A Shared Collator ->> Shared Collator: PoV block for chain B Shared Collator ->> Guarantors: Work Package Imports DA ->> Guarantors: Import segments Guarantors ->> Guarantors: Refine to Work Result Guarantors ->> Guarantors: Chunk to segments Guarantors ->> Imports DA: Upload export segments and Work Result justification Guarantors ->> Audits DA: Upload Work Result justification Guarantors ->> Next Block Author: Guarantor signatures Next Block Author ->> Next Block Author: Accumulate work package Next Block Author ->> Next Block Author: Update state Next Block Author ->> Validators: New block Audits DA ->> Validators: Work Result justifications Validators ->> Validators: Audit work packages Validators ->> Next Block Author: Send judgements if needed Validators ->> Validators: Broadcast Grandpa message Validators ->> Validators: Finalize block Validators ->> Validators: Broadcast Beefy signature ``` ## Systems ```mermaid sequenceDiagram participant External participant Guaranteeing participant Imports DA participant Audits DA participant Auditing & Judgements participant Safrole participant STF participant Grandpa participant Beefy External ->> Guaranteeing: Work package Imports DA ->> Guaranteeing: Imported segments Guaranteeing ->> Imports DA: Exported segments Guaranteeing ->> Audits DA: Work Result Justifications Guaranteeing ->> STF: Guarantor signatures Imports DA ->> STF: Availability Safrole ->> Safrole: Select block authors Audits DA ->> Auditing & Judgements: Work Result Justifications Auditing & Judgements ->> Auditing & Judgements: Audit Work Results Auditing & Judgements ->> STF: Judgements Safrole ->> STF: Tickets STF ->> Grandpa: New block Grandpa ->> Grandpa: Finalzie block Grandpa ->> Beefy: New finalized block Beefy ->> External: Beefy signature ``` ## Networking Validators connects to each other Validators may connect to other proxy/full nodes Proxy nodes connects to each other Parachain nodes (RPC or collator or fullnode) connects proxy node Parachain nodes submit work to shared collator Shared collator connect to Proxy nodes ```graphviz digraph { Validator1 [shape=box] Validator2 [shape=box] Validator3 [shape=box] Validator4 [shape=box] "Chain A RPC/LightClient" [color=red,fontcolor=red] "Chain B RPC/LightClient" [color=purple,fontcolor=purple] dApp [color=blue,fontcolor=blue] "Shared Collator" [color=brown,fontcolor=brown] Validator1->Validator2 [dir=both] Validator1->Validator3 [dir=both] Validator1->Validator4 [dir=both] Validator2->Validator3 [dir=both] Validator2->Validator4 [dir=both] Validator3->Validator4 [dir=both] Proxy1->Validator1 [dir=both] Proxy2->Validator2 [dir=both] Proxy1->Proxy2 [dir=both] Proxy1->"Shared Collator" Proxy2->"Shared Collator" Proxy1->"Chain A RPC/LightClient" Proxy2->"Chain B RPC/LightClient" "Shared Collator"->"Chain A RPC/LightClient" [dir=both] "Shared Collator"->"Chain B RPC/LightClient" [dir=both] "Chain A RPC/LightClient"->dApp [dir=both] "Chain B RPC/LightClient"->dApp [dir=both] "Shared Collator"->Proxy1 "Shared Collator"->Proxy2 } ``` ## ==Join-Accumulate== Machine <!-- 越南人畫的架構圖 https://excalidraw.com/ --> - sharding (數據和工作切割) : part of Refine (==Join==) - 類似 Optimistic rollup (數據彙整) : part of ==Accumulate==,accumulation 的前置作業 > [name=yu2C] Optimistic or cynical rollup here? > [name=kk7]不完全是 optimistic rollup,只是類似 ![image](https://hackmd.io/_uploads/BkQ3FLJQ1x.png) - Work Package(block) 進入 JAM - PVM 負責 refine - Join is fn refine(), when all Polkadot cores do a lot of work, all in parallel, for different services. Join is when the data is distilled into a smaller subset, and is then passed onto the next stage.[reference](https://www.parity.io/blog/JAM-demystified-explainer) - Sharding 是鏈下進行,Optimisitic rollup 加上一個dispute 機制,一方面彙整數據,一方面驗證數據的正確性(on-chain, assuring, reporting)