-
Notifications
You must be signed in to change notification settings - Fork 1
/
update4_new.sh
executable file
·81 lines (54 loc) · 2.66 KB
/
update4_new.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
#!/usr/bin/env bash
set -e
# set -x
# This script will initiate the transition to protocol version 4 (Mary).
# 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
# 3 (which happens one or two epoch boundaries after invoking update-3.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-4.sh: expects an <N> epoch argument"; exit; fi
EPOCH=$1
#VERSION=4
VERSION=$2
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 tx2.tx)
TXID=$(cardano-cli transaction txid --tx-file ${3})
# Create the update proposal to change the protocol version to 4
cardano-cli governance create-update-proposal \
--out-file update-proposal-mary \
--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 \
--fee 0 \
--tx-in $TXID#0\
--tx-out $(cat addresses/user1.addr)+$((${COINS_IN_INPUT} )) \
--update-proposal-file update-proposal-mary \
--out-file tx3.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 tx3.txbody && cardano-cli transaction build-raw \
--fee ${FEE} \
--tx-in $TXID#0\
--tx-out $(cat addresses/user1.addr)+$(( ${COINS_IN_INPUT} - ${FEE} )) \
--update-proposal-file update-proposal-mary \
--out-file tx3.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 tx3.txbody \
--out-file tx3.tx
cardano-cli transaction submit --tx-file tx3.tx --testnet-magic 141
sed -i config.json \
-e 's/LastKnownBlockVersion-Major": 3/LastKnownBlockVersion-Major": 4/' \
popd
echo "Restart the nodes now to endorse the update."