Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion .env
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ NEO_GO_URL=https://github.com/nspcc-dev/neo-go/releases/download/v${NEOGO_VERSIO
# NeoFS InnerRing nodes
IR_VERSION=0.44.1
IR_IMAGE=nspccdev/neofs-ir
IR_NUMBER_OF_NODES=1

# NeoFS Storage nodes
NODE_VERSION=0.44.1
Expand Down Expand Up @@ -47,7 +48,13 @@ NEOFS_CONTRACTS_URL=https://github.com/nspcc-dev/neofs-contract/releases/downloa
#NEOFS_CONTRACTS_PATH=/path/to/unpacked/neofs-contracts-dir

# Control service addresses used for healthchecks
NEOFS_IR_CONTROL_GRPC_ENDPOINT=127.0.0.1:16512
NEOFS_IR_CONTROL_GRPC_ENDPOINT_1=ir01.${LOCAL_DOMAIN}:16512
NEOFS_IR_CONTROL_GRPC_ENDPOINT_2=ir02.${LOCAL_DOMAIN}:16512
NEOFS_IR_CONTROL_GRPC_ENDPOINT_3=ir03.${LOCAL_DOMAIN}:16512
NEOFS_IR_CONTROL_GRPC_ENDPOINT_4=ir04.${LOCAL_DOMAIN}:16512
NEOFS_IR_CONTROL_GRPC_ENDPOINT_5=ir05.${LOCAL_DOMAIN}:16512
NEOFS_IR_CONTROL_GRPC_ENDPOINT_6=ir06.${LOCAL_DOMAIN}:16512
NEOFS_IR_CONTROL_GRPC_ENDPOINT_7=ir07.${LOCAL_DOMAIN}:16512
NEOFS_STORAGE_CONTROL_GRPC_ENDPOINT_1=s01.${LOCAL_DOMAIN}:8081
NEOFS_STORAGE_CONTROL_GRPC_ENDPOINT_2=s02.${LOCAL_DOMAIN}:8081
NEOFS_STORAGE_CONTROL_GRPC_ENDPOINT_3=s03.${LOCAL_DOMAIN}:8081
Expand Down
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@ services/storage/*tls.crt
services/storage/*tls.key

# IR NeoFS contract configuration
services/ir/.ir.env
.ir.env
27 changes: 20 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ include services/*/prepare.mk
# List of services to run
START_SVCS = $(shell cat .services | grep -v '\#')
START_BASIC = $(shell cat .basic_services | grep -ve '\#')
START_BOOTSTRAP = $(shell cat .bootstrap_services | grep -v '\#')
START_BOOTSTRAP = $(shell cat .bootstrap_services | grep -v '\#' | sed 's/^ir$$/&$(IR_NUMBER_OF_NODES)/')
STOP_SVCS = $(shell tac .services | grep -v '\#')
STOP_BASIC = $(shell tac .basic_services | grep -v '\#')
STOP_BOOTSTRAP = $(shell tac .bootstrap_services | grep -v '\#')
STOP_BOOTSTRAP = $(shell tac .bootstrap_services | grep -v '\#' | sed 's/^ir$$/&$(IR_NUMBER_OF_NODES)/')

# Enabled services dirs
ENABLED_SVCS_DIRS = $(shell echo "${START_BOOTSTRAP} ${START_BASIC} ${START_SVCS}" | sed 's|[^ ]* *|./services/&|g')
Expand All @@ -46,6 +46,8 @@ CHAIN_PROTOCOL = './services/chain/protocol.privnet.yml'
# List of grepped environment variables from *.env
GREP_DOTENV = $(shell find . -name '*.env' -exec grep -rhv -e '^\#' -e '^$$' {} + | sort -u )

AVAILABLE_NUMBER_OF_NODES = 1 4 7

# Error handling function
define error_handler
ret_val=$$?;\
Expand All @@ -67,6 +69,14 @@ define error_handler
fi
endef

# Check if number of IR nodes from .env file is correct
.PHONY: check_nodes
check_nodes:
@if ! echo "$(AVAILABLE_NUMBER_OF_NODES)" | grep -wq "$(IR_NUMBER_OF_NODES)"; then \
echo "Invalid IR number $(IR_NUMBER_OF_NODES); supported numbers: ($(AVAILABLE_NUMBER_OF_NODES))"; \
exit 1; \
fi

# Pull all required Docker images
.PHONY: pull
pull:
Expand Down Expand Up @@ -105,23 +115,26 @@ up/basic: up/bootstrap
docker-compose -f services/$${svc}/docker-compose.yml up -d 2>&1 | tee -a docker-compose.err; \
done
@./bin/tick.sh
@./bin/config.sh string SystemDNS container
@./bin/config.sh SystemDNS container
$(call error_handler,$@);
@echo "Basic NeoFS Developer Environment is ready"

