-
Notifications
You must be signed in to change notification settings - Fork 0
CDCP Core Lib #9
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
base: main
Are you sure you want to change the base?
Changes from all commits
dc8d553
9219656
3098e7f
6596525
b434865
af59b02
b387094
05deb09
1f8c47a
6bad137
96f717a
4e6df41
b67e314
f16afce
b96001e
7c95866
397ad85
4597cc5
29572a9
b384351
6318cbc
09620b4
d180d98
8fefc57
90d7ea4
1480ead
6ea0acb
5814c6f
2c50d7d
9c26848
c787c13
2c679ab
9fc99f6
ed1922e
28b382a
03dafa1
2047756
bfa4f5b
dca0e01
f59c1ff
69cad85
82cdcd7
b2fb540
da998f2
438759c
2370e40
0794e98
e1166ec
2135f96
7513967
66bab2e
3b23404
015761b
2a2b6e6
3586694
882667e
c5f08ad
1452b93
bd161d8
b08aeb5
49647f2
4998334
0a5d814
eafc14b
ef208d8
ff18057
18478c6
4833bb3
201c4cc
34aa6e0
5e6b18b
c064476
d738783
7855cc0
84de545
1f49e15
89001bd
84d7483
8377c9a
495acaa
8e58dd4
a8fa96b
3ac7a6e
f65e0de
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||
|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,221 @@ | ||||||||
| # Cross-Domain Composability Protocol (CDCP) — Minimal Spec Implementation | ||||||||
|
|
||||||||
| This package provides a minimal, testable implementation of the [CDCP](./../../cross_domain_composability_protocol.md) protocol that coordinates atomic execution between Compose native rollups and an external rollup. | ||||||||
|
|
||||||||
| ## Publisher | ||||||||
|
|
||||||||
| The package exposes the `PublisherInstance` interface with the core logic for the CDCP publisher role. | ||||||||
| It requires the following implementation dependency: | ||||||||
| - `PublisherNetwork`: transports `StartInstance` to all participants, | ||||||||
| `NativeDecided` to the WS, and final `Decided` messages to all NSs. | ||||||||
|
|
||||||||
| And provides the following methods: | ||||||||
| - `Instance()`: returns the immutable `compose.Instance` metadata (ID, period, sequence number, chain list, request payload). | ||||||||
| - `DecisionState()`: returns the current decision state (`Pending`, `Accepted`, `Rejected`). | ||||||||
| - `Run()`: broadcasts the `StartInstance` message to every participant chain. | ||||||||
| - `ProcessVote(sender, vote)`: records votes from native chains only, rejecting duplicates and ignoring non-native senders. Any `false` vote immediately decides and broadcasts rejection while `true` votes from all natives trigger `NativeDecided(true)` to the WS. | ||||||||
| - `ProcessWSDecided(sender, decision)`: accepts exactly one decision from the ER chain. `false` finalizes the instance immediately (even if native votes are still missing); `true` is only valid after `NativeDecided(true)` has been sent and leads to acceptance. | ||||||||
| - `Timeout()`: if still waiting for native votes, decides rejection and emits both `Decided(false)` and `NativeDecided(false)`. | ||||||||
|
|
||||||||
| The publisher validates the instance at construction time: the ER chain must belong to the instance and there must be at least one native chain. | ||||||||
| Its state machine advances from WaitingVotes → WaitingWSDecided → Done, guarding impossible combinations (e.g. `WSDecided(true)` while still waiting for votes). | ||||||||
|
|
||||||||
| ```mermaid | ||||||||
| classDiagram | ||||||||
| direction TB | ||||||||
|
|
||||||||
| class PublisherInstance { | ||||||||
| +Instance() Instance | ||||||||
| +DecisionState() DecisionState | ||||||||
| +Run() | ||||||||
| +ProcessVote(ChainID, bool) error | ||||||||
| +ProcessWSDecided(ChainID, bool) error | ||||||||
| +Timeout() error | ||||||||
| } | ||||||||
|
|
||||||||
| class PublisherNetwork { | ||||||||
| <<interface>> | ||||||||
| +SendStartInstance(Instance) | ||||||||
| +SendNativeDecided(InstanceID, bool) | ||||||||
| +SendDecided(InstanceID, bool) | ||||||||
| } | ||||||||
|
|
||||||||
| class PublisherState { | ||||||||
| instance : Instance | ||||||||
| nativeChains : map[ChainID]struct | ||||||||
| erChainID : ChainID | ||||||||
| state : PublisherState | ||||||||
| decisionState : DecisionState | ||||||||
| votes : map[ChainID]bool | ||||||||
| wsDecision : *bool | ||||||||
| } | ||||||||
|
|
||||||||
| PublisherInstance --> PublisherNetwork | ||||||||
| PublisherInstance --> PublisherState | ||||||||
| ``` | ||||||||
|
|
||||||||
| ## Native Sequencer | ||||||||
|
|
||||||||
| Native sequencer behavior in CDCP is identical to the SCP sequencer role. | ||||||||
| `NewNativeSequencerInstance` simply proxies to `scp.NewSequencerInstance`, so implementers can reuse the same execution engine, network adapter, and VM snapshot logic described in [`scp`](./../scp/README.md). | ||||||||
|
|
||||||||
| ## Wrapped Sequencer | ||||||||
|
|
||||||||
| Wrapped sequencer (WS) logic is provided through the `WrappedSequencerInstance` interface. | ||||||||
| It orchestrates mailbox-aware simulations of the external rollup transactions, waits for the native decision, and interacts with the external rollup client to submit the canonical transaction. | ||||||||
| It requires the following implementation dependencies: | ||||||||
| - `WSExecutionEngine`: performs mailbox-aware simulations of `safe_execute`, returning read/write misses plus the produced mailbox messages. | ||||||||
| - `WSNetwork`: sends mailbox messages to native chains and reports `WSDecided` results back to the publisher. | ||||||||
| - `ERClient`: submits `safe_execute` on the external rollup once the native decision allows it. | ||||||||
|
|
||||||||
|
||||||||
| > **Note:** `safe_execute` is a Solidity function defined in the external rollup's smart contract. It is responsible for atomically executing cross-domain transactions according to the CDCP protocol. For details on its interface and behavior, see the [CDCP protocol specification](./../../cross_domain_composability_protocol.md) or the external rollup's contract source code. |
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.
The README references a file "./../../cross_domain_composability_protocol.md" that does not exist in the repository. This broken link will cause confusion for users trying to understand the protocol. Either add the missing documentation file or update the link to point to an existing resource that describes the CDCP protocol.