From 12a4c5e03ffac1e91af6624f360a14e1322c6cd0 Mon Sep 17 00:00:00 2001 From: Leonard Lyubich Date: Mon, 28 Aug 2023 22:39:39 +0400 Subject: [PATCH] WIP: Internal consensus mode of Inner Ring with Sidechain auto-deploy Signed-off-by: Leonard Lyubich --- .basic_services | 1 - .bootstrap_services | 2 +- Makefile | 1 - bin/config.sh | 2 +- bin/resolve.sh | 6 +-- bin/tick.sh | 4 +- neofs-adm.yml | 2 +- services/ir/cfg/config.yml | 70 ++++++++++++++++++++++++++++++++- services/ir/docker-compose.yml | 6 +-- services/storage/cfg/config.yml | 2 +- 10 files changed, 80 insertions(+), 16 deletions(-) diff --git a/.basic_services b/.basic_services index 201ea70..6d97490 100644 --- a/.basic_services +++ b/.basic_services @@ -1,5 +1,4 @@ # Services start/stop order # Will start from top to bottom and stop in reverse nats -ir storage diff --git a/.bootstrap_services b/.bootstrap_services index 3d2562c..85be5d8 100644 --- a/.bootstrap_services +++ b/.bootstrap_services @@ -2,4 +2,4 @@ # Will start from top to bottom and stop in reverse basenet chain -morph_chain +ir diff --git a/Makefile b/Makefile index 7e88e31..35725be 100644 --- a/Makefile +++ b/Makefile @@ -119,7 +119,6 @@ up/bootstrap: get vendor/hosts docker-compose -f services/$${svc}/docker-compose.yml up -d 2>&1 | tee -a docker-compose.err; \ done @source ./bin/helper.sh - @./vendor/neofs-adm --config neofs-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/neofs-adm -c neofs-adm.yml morph refill-gas --storage-wallet $${f} --gas 10.0 --alphabet-wallets services/ir || die "Failed to transfer GAS to alphabet wallets"; done $(call error_handler,$@); @echo "NeoFS sidechain environment is deployed" diff --git a/bin/config.sh b/bin/config.sh index f63a49c..e6eeaae 100755 --- a/bin/config.sh +++ b/bin/config.sh @@ -40,7 +40,7 @@ echo "Changing ${KEY} configration value to ${VALUE}" ${NEOGO} contract invokefunction \ --wallet-config ${CONFIG_IMG} \ -a ${ADDR} --force \ - -r http://morph-chain.${LOCAL_DOMAIN}:30333 \ + -r http://ir01.${LOCAL_DOMAIN}:30333 \ ${NETMAP_ADDR} \ setConfig bytes:beefcafe \ string:${KEY} \ diff --git a/bin/resolve.sh b/bin/resolve.sh index 9aba65b..74e4f8d 100755 --- a/bin/resolve.sh +++ b/bin/resolve.sh @@ -5,17 +5,17 @@ source bin/helper.sh # NeoGo binary path. -NEOGO="${NEOGO:-docker exec morph_chain neo-go}" +NEOGO="${NEOGO:-docker exec main_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/") \ + "http://ir01.${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" \ + -r "http://ir01.${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 \ diff --git a/bin/tick.sh b/bin/tick.sh index 2ec509e..ed469d1 100755 --- a/bin/tick.sh +++ b/bin/tick.sh @@ -29,7 +29,7 @@ NETMAP_ADDR=$(bin/resolve.sh netmap.neofs) || die "Cannot resolve netmap.neofs" # Fetch current epoch value EPOCH=$(${NEOGO} contract testinvokefunction \ - -r "http://morph-chain.${LOCAL_DOMAIN}:30333" "${NETMAP_ADDR}" epoch \ + -r "http://ir01.${LOCAL_DOMAIN}:30333" "${NETMAP_ADDR}" epoch \ | grep 'value' | awk -F'"' '{ print $4 }') \ || die "Cannot fetch epoch from netmap contract" @@ -39,7 +39,7 @@ echo "Updating NeoFS epoch to $((EPOCH+1))" ${NEOGO} contract invokefunction \ --wallet-config ${CONFIG_IMG} \ -a ${ADDR} --force \ - -r http://morph-chain.${LOCAL_DOMAIN}:30333 \ + -r http://ir01.${LOCAL_DOMAIN}:30333 \ ${NETMAP_ADDR} \ newEpoch int:$((EPOCH+1)) -- ${ADDR}:Global \ || die "Cannot increment an epoch" diff --git a/neofs-adm.yml b/neofs-adm.yml index dc10a6e..f3efce0 100644 --- a/neofs-adm.yml +++ b/neofs-adm.yml @@ -1,4 +1,4 @@ -rpc-endpoint: http://morph-chain.neofs.devenv:30333 +rpc-endpoint: http://ir01.neofs.devenv:30333 network: max_object_size: 67108864 epoch_duration: 240 diff --git a/services/ir/cfg/config.yml b/services/ir/cfg/config.yml index 8bbc520..5d2d1f4 100644 --- a/services/ir/cfg/config.yml +++ b/services/ir/cfg/config.yml @@ -30,10 +30,76 @@ mainnet: # Neo side chain RPC settings morph: - endpoints: # List of websocket RPC endpoints in sidechain - - ws://morph-chain:30333/ws validators: # List of hex-encoded 33-byte public keys of sidechain validators to vote for at application startup - 02b3622bf4017bdfe317c58aed5f4c753f206b7db896046fa7d774bbc4bf7f8dc2 + consensus: + magic: 15405 + committee: + - 02b3622bf4017bdfe317c58aed5f4c753f206b7db896046fa7d774bbc4bf7f8dc2 + storage: + type: boltdb + path: ./db/morph.bolt + time_per_block: 1s + max_traceable_blocks: 200000 + seed_nodes: + - :20333 + rpc: + listen: + - ":30333" + p2p: + dial_timeout: 3s + proto_tick_interval: + listen: + - ":20333" + peers: + min: 0 + max: 10 + attempts: 5 + ping: + interval: 30s + timeout: 90s + +network_settings: # NeoFS network settings managed in the Netmap contract + epoch_duration: 240 # Time interval (approximate) between two adjacent NeoFS epochs measured in Sidechain blocks. + # Must be an integer in range [1, 18446744073709551615] + max_object_size: 67108864 # [bytes] Maximum size of physically stored NeoFS objects. Note that this applies + # only to objects located on storage nodes: user objects have no restrictions and, if necessary, are sliced. + # Must be an integer in range [1, 18446744073709551615] + require_homomorphic_hashing: true # Toggles the requirement for homomorphic hashing of object payloads. + # Must be 'true' or 'false' + allow_maintenance_mode: true # Toggles permission to transition storage nodes to maintenance state. + # Must be 'true' or 'false' + eigen_trust: + alpha: 0.1 # Alpha parameter of EigenTrust algorithm used in the Reputation system. + # Must be a floating point number in range [0, 1]. + iterations_number: 4 # Number of EigenTrust algorithm iterations to pass in the Reputation system. + # Must be an integer in range [1, 18446744073709551615] + price: # Price settings. NEOFS means NeoFS Balance contract tokens (usually GASe-12). + storage: 100000000 # [NEOFS] Price for 1GB of data paid every epoch by data owner to storage nodes. + # Must be an integer in range [0, 18446744073709551615] + fee: + ir_candidate: 100 # [GASe-8] Contribution from the new candidate to the Inner Ring. Must be non-negative integer + # Must be an integer in range [0, 18446744073709551615] + withdraw: 100000000 # [GASe-8] Fee paid by the user account to; + # - NeoFS Processing contract (if Notary service is enabled in the NeoFS Mainchain) + # - each Alphabet member (otherwise) + # Must be an integer in range [0, 18446744073709551615] + audit: 10000 # [NEOFS] Fee for data audit paid by storage group owner to the auditor (Inner Ring member). + # Must be an integer in range [0, 18446744073709551615] + new_container: 1000 # [NEOFS] Fee for new container paid by creator to each Alphabet member. + # Must be an integer in range [0, 18446744073709551615] + container_domain: 500 # [NEOFS] Fee for container's NNS domain paid by container creator to each Alphabet member. + # Must be a non-negative integer + custom: # Optional list of custom key-value pairs to be set in the network configuration. Forbidden keys: + # [AuditFee, BasicIncomeRate, ContainerAliasFee, ContainerFee, EigenTrustAlpha, EigenTrustIterations, EpochDuration, + # HomomorphicHashingDisabled, InnerRingCandidateFee, MaintenanceModeAllowed, MaxObjectSize, WithdrawFee] + # Note that this list can be extended in the future, so, to avoid potential collision, it is recommended + # to use the most specific keys. + - my_custom_key1=val1 + - my_custom_key2=val2 + +nns: + system_email: ops@nspcc.io # Network time settings timers: diff --git a/services/ir/docker-compose.yml b/services/ir/docker-compose.yml index b78ae48..74874aa 100644 --- a/services/ir/docker-compose.yml +++ b/services/ir/docker-compose.yml @@ -26,10 +26,10 @@ services: command: [ "neofs-ir", "--config", "/etc/neofs/ir/config.yml" ] healthcheck: test: ["CMD", "/neofs-cli", "control", "healthcheck", "-c", "/cli-cfg.yml", "--endpoint", "${NEOFS_IR_CONTROL_GRPC_ENDPOINT}", "--ir"] - interval: 2s + interval: 20s timeout: 1s - retries: 5 - start_period: 20s + retries: 20 + start_period: 1m ir-healthcheck: container_name: ir-healthcheck diff --git a/services/storage/cfg/config.yml b/services/storage/cfg/config.yml index 82bdb96..afccafe 100644 --- a/services/storage/cfg/config.yml +++ b/services/storage/cfg/config.yml @@ -18,7 +18,7 @@ prometheus: morph: dial_timeout: 30s # Timeout for side chain NEO RPC client connection endpoints: # Side chain NEO RPC endpoints - - ws://morph-chain:30333/ws + - ws://ir01.neofs.devenv:30333/ws # Common storage node settings node: