2021-06-29 19:01:40 +00:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
|
|
|
# Source env settings
|
|
|
|
. .env
|
|
|
|
. services/ir/.ir.env
|
2022-06-10 08:32:20 +00:00
|
|
|
source bin/helper.sh
|
2021-06-29 19:01:40 +00:00
|
|
|
|
|
|
|
# NeoGo binary path.
|
|
|
|
NEOGO="${NEOGO:-docker exec -it main_chain neo-go}"
|
2022-07-26 17:23:11 +00:00
|
|
|
NEOGO_NONINTERACTIVE="${NEOGO_NONINTERACTIVE:-docker exec -t main_chain neo-go}"
|
2021-06-29 19:01:40 +00:00
|
|
|
|
|
|
|
# Wallet files to change config value
|
|
|
|
WALLET="${WALLET:-services/chain/node-wallet.json}"
|
|
|
|
WALLET_IMG="${WALLET_IMG:-wallets/node-wallet.json}"
|
|
|
|
|
|
|
|
# Wallet password that would be entered automatically; '-' means no password
|
|
|
|
PASSWD="one"
|
|
|
|
|
|
|
|
# Internal variables
|
2021-07-22 17:22:58 +00:00
|
|
|
if [[ -z "${NEOFS_NOTARY_DISABLED}" ]]; then
|
2022-06-10 08:32:20 +00:00
|
|
|
ADDR=$(jq -r .accounts[2].address < "${WALLET}" || die "Cannot get address from ${WALLET}")
|
2021-07-22 17:22:58 +00:00
|
|
|
else
|
2022-06-10 08:32:20 +00:00
|
|
|
ADDR=$(jq -r .accounts[0].address < "${WALLET}" || die "Cannot get address from ${WALLET}")
|
2021-07-22 17:22:58 +00:00
|
|
|
fi
|
2021-06-29 19:01:40 +00:00
|
|
|
|
2021-08-25 12:20:40 +00:00
|
|
|
# Grep Morph block time
|
|
|
|
SIDECHAIN_PROTO="${SIDECHAIN_PROTO:-services/morph_chain/protocol.privnet.yml}"
|
2022-06-10 08:32:20 +00:00
|
|
|
BLOCK_DURATION=$(grep SecondsPerBlock < "$SIDECHAIN_PROTO" | awk '{print $2}') \
|
|
|
|
|| die "Cannot fetch block duration"
|
|
|
|
NETMAP_ADDR=$(bin/resolve.sh netmap.neofs) || die "Cannot resolve netmap.neofs"
|
2021-08-25 12:20:40 +00:00
|
|
|
|
2021-06-29 19:01:40 +00:00
|
|
|
# Fetch current epoch value
|
2022-07-26 17:23:11 +00:00
|
|
|
EPOCH=$(${NEOGO_NONINTERACTIVE} contract testinvokefunction \
|
2022-06-10 08:32:20 +00:00
|
|
|
-r "http://morph-chain.${LOCAL_DOMAIN}:30333" "${NETMAP_ADDR}" epoch \
|
|
|
|
| grep 'value' | awk -F'"' '{ print $4 }') \
|
|
|
|
|| die "Cannot fetch epoch from netmap contract"
|
2021-06-29 19:01:40 +00:00
|
|
|
|
|
|
|
echo "Updating NeoFS epoch to $((EPOCH+1))"
|
2022-06-10 08:32:20 +00:00
|
|
|
|
|
|
|
# shellcheck disable=SC2086
|
2021-06-29 19:01:40 +00:00
|
|
|
./bin/passwd.exp ${PASSWD} ${NEOGO} contract invokefunction \
|
2022-06-10 08:32:20 +00:00
|
|
|
-w ${WALLET_IMG} \
|
|
|
|
-a ${ADDR} \
|
|
|
|
-r http://morph-chain.${LOCAL_DOMAIN}:30333 \
|
|
|
|
${NETMAP_ADDR} \
|
|
|
|
newEpoch int:$((EPOCH+1)) -- ${ADDR}:Global
|
2021-08-25 12:20:40 +00:00
|
|
|
|
|
|
|
# Wait one Morph block to ensure the transaction broadcasted
|
2022-06-10 08:32:20 +00:00
|
|
|
# shellcheck disable=SC2086
|
2021-08-25 12:20:40 +00:00
|
|
|
sleep $BLOCK_DURATION
|