4
4
5
5
This is the process for storing Mithril activation eras markers on the Cardano chain (bootstrap and update operations).
6
6
7
- :warning : The process described in this document can lead to disturbed service of the associated Mihtril network. Thus it should be manipulated by experts only.
7
+ > [ !IMPORTANT]
8
+ > :fire : The process described in this document can lead to disturbed service of the associated Mihtril network. Thus it should be manipulated by experts only.
8
9
9
10
## Pre-requisites
10
11
@@ -16,36 +17,119 @@ This is the process for storing Mithril activation eras markers on the Cardano c
16
17
17
18
## Setup
18
19
20
+ ### Setup environment variables
21
+
19
22
Export the environment variables needed to complete the process:
20
23
21
24
``` bash
22
- $ export CARDANO_NODE_SOCKET_PATH=** PATH_TO_YOUR_NODE_SOCKET**
23
- $ export CARDANO_TESTNET_MAGIC=** YOUR_TESTNET_MAGIC**
24
- $ export CARDANO_WALLET_PATH=** PATH_TO_YOUR_KEYPAIRS**
25
- $ export ERA_ACTIVATION_SECRET_KEY=** YOUR_ERA_ACTIVATION_SECRET_KEY**
26
- $ export ASSETS_PATH=** YOUR_ASSETS_PATH**
25
+ export CARDANO_CLI=** CARDANO_CLI_COMMAND**
26
+ export CARDANO_NODE_SOCKET_PATH=** PATH_TO_YOUR_NODE_SOCKET**
27
+ export CARDANO_WALLET_PATH=** PATH_TO_YOUR_KEYPAIRS**
28
+ export ERA_ACTIVATION_SECRET_KEY=** YOUR_ERA_ACTIVATION_SECRET_KEY**
29
+ export ASSETS_PATH=** YOUR_ASSETS_PATH**
30
+ export SCRIPT_TX_VALUE=** MINIUM_SCRIPT_TX_VALUE**
31
+ ```
32
+
33
+ A common value for the transaction amount used when a script transaction is made is:
34
+
35
+ ``` bash
36
+ export SCRIPT_TX_VALUE=2000000
37
+ ```
38
+
39
+ Compute the network magic parameter that handles both the Cardano mainnet and Cardano test networks:
40
+
41
+ - If this is for a testing network
42
+
43
+ ``` bash
44
+ export CARDANO_TESTNET_MAGIC=** YOUR_TESTNET_MAGIC**
45
+ export CARDANO_NETWORK_MAGIC=" --testnet-magic $CARDANO_TESTNET_MAGIC "
46
+ ```
47
+
48
+ - If this is for the ` mainnet `
49
+
50
+ ``` bash
51
+ export CARDANO_NETWORK_MAGIC=" --mainnet"
27
52
```
28
53
29
54
Compute the current Cardano era:
30
55
31
56
``` bash
32
- CARDANO_ERA=$( cardano-cli query tip --testnet-magic $CARDANO_TESTNET_MAGIC | jq -r ' .era |= ascii_downcase | .era' )
57
+ export CARDANO_ERA=$( $CARDANO_CLI query tip $CARDANO_NETWORK_MAGIC --socket-path $CARDANO_NODE_SOCKET_PATH | jq -r ' .era |= ascii_downcase | .era' )
58
+ ```
59
+
60
+ ### Prepare era markers
61
+
62
+ > [ !IMPORTANT]
63
+ > :fire : A misconfiguration of the era markers can cause disturbed service on a Mithril network. The ` CURRENT_ERA_EPOCH ` and ` NEXT_ERA_EPOCH ` must be selected very cautiously.
64
+
65
+ #### If there is only one supported era
66
+
67
+ Set the epoch at which the era is active:
68
+
69
+ ``` bash
70
+ export CURRENT_ERA_EPOCH=** ERA_FIRST_ACTIVATION_EPOCH**
71
+ ```
72
+
73
+ Create the datum file for a unique era:
74
+
75
+ ``` bash
76
+ ./mithril-aggregator era generate-tx-datum --current-era-epoch $CURRENT_ERA_EPOCH --era-markers-secret-key $ERA_ACTIVATION_SECRET_KEY --target-path $ASSETS_PATH /mithril-era-datum.json
33
77
```
34
78
35
- Set the transaction amount used when a script transaction is made:
79
+ #### If there are two supported era
80
+
81
+ Set the epoch at which the current era and the next era are active (the ` CURRENT_ERA_EPOCH ` must be lower than the current epoch and the ` NEXT_ERA_EPOCH ` must be set to a strictly greater epoch than the current epoch):
36
82
37
83
``` bash
38
- $ export SCRIPT_TX_VALUE=2000000
84
+ export CURRENT_ERA_EPOCH=** CURRENT_ERA_FIRST_ACTIVATION_EPOCH**
85
+ export NEXT_ERA_EPOCH=** NEXT_ERA_FIRST_ACTIVATION_EPOCH**
86
+ ```
87
+
88
+ Create the datum file for two eras:
89
+
90
+ ``` bash
91
+ ./mithril-aggregator era generate-tx-datum --current-era-epoch $CURRENT_ERA_EPOCH --next-era-epoch $NEXT_ERA_EPOCH --era-markers-secret-key $ERA_ACTIVATION_SECRET_KEY --target-path $ASSETS_PATH /mithril-era-datum.json
92
+ ```
93
+
94
+ #### Verify the produced era marker
95
+
96
+ > [ !IMPORTANT]
97
+ > :fire : The ` mithril-aggregator ` binary used to create the era markers must imperatively be compiled with all the targeted supported eras.
98
+
99
+ Verify that the produced era markers are exactly what is expected with the following command:
100
+
101
+ ``` bash
102
+ cat $ASSETS_PATH /mithril-era-datum.json| jq -r ' .fields[].bytes' | tr ' \n' ' ' | xxd -r -p | jq
103
+ ```
104
+
105
+ An example output of the command is:
106
+
107
+ ``` json
108
+ {
109
+ "markers" : [
110
+ {
111
+ "name" : " thales" ,
112
+ "epoch" : 1
113
+ },
114
+ {
115
+ "name" : " pythagoras" ,
116
+ "epoch" : 723
117
+ }
118
+ ],
119
+ "signature" : " fdcd45debabc148ef11c0bf71e42b7e583102dd5b8e486cd621a18e56136a57ff4f7bf9d036aed6148328a30a20eb6e79422ea4d1cc613e0bf97e14da64a5f00"
120
+ }
39
121
```
40
122
41
123
## Bootstrap Era Markers: Write a transaction with the first version of datum on chain
42
124
43
- :warning : This step must be done only once for an address
125
+ > [ !IMPORTANT]
126
+ > :fire : This step must be done only once for an address when no prior datum has been written in a UTxO.
127
+ > Otherwise, you need to refer to this [ section] ( #update-era-markers-write-a-new-version-of-datum-on-chain )
44
128
45
129
Verify that the payment address has funds:
46
130
47
131
``` bash
48
- $ cardano-cli query utxo --address $( cat $CARDANO_WALLET_PATH /payment.addr) --testnet-magic $CARDANO_TESTNET_MAGIC
132
+ $CARDANO_CLI query utxo --address $( cat $CARDANO_WALLET_PATH /payment.addr) $CARDANO_NETWORK_MAGIC --socket-path $CARDANO_NODE_SOCKET_PATH
49
133
TxHash TxIx Amount
50
134
--------------------------------------------------------------------------------------
51
135
f0c0345f151f9365fbbb4e7afa217e56b987d9e91fd754ca609d9dfec97275c7 0 10000000000 lovelace + TxOutDatumNone
@@ -54,57 +138,53 @@ f0c0345f151f9365fbbb4e7afa217e56b987d9e91fd754ca609d9dfec97275c7 0 10
54
138
And create the variable ` TX_IN={TxHash}#{TxIn} ` by replacing with values from the previous command:
55
139
56
140
``` bash
57
- $ TX_IN=f0c0345f151f9365fbbb4e7afa217e56b987d9e91fd754ca609d9dfec97275c7#0
58
- ```
59
-
60
- Create the initial datum file:
61
-
62
- ``` bash
63
- $ ./mithril-aggregator era generate-tx-datum --current-era-epoch 1 --era-markers-secret-key $ERA_ACTIVATION_SECRET_KEY --target-path $ASSETS_PATH /mithril-era-datum-1.json
141
+ TX_IN=f0c0345f151f9365fbbb4e7afa217e56b987d9e91fd754ca609d9dfec97275c7#0
64
142
```
65
143
66
144
Now create the bootstrap transaction with datum:
67
145
68
146
``` bash
69
- $ cardano-cli $CARDANO_ERA transaction build --testnet-magic $CARDANO_TESTNET_MAGIC \
147
+ $CARDANO_CLI $CARDANO_ERA transaction build $CARDANO_NETWORK_MAGIC \
70
148
--tx-in $TX_IN \
71
149
--tx-out $( cat $CARDANO_WALLET_PATH /payment.addr) +$SCRIPT_TX_VALUE \
72
- --tx-out-inline-datum-file $ASSETS_PATH /mithril-era-datum-1 .json \
150
+ --tx-out-inline-datum-file $ASSETS_PATH /mithril-era-datum.json \
73
151
--change-address $( cat $CARDANO_WALLET_PATH /payment.addr) \
74
- --out-file $ASSETS_PATH /tx.raw
152
+ --out-file $ASSETS_PATH /tx.raw \
153
+ --socket-path $CARDANO_NODE_SOCKET_PATH
75
154
Estimated transaction fee: Lovelace 168669
76
155
```
77
156
78
157
Then sign the transaction:
79
158
80
159
``` bash
81
- $ cardano-cli $CARDANO_ERA transaction sign \
160
+ $CARDANO_CLI $CARDANO_ERA transaction sign \
82
161
--tx-body-file $ASSETS_PATH /tx.raw \
83
162
--signing-key-file $CARDANO_WALLET_PATH /payment.skey \
84
- --testnet-magic $CARDANO_TESTNET_MAGIC \
163
+ $CARDANO_NETWORK_MAGIC \
85
164
--out-file $ASSETS_PATH /tx.signed
86
165
```
87
166
88
167
And submit it:
89
168
90
169
``` bash
91
- $ cardano-cli $CARDANO_ERA transaction submit \
92
- --testnet-magic $CARDANO_TESTNET_MAGIC \
93
- --tx-file $ASSETS_PATH /tx.signed
170
+ $CARDANO_CLI $CARDANO_ERA transaction submit \
171
+ $CARDANO_NETWORK_MAGIC \
172
+ --tx-file $ASSETS_PATH /tx.signed \
173
+ --socket-path $CARDANO_NODE_SOCKET_PATH
94
174
Transaction successfully submitted.
95
175
```
96
176
97
177
Also get the transaction id:
98
178
99
179
``` bash
100
- $ cardano-cli transaction txid --tx-file $ASSETS_PATH /tx.signed
180
+ $CARDANO_CLI transaction txid --tx-file $ASSETS_PATH /tx.signed
101
181
6518b3cea0b49b55746ec61148e7c60ab042959d534f6bb6e8f6a844d4af69fb
102
182
```
103
183
104
184
We need to wait a few seconds before the transaction is available and we can see the initial datum for the script address:
105
185
106
186
``` bash
107
- $ cardano-cli query utxo --address $( cat $CARDANO_WALLET_PATH /payment.addr) --testnet-magic $CARDANO_TESTNET_MAGIC
187
+ $CARDANO_CLI query utxo --address $( cat $CARDANO_WALLET_PATH /payment.addr) $CARDANO_NETWORK_MAGIC --socket-path $CARDANO_NODE_SOCKET_PATH
108
188
TxHash TxIx Amount
109
189
--------------------------------------------------------------------------------------
110
190
6518b3cea0b49b55746ec61148e7c60ab042959d534f6bb6e8f6a844d4af69fb 0 1500000 lovelace + TxOutDatumInline ReferenceTxInsScriptsInlineDatumsInBabbageEra (ScriptDataConstructor 0 [ScriptDataBytes " [{\" n\" :\" thales\" ,\" e\" :1}]" ,ScriptDataBytes " \165\143\232\227\&6\244e\222\211\187\167\197\167\175\229\181\162o/\182[|Nnt.h\ACKE\241=\242\139\242\182:a\204r\217\200&\190I\SO,\US\DLE\152\217U\223P5\128\164\232\153\181\ETB8\132\227\SO" ])
@@ -116,7 +196,7 @@ Optional: We can retrieve the initial value stored in the datum with the cardano
116
196
The full utxo json representation:
117
197
118
198
``` bash
119
- $ cardano-cli query utxo --address $( cat $CARDANO_WALLET_PATH /payment.addr) --testnet-magic $CARDANO_TESTNET_MAGIC --out-file temp.json && cat temp.json | jq ' . [] | select(.inlineDatum | . != null and . != "")'
199
+ $CARDANO_CLI query utxo --address $( cat $CARDANO_WALLET_PATH /payment.addr) $CARDANO_NETWORK_MAGIC --socket-path $CARDANO_NODE_SOCKET_PATH --out-file temp.json && cat temp.json | jq ' . [] | select(.inlineDatum | . != null and . != "")'
120
200
{
121
201
" address" : " addr_test1qzzngukkj9ydjemqjlgfn42sevy2xnvauay46weushlpuq9thd4ray00csjssf4sxftv04xeequ3xfx72nujg9y4d5ysgkxxlh" ,
122
202
" datum" : null,
@@ -141,12 +221,14 @@ $ cardano-cli query utxo --address $(cat $CARDANO_WALLET_PATH/payment.addr) --te
141
221
142
222
## Update Era Markers: Write a new version of datum on chain
143
223
144
- :warning : This step must be used anytime the era markers must be updated on chain
224
+ > [ !IMPORTANT]
225
+ > :fire : This step must be used anytime the era markers must be updated on chain for an address when prior datum has already been written in a UTxO.
226
+ > Otherwise, you need to refer to this [ section] ( #bootstrap-era-markers-write-a-transaction-with-the-first-version-of-datum-on-chain )
145
227
146
228
Retrieve the utxo of the payment address:
147
229
148
230
``` bash
149
- $ cardano-cli query utxo --address $( cat $CARDANO_WALLET_PATH /payment.addr) --testnet-magic $CARDANO_TESTNET_MAGIC
231
+ $CARDANO_CLI query utxo --address $( cat $CARDANO_WALLET_PATH /payment.addr) $CARDANO_NETWORK_MAGIC --socket-path $CARDANO_NODE_SOCKET_PATH
150
232
TxHash TxIx Amount
151
233
--------------------------------------------------------------------------------------
152
234
6518b3cea0b49b55746ec61148e7c60ab042959d534f6bb6e8f6a844d4af69fb 0 1500000 lovelace + TxOutDatumInline ReferenceTxInsScriptsInlineDatumsInBabbageEra (ScriptDataConstructor 0 [ScriptDataBytes " [{\" n\" :\" thales\" ,\" e\" :1}]" ,ScriptDataBytes " \165\143\232\227\&6\244e\222\211\187\167\197\167\175\229\181\162o/\182[|Nnt.h\ACKE\241=\242\139\242\182:a\204r\217\200&\190I\SO,\US\DLE\152\217U\223P5\128\164\232\153\181\ETB8\132\227\SO" ])
@@ -156,66 +238,60 @@ $ cardano-cli query utxo --address $(cat $CARDANO_WALLET_PATH/payment.addr) --te
156
238
And create the variable ` TX_IN_DATUM={TxHash}#{TxIn} ` by replacing with values from the previous command (where inline datumn are available):
157
239
158
240
``` bash
159
- $ TX_IN_DATUM=6518b3cea0b49b55746ec61148e7c60ab042959d534f6bb6e8f6a844d4af69fb#0
241
+ TX_IN_DATUM=6518b3cea0b49b55746ec61148e7c60ab042959d534f6bb6e8f6a844d4af69fb#0
160
242
```
161
243
162
244
And create the variable ` TX_IN_NO_DATUM={TxHash}#{TxIn} ` by replacing with values from the previous command (where inline datumn are not available):
163
245
164
246
``` bash
165
- $ TX_IN_NO_DATUM=6518b3cea0b49b55746ec61148e7c60ab042959d534f6bb6e8f6a844d4af69fb#1
166
- ```
167
-
168
- Create the updated datum file:
169
-
170
- :warning : The options provided in the following command are for example only, you need to use adequately the options of the ` era generate-tx-datum ` command, which will depend on the operation you want to execute: announce an upcoming era or activate an upcoming era. This operation should be done very cautiously as a misconfiguration can lead to disturbed service of the network.
171
-
172
- ``` bash
173
- $ ./mithril-aggregator era generate-tx-datum --current-era-epoch 1 --era-markers-secret-key $ERA_ACTIVATION_SECRET_KEY --target-path $ASSETS_PATH /mithril-era-datum-2.json
247
+ TX_IN_NO_DATUM=6518b3cea0b49b55746ec61148e7c60ab042959d534f6bb6e8f6a844d4af69fb#1
174
248
```
175
249
176
250
Now create the update transaction with datum:
177
251
178
252
``` bash
179
- $ cardano-cli $CARDANO_ERA transaction build --testnet-magic $CARDANO_TESTNET_MAGIC \
253
+ $CARDANO_CLI $CARDANO_ERA transaction build $CARDANO_NETWORK_MAGIC \
180
254
--tx-in $TX_IN_DATUM \
181
255
--tx-in $TX_IN_NO_DATUM \
182
256
--tx-out $( cat $CARDANO_WALLET_PATH /payment.addr) +$SCRIPT_TX_VALUE \
183
- --tx-out-inline-datum-file $ASSETS_PATH /mithril-era-datum-2 .json \
257
+ --tx-out-inline-datum-file $ASSETS_PATH /mithril-era-datum.json \
184
258
--change-address $( cat $CARDANO_WALLET_PATH /payment.addr) \
185
- --out-file $ASSETS_PATH /tx.raw
259
+ --out-file $ASSETS_PATH /tx.raw \
260
+ --socket-path $CARDANO_NODE_SOCKET_PATH
186
261
Estimated transaction fee: Lovelace 179889
187
262
```
188
263
189
264
Then sign the transaction:
190
265
191
266
``` bash
192
- $ cardano-cli $CARDANO_ERA transaction sign \
267
+ $CARDANO_CLI $CARDANO_ERA transaction sign \
193
268
--tx-body-file $ASSETS_PATH /tx.raw \
194
269
--signing-key-file $CARDANO_WALLET_PATH /payment.skey \
195
- --testnet-magic $CARDANO_TESTNET_MAGIC \
270
+ $CARDANO_NETWORK_MAGIC \
196
271
--out-file $ASSETS_PATH /tx.signed
197
272
```
198
273
199
274
And submit it:
200
275
201
276
``` bash
202
- $ cardano-cli $CARDANO_ERA transaction submit \
203
- --testnet-magic $CARDANO_TESTNET_MAGIC \
204
- --tx-file $ASSETS_PATH /tx.signed
277
+ $CARDANO_CLI $CARDANO_ERA transaction submit \
278
+ $CARDANO_NETWORK_MAGIC \
279
+ --tx-file $ASSETS_PATH /tx.signed \
280
+ --socket-path $CARDANO_NODE_SOCKET_PATH
205
281
Transaction successfully submitted.
206
282
```
207
283
208
284
Also get the transaction id:
209
285
210
286
``` bash
211
- $ cardano-cli transaction txid --tx-file $ASSETS_PATH /tx.signed
287
+ $CARDANO_CLI transaction txid --tx-file $ASSETS_PATH /tx.signed
212
288
1fd4d3e131afe3c8b212772a3f3083d2fbc6b2a7b20e54e4ff08e001598818d8
213
289
```
214
290
215
291
We need to wait a few seconds before the transaction is available and we can see the updated datum for the script address:
216
292
217
293
``` bash
218
- $ cardano-cli query utxo --address $( cat $CARDANO_WALLET_PATH /payment.addr) --testnet-magic $CARDANO_TESTNET_MAGIC
294
+ $CARDANO_CLI query utxo --address $( cat $CARDANO_WALLET_PATH /payment.addr) $CARDANO_NETWORK_MAGIC --socket-path $CARDANO_NODE_SOCKET_PATH
219
295
TxHash TxIx Amount
220
296
--------------------------------------------------------------------------------------
221
297
1f139b47017c9c90d4622ac768e249d25d37ad4461db44a20486b7da72a78915 0 2000000 lovelace + TxOutDatumInline ReferenceTxInsScriptsInlineDatumsInBabbageEra (ScriptDataConstructor 0 [ScriptDataBytes " [{\" n\" :\" thales\" ,\" e\" :1},{\" n\" :\" pythagoras\" ,\" e\" :null}]" ,ScriptDataBytes " ^P\EOT\248k3\196/\139\tU\173H\138\FS\194MD\240\153\227\142z\181\134\213\168\&2\222\219i1\246\NAK\\ ]\247\154U\143-^vmtq\204\207#\236\213\f\201\&1\152\145(\161\ETX;\183\128\195\r" ])
@@ -227,7 +303,7 @@ We can retrieve the updated value stored in the datum with the cardano cli:
227
303
The full utxo json representation:
228
304
229
305
``` bash
230
- $ cardano-cli query utxo --address $( cat $CARDANO_WALLET_PATH /payment.addr) --testnet-magic $CARDANO_TESTNET_MAGIC --out-file temp.json && cat temp.json | jq ' . [] | select(.inlineDatum | . != null and . != "")'
306
+ $CARDANO_CLI query utxo --address $( cat $CARDANO_WALLET_PATH /payment.addr) $CARDANO_NETWORK_MAGIC --socket-path $CARDANO_NODE_SOCKET_PATH --out-file temp.json && cat temp.json | jq ' . [] | select(.inlineDatum | . != null and . != "")'
231
307
{
232
308
" address" : " addr_test1qzzngukkj9ydjemqjlgfn42sevy2xnvauay46weushlpuq9thd4ray00csjssf4sxftv04xeequ3xfx72nujg9y4d5ysgkxxlh" ,
233
309
" datum" : null,
0 commit comments