diff --git a/Makefile b/Makefile index 61782ba..0322582 100644 --- a/Makefile +++ b/Makefile @@ -66,8 +66,8 @@ up: up/basic .PHONY: up/basic up/basic: up/bootstrap @$(foreach SVC, $(START_BASIC), $(shell docker-compose -f services/$(SVC)/docker-compose.yml up -d)) - @./bin/tick.sh - @./bin/config.sh string SystemDNS container + @./vendor/frostfs-adm -c ./frostfs-adm.yml morph force-new-epoch + @./vendor/frostfs-adm -c ./frostfs-adm.yml morph set-config SystemDNS=container --force @echo "Basic FrostFS Developer Environment is ready" # Start bootstrap services @@ -75,8 +75,12 @@ up/basic: up/bootstrap up/bootstrap: get vendor/hosts @$(foreach SVC, $(START_BOOTSTRAP), $(shell docker-compose -f services/$(SVC)/docker-compose.yml up -d)) @source ./bin/helper.sh - @./vendor/frostfs-adm --config frostfs-adm.yml morph init --alphabet-wallets ./services/ir --contracts vendor/contracts || die "Failed to initialize Alphabet wallets" - @for f in ./services/storage/wallet*.json; do echo "Transfer GAS to wallet $${f}" && ./vendor/frostfs-adm -c frostfs-adm.yml morph refill-gas --storage-wallet $${f} --gas 10.0 --alphabet-wallets services/ir || die "Failed to transfer GAS to alphabet wallets"; done + @./vendor/frostfs-adm --config frostfs-adm.yml morph init --contracts vendor/contracts + @for f in ./services/storage/wallet*.json; do \ + echo "Transfer GAS to wallet $${f}" \ + && ./vendor/frostfs-adm -c frostfs-adm.yml morph refill-gas --storage-wallet $${f} --gas 10.0 \ + || die "Failed to transfer GAS to alphabet wallets"; \ + done @echo "FrostFS sidechain environment is deployed" # Build up certain service diff --git a/bin/config.sh b/bin/config.sh deleted file mode 100755 index 31b613f..0000000 --- a/bin/config.sh +++ /dev/null @@ -1,50 +0,0 @@ -#!/usr/bin/env bash - -echo "Running bin/config.sh" - -# Source env settings -. .env -. services/ir/.ir.env -source bin/helper.sh - -# NeoGo binary path. -NEOGO="${NEOGO:-docker exec morph_chain neo-go}" - -# Wallet files to change config value -WALLET="${WALLET:-services/morph_chain/node-wallet.json}" -CONFIG_IMG="${CONFIG_IMG:-/wallets/config.yml}" - -NETMAP_ADDR=$(bin/resolve.sh netmap.frostfs) || die "Failed to resolve 'netmap.frostfs' domain name" - -# FrostFS configuration record: variable type [string|int|etc], -# key is a string and value is a constant of given type -TYPE=${1} -KEY=${2} -VALUE="${3}" - -[ -z "$TYPE" ] && echo "Empty config value type" && exit 1 -[ -z "$KEY" ] && echo "Empty config key" && exit 1 -[ -z "$VALUE" ] && echo "Empty config value" && exit 1 - -# Internal variables -if [[ -z "${FROSTFS_NOTARY_DISABLED}" ]]; then - ADDR=$(jq -r .accounts[2].address < "${WALLET}" || die "Cannot get address from ${WALLET}") -else - ADDR=$(jq -r .accounts[0].address < "${WALLET}" || die "Cannot get address from ${WALLET}") -fi - -# Change config value in side chain -echo "Changing ${KEY} configration value to ${VALUE}" - -# shellcheck disable=SC2086 -${NEOGO} contract invokefunction \ - --wallet-config ${CONFIG_IMG} \ - -a ${ADDR} --force \ - -r http://morph-chain.${LOCAL_DOMAIN}:30333 \ - ${NETMAP_ADDR} \ - setConfig bytes:beefcafe \ - string:${KEY} \ - ${TYPE}:${VALUE} -- ${ADDR} || exit 1 - -# Update epoch to apply new configuration value -./bin/tick.sh diff --git a/bin/passwd.exp b/bin/passwd.exp deleted file mode 100755 index 08fd3c7..0000000 --- a/bin/passwd.exp +++ /dev/null @@ -1,23 +0,0 @@ -#!/usr/bin/expect - -set passwd [lindex $argv 0] -set args [lrange $argv 1 end] - -spawn -noecho {*}$args -expect -re {^.*assword.*$} - -if { $passwd == "-"} { - send -- "\r" -} else { - send -- "$passwd\r" -} - -expect { - "Relay transaction" { - send "y\r" - exp_continue - } - EOF -} -lassign [wait] pid spawnid os_error_flag value -exit $value diff --git a/bin/resolve.sh b/bin/resolve.sh deleted file mode 100755 index 9aba65b..0000000 --- a/bin/resolve.sh +++ /dev/null @@ -1,22 +0,0 @@ -#!/usr/bin/env bash - -# Source env settings -. .env -source bin/helper.sh - -# NeoGo binary path. -NEOGO="${NEOGO:-docker exec morph_chain neo-go}" -# NNS contract script hash -output=$(curl -s --data '{ "id": 1, "jsonrpc": "2.0", "method": "getcontractstate", "params": [1] }' \ - "http://morph-chain.${LOCAL_DOMAIN}:30333/") \ - || die "Cannot fetch NNS contract state" - -NNS_ADDR=$(jq -r '.result.hash' <<< "$output") \ - || die "Cannot parse NNS contract hash: $NNS_ADDR" - -${NEOGO} contract testinvokefunction \ - -r "http://morph-chain.${LOCAL_DOMAIN}:30333" \ - "${NNS_ADDR}" resolve string:"${1}" int:16 \ - | jq -r '.stack[0].value | if type=="array" then .[0].value else . end' \ - | base64 -d \ - || die "Cannot invoke 'NNS.resolve' $output" diff --git a/bin/tick.sh b/bin/tick.sh deleted file mode 100755 index 75482f0..0000000 --- a/bin/tick.sh +++ /dev/null @@ -1,49 +0,0 @@ -#!/usr/bin/env bash - -echo "Running bin/tick.sh" - -# Source env settings -. .env -. services/ir/.ir.env -source bin/helper.sh - -# NeoGo binary path. -NEOGO="${NEOGO:-docker exec morph_chain neo-go}" - -# Wallet files to change config value -WALLET="${WALLET:-services/morph_chain/node-wallet.json}" -CONFIG_IMG="${CONFIG_IMG:-/wallets/config.yml}" - -# Internal variables -if [[ -z "${FROSTFS_NOTARY_DISABLED}" ]]; then - ADDR=$(jq -r .accounts[2].address < "${WALLET}" || die "Cannot get address from ${WALLET}") -else - ADDR=$(jq -r .accounts[0].address < "${WALLET}" || die "Cannot get address from ${WALLET}") -fi - -# Grep Morph block time -SIDECHAIN_PROTO="${SIDECHAIN_PROTO:-services/morph_chain/protocol.privnet.yml}" -BLOCK_DURATION=$(grep SecondsPerBlock < "$SIDECHAIN_PROTO" | awk '{print $2}') \ - || die "Cannot fetch block duration" -NETMAP_ADDR=$(bin/resolve.sh netmap.frostfs) || die "Cannot resolve netmap.frostfs" - -# Fetch current epoch value -EPOCH=$(${NEOGO} contract testinvokefunction \ - -r "http://morph-chain.${LOCAL_DOMAIN}:30333" "${NETMAP_ADDR}" epoch \ - | grep 'value' | awk -F'"' '{ print $4 }') \ - || die "Cannot fetch epoch from netmap contract" - -echo "Updating FrostFS epoch to $((EPOCH+1))" - -# shellcheck disable=SC2086 -${NEOGO} contract invokefunction \ - --wallet-config ${CONFIG_IMG} \ - -a ${ADDR} --force \ - -r http://morph-chain.${LOCAL_DOMAIN}:30333 \ - ${NETMAP_ADDR} \ - newEpoch int:$((EPOCH+1)) -- ${ADDR}:Global \ - || die "Cannot increment an epoch" - -# Wait one Morph block to ensure the transaction broadcasted -# shellcheck disable=SC2086 -sleep $BLOCK_DURATION diff --git a/frostfs-adm.yml b/frostfs-adm.yml index dcc4ba2..c44046d 100644 --- a/frostfs-adm.yml +++ b/frostfs-adm.yml @@ -1,4 +1,5 @@ rpc-endpoint: http://morph-chain.frostfs.devenv:30333 +alphabet-wallets: ./services/ir network: max_object_size: 67108864 epoch_duration: 240 diff --git a/frostfs_config.mk b/frostfs_config.mk index 8f164d1..71eb8f1 100644 --- a/frostfs_config.mk +++ b/frostfs_config.mk @@ -1,44 +1,40 @@ # Update epoch duration in side chain blocks (make update.epoch_duration val=30) update.epoch_duration: - @./bin/config.sh int EpochDuration $(val) + @./vendor/frostfs-adm -c ./frostfs-adm.yml morph set-config EpochDuration=$(val) # Update max object size in bytes (make update.max_object_size val=1000) update.max_object_size: - @./bin/config.sh int MaxObjectSize $(val) + @./vendor/frostfs-adm -c ./frostfs-adm.yml morph set-config MaxObjectSize=$(val) # Update audit fee per result in fixed 12 (make update.audit_fee val=100) update.audit_fee: - @./bin/config.sh int AuditFee $(val) + @./vendor/frostfs-adm -c ./frostfs-adm.yml morph set-config AuditFee=$(val) # Update container fee per alphabet node in fixed 12 (make update.container_fee val=500) update.container_fee: - @./bin/config.sh int ContainerFee $(val) + @./vendor/frostfs-adm -c ./frostfs-adm.yml morph set-config ContainerFee=$(val) # Update container alias fee per alphabet node in fixed 12 (make update.container_alias_fee val=100) update.container_alias_fee: - @./bin/config.sh int ContainerAliasFee $(val) + @./vendor/frostfs-adm -c ./frostfs-adm.yml morph set-config ContainerAliasFee=$(val) # Update amount of EigenTrust iterations (make update.eigen_trust_iterations val=2) update.eigen_trust_iterations: - @./bin/config.sh int EigenTrustIterations $(val) - + @./vendor/frostfs-adm -c ./frostfs-adm.yml morph set-config EigenTrustIterations=$(val) # Update system dns to resolve container names (make update.system_dns val=container) update.system_dns: - @./bin/config.sh string SystemDNS $(val) + @./vendor/frostfs-adm -c ./frostfs-adm.yml morph set-config SystemDNS=$(val) --force # Update alpha parameter of EigenTrust algorithm in 0 <= f <= 1.0 (make update.eigen_trust_alpha val=0.2) update.eigen_trust_alpha: - @./bin/config.sh string EigenTrustAlpha $(val) + @./vendor/frostfs-adm -c ./frostfs-adm.yml morph set-config EigenTrustAlpha=$(val) # Update basic income rate in fixed 12 (make update.basic_income_rate val=1000) update.basic_income_rate: - @./bin/config.sh int BasicIncomeRate $(val) + @./vendor/frostfs-adm -c ./frostfs-adm.yml morph set-config BasicIncomeRate=$(val) # Update homomorphic hashing disabled flag (make update.homomorphic_hashing_disable val=true) update.homomorphic_hashing_disable: - @./bin/config.sh bool HomomorphicHashingDisabled $(val) + @./vendor/frostfs-adm -c ./frostfs-adm.yml morph set-config HomomorphicHashingDisabled=$(val) -# Tick new epoch in side chain -tick.epoch: - @./bin/tick.sh diff --git a/services/ir/prepare.mk b/services/ir/prepare.mk index fd7f253..af13d12 100644 --- a/services/ir/prepare.mk +++ b/services/ir/prepare.mk @@ -1,4 +1,3 @@ # Deposit GAS from default wallet to FrostFS privnet contract prepare.ir: - @./bin/config.sh int ContainerFee 0 - @./bin/config.sh int ContainerAliasFee 0 + @./vendor/frostfs-adm -c ./frostfs-adm.yml ContainerFee=0 ContainerAliasFee=0