From 9a7c70c5c6fa14706c315edddc2b3ad6bd740589 Mon Sep 17 00:00:00 2001 From: Alex Vanin Date: Tue, 29 Jun 2021 22:01:40 +0300 Subject: [PATCH] [#106] bin: Add separate tick epoch script Signed-off-by: Alex Vanin --- bin/config.sh | 14 +------------- bin/tick.sh | 32 ++++++++++++++++++++++++++++++++ neofs_config.mk | 4 +--- 3 files changed, 34 insertions(+), 16 deletions(-) create mode 100755 bin/tick.sh diff --git a/bin/config.sh b/bin/config.sh index 5160cbf..dc89216 100755 --- a/bin/config.sh +++ b/bin/config.sh @@ -34,17 +34,5 @@ setConfig bytes:beefcafe \ string:${KEY} \ int:${VALUE} -- ${ADDR} || exit 1 -# Fetch current epoch value -EPOCH=`${NEOGO} contract testinvokefunction -r \ -http://morph_chain.${LOCAL_DOMAIN}:30333 \ -${NEOFS_IR_CONTRACTS_NETMAP} \ -epoch | grep 'value' | awk -F'"' '{ print $4 }'` - # Update epoch to apply new configuration value -echo "Updating NeoFS epoch to $((EPOCH+1))" -./bin/passwd.exp ${PASSWD} ${NEOGO} contract invokefunction \ --w ${WALLET_IMG} \ --a ${ADDR} \ --r http://morph_chain.${LOCAL_DOMAIN}:30333 \ -${NEOFS_IR_CONTRACTS_NETMAP} \ -newEpoch int:$((EPOCH+1)) -- ${ADDR}:Global +./bin/tick.sh diff --git a/bin/tick.sh b/bin/tick.sh new file mode 100755 index 0000000..a6f3530 --- /dev/null +++ b/bin/tick.sh @@ -0,0 +1,32 @@ +#!/usr/bin/env bash + +# Source env settings +. .env +. services/ir/.ir.env + +# NeoGo binary path. +NEOGO="${NEOGO:-docker exec -it main_chain neo-go}" + +# 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 +ADDR=`cat ${WALLET} | jq -r .accounts[2].address` + +# Fetch current epoch value +EPOCH=`${NEOGO} contract testinvokefunction -r \ +http://morph_chain.${LOCAL_DOMAIN}:30333 \ +${NEOFS_IR_CONTRACTS_NETMAP} \ +epoch | grep 'value' | awk -F'"' '{ print $4 }'` + +echo "Updating NeoFS epoch to $((EPOCH+1))" +./bin/passwd.exp ${PASSWD} ${NEOGO} contract invokefunction \ +-w ${WALLET_IMG} \ +-a ${ADDR} \ +-r http://morph_chain.${LOCAL_DOMAIN}:30333 \ +${NEOFS_IR_CONTRACTS_NETMAP} \ +newEpoch int:$((EPOCH+1)) -- ${ADDR}:Global diff --git a/neofs_config.mk b/neofs_config.mk index 1b12e70..d2929aa 100644 --- a/neofs_config.mk +++ b/neofs_config.mk @@ -24,6 +24,4 @@ update.basic_income_rate: # Tick new epoch in side chain tick.epoch: -# UnusedGlobalVariable is passed as argument to -# provoke epoch change without any changes in `bin/*`. - @./bin/config.sh UnusedGlobalVariable 0 + @./bin/tick.sh