From 25e6fbf5d729374c58680f2ae2baa4e5c53bc807 Mon Sep 17 00:00:00 2001 From: Alex Vanin Date: Fri, 16 Apr 2021 13:57:21 +0300 Subject: [PATCH] Add Makefile targets to change NeoFS global config values Signed-off-by: Alex Vanin --- Makefile | 3 +++ bin/config.sh | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ neofs_config.mk | 23 +++++++++++++++++++++++ 3 files changed, 74 insertions(+) create mode 100755 bin/config.sh create mode 100644 neofs_config.mk diff --git a/Makefile b/Makefile index fbdaa8c..c8d2fc5 100644 --- a/Makefile +++ b/Makefile @@ -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 diff --git a/bin/config.sh b/bin/config.sh new file mode 100755 index 0000000..74b6117 --- /dev/null +++ b/bin/config.sh @@ -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} diff --git a/neofs_config.mk b/neofs_config.mk new file mode 100644 index 0000000..59e58a6 --- /dev/null +++ b/neofs_config.mk @@ -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)