Skip to content

Commit 165a2ee

Browse files
committed
fix immutable ledger cddl definitions
1 parent ed6da67 commit 165a2ee

File tree

5 files changed

+44
-44
lines changed

5 files changed

+44
-44
lines changed

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

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

88
WORKDIR /cddl
99

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

12+
RUN cddlc -2 hash.cddl
1213
RUN cddlc -2 block.cddl
1314
RUN cddlc -2 genesis_to_prev_hash.cddl
Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
block = [
2-
block_header,
2+
block-header,
33
block-data,
44
validator-signature,
55
]
66

7-
block_header = [
7+
block-header = [
88
chain-id: ULID,
99
height: int,
1010
timestamp: #6.1(uint .ge 1722470400), ; Epoch-based date/time
11-
prev-block-id: hash_bytes, ; hash of the previous block
11+
prev-block-id: hash-bytes, ; hash of the previous block
1212
?ledger-type: UUID,
1313
?purpose-id: ULID / UUID,
1414
?validator,
@@ -20,14 +20,11 @@ block-data = encoded-cbor
2020
UUID = #6.37(bytes) ; UUID type
2121
ULID = #6.32780(bytes) ; ULID type
2222

23-
hash_bytes = (
24-
#6.32781(bytes) / ; Blake3 hash
25-
#6.32782(bytes) / ; Blake2b hash
26-
#6.32783(bytes) ; Blake2s hash
27-
)
28-
kid = hash_bytes ; hash of the x509/c509 certificate
23+
kid = hash-bytes ; hash of the x509/c509 certificate
2924

3025
validator = (kid / [2* kid])
3126
metadata = [ *any ]
3227

3328
validator-signature = (bytes / [2* bytes])
29+
30+
;# include hash
Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,15 @@
1-
genesis_to_prev_hash = [
2-
chain_id: ULID,
3-
timestamp: ~#6.1(uint .ge 1722470400), ; Epoch-based date/time
4-
ledger_type: UUID,
5-
purpose_id: ULID / UUID,
1+
genesis-to-prev-hash = [
2+
chain-id: ULID,
3+
timestamp: #6.1(uint .ge 1722470400), ; Epoch-based date/time
4+
ledger-type: UUID,
5+
purpose-id: ULID / UUID,
66
validator,
77
]
88

99
UUID = #6.37(bytes) ; UUID type
1010
ULID = #6.32780(bytes) ; ULID type
1111

1212
validator = (kid / [2* kid])
13-
kid = hash_bytes ; hash of the x509/c509 certificate
14-
hash_bytes = (
15-
#6.32781(bytes) \ ; Blake3 hash
16-
#6.32782(bytes) \ ; Blake2b hash
17-
#6.32783(bytes) ; Blake2s hash
18-
)
13+
kid = hash-bytes ; hash of the x509/c509 certificate
14+
15+
;# include hash
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
hash-bytes = (
2+
#6.32781(bytes) / ; Blake3 hash
3+
#6.32782(bytes) / ; Blake2b hash
4+
#6.32783(bytes) ; Blake2s hash
5+
)

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

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -82,17 +82,17 @@ Which is well suited where it comes to process some temporary event e.g. voting.
8282

8383
Header:
8484

85-
* `chain_id` - unique identifier of the chain.
85+
* `chain-id` - unique identifier of the chain.
8686
* `height` - block's height.
8787
Also is used to identify the block type: *genesis*, *regular*, *final*
8888
(in more details described in [validation section](#block-validation-rules)).
8989
* `timestamp` - block's timestamp.
90-
* `prev_block_id` - previous block hash.
91-
* `ledger_type` - unique identifier of the ledger type.
92-
In general, this is the way to strictly bound and specify `block_data` of the ledger for the specific `ledger_type`.
90+
* `prev-block-id` - previous block hash.
91+
* `ledger-type` - unique identifier of the ledger type.
92+
In general, this is the way to strictly bound and specify `block-data` of the ledger for the specific `ledger-type`.
9393
But such rules will be a part of the specific ledger type definition,
9494
and not specified by this document.
95-
* `purpose_id` - unique identifier of the purpose.
95+
* `purpose-id` - unique identifier of the purpose.
9696
As it was stated before,
9797
each Ledger instance will have a strict time boundaries,
9898
so each of them will run for different purposes.
@@ -102,39 +102,39 @@ Header:
102102

103103
Block:
104104

105-
* `block_header` - block header described above,
106-
* `block_data` - an array of some CBOR encoded data
107-
* `validator_signature` - a signature or signatures of the validator's.
105+
* `block-header` - block header described above,
106+
* `block-data` - an array of some CBOR encoded data
107+
* `validator-signature` - a signature or signatures of the validator's.
108108

109109
### Block validation rules
110110

111-
* `chain_id` **MUST** be the same as for the previous block (except for genesis).
111+
* `chain-id` **MUST** be the same as for the previous block (except for genesis).
112112
* `height` **MUST** be incremented by `1` from the previous block height value (except for genesis and final block).
113113
*Genesis* block **MUST** have `0` value.
114114
*Final* block **MUST** hash be incremented by `1` from the previous block height and changed the sign to negative.
115115
E.g. previous block height is `9` and the *Final* block height is `-10`.
116116
* *Final* block is the last one for the specific chain and any other block could not be referenced to the *Final* one.
117117

118118
* `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).
119+
* `prev-block-id` **MUST** be a hash of the previous block bytes (except for genesis).
120120

121-
* `ledger_type` **MUST** be the same as for the previous block if present (except for genesis).
121+
* `ledger-type` **MUST** be the same as for the previous block if present (except for genesis).
122122
**MANDATORY** field for *Genesis* and *Final* blocks.
123-
* `purpose_id` **MUST** be the same as for the previous block if present (except for genesis).
123+
* `purpose-id` **MUST** be the same as for the previous block if present (except for genesis).
124124
**MANDATORY** field for *Genesis* and *Final* blocks.
125125
* `validator` **MUST** be the same as for the previous block if present (except for genesis).
126126
**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).
127+
* `prev-block-id`'s CBOR tag value and `bstr` size **MUST** be the same as for the previous block (except for genesis).
128128
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`.
129+
* `prev-block-id` and `validator-signature` **MUST** use the same hash function, defined with the
130+
`hash-bytes`.
131131

132-
* `prev_block_id` for the *Genesis* block **MUST** be a hash of the `genesis_to_prev_hash` bytes.
132+
* `prev-block-id` for the *Genesis* block **MUST** be a hash of the `genesis-to-prev-hash` bytes.
133133

134-
* `block_data` **MUST** be a [deterministically][CBOR-deterministically-encoded] encoded CBOR.
134+
* `block-data` **MUST** be a [deterministically][CBOR-deterministically-encoded] encoded CBOR.
135135

136136
<!-- markdownlint-disable max-one-sentence-per-line code-block-style -->
137-
??? note "Genesis to previous block hash CDDL definition: `genesis_to_prev_hash.cddl`"
137+
??? note "Genesis to previous block hash CDDL definition: `genesis-to-prev-hash.cddl`"
138138

139139
```CDDL
140140
{{ include_file('src/architecture/08_concepts/immutable_ledger/cddl/genesis_to_prev_hash.cddl',indent=4) }}
@@ -143,16 +143,16 @@ Block:
143143

144144
#### Signature rules
145145

146-
`validator_signature`
147-
**MUST** be a signature of the hashed `block_header` bytes and the `block_data` bytes
146+
`validator-signature`
147+
**MUST** be a signature of the hashed `block-header` bytes and the `block-data` bytes
148148
(with the order the same as defined for `block`).
149149
Signed by the validator's keys defined in the corresponding certificates referenced by the `validator`.
150150
Signature algorithm is defined by the certificate.
151151
The format and size of this field **MUST** be totally the same as `validator` field:
152152

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.
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.
156156

157157
## Rationale
158158

0 commit comments

Comments
 (0)