Skip to content

Commit a4c7665

Browse files
committed
clarify contract structure
1 parent 915414e commit a4c7665

2 files changed

Lines changed: 41 additions & 26 deletions

File tree

specs/channel_api_contract.qnt

Lines changed: 35 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@
99
// Models what the Malachite team would publish for applications to consume.
1010
//
1111
// This contract defines:
12-
// 1. The request types for the Channel API
13-
// 2. Safety guarantees (agreement, validity)
14-
// 3. Ordering guarantees (declarative properties over request histories)
15-
// 4. Assumptions (what the application must do for guarantees to hold)
12+
// 1. The request/response types for the Channel API
13+
// 2. Component guarantees (Malachite → requests): safety + ordering
14+
// 3. Application guarantees (Emerald → responses): informal, to be formalized
15+
// 4. Environment assumptions
1616
//
1717
// Both safety and ordering properties are checked as invariants on any
1818
// conforming generator (e.g., channel_api_generator.qnt). The generator
@@ -148,8 +148,11 @@ module channel_api_contract {
148148
}
149149

150150
// ===========================================================================
151-
// SAFETY PROPERTIES
151+
// COMPONENT GUARANTEES: SAFETY
152152
// ===========================================================================
153+
//
154+
// Properties on the requests Malachite sends. These are guarantees that
155+
// Malachite provides to any application consuming the Channel API.
153156

154157
// Agreement: For any two Decided requests across all nodes, if they are for
155158
// the same height, the decided proposals must be identical.
@@ -247,13 +250,14 @@ module channel_api_contract {
247250
}
248251

249252
// ===========================================================================
250-
// ORDERING PROPERTIES
253+
// COMPONENT GUARANTEES: ORDERING
251254
// ===========================================================================
252255
//
253-
// These properties constrain the order in which Channel API requests are
254-
// delivered to each node. They are expressed declaratively over per-node
255-
// request histories, making them readable and auditable without understanding
256-
// any generator's internal state machine.
256+
// Properties on the order in which Malachite delivers Channel API requests
257+
// to each node. These are guarantees that Malachite provides about request
258+
// sequencing. Expressed declaratively over per-node request histories,
259+
// making them readable and auditable without understanding any generator's
260+
// internal state machine.
257261
//
258262
// Request histories contain only current-session requests (cleared on fault).
259263
// This simplifies all fold-based properties — no session boundary logic
@@ -744,10 +748,14 @@ module channel_api_contract {
744748
}
745749

746750
// ===========================================================================
747-
// ASSUMPTIONS (what the application must do)
751+
// APPLICATION GUARANTEES (Emerald → responses)
748752
// ===========================================================================
749753
//
750-
// Stated informally. These constrain the application's behavior.
754+
// Obligations on the responses Emerald sends back to Malachite. These are
755+
// predominantly liveness obligations ("the application eventually responds
756+
// with a correct value") with some safety mixed in (e.g., #3 requires
757+
// response fields match the request). Stated informally — to be formalized
758+
// as checkable properties in future work.
751759
//
752760
// 1. On ConsensusReady: the application MUST reply with a starting height
753761
// and validator set.
@@ -768,22 +776,28 @@ module channel_api_contract {
768776
//
769777
// 6. On ProcessSyncedValue: the application MUST reply with the decoded
770778
// value, or None.
779+
780+
// ===========================================================================
781+
// ENVIRONMENT ASSUMPTIONS
782+
// ===========================================================================
783+
//
784+
// External conditions required for both component and application
785+
// guarantees to hold. Not obligations of either side.
771786
//
772-
// 7. Environment: at most f validators are faulty, where n >= 3f+1.
787+
// 7. At most f validators are faulty, where n >= 3f+1.
773788
//
774-
// 8. Environment: the network eventually delivers messages between
775-
// correct validators.
789+
// 8. The network eventually delivers messages between correct validators.
776790
//
777-
// 9. Voting power: all validators have equal voting power. The quorum
778-
// threshold (strictly more than 2/3 of node count) assumes this.
779-
// With non-uniform voting power, quorumDecision would need the
780-
// validator set's total voting power instead of nNodes.
791+
// 9. All validators have equal voting power. The quorum threshold
792+
// (strictly more than 2/3 of node count) assumes this. With
793+
// non-uniform voting power, quorumDecision would need the validator
794+
// set's total voting power instead of nNodes.
781795

782796
// ===========================================================================
783-
// LIVENESS GUARANTEES (semi-formal)
797+
// COMPONENT GUARANTEES: LIVENESS (semi-formal)
784798
// ===========================================================================
785799
//
786-
// Under the assumptions above:
800+
// Under the environment assumptions above:
787801
//
788802
// - For every height h, eventually Decided(h) is sent to all correct nodes.
789803
//

specs/engine_api_contract.qnt

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,10 @@
99
// Models what the Reth team would publish for Emerald to consume.
1010
//
1111
// This contract defines:
12-
// 1. The request types for the Engine API
13-
// 2. Response correctness guarantees (what Reth guarantees)
14-
// 3. Request ordering constraints (what Emerald must do)
12+
// 1. The request/response types for the Engine API
13+
// 2. Component guarantees (Reth → responses): response correctness
14+
// 3. Application guarantees (Emerald → requests): request ordering
15+
// 4. Phase 1 constraints
1516
//
1617
// Key structural difference from Channel API:
1718
// - Channel API: Malachite sends requests to Emerald (Emerald responds)
@@ -147,7 +148,7 @@ module engine_api_contract {
147148
}
148149

149150
// ===========================================================================
150-
// RESPONSE CORRECTNESS PROPERTIES (Reth guarantees)
151+
// COMPONENT GUARANTEES: RESPONSE CORRECTNESS
151152
// ===========================================================================
152153

153154
// validationStability: Once newPayload(block) returns Valid, subsequent
@@ -350,7 +351,7 @@ module engine_api_contract {
350351
}
351352

352353
// ===========================================================================
353-
// REQUEST ORDERING PROPERTIES (Emerald obligations)
354+
// APPLICATION GUARANTEES: REQUEST ORDERING
354355
// ===========================================================================
355356

356357
// buildLifecycle: getPayload(id) must follow a forkchoiceUpdated that

0 commit comments

Comments
 (0)