# Start bootstrap services
.PHONY: up/bootstrap
up/bootstrap: get vendor/hosts
@echo "NEOFS_IR_CONTRACTS_NEOFS="`./vendor/neo-go contract calc-hash -s NbUgTSFvPmsRxmGeWpuuGeJUoRoi6PErcM --in vendor/contracts/neofs/contract.nef -m vendor/contracts/neofs/manifest.json | grep -Eo '[a-fA-F0-9]{40}'` > services/ir/.ir.env
up/bootstrap: check_nodes get vendor/hosts
@echo "NEOFS_IR_CONTRACTS_NEOFS="`./vendor/neo-go contract calc-hash -s NbUgTSFvPmsRxmGeWpuuGeJUoRoi6PErcM --in vendor/contracts/neofs/contract.nef -m vendor/contracts/neofs/manifest.json | grep -Eo '[a-fA-F0-9]{40}'` > services/ir${IR_NUMBER_OF_NODES}/.ir.env
@for svc in $(START_BOOTSTRAP); do \
echo "$@ for service: $${svc}"; \
docker-compose -f services/$${svc}/docker-compose.yml up -d 2>&1 | tee -a docker-compose.err; \
done
@source ./bin/helper.sh
@docker exec main_chain neo-go wallet nep17 transfer --force --await --wallet-config /wallets/config.yml -r http://main-chain.neofs.devenv:30333 --from NfgHwwTi3wHAS8aFAN243C5vGbkYDpqLHP --to NbUgTSFvPmsRxmGeWpuuGeJUoRoi6PErcM --token GAS --amount 1000
@docker exec main_chain neo-go wallet nep17 transfer --force --await --wallet-config /wallets/config.yml -r http://main-chain.neofs.devenv:30333 --from NfgHwwTi3wHAS8aFAN243C5vGbkYDpqLHP --to NbUgTSFvPmsRxmGeWpuuGeJUoRoi6PErcM --token GAS --amount 1000
@./vendor/neo-go contract deploy --wallet-config wallets/config.yml --in vendor/contracts/neofs/contract.nef --manifest vendor/contracts/neofs/manifest.json --force --await -r http://main-chain.neofs.devenv:30333 [ true ffffffffffffffffffffffffffffffffffffffff [ 02b3622bf4017bdfe317c58aed5f4c753f206b7db896046fa7d774bbc4bf7f8dc2 ] [ InnerRingCandidateFee 10000000000 WithdrawFee 100000000 ] ]
@NEOGO=vendor/neo-go WALLET=wallets/wallet.json CONFIG=wallets/config.yml ./bin/deposit.sh
@for f in ./services/storage/wallet*.json; do echo "Transfer GAS to wallet $${f}" && ./vendor/neofs-adm -c neofs-adm.yml fschain refill-gas --storage-wallet $${f} --gas 10.0 --alphabet-wallets services/ir || die "Failed to transfer GAS to alphabet wallets"; done
@for f in ./services/storage/wallet*.json; do \
echo "Transfer GAS to wallet $${f}" && \
./vendor/neofs-adm -c neofs-adm.yml fschain refill-gas --storage-wallet $${f} --gas 10.0 --alphabet-wallets services/ir${IR_NUMBER_OF_NODES}/alphabet || die "Failed to transfer GAS to alphabet wallets"; \
done
$(call error_handler,$@);
@echo "NeoFS chain environment is deployed"

Expand Down
40 changes: 9 additions & 31 deletions bin/config.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,47 +4,25 @@ echo "Running bin/config.sh"

# Source env settings
. .env
. services/ir/.ir.env
source bin/helper.sh

# NeoGo binary path.
NEOGO="${NEOGO:-docker exec main_chain neo-go}"
# NeoFS ADM binary path and config path.
NEOFS_ADM="${NEOFS_ADM:-./vendor/neofs-adm}"
CONFIG_ADM="${CONFIG_ADM:-./neofs-adm.yml}"

# Wallet files to change config value
WALLET="${WALLET:-services/chain/node-wallet.json}"
CONFIG_IMG="${CONFIG_IMG:-/wallets/config.yml}"
# NeoFS configuration record:
# key is a string and value is a constant of [string|int|etc] type
KEY=${1}
VALUE="${2}"

NETMAP_ADDR=$(bin/resolve.sh netmap.neofs) || die "Failed to resolve 'netmap.neofs' domain name"

# NeoFS 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 "${NEOFS_NOTARY_DISABLED}" ]]; then
ADDR=$(jq -r .accounts[1].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} configuration value to ${VALUE}"

