2021-06-29 19:01:40 +00:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
2022-11-14 12:15:00 +00:00
|
|
|
echo "Running bin/tick.sh"
|
|
|
|
|
2021-06-29 19:01:40 +00:00
|
|
|
# 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.
|
2022-11-14 12:15:00 +00:00
|
|
|
NEOGO="${NEOGO:-docker exec 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}"
|
2022-11-14 12:15:00 +00:00
|
|
|
CONFIG_IMG="${CONFIG_IMG:-/wallets/config.yml}"
|
2021-06-29 19:01:40 +00:00
|
|
|
|
|
|
|
# Internal variables
|
2022-12-21 12:34:14 +00:00
|
|
|
if [[ -z "${FROSTFS_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-11-14 12:15:00 +00:00
|
|
|
EPOCH=$(${NEOGO} 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
|
|
|
|
2022-12-21 12:34:14 +00:00
|
|
|
echo "Updating FrostFS epoch to $((EPOCH+1))"
|
2022-06-10 08:32:20 +00:00
|
|
|
|
|
|
|
# shellcheck disable=SC2086
|
2022-11-14 12:15:00 +00:00
|
|
|
${NEOGO} contract invokefunction \
|
|
|
|
--wallet-config ${CONFIG_IMG} \
|
|
|
|
-a ${ADDR} --force \
|
2022-06-10 08:32:20 +00:00
|
|
|
-r http://morph-chain.${LOCAL_DOMAIN}:30333 \
|
|
|
|
${NETMAP_ADDR} \
|
2022-11-14 12:15:00 +00:00
|
|
|
newEpoch int:$((EPOCH+1)) -- ${ADDR}:Global \
|
|
|
|
|| die "Cannot increment an epoch"
|
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
|