Skip to content

Commit 2e71655

Browse files
committed
update immutable ledger spec
1 parent ba32dd5 commit 2e71655

File tree

6 files changed

+81
-86
lines changed

6 files changed

+81
-86
lines changed

docs/src/architecture/08_concepts/immutable_ledger/cddl/Earthfile

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,7 @@ check-cddl:
77

88
WORKDIR /cddl
99

10-
COPY ./block.cddl ./genesis_to_prev_hash.cddl ./hash.cddl .
10+
COPY ./block.cddl ./hash.cddl .
1111

1212
RUN cddlc -2 hash.cddl
1313
RUN cddlc -2 block.cddl
14-
RUN cddlc -2 genesis_to_prev_hash.cddl

docs/src/architecture/08_concepts/immutable_ledger/cddl/block.cddl

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,13 @@
44
block = [
55
block-header,
66
block-data,
7-
validator-signature,
87
]
98

109
block-header = [
11-
chain-id: UUID, ; UUID v7
1210
height: int,
13-
timestamp: #6.1(uint .ge 1722470400), ; Epoch-based date/time
14-
prev-block-id: hash-bytes, ; hash of the previous block
1511
?ledger-type: UUID, ; UUID v4
1612
?purpose-id: UUID, ; UUID v7
17-
?validator,
18-
~metadata,
13+
~extra-header-data,
1914
]
2015

2116
block-data = encoded-cbor
@@ -24,9 +19,6 @@ UUID = #6.37(bytes) ; UUID type
2419

2520
kid = hash-bytes ; hash of the x509/c509 certificate
2621

27-
validator = (kid / [2* kid])
28-
metadata = [ *any ]
29-
30-
validator-signature = (bytes / [2* bytes])
22+
extra-header-data = [ *any ]
3123

3224
;# include hash

docs/src/architecture/08_concepts/immutable_ledger/cddl/genesis_to_prev_hash.cddl

Lines changed: 0 additions & 18 deletions
This file was deleted.

docs/src/architecture/08_concepts/immutable_ledger/ledger.md

Lines changed: 57 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,47 @@ Which is well suited where it comes to process some temporary event e.g. voting.
7272

7373
### Block structure
7474