# shellcheck disable=SC2086
${NEOGO} contract invokefunction \
--wallet-config ${CONFIG_IMG} \
-a ${ADDR} --force --await \
-r http://ir01.${LOCAL_DOMAIN}:30333 \
${NETMAP_ADDR} \
setConfig bytes:beefcafe \
string:${KEY} \
${TYPE}:${VALUE} -- ${ADDR} || exit 1
${NEOFS_ADM} fschain set-config --alphabet-wallets services/ir${IR_NUMBER_OF_NODES}/alphabet \
-r http://ir01.${LOCAL_DOMAIN}:30333 -c ${CONFIG_ADM} ${KEY}=${VALUE} --force

# Update epoch to apply new configuration value
./bin/tick.sh
2 changes: 1 addition & 1 deletion bin/deposit.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ echo "Running bin/deposit.sh"

# Source env settings
. .env
. services/ir/.ir.env
. services/ir${IR_NUMBER_OF_NODES}/.ir.env
source bin/helper.sh

# NeoGo binary path.
Expand Down
41 changes: 5 additions & 36 deletions bin/tick.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,42 +4,11 @@ echo "Running bin/tick.sh"

# Source env settings
. .env
. services/ir/.ir.env
source bin/helper.sh

# NeoGo binary path.
NEOGO="${NEOGO:-docker exec main_chain neo-go}"
# NeoFS ADM binary path and config path.
NEOFS_ADM="${NEOFS_ADM:-./vendor/neofs-adm}"
CONFIG_ADM="${CONFIG_ADM:-./neofs-adm.yml}"

# Wallet files to change config value
WALLET="${WALLET:-services/chain/node-wallet.json}"
CONFIG_IMG="${CONFIG_IMG:-/wallets/config.yml}"

# Internal variables
if [[ -z "${NEOFS_NOTARY_DISABLED}" ]]; then
ADDR=$(jq -r .accounts[1].address < "${WALLET}" || die "Cannot get address from ${WALLET}")
else
ADDR=$(jq -r .accounts[0].address < "${WALLET}" || die "Cannot get address from ${WALLET}")
fi

# Grep NeoFS chain block time
NEOFS_CHAIN_PROTO="${NEOFS_CHAIN_PROTO:-services/ir/cfg/config.yml}"
BLOCK_DURATION=$(grep time_per_block < "$NEOFS_CHAIN_PROTO" | awk '{print $2}') \
|| die "Cannot fetch block duration"
NETMAP_ADDR=$(bin/resolve.sh netmap.neofs) || die "Cannot resolve netmap.neofs"

# Fetch current epoch value
EPOCH=$(${NEOGO} contract testinvokefunction \
-r "http://ir01.${LOCAL_DOMAIN}:30333" "${NETMAP_ADDR}" epoch \
| grep 'value' | awk -F'"' '{ print $4 }') \
|| die "Cannot fetch epoch from netmap contract"

echo "Updating NeoFS epoch to $((EPOCH+1))"

# shellcheck disable=SC2086
${NEOGO} contract invokefunction \
--wallet-config ${CONFIG_IMG} \
-a ${ADDR} --force --await \
-r http://ir01.${LOCAL_DOMAIN}:30333 \
${NETMAP_ADDR} \
newEpoch int:$((EPOCH+1)) -- ${ADDR}:Global \
|| die "Cannot increment an epoch"
${NEOFS_ADM} fschain force-new-epoch --alphabet-wallets services/ir${IR_NUMBER_OF_NODES}/alphabet \
-r http://ir01.${LOCAL_DOMAIN}:30333 -c ${CONFIG_ADM}
4 changes: 4 additions & 0 deletions docs/ir.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ pulling from DockerHub, the local image will be used.

Image label prefix to use for Inner Ring docker containers.

### IR_NUMBER_OF_NODES

The number of IR nodes that will work. The value must be either 1, 4, or 7.

## NeoFS global config

NeoFS uses global configuration to store epoch duration, maximum object size,
Expand Down
6 changes: 6 additions & 0 deletions neofs-adm.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
rpc-endpoint: http://ir01.neofs.devenv:30333
credentials:
az: "one"
buky: "one"
glagoli: "one"
vedi: "one"
dobro: "one"
yest: "one"
zhivete: "one"
contract: "one"
20 changes: 10 additions & 10 deletions neofs_config.mk
Original file line number Diff line number Diff line change
@@ -1,43 +1,43 @@
# Update epoch duration in side chain blocks (make update.epoch_duration val=30)
update.epoch_duration:
@./bin/config.sh int EpochDuration $(val)
@./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 int MaxObjectSize $(val)
@./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 int AuditFee $(val)
@./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 int ContainerFee $(val)
@./bin/config.sh 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)
@./bin/config.sh ContainerAliasFee $(val)

