Skip to content

Commit

Permalink
WIP: Internal consensus mode of Inner Ring with Sidechain auto-deploy
Browse files Browse the repository at this point in the history
Signed-off-by: Leonard Lyubich <[email protected]>
  • Loading branch information
cthulhu-rider committed Aug 28, 2023
1 parent 8ba9771 commit 12a4c5e
Show file tree
Hide file tree
Showing 10 changed files with 80 additions and 16 deletions.
1 change: 0 additions & 1 deletion .basic_services
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
# Services start/stop order
# Will start from top to bottom and stop in reverse
nats
ir
storage
2 changes: 1 addition & 1 deletion .bootstrap_services
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
# Will start from top to bottom and stop in reverse
basenet
chain
morph_chain
ir
1 change: 0 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion bin/config.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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} \
Expand Down
6 changes: 3 additions & 3 deletions bin/resolve.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand Down
4 changes: 2 additions & 2 deletions bin/tick.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand All @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion neofs-adm.yml
Original file line number Diff line number Diff line change
@@ -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
Expand Down
70 changes: 68 additions & 2 deletions services/ir/cfg/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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: [email protected]

# Network time settings
timers:
Expand Down
6 changes: 3 additions & 3 deletions services/ir/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion services/storage/cfg/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit 12a4c5e

Please sign in to comment.