Add Makefile targets to change NeoFS global config values

Signed-off-by: Alex Vanin <alexey@nspcc.ru>
This commit is contained in:
Alex Vanin 2021-04-16 13:57:21 +03:00 committed by Alex Vanin
parent 5bef7fc923
commit 25e6fbf5d7
3 changed files with 74 additions and 0 deletions

View file

@ -10,6 +10,9 @@ include .env
# help target
include help.mk
# update NeoFS global config targets
include neofs_config.mk
# Targets to get required artifacts and external resources for each service
include services/*/artifacts.mk

48
bin/config.sh Executable file
View file

@ -0,0 +1,48 @@
#!/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}"
# NeoFS configuration record: key is a string and value is an int
KEY=${1}
VALUE="${2}"
[ -z "$KEY" ] && echo "Empty config key" && exit 1
[ -z "$VALUE" ] && echo "Empty config value" && exit 1
# Internal variables
ADDR=`cat ${WALLET} | jq -r .accounts[2].address`
# Change config value in side chain
echo "Changing ${KEY} configration value to ${VALUE}"
${NEOGO} contract invokefunction \
-w ${WALLET_IMG} \
-a ${ADDR} \
-r http://morph_chain.${LOCAL_DOMAIN}:30333 \
${NEOFS_IR_CONTRACTS_NETMAP} \
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 configuartion value
echo "Updating NeoFS epoch to $((EPOCH+1))"
${NEOGO} contract invokefunction \
-w ${WALLET_IMG} \
-a ${ADDR} \
-r http://morph_chain.${LOCAL_DOMAIN}:30333 \
${NEOFS_IR_CONTRACTS_NETMAP} \
newEpoch int:$((EPOCH+1)) -- ${ADDR}

23
neofs_config.mk Normal file
View file

@ -0,0 +1,23 @@
# Update epoch duration in side chain blocks (make update.epoch_duration val=30)
update.epoch_duration:
@./bin/config.sh EpochDuration $(val)
# Update max object size in bytes (make update.max_object_size val=1000)
update.max_object_size:
@./bin/config.sh MaxObjectSize $(val)
# Update audit fee per result in fixed 12 (make update.audit_fee val=100)
update.audit_fee:
@./bin/config.sh AuditFee $(val)
# Update container fee per alphabet node in fixed 12 (make update.container_fee val=500)
update.container_fee:
@./bin/config.sh ContainerFee $(val)
# Update amount of EigenTrust iterations (make update.eigen_trust_iterations val=2)
update.eigen_trust_iterations:
@./bin/config.sh EigenTrustIterations $(val)
# Update basic income rate in fixed 12 (make update.basic_income_rate val=1000)
update.basic_income_rate:
@./bin/config.sh BasicIncomeRate $(val)