# Update amount of EigenTrust iterations (make update.eigen_trust_iterations val=2)
update.eigen_trust_iterations:
@./bin/config.sh int EigenTrustIterations $(val)
@./bin/config.sh EigenTrustIterations $(val)


# Update system dns to resolve container names (make update.system_dns val=container)
update.system_dns:
@./bin/config.sh string SystemDNS $(val)
@./bin/config.sh SystemDNS $(val)

# 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)
@./bin/config.sh 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)
@./bin/config.sh BasicIncomeRate $(val)

# Update homomorphic hashing disabled flag (make update.homomorphic_hashing_disable val=true)
update.homomorphic_hashing_disable:
@./bin/config.sh bool HomomorphicHashingDisabled $(val)
@./bin/config.sh HomomorphicHashingDisabled $(val)

# Tick new epoch in side chain
tick.epoch:
Expand Down
1 change: 0 additions & 1 deletion services/basenet/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
---

version: "2.4"
services:

basenet:
Expand Down
3 changes: 1 addition & 2 deletions services/chain/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
---

version: "2.4"
services:
neofs_main_chain:
image: ${NEOGO_IMAGE}:${NEOGO_VERSION}
Expand All @@ -21,7 +20,7 @@ services:
ipv4_address: ${IPV4_PREFIX}.50
stop_signal: SIGKILL
volumes:
- ./protocol.privnet.yml:/config/protocol.privnet.yml
- ./protocol.privnet${IR_NUMBER_OF_NODES}.yml:/config/protocol.privnet.yml
- ./node-wallet.json:/wallets/node-wallet.json
- ./config.yml:/wallets/config.yml
- ./../../vendor/hosts:/etc/hosts
Expand Down
77 changes: 77 additions & 0 deletions services/chain/protocol.privnet4.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
ProtocolConfiguration:
Magic: 56753
MaxTraceableBlocks: 200000
TimePerBlock: 1s
MemPoolSize: 50000
StandbyCommittee:
- 02b3622bf4017bdfe317c58aed5f4c753f206b7db896046fa7d774bbc4bf7f8dc2
ValidatorsCount: 1
VerifyTransactions: true
P2PSigExtensions: false
Genesis:
Roles:
NeoFSAlphabet:
- 0345eefc50545e83dfc7ec9ab648210dddbeb3996912a8ff6416e2d3ec51a8e324
- 039a1c33ed18bb57f6e6b3e712b54b924d2b9137c4906cf433ee8693a3810e380e
- 02d3088931c034a390c5bea16d19ef2debe9702019270c94913528a8ac30e17373
- 02fb7531661401222dcf2711bbd78597e8152ba886612e44ea530a08bbe4eba810
P2PNotary:
- 0345eefc50545e83dfc7ec9ab648210dddbeb3996912a8ff6416e2d3ec51a8e324
- 039a1c33ed18bb57f6e6b3e712b54b924d2b9137c4906cf433ee8693a3810e380e
- 02d3088931c034a390c5bea16d19ef2debe9702019270c94913528a8ac30e17373
- 02fb7531661401222dcf2711bbd78597e8152ba886612e44ea530a08bbe4eba810


ApplicationConfiguration:
SkipBlockVerification: false
DBConfiguration:
Type: "boltdb"
BoltDBOptions:
FilePath: "./db/privnet.bolt"
P2P:
Addresses:
- ":20333"
DialTimeout: 3s
ProtoTickInterval: 2s
PingInterval: 30s
PingTimeout: 90s
MaxPeers: 10
AttemptConnPeers: 5
MinPeers: 0
Relay: true
RPC:
Addresses:
- ":30333"
Enabled: true
SessionEnabled: true
EnableCORSWorkaround: false
MaxGasInvoke: 15
Prometheus:
Addresses:
- ":20001"
Enabled: true
Pprof:
Addresses:
- ":20011"
Enabled: true
Consensus:
Enabled: true
UnlockWallet:
Path: "./wallets/node-wallet.json"
Password: "one"
Oracle:
Enabled: true
NeoFS:
Nodes:
- s01.neofs.devenv:8080
- s02.neofs.devenv:8080
- s03.neofs.devenv:8080
- s04.neofs.devenv:8080
UnlockWallet:
Path: "./wallets/node-wallet.json"
Password: "one"
P2PNotary:
Enabled: false
UnlockWallet:
Path: "./wallets/node-wallet.json"
Password: "one"
Loading
Loading