Skip to content

Commit 5d55a1b

Browse files
will-break-itch1bo
authored andcommitted
CDDL (#420)
* docs(CDDL): added base definitions for blocks, votes & certificates and sharding-specific definitions
1 parent 13c2b35 commit 5d55a1b

File tree

6 files changed

+363
-0
lines changed

6 files changed

+363
-0
lines changed
Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
# Endorser Blocks - Leios CDDL
2+
3+
Endorser Blocks (EBs) are new block types in Leios that aggregate multiple Input Blocks from the current pipeline.
4+
5+
## Endorser Block Sortition
6+
7+
**Single EB Limit**: Each producer can generate **at most one Endorser Block per pipeline**, following the crypto-benchmarks implementation approach rather than the full Poisson sortition used in simulations.
8+
9+
**VRF Lottery**: Eligibility uses the simplified probability model:
10+
11+
$$P = 1 - e^{-f_{EB} \cdot \sigma}$$
12+
13+
Where $f_{EB}$ is the per-pipeline EB generation rate and $\sigma$ is the producer's stake fraction.
14+
15+
> [!Important]
16+
> **Precision Requirements**: This computation MUST be performed using machine precision-independent arithmetic to ensure deterministic results across all implementations. The exponential function SHALL be computed using rational arithmetic (e.g., `num_rational::Ratio<BigInt>`) with a Taylor series expansion to a predefined precision (minimum 34 decimal places as implemented in crypto-benchmarks). This prevents floating-point precision variations between different hardware architectures and ensures consensus consistency.
17+
18+
Sources: [Crypto-benchmarks Sortition](https://github.com/input-output-hk/ouroboros-leios/blob/main/crypto-benchmarks.rs/Specification.md#L63-L65), [Rust Simulation EB Generation](https://github.com/input-output-hk/ouroboros-leios/blob/main/sim-rs/sim-core/src/sim/node.rs#L606-L641), [Rational Arithmetic Implementation](https://github.com/input-output-hk/ouroboros-leios/blob/main/crypto-benchmarks.rs/src/sortition.rs#L1-L25), [Technical Report - Deterministic Computation](https://github.com/input-output-hk/ouroboros-leios/blob/main/docs/technical-report-1.md?plain=1#L510-L513)
19+
20+
## Block Structure
21+
22+
```diff
23+
+ endorser_block =
24+
+ [ eb_header : eb_header
25+
+ , eb_body : eb_body
26+
+ ]
27+
```
28+
29+
## Header Structure
30+
31+
```diff
32+
+ eb_header =
33+
+ [ eb_header_body : eb_header_body
34+
+ , body_signature : kes_signature
35+
+ ]
36+
+
37+
+ eb_header_body =
38+
+ [ slot : slot_no ; Slot when EB was created
39+
+ , producer : pool_id ; Block producer identifier
40+
+ , ? vrf_proof : vrf_cert ; VRF proof of eligibility to produce EB
41+
+ ]
42+
```
43+
Sources: [Haskell Simulation EndorserBlock](https://github.com/input-output-hk/ouroboros-leios/blob/main/simulation/src/LeiosProtocol/Common.hs#L160-L171), [Rust Simulation EndorserBlock](https://github.com/input-output-hk/ouroboros-leios/blob/main/sim-rs/sim-core/src/model.rs#L167-L176), [Formal Spec EndorserBlockOSig](https://github.com/input-output-hk/ouroboros-leios-formal-spec/blob/main/formal-spec/Leios/Blocks.agda#L97-L106)
44+
45+
## Body Structure
46+
47+
**Design Rationale**: The block references are separated into the body to align with the network protocol design. At high TPS, the combined size of IB and EB references could exceed TCP MTU, making separate header/body transmission essential for efficient network diffusion.
48+
49+
```diff
50+
+ eb_body =
51+
+ [ input_blocks : [* ib_reference] ; References to input blocks
52+
+ , ? endorser_blocks : [* eb_reference] ; References to earlier endorser blocks (Full Leios)
53+
+ ]
54+
```
55+
Sources: [Network Specification - Relay Protocol](https://github.com/input-output-hk/ouroboros-leios/blob/main/docs/technical-report-2.md#relay-mini-protocol), [Network Specification - Fetch Protocol](https://github.com/input-output-hk/ouroboros-leios/blob/main/docs/technical-report-2.md#fetch-mini-protocol)
56+
57+
## Input Block Reference Structure
58+
59+
```diff
60+
+ ; References to input blocks within endorser blocks
61+
+ ib_reference = hash32 ; Hash identifier of the input block
62+
```
63+
64+
**Design Rationale**: IB references contain only the hash identifier, following the principle that references should include only what's needed for unique identification. Producer and slot information can be obtained by fetching the block header when needed. This aligns with the formal specification's `IBRef = Hash` approach.
65+
66+
Sources: [Haskell Simulation - InputBlockId](https://github.com/input-output-hk/ouroboros-leios/blob/main/simulation/src/LeiosProtocol/Common.hs#L100-L105), [Rust Simulation - InputBlockId](https://github.com/input-output-hk/ouroboros-leios/blob/main/sim-rs/sim-core/src/model.rs#L98-L105), [Formal Spec - IBRef](https://github.com/input-output-hk/ouroboros-leios-formal-spec/blob/main/formal-spec/Leios/Blocks.agda#L33), [Formal Spec - ibRefs](https://github.com/input-output-hk/ouroboros-leios-formal-spec/blob/main/formal-spec/Leios/Blocks.agda#L101)
67+
68+
## Endorser Block Reference Structure
69+
70+
```diff
71+
+ ; References to earlier endorser blocks (for Full Leios)
72+
+ eb_reference = hash32 ; Hash identifier of the endorser block
73+
```
74+
Sources: [Haskell Simulation](https://github.com/input-output-hk/ouroboros-leios/blob/main/simulation/src/LeiosProtocol/Common.hs#L161-L163), [Rust Simulation](https://github.com/input-output-hk/ouroboros-leios/blob/main/sim-rs/sim-core/src/model.rs#L148-L152), [Formal Spec](https://github.com/input-output-hk/ouroboros-leios-formal-spec/blob/main/formal-spec/Leios/Blocks.agda#L34)
75+
76+
## Supporting Types
77+
78+
```diff
79+
+ pool_id = bytes .size 28 ; Stake pool identifier (28 bytes)
80+
+ slot_no = uint64 ; Slot number
81+
+ hash32 = bytes .size 32 ; 32-byte hash
82+
+ vrf_cert = bytes ; VRF certificate/proof
83+
+ kes_signature = bytes ; KES signature
84+
```
85+
86+
## Next
87+
**[Input Block - CDDL](input-blocks.md)**
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
# Input Blocks - Leios CDDL
2+
3+
**Single IB Limit**: Each producer can generate **at most one Input Block per slot**, following the crypto-benchmarks implementation approach rather than the full Poisson sortition used in simulations.
4+
5+
**VRF Lottery**: Eligibility uses the simplified probability model:
6+
7+
$$P = 1 - e^{-f_{IB} \cdot \sigma}$$
8+
9+
Where $f_{IB}$ is the per-slot IB generation rate and $\sigma$ is the producer's stake fraction.
10+
11+
Sources: [Crypto-benchmarks Sortition](https://github.com/input-output-hk/ouroboros-leios/blob/main/crypto-benchmarks.rs/Specification.md?plain=1#L64), [Rust Simulation IB Generation](https://github.com/input-output-hk/ouroboros-leios/blob/main/sim-rs/sim-core/src/sim/node.rs#L561-L597)
12+
13+
## Block Structure
14+
15+
```diff
16+
+ input_block =
17+
+ [ ib_header : ib_header
18+
+ , transaction_bodies : [* transaction_body]
19+
+ , transaction_witness_sets : [* transaction_witness_set]
20+
+ , auxiliary_data_set : {* transaction_index => auxiliary_data}
21+
+ , invalid_transactions : [* transaction_index]
22+
+ ]
23+
```
24+
Sources: [Formal Spec](https://github.com/input-output-hk/ouroboros-leios-formal-spec/blob/main/formal-spec/Leios/Blocks.agda#L40-L57), [Haskell Simulation](https://github.com/input-output-hk/ouroboros-leios/blob/main/simulation/src/LeiosProtocol/Common.hs#L138-L142), [Rust Simulation](https://github.com/input-output-hk/ouroboros-leios/blob/main/sim-rs/sim-core/src/model.rs#L136-L141)
25+
26+
## Header Structure
27+
28+
```diff
29+
+ ib_header =
30+
+ [ ib_header_body : ib_header_body
31+
+ , body_signature : kes_signature
32+
+ ]
33+
+
34+
+ ib_header_body =
35+
+ [ slot : slot_no ; Slot when IB was created
36+
+ , producer_id : pool_id ; Block producer identifier
37+
+ , vrf_proof : vrf_cert ; VRF proof of eligibility to produce IB
38+
+ , block_body_hash : hash32 ; Hash of the block body
39+
+ , ranking_block_ref : hash32 ; Reference to ranking block for ledger state
40+
+ ]
41+
```
42+
Sources: [Formal Spec](https://github.com/input-output-hk/ouroboros-leios-formal-spec/blob/main/formal-spec/Leios/Blocks.agda#L40-L45), [Haskell Simulation](https://github.com/input-output-hk/ouroboros-leios/blob/main/simulation/src/LeiosProtocol/Common.hs#L114-L124), [Rust Simulation](https://github.com/input-output-hk/ouroboros-leios/blob/main/sim-rs/sim-core/src/model.rs#L127-L133)
43+
44+
## Supporting Types
45+
46+
```diff
47+
+ ; Block identifiers
48+
+ ib_id = hash32 ; Input block identifier (hash)
49+
+
50+
+ ; Basic types
51+
+ pool_id = bytes ; Pool/producer identifier
52+
+ slot_no = uint64 ; Slot number
53+
+ hash32 = bytes .size 32 ; 32-byte hash
54+
+ vrf_cert = bytes ; VRF certificate/proof
55+
+ kes_signature = bytes ; KES signature
56+
```
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Ranking Blocks - Leios CDDL
2+
3+
Ranking Blocks (RBs) are extended Praos blocks that include optional Leios certificates.
4+
5+
## Block Structure - (Conway) Extension
6+
7+
```diff
8+
ranking_block =
9+
[ header : block_header
10+
, transaction_bodies : [* transaction_body]
11+
, transaction_witness_sets : [* transaction_witness_set]
12+
, auxiliary_data_set : {* transaction_index => auxiliary_data}
13+
, invalid_transactions : [* transaction_index]
14+
+ , ? leios_cert : leios_certificate
15+
]
16+
```
17+
Sources: [Conway Base](https://github.com/IntersectMBO/cardano-ledger/blob/master/eras/conway/impl/cddl-files/conway.cddl#L8-L14), [Leios Base](https://github.com/input-output-hk/ouroboros-leios-formal-spec/blob/main/formal-spec/Leios/Base.agda#L21-L22)
18+
19+
## Next
20+
**[Votes and Certificates - CDDL](votes-certificates.md)**
Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
# Votes and Certificates - Leios CDDL
2+
3+
Leios introduces a new BLS-based voting system with certificates for endorser block validation.
4+
5+
## Certificate Structure
6+
7+
Leios certificates are embedded in Ranking Blocks as described in [Ranking Block - CDDL](ranking-blocks.md). These certificates attest to the validity of Endorser Blocks as described in [Endorser Block - CDDL](endorser-blocks.md). Here is the complete certificate structure:
8+
9+
```cddl
10+
; Complete Leios certificate structure (from crypto-benchmarks implementation)
11+
leios_certificate =
12+
[ election_id : election_id ; 8-byte election identifier (EID)
13+
, endorser_block_hash : hash32 ; Hash of the endorsed block (EB)
14+
, persistent_voters : [* persistent_voter_id] ; Set of persistent voter IDs
15+
, nonpersistent_voters : {* pool_id => bls_signature} ; Non-persistent voters with eligibility proofs
16+
, ? aggregate_elig_sig : bls_signature ; Aggregate eligibility signature (present when non-persistent voters exist)
17+
, aggregate_vote_sig : bls_signature ; Aggregate BLS signature on (election_id || endorser_block_hash)
18+
]
19+
```
20+
Sources: [Certificate Reference Implementation](https://github.com/input-output-hk/ouroboros-leios/blob/main/crypto-benchmarks.rs/src/cert.rs#L13-L21), [Certificate Abstract Interface](https://github.com/input-output-hk/ouroboros-leios-formal-spec/blob/main/formal-spec/Leios/Base.agda#L24-L28)
21+
22+
## Vote Structure
23+
24+
The Leios voting system supports two types of voters: persistent voters (selected per epoch) and non-persistent voters (selected per election via local sortition).
25+
26+
> [!Note]
27+
> Individual votes are ephemeral data structures used during the voting process. They are aggregated into certificates and do not appear on the ledger or persistent storage. Only the resulting certificates are stored permanently.
28+
29+
```cddl
30+
; Vote bundle containing votes for multiple endorser blocks from same voter
31+
leios_vote_bundle = persistent_vote_bundle / non_persistent_vote_bundle
32+
33+
persistent_vote_bundle =
34+
[ 0 ; Vote type identifier for persistent voter
35+
, election_id ; 8-byte election identifier
36+
, persistent_voter_id ; 2-byte epoch-specific pool identifier
37+
, vote_entries ; Map of endorser blocks to signatures
38+
]
39+
40+
non_persistent_vote_bundle =
41+
[ 1 ; Vote type identifier for non-persistent voter
42+
, election_id ; 8-byte election identifier
43+
, pool_id ; 28-byte pool identifier
44+
, eligibility_signature ; 48-byte BLS signature proving eligibility
45+
, vote_entries ; Map of endorser blocks to signatures
46+
]
47+
48+
vote_entries = {* endorser_block_hash => vote_signature}
49+
```
50+
Sources: [Vote Reference Implementation](https://github.com/input-output-hk/ouroboros-leios/blob/main/crypto-benchmarks.rs/src/vote.rs#L13-L27), [Formal Specification - Vote Abstract Interface](https://github.com/input-output-hk/ouroboros-leios-formal-spec/blob/main/formal-spec/Leios/Abstract.agda#L24-L27), [Haskell Bundle Usage](https://github.com/input-output-hk/ouroboros-leios/blob/main/simulation/src/LeiosProtocol/Short.hs#L231-L234), [Rust Vote Bundle](https://github.com/input-output-hk/ouroboros-leios/blob/main/sim-rs/sim-core/src/model.rs#L208-L212)
51+
52+
## BLS Key Registration
53+
54+
For pools to participate in Leios voting, they must register BLS keys in their operational certificates:
55+
56+
```diff
57+
operational_cert =
58+
[ hot_vkey : kes_vkey
59+
, sequence_number : uint .size 8
60+
, kes_period : uint
61+
, sigma : signature
62+
+ , ? bls_key_reg : bls_key_registration
63+
]
64+
```
65+
Sources: [Conway Base](https://github.com/IntersectMBO/cardano-ledger/blob/master/eras/conway/impl/cddl-files/conway.cddl#L114-L119)
66+
67+
```cddl
68+
; BLS key registration for voting (included in operational certificates)
69+
bls_key_registration =
70+
[ pool_id : pool_id ; Pool identifier (28 bytes)
71+
, bls_public_key : bls_vkey ; BLS12-381 G2 public key (96 bytes)
72+
, proof_of_possession : bls_proof_of_possession ; Proof of secret key possession (96 bytes)
73+
, kes_signature : kes_signature ; KES signature over the registration (448 bytes)
74+
]
75+
76+
; Total size: 28 + 96 + 96 + 448 = 668 bytes
77+
```
78+
Sources: [Registration Struct](https://github.com/input-output-hk/ouroboros-leios/blob/main/crypto-benchmarks.rs/src/key.rs#L156-L162), [Proof Generation](https://github.com/input-output-hk/ouroboros-leios/blob/main/crypto-benchmarks.rs/src/bls_vote.rs#L19-L23)
79+
80+
## Cryptographic Types
81+
82+
```cddl
83+
; Core BLS cryptographic primitives
84+
bls_signature = bytes .size 48 ; BLS12-381 G1 signature (compressed)
85+
bls_vkey = bytes .size 96 ; BLS12-381 G2 public key (compressed)
86+
bls_proof_of_possession =
87+
[ mu1 : bls_signature ; Signature on public key
88+
, mu2 : bls_signature ; Signature on empty message
89+
]
90+
91+
; Leios-specific identifiers
92+
election_id = bytes .size 8 ; Slot-based election identifier
93+
persistent_voter_id = uint .size 2 ; Epoch-specific voter identifier (0-65535)
94+
pool_id = bytes .size 28 ; Stake pool identifier
95+
endorser_block_hash = bytes .size 32 ; Hash of endorser block
96+
97+
; Additional Cardano types used
98+
kes_signature = bytes .size 448 ; KES signature
99+
hash32 = bytes .size 32 ; 32-byte hash (used for endorser_block_hash)
100+
```
101+
Sources: [Sig](https://github.com/input-output-hk/ouroboros-leios/blob/main/crypto-benchmarks.rs/src/key.rs#L100), [PubKey](https://github.com/input-output-hk/ouroboros-leios/blob/main/crypto-benchmarks.rs/src/key.rs#L62), [PoP](https://github.com/input-output-hk/ouroboros-leios/blob/main/crypto-benchmarks.rs/src/key.rs#L139-L143), [Eid](https://github.com/input-output-hk/ouroboros-leios/blob/main/crypto-benchmarks.rs/src/primitive.rs#L76), [PersistentId](https://github.com/input-output-hk/ouroboros-leios/blob/main/crypto-benchmarks.rs/src/registry.rs#L14), [PoolKeyhash](https://github.com/input-output-hk/ouroboros-leios/blob/main/crypto-benchmarks.rs/src/primitive.rs#L14), [EbHash](https://github.com/input-output-hk/ouroboros-leios/blob/main/crypto-benchmarks.rs/src/primitive.rs#L117), [KesSig](https://github.com/input-output-hk/ouroboros-leios/blob/main/crypto-benchmarks.rs/src/primitive.rs#L170)
102+
103+
104+
105+
## Next
106+
**[Endorser Block - CDDL](endorser-blocks.md)**
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
# Input Blocks - Full Sharding CDDL
2+
3+
The common [`input_block`](../common/input-blocks.md#block-structure) structure is used with shard assignment in the IB header.
4+
5+
## Sharded IB Header
6+
7+
```diff
8+
; Common IB header body from leios-common.cddl
9+
ib_header_body =
10+
[ slot : slot_no
11+
, producer : node_id
12+
, ib_certificate : ib_cert
13+
, ? vrf_proof : vrf_cert
14+
+ , shard : shard_id ; Shard assignment from VRF
15+
]
16+
```
17+
Sources: [Common CDDL](../common/input-blocks.md#block-structure), [Rust simulation](https://github.com/input-output-hk/ouroboros-leios/blob/main/sim-rs/sim-core/src/model.rs#L130)
18+
19+
## Shard Assignment
20+
21+
```cddl
22+
; Shard identifier (16-bit allows up to 65,536 shards)
23+
; Current simulation configs use 1-900 shards
24+
shard_id = uint .size 2
25+
26+
; Shard assignment based on VRF value
27+
; Implementation: shard = vrf_value mod total_shards
28+
```
29+
Sources: Ledger v0.2: "each IB has a shard id (determined through its VRF value)", [Rust Shard Assignment](https://github.com/input-output-hk/ouroboros-leios/blob/main/sim-rs/sim-core/src/sim/node.rs#L599-L604)
30+
31+
## Supporting Types
32+
33+
```cddl
34+
; Basic types
35+
shard_id = uint .size 2 ; 16-bit shard identifier (current range: 1-900)
36+
slot_no = uint64 ; Slot number
37+
```
38+
39+
## Next
40+
41+
**[Sharded Transactions - CDDL](transactions.md)**

0 commit comments

Comments
 (0)