Skip to content

Commit 0221c37

Browse files
feat(rust/rbac-registration): Update RBAC examples according to the latest channges (#314)
* Describe overriding chains with multiple stake addresses * Rename stake addresses according to other examples * Describe new decisions * Review comments * Update rust/rbac-registration/examples.md Co-authored-by: Artur Helmanau <[email protected]> * Update rust/rbac-registration/examples.md Co-authored-by: Artur Helmanau <[email protected]> * Update rust/rbac-registration/examples.md Co-authored-by: Artur Helmanau <[email protected]> * Update rust/rbac-registration/examples.md Co-authored-by: Artur Helmanau <[email protected]> * Some more changes * More fixes * Clarify that is is forbidden to reuse a public key in different chains --------- Co-authored-by: Artur Helmanau <[email protected]>
1 parent cc9ba8f commit 0221c37

File tree

1 file changed

+126
-68
lines changed

1 file changed

+126
-68
lines changed

rust/rbac-registration/examples.md

Lines changed: 126 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,10 @@ a letter with a number (`A0 --- A1`) when there are multiple ones.
2828
```mermaid
2929
flowchart LR
3030
Root[Cert] --- R1[Cert] --- R2[Cert] --- R3[...]
31+
style Root fill: green
32+
style R1 fill: green
33+
style R2 fill: green
34+
style R3 fill: green
3135
```
3236

3337
It is allowed to update the role 0 with the exact same certificate.
@@ -39,9 +43,12 @@ to prevent it.
3943
```mermaid
4044
flowchart LR
4145
Root[Valid Root] --- R1[Valid update 1] --- R2[Invalid update 2] --- R3[Invalid update 3]
42-
R1 --- R4[Valid update 4]
46+
R1 ----- R4[Valid update 4]
47+
style Root fill: green
48+
style R1 fill: green
4349
style R2 fill: red
44-
style R3 fill: red
50+
style R3 fill: yellow
51+
style R4 fill: green
4552
```
4653

4754
All following registrations (either a role update or an additional role) must reference the previous valid registration.
@@ -61,6 +68,7 @@ flowchart LR
6168
Root[Root] --- A[A]
6269
Root --- B[B]
6370
Root --- C[C]
71+
style Root fill: green
6472
style A fill: yellow
6573
style B fill: yellow
6674
style C fill: yellow
@@ -71,31 +79,40 @@ no way to specify the ordering.
7179
Therefore, one should normally wait for the previous transaction to be processed before submitting the next one.
7280

7381
In the example above there are three transactions: `A`, `B` and `C`.
74-
If all of them reference the root registration and are included into the same block then only one of them will be
75-
applied to the registration chain and the other two will be considered invalid.
76-
If these transactions reference each other (`A - B - C`) then only the first one will be applied regardless of the
77-
processing order.
82+
If all of them reference the root registration and are included into the same block then only one of them that has the
83+
lowest transaction index will be applied to the registration chain and the other two will be considered invalid.
84+
If these transactions reference each other (`A - B - C`) then the order entirely depends on Cardano blockchain and
85+
cannot be predicted.
86+
It is possible that transactions `B` and `C` would be executed first and rejected as invalid and only `A` will be
87+
applied.
88+
It is better to avoid such situations and submit the next transaction after the previous one was included into a block.
7889

7990
### Branching registrations
8091

8192
```mermaid
8293
flowchart LR
83-
Root[Slot 100] --- R1[Slot 110] --- R2[Slot 121]
84-
Root ---- R3[Slot 120] --- R4[Slot 130]
94+
Root[Slot 100] --- R1[Slot 110] --- R2[Slot 120]
95+
Root ----- R3[Slot 130] --- R4[Slot 140]
96+
style Root fill: green
97+
style R1 fill: green
98+
style R2 fill: green
8599
style R3 fill: red
86-
style R4 fill: red
100+
style R4 fill: yellow
87101
```
88102

89-
It isn't allowed to reference not the latest registration in the chain.
90-
In the example the registration in the slot number 120 would be ignored because it references the root registration, but
91-
the latest transaction is the one in the slot number 110.
92-
The registration in the slot number 130 is ignored because it references an invalid transaction.
103+
Only the latest valid registration in the chain can be referenced.
104+
In the example the registration at slot 130 is ignored because it references the root registration, while the most
105+
recent valid transaction is the one at slot 120.
106+
The registration at slot 140 is also ignored because it references an invalid transaction.
93107

94108
### Updating a stake address
95109

96110
```mermaid
97111
flowchart LR
98112
Root[Stake1] --- R1[Stake2] --- R2[Stake3]
113+
style Root fill: green
114+
style R1 fill: green
115+
style R2 fill: green
99116
```
100117

101118
It is allowed to change a stake address by updating the role 0.
@@ -105,6 +122,9 @@ It is allowed to change a stake address by updating the role 0.
105122
```mermaid
106123
flowchart LR
107124
Root[PubKey1] --- R1[PubKey2] --- R2[PubKey3]
125+
style Root fill: green
126+
style R1 fill: green
127+
style R2 fill: green
108128
```
109129

110130
It is allowed to change a subject public key by updating the role 0.
@@ -115,78 +135,116 @@ In the example above the Catalyst ID is based on the `PubKey1`.
115135
### Reusing a public key
116136

117137
```mermaid
118-
flowchart LR
119-
subgraph Chain4
120-
direction LR
121-
E0[Stake4 PubKey3]
122-
end
123-
subgraph Chain3
124-
direction LR
125-
D0[Stake3 PubKey2]
126-
end
127-
subgraph Chain2
128-
direction LR
129-
B0[Stake2 PubKey1]
130-
end
131-
subgraph Chain1
132-
direction LR
133-
A0[Stake1 PubKey1] --- A1[Stake1 PubKey2] --- A2[Stake1 PubKey3]
134-
end
138+
block-beta
139+
columns 5
140+
space s1["slot 1"] s2["slot 2"] s3["slot 3"] s4["slot 4"]
141+
c1["chain 1"] A0["Stake1\nPubKey1"] A1["Stake1\nPubKey2"] A2["Stake1\nPubKey3"] space
142+
c2["chain 2"] space space space B0["Stake2\nPubKey1"]
143+
c3["chain 3"] space space space C0["Stake3\nPubKey2"]
144+
c4["chain 4"] space space space D0["Stake4\nPubKey3"]
145+
style A0 fill: green
146+
style A1 fill: green
147+
style A2 fill: red
148+
style B0 fill: red
149+
style C0 fill: red
150+
style D0 fill: green
135151
```
136152

137-
It isn't allowed to use the key that was already used to start any of existing chains because it would result in the
138-
same Catalyst ID.
139-
In the example above the `Chain1` chain consists of the initial registration with the `PubKey1` key (therefore the
140-
Catalyst ID is based on it) with two subject public key updates (`PubKey2` and `PubKey3`).
141-
The `Chain2` chain is invalid because it uses the same `PubKey1` and would have the same Catalyst ID.
142-
Both `Chain3` and `Chain4` chains are valid even though they use the `PubKey2` and `PubKey3` keys that are already used
143-
in the `Chain1` chain.
153+
It isn't allowed to use a role 0 public key that was used in any of the other registration chains.
144154

145-
It is worth noting that while it is allowed to reuse a public key there is no practical reason to do so.
146-
The existing chain can be updated instead.
155+
In the example above the third registration in the first chain is invalid, so `PubKey3` that is used in that transaction
156+
can be used in the fourth chain.
157+
Both second and third chain are invalid because they use `PubKey1` and `PubKey2` keys that are already used in the first
158+
chain.
147159

148160
### Restarting a chain
149161

150162
```mermaid
151-
flowchart LR
152-
subgraph Chain4
153-
direction LR
154-
E0[Stake2 PubKey3]
155-
end
156-
subgraph Chain3
157-
direction LR
158-
D0[Stake1 PubKey2]
159-
end
160-
subgraph Chain2
161-
direction LR
162-
B0[Stake2 PubKey2]
163-
end
164-
subgraph Chain1
165-
direction LR
166-
A0[Stake1 PubKey1] --- A1[Stake2 PubKey2]
167-
end
163+
block-beta
164+
columns 7
165+
space s1["slot 1"] s2["slot 2"] s3["slot 3"] s4["slot 4"] space res["result"]
166+
c1["chain 1"] A0["Stake1\nPubKey1"] A1["Stake2\nPubKey2"] space space space AF["\nPubKey2"]
167+
c2["chain 2"] space space B0["Stake2\nPubKey2"] space space space
168+
c3["chain 4"] space space space C0["Stake1\nPubKey3"] space CF["Stake1\nPubKey3"]
169+
c4["chain 5"] space space space D0["Stake2\nPubKey4"] space DF["Stake2\nPubKey4"]
170+
style A0 fill: green
171+
style A1 fill: green
172+
style AF fill: gray
173+
style B0 fill: red
174+
style C0 fill: green
175+
style CF fill: green
176+
style D0 fill: green
177+
style DF fill: green
168178
```
169179

170180
In the example above there is the `Chain1` registration chain that was created with some `Stake1` stake address and
171181
`PubKey1` key then both address and key were updated to `Stake2` and `PubKey2`.
182+
172183
The `Chain2` registration is invalid because it uses the same stake address and key.
173184
There are no reason to start a new registration chain with the same data already registered and not to update the
174185
existing one, so this isn't allowed.
175186

176-
The `Chain3` registration is valid because the `PubKey2` key wasn't used before to start a chain and the `Stake1` stake
177-
address isn't currently used by `Chain1`.
178-
Warning: this scenario is currently problematic because we never remove entries from the `catalyst_id_for_stake_address`
179-
table.
180-
Therefore, when registration information is requested using the `Stake1` address we need to build both chains to
181-
determine that only `Chain3` is relevant.
187+
The `Chain3` is valid because it uses a new public key and the `Stake1` stake address isn't currently used by `Chain1`.
182188

183-
The `Chain4` registration is valid, but it "overrides" `Chain1` essentially discarding it and starting a new chain
184-
because it has the same stake address (`Stake2`).
189+
The `Chain4` registration is valid, but it takes ownership over the `Stake2` stake address of the first chain.
190+
It is allowed because the new chain uses a new public key.
185191
This can be useful if a user lost his private key while maintaining access to his Cardano wallet (and the stake address
186192
used in that registration chain).
187-
After that `Chain1` is considered no longer valid and must not be used.
193+
This can also be referred to as "restarting" or "overriding" a chain.
194+
After that `Chain1` is still valid and can be potentially continued, but as for now it has zero voting power because it
195+
has no active stake address.
196+
It is allowed to use an RBAC token based on that chain and perform actions such as submitting a proposal.
197+
198+
### Restarting multiple chains
199+
200+
```mermaid
201+
block-beta
202+
columns 6
203+
space s1["slot 1"] s2["slot 2"] s3["slot 3"] space res["result"]
204+
c1["chain 1"] A0["..."] A1["Stake1\nPubKey1"] space space AF["\nPubKey1"]
205+
c2["chain 2"] B0["..."] B1["Stake2\nPubKey2"] space space BF["\nPubKey2"]
206+
c3["chain 3"] space space C0["Stake1, Stake2\nPubKey3"] space CF["Stake1, Stake2\nPubKey3"]
207+
style A0 fill: green
208+
style A1 fill: green
209+
style AF fill: gray
210+
style B0 fill: green
211+
style B1 fill: green
212+
style BF fill: gray
213+
style C0 fill: green
214+
style CF fill: green
215+
```
216+
217+
It is possible to restart/override multiple chains with one new registration.
218+
In the example above there are two chains with stake addresses `Stake1` and `Stake2` correspondingly.
219+
The new root registration contains both of these addresses, so assuming it is valid, it "restarts" both previous
220+
registrations.
221+
222+
As explained in the [restarting a chain](#restarting-a-chain) example, a new registration must use a different public
223+
key, so using both `PubKey1` and `PubKey2` isn't allowed.
224+
225+
Both first and second chains are still valid and can be continued, but have zero voting power unless a new stake address
226+
is associated with them by a registration update.
188227

189-
### Multiple stake addresses
228+
### Restarting chain(s) with multiple stake addresses
229+
230+
```mermaid
231+
block-beta
232+
columns 6
233+
space s1["slot 1"] s2["slot 2"] s3["slot 3"] space res["result"]
234+
c1["chain 1"] A0["..."] A1["Stake1, Stake2\nPubKey1"] space space AF["\nPubKey1"]
235+
c2["chain 2"] B0["..."] B1["Stake3, Stake4\nPubKey2"] space space BF["Stake4\nPubKey2"]
236+
c3["chain 3"] space space C0["Stake1, Stake2, Stake3\nPubKey3"] space CF["Stake1, Stake2, Stake3\nPubKey2"]
237+
style A0 fill: green
238+
style A1 fill: green
239+
style AF fill: gray
240+
style B0 fill: green
241+
style B1 fill: green
242+
style BF fill: green
243+
style C0 fill: green
244+
style CF fill: green
245+
```
190246

191-
Multiple stake addresses support will be addressed in a future revision.
192-
Currently we only support a single stake address per registration chain.
247+
It isn't required for a new chain to use all stake addresses of a previous one.
248+
In the example above the new registration uses only three addresses of four used in two previous chains.
249+
As a result, the first chain has no active stake addresses, but the second one still has the `Stake4` stake address
250+
associated with it.

0 commit comments

Comments
 (0)