75+
Immutable ledger block is a [Catalyst Signed Document],
76+
so its fully follows the structure of the [Catalyst Signed Document] specification.
77+
78+
### Metadata Fields
79+
80+
* [`id`](./../signed_doc/spec.md#id).
81+
Used as a unique identifier of the chain.
82+
So all blocks from the same chain must have the same
83+
[`id`](./../signed_doc/spec.md#id) field value.
84+
* [`ver`](./../signed_doc/spec.md#ver).
85+
Used as a unique identifier of the block itself.
86+
Also the block's creation `timestamp` value is determined from the
87+
[`ver`](./../signed_doc/spec.md#ver) field.
88+
* [`content type`](./../signed_doc/spec.md#content-type): `application/cbor`.
89+
[Catalyst Signed Document content] must be a [CBOR] encoded.
90+
91+
```CDDL
92+
3 => 50
93+
```
94+
95+
* [`content encoding`](./../signed_doc/spec.md#content-encoding-optional):
96+
[Catalyst Signed Document content] must be [Brotli] compressed.
97+
98+
```CDDL
99+
"content-type" => "br"
100+
```
101+
102+
* [`type`](./../signed_doc/spec.md#type): `d9e7e6ce-2401-4d7d-9492-f4f7c64241c3` [UUID] value.
103+
104+
```CDDL
105+
"type" => 37(h'D9E7E6CE24014D7D9492F4F7C64241C3')
106+
```
107+
108+
* [`ref_hash`](./../signed_doc/meta.md#ref-hash-secured-document-reference).
109+
Previous block reference.
110+
A [`ref`](./../signed_doc/meta.md#ref-document-reference) part **must** be a pair of
111+
[`id`](./../signed_doc/spec.md#id) and
112+
[`ver`](./../signed_doc/spec.md#ver).
113+
114+
### Content format
115+
75116
<!-- markdownlint-disable max-one-sentence-per-line code-block-style -->
76117
??? note "Block CDDL definition: `block.cddl`"
77118

@@ -82,12 +123,9 @@ Which is well suited where it comes to process some temporary event e.g. voting.
82123

83124
Header:
84125

85-
* `chain-id` - unique identifier of the chain.
86126
* `height` - block's height.
87127
Also is used to identify the block type: *genesis*, *regular*, *final*
88128
(in more details described in [validation section](#block-validation-rules)).
89-
* `timestamp` - block's timestamp.
90-
* `prev-block-id` - previous block hash.
91129
* `ledger-type` - unique identifier of the ledger type.
92130
In general, this is the way to strictly bound and specify `block-data` of the ledger for the specific `ledger-type`.
93131
But such rules will be a part of the specific ledger type definition,
@@ -97,63 +135,42 @@ Header:
97135
each Ledger instance will have a strict time boundaries,
98136
so each of them will run for different purposes.
99137
This is the way to distinguish them.
100-
* `validator` - identifier or identifiers of the entity who was produced and processed a block.
101-
* `metadata` - fully optional field, to add some arbitrary metadata to the block.
138+
* `extra-header-data` - fully optional field, to add some arbitrary data to the block header.
102139

103140
Block:
104141

105142
* `block-header` - block header described above,
106143
* `block-data` - an array of some CBOR encoded data
107-
* `validator-signature` - a signature or signatures of the validator's.
108144

109145
### Block validation rules
110146

111-
* `chain-id` **MUST** be the same as for the previous block (except for genesis).
147+
* [`id`](./../signed_doc/spec.md#id)
148+
**MUST** be the same as for the previous block (except for genesis).
112149
* `height` **MUST** be incremented by `1` from the previous block height value (except for genesis and final block).
113150
*Genesis* block **MUST** have `0` value.
114151
*Final* block **MUST** hash be incremented by `1` from the previous block height and changed the sign to negative.
115152
E.g. previous block height is `9` and the *Final* block height is `-10`.
116153
* *Final* block is the last one for the specific chain and any other block could not be referenced to the *Final* one.
117154

118-
* `timestamp` **MUST** be greater or equals than the `timestamp` of the previous block (except for genesis).
119-
* `prev-block-id` **MUST** be a hash of the previous block bytes (except for genesis).
120-
155+
* [`ver`](./../signed_doc/spec.md#ver)
156+
timestamp value **MUST** be greater or equals than the corresponding `timestamp`
157+
of the previous block (except for genesis).
158+
* [`ref_hash`](./../signed_doc/meta.md#ref-hash-secured-document-reference)
159+
**MUST** be a reference to the previous block (except for genesis).
121160
* `ledger-type` **MUST** be the same as for the previous block if present (except for genesis).
122161
**MANDATORY** field for *Genesis* and *Final* blocks.
123162
* `purpose-id` **MUST** be the same as for the previous block if present (except for genesis).
124163
**MANDATORY** field for *Genesis* and *Final* blocks.
125-
* `validator` **MUST** be the same as for the previous block if present (except for genesis).
126-
**MANDATORY** field for *Genesis* and *Final* blocks.
127-
* `prev-block-id`'s CBOR tag value and `bstr` size **MUST** be the same as for the previous block (except for genesis).
164+
* [`kid`](./../signed_doc/spec.md#cose-signature-protected-header) field
165+
**MUST** be the same as for the previous block (except for genesis).
166+
* [`ref_hash`](./../signed_doc/meta.md#ref-hash-secured-document-reference)'s
167+
`hash-bytes` CBOR tag value and `bytes` size
168+
**MUST** be the same as for the previous block (except for genesis).
128169
Means that the hash function type and hash size itself must be the same.
129-
* `prev-block-id` and `validator-signature` **MUST** use the same hash function, defined with the
130-
`hash-bytes`.
131-
132-
* `prev-block-id` for the *Genesis* block **MUST** be a hash of the `genesis-to-prev-hash` bytes.
133-
170+
* [`ref_hash`](./../signed_doc/meta.md#ref-hash-secured-document-reference)
171+
field for the *Genesis* block **MUST** be omitted.
134172
* `block-data` **MUST** be a [deterministically][CBOR-deterministically-encoded] encoded CBOR.
135173

136-
<!-- markdownlint-disable max-one-sentence-per-line code-block-style -->
137-
??? note "Genesis to previous block hash CDDL definition: `genesis-to-prev-hash.cddl`"
138-
139-
```CDDL
140-
{{ include_file('src/architecture/08_concepts/immutable_ledger/cddl/genesis_to_prev_hash.cddl',indent=4) }}
141-
```
142-
<!-- markdownlint-enable max-one-sentence-per-line code-block-style -->
143-
144-
#### Signature rules
145-
146-
`validator-signature`
147-
**MUST** be a signature of the hashed `block-header` bytes and the `block-data` bytes
148-
(with the order the same as defined for `block`).
149-
Signed by the validator's keys defined in the corresponding certificates referenced by the `validator`.
150-
Signature algorithm is defined by the certificate.
151-
The format and size of this field **MUST** be totally the same as `validator` field:
152-
153-
* if `validator` is only one id => `validator-signature` contains only 1 signature;
154-
* if `validator` is array => `validator-signature` contains an array with the same length;
155-
* order of signatures from the `validator-signature`'s array corresponds to the validators order of `validator`'s array.
156-
157174
## Rationale
158175

159176
## Path to Active
@@ -166,4 +183,5 @@ The format and size of this field **MUST** be totally the same as `validator` fi
166183

167184
<!-- OPTIONAL SECTIONS: see CIP-0001 > Document > Structure table -->
168185

186+
[Catalyst Signed Document]: ./../signed_doc/spec.md
169187
[CBOR-deterministically-encoded]: https://datatracker.ietf.org/doc/html/rfc8949#name-deterministically-encoded-c

docs/src/architecture/08_concepts/signed_doc/meta.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,3 +105,6 @@ e.g. "Catalyst Fund 1", "Catalyst Fund 2".
105105

106106
Unique identifier [UUID] v4 which defines a voting category as a collection of proposals,
107107
e.g. "Development & Infrastructure", "Products & Integrations".
108+
109+
[UUID]: https://www.rfc-editor.org/rfc/rfc9562.html
110+
[CBOR]: https://datatracker.ietf.org/doc/rfc8949/

docs/src/architecture/08_concepts/signed_doc/types.md

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,23 @@
11
# Document Types Table
22

3-
| [UUID] | [CBOR] | Type Description | Payload Type | Specification Link |
4-
| ------------------------------------ | ----------------------------------------- | ---------------------------- | --------------------------------- | -------------------------------------------------------------------------- |
5-
| 7808d2ba-d511-40af-84e8-c0d1625fdfdc | `37(h'7808d2bad51140af84e8c0d1625fdfdc')` | Proposal Document | [Brotli] Compressed [JSON] | [Proposal Spec](./../catalyst_docs/proposal.md#proposal-document) |
6-
| 0ce8ab38-9258-4fbc-a62e-7faa6e58318f | `37(h'0ce8ab3892584fbca62e7faa6e58318f')` | Proposal Template | [Brotli] Compressed [JSON Schema] | [Proposal Template Spec](./../catalyst_docs/proposal.md#proposal-template) |
7-
| b679ded3-0e7c-41ba-89f8-da62a17898ea | `37(h'b679ded30e7c41ba89f8da62a17898ea')` | Comment Document | [Brotli] Compressed [JSON] | [Comment Spec](./../catalyst_docs/comment.md#comment-document) |
8-
| 0b8424d4-ebfd-46e3-9577-1775a69d290c | `37(h'0b8424d4ebfd46e395771775a69d290c')` | Comment Template | [Brotli] Compressed [JSON Schema] | [Comment Template Spec](./../catalyst_docs/comment.md#comment-template) |
9-
| e4caf5f0-098b-45fd-94f3-0702a4573db5 | `37(h'e4caf5f0098b45fd94f30702a4573db5')` | Review Document | [Brotli] Compressed [JSON] | [Review Spec](./../catalyst_docs/review.md#review-document) |
10-
| ebe5d0bf-5d86-4577-af4d-008fddbe2edc | `37(h'ebe5d0bf5d864577af4d008fddbe2edc')` | Review Template | [Brotli] Compressed [JSON Schema] | [Review Template Spec](./../catalyst_docs/review.md#review-template) |
11-
| 48c20109-362a-4d32-9bba-e0a9cf8b45be | `37(h'48c20109362a4d329bbae0a9cf8b45be')` | Category Parameters Document | [Brotli] Compressed [JSON] | *TBD* |
12-
| 65b1e8b0-51f1-46a5-9970-72cdf26884be | `37(h'65b1e8b051f146a5997072cdf26884be')` | Category Parameters Template | [Brotli] Compressed [JSON Schema] | *TBD* |
13-
| 0110ea96-a555-47ce-8408-36efe6ed6f7c | `37(h'0110ea96a55547ce840836efe6ed6f7c')` | Campaign Parameters Document | [Brotli] Compressed [JSON] | *TBD* |
14-
| 7e8f5fa2-44ce-49c8-bfd5-02af42c179a3 | `37(h'7e8f5fa244ce49c8bfd502af42c179a3')` | Campaign Parameters Template | [Brotli] Compressed [JSON Schema] | *TBD* |
15-
| 3e4808cc-c86e-467b-9702-d60baa9d1fca | `37(h'3e4808ccc86e467b9702d60baa9d1fca')` | Brand Parameters Document | [Brotli] Compressed [JSON] | *TBD* |
16-
| fd3c1735-80b1-4eea-8d63-5f436d97ea31 | `37(h'fd3c173580b14eea8d635f436d97ea31')` | Brand Parameters Template | [Brotli] Compressed [JSON Schema] | *TBD* |
17-
| 5e60e623-ad02-4a1b-a1ac-406db978ee48 | `37(h'5e60e623ad024a1ba1ac406db978ee48')` | Proposal Action Document | *TBD* | *TBD* |
18-
| 8de5586c-e998-4b95-8742-7be3c8592803 | `37(h'8DE5586CE9984B9587427BE3C8592803')` | Public Vote Tx V2 | [Brotli] Compressed [CBOR] | [Public Vote Tx V2 Spec](./../catalyst_voting/v2.md#public-vote) |
19-
| e78ee18d-f380-44c1-a852-80aa6ecb07fe | `37(h'E78EE18DF38044C1A85280AA6ECB07FE')` | Private Vote Tx V2 | [Brotli] Compressed [CBOR] | [Private Vote Tx V2 Spec](./../catalyst_voting/v2.md#private-vote) |
3+
| [UUID] | [CBOR] | Type Description | Payload Type | Specification Link |
4+
| ------------------------------------ | ----------------------------------------- | ---------------------------- | --------------------------------- | ------------------------------------------------------------------------------ |
5+
| 7808d2ba-d511-40af-84e8-c0d1625fdfdc | `37(h'7808d2bad51140af84e8c0d1625fdfdc')` | Proposal Document | [Brotli] Compressed [JSON] | [Proposal Spec](./../catalyst_docs/proposal.md#proposal-document) |
6+
| 0ce8ab38-9258-4fbc-a62e-7faa6e58318f | `37(h'0ce8ab3892584fbca62e7faa6e58318f')` | Proposal Template | [Brotli] Compressed [JSON Schema] | [Proposal Template Spec](./../catalyst_docs/proposal.md#proposal-template) |
7+
| b679ded3-0e7c-41ba-89f8-da62a17898ea | `37(h'b679ded30e7c41ba89f8da62a17898ea')` | Comment Document | [Brotli] Compressed [JSON] | [Comment Spec](./../catalyst_docs/comment.md#comment-document) |
8+
| 0b8424d4-ebfd-46e3-9577-1775a69d290c | `37(h'0b8424d4ebfd46e395771775a69d290c')` | Comment Template | [Brotli] Compressed [JSON Schema] | [Comment Template Spec](./../catalyst_docs/comment.md#comment-template) |
9+
| e4caf5f0-098b-45fd-94f3-0702a4573db5 | `37(h'e4caf5f0098b45fd94f30702a4573db5')` | Review Document | [Brotli] Compressed [JSON] | [Review Spec](./../catalyst_docs/review.md#review-document) |
10+
| ebe5d0bf-5d86-4577-af4d-008fddbe2edc | `37(h'ebe5d0bf5d864577af4d008fddbe2edc')` | Review Template | [Brotli] Compressed [JSON Schema] | [Review Template Spec](./../catalyst_docs/review.md#review-template) |
11+
| 48c20109-362a-4d32-9bba-e0a9cf8b45be | `37(h'48c20109362a4d329bbae0a9cf8b45be')` | Category Parameters Document | [Brotli] Compressed [JSON] | *TBD* |
12+
| 65b1e8b0-51f1-46a5-9970-72cdf26884be | `37(h'65b1e8b051f146a5997072cdf26884be')` | Category Parameters Template | [Brotli] Compressed [JSON Schema] | *TBD* |
13+
| 0110ea96-a555-47ce-8408-36efe6ed6f7c | `37(h'0110ea96a55547ce840836efe6ed6f7c')` | Campaign Parameters Document | [Brotli] Compressed [JSON] | *TBD* |
14+
| 7e8f5fa2-44ce-49c8-bfd5-02af42c179a3 | `37(h'7e8f5fa244ce49c8bfd502af42c179a3')` | Campaign Parameters Template | [Brotli] Compressed [JSON Schema] | *TBD* |
15+
| 3e4808cc-c86e-467b-9702-d60baa9d1fca | `37(h'3e4808ccc86e467b9702d60baa9d1fca')` | Brand Parameters Document | [Brotli] Compressed [JSON] | *TBD* |
16+
| fd3c1735-80b1-4eea-8d63-5f436d97ea31 | `37(h'fd3c173580b14eea8d635f436d97ea31')` | Brand Parameters Template | [Brotli] Compressed [JSON Schema] | *TBD* |
17+
| 5e60e623-ad02-4a1b-a1ac-406db978ee48 | `37(h'5e60e623ad024a1ba1ac406db978ee48')` | Proposal Action Document | *TBD* | *TBD* |
18+
| 8de5586c-e998-4b95-8742-7be3c8592803 | `37(h'8DE5586CE9984B9587427BE3C8592803')` | Public Vote Tx V2 | [Brotli] Compressed [CBOR] | [Public Vote Tx V2 Spec](./../catalyst_voting/v2.md#public-vote) |
19+
| e78ee18d-f380-44c1-a852-80aa6ecb07fe | `37(h'E78EE18DF38044C1A85280AA6ECB07FE')` | Private Vote Tx V2 | [Brotli] Compressed [CBOR] | [Private Vote Tx V2 Spec](./../catalyst_voting/v2.md#private-vote) |
20+
| d9e7e6ce-2401-4d7d-9492-f4f7c64241c3 | `37(h'D9E7E6CE24014D7D9492F4F7C64241C3')` | Immutable Ledger Block | [Brotli] Compressed [CBOR] | [Immutable Ledger Block Spec](./../immutable_ledger/ledger.md#block-structure) |
2021

2122
[JSON Schema]: https://json-schema.org/draft-07
2223
[JSON]: https://datatracker.ietf.org/doc/html/rfc7159

0 commit comments

Comments
 (0)