-
Notifications
You must be signed in to change notification settings - Fork 1
/
update-5.sh
executable file
·82 lines (56 loc) · 2.82 KB
/
update-5.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
#!/usr/bin/env bash
set -e
# set -x
# This script will initiate the transition to protocol version 5 (Alonzo).
# You need to provide the current epoch as a positional argument (the Shelley
# update system requires this to be includded in the update proposal).
# In order for this to be successful, you need to already be in protocol version
# 4 (which happens one or two epoch boundaries after invoking update-4.sh).
# Also, you need to restart the nodes after running this script in order for the
# update to be endorsed by the nodes.
if [ ! "$1" ]; then echo "update-5.sh: expects an <N> epoch argument"; exit; fi
EPOCH=$1
VERSION=5
ROOT=example
COINS_IN_INPUT=$(cardano-cli query utxo --address $(cat example/addresses/user1.addr) --testnet-magic 141 | grep \ 0\ |awk '{print $3}')
pushd ${ROOT}
export CARDANO_NODE_SOCKET_PATH=node-bft1/node.sock
#TXID2=$(cardano-cli transaction txid --tx-file tx3.tx)
TXID=$(cardano-cli transaction txid --tx-file ${3})
# Create the update proposal to change the protocol version to 5
rm -f update-proposal-alonzo && cardano-cli governance create-update-proposal \
--out-file update-proposal-alonzo \
--epoch ${EPOCH} \
--genesis-verification-key-file shelley/genesis-keys/genesis1.vkey \
--protocol-major-version ${VERSION} \
--protocol-minor-version 0
# Create a transaction body containing the update proposal.
cardano-cli transaction build-raw \
--mary-era \
--fee 0 \
--tx-in $TXID#0\
--tx-out $(cat addresses/user1.addr)+$((${COINS_IN_INPUT} )) \
--update-proposal-file update-proposal-alonzo \
--out-file tx4.txbody
FEE=$(cardano-cli transaction calculate-min-fee --tx-body-file tx3.txbody --tx-in-count 1 --tx-out-count 1 --witness-count 2 --genesis shelley/genesis.json | awk '{print $1}')
rm -f tx4.txbody && cardano-cli transaction build-raw \
--mary-era \
--fee ${FEE} \
--tx-in $TXID#0\
--tx-out $(cat addresses/user1.addr)+$(( ${COINS_IN_INPUT} - ${FEE} )) \
--update-proposal-file update-proposal-alonzo \
--out-file tx4.txbody
# Sign the transaction body with the two genesis delegate keys,
# and the the uxto spending key.
cardano-cli transaction sign \
--signing-key-file addresses/user1.skey \
--signing-key-file shelley/delegate-keys/delegate1.skey \
--testnet-magic 141 \
--tx-body-file tx4.txbody \
--out-file tx4.tx
cardano-cli transaction submit --tx-file tx4.tx --testnet-magic 141
sed -i config.json \
-e 's/LastKnownBlockVersion-Major": 4/LastKnownBlockVersion-Major": 5/' \
popd
echo "Restart the nodes now to endorse the update."
#cardano-cli transaction submit --cardano-mode --testnet-magic 141 --tx-file mary.tx