From 6b41f399d02a6411f3a0f70a2cf96960631807cf Mon Sep 17 00:00:00 2001 From: Alex Vanin Date: Wed, 13 Jan 2021 16:07:01 +0300 Subject: [PATCH] [#309] Add configuration for storage node testnet deployment Signed-off-by: Alex Vanin --- Dockerfile.storage-testnet | 21 +++++++ config/testnet/README.md | 93 +++++++++++++++++++++++++++++++ config/testnet/config.yml | 51 +++++++++++++++++ config/testnet/docker-compose.yml | 19 +++++++ 4 files changed, 184 insertions(+) create mode 100644 Dockerfile.storage-testnet create mode 100644 config/testnet/README.md create mode 100644 config/testnet/config.yml create mode 100644 config/testnet/docker-compose.yml diff --git a/Dockerfile.storage-testnet b/Dockerfile.storage-testnet new file mode 100644 index 000000000..22f67fdb2 --- /dev/null +++ b/Dockerfile.storage-testnet @@ -0,0 +1,21 @@ +FROM golang:1.14-alpine as basebuilder +RUN apk add --update make bash + +FROM basebuilder as builder +ARG BUILD=now +ARG VERSION=dev +ARG REPO=repository +WORKDIR /src +COPY . /src + +RUN make bin/neofs-node + +# Executable image +FROM scratch AS neofs-node + +WORKDIR / + +COPY --from=builder /src/bin/neofs-node /bin/neofs-node +COPY --from=builder /src/config/testnet/config.yml /config.yml + +CMD ["neofs-node", "--config", "/config.yml"] diff --git a/config/testnet/README.md b/config/testnet/README.md new file mode 100644 index 000000000..7fbe2f067 --- /dev/null +++ b/config/testnet/README.md @@ -0,0 +1,93 @@ +# NEO testnet-preview4 storage node configuration + +There is a prepared configuration for NeoFS storage node deployment in +NEO testnet-preview4. The Easiest way to deploy storage node is to use prepared +docker image of storage node and run it with docker-compose. + +## Build image + +To build custom neofs-storage node image for NEO testnet-preview4: + +``` +neofs-node$ make image-storage-testnet +... +Successfully built 80ef4e3c488d +Successfully tagged nspccdev/neofs-storage-testnet:0.14.1-dirty +$ +``` + +## Deploy node + +To run storage node in NEO testnet-preview4 environment you should deposit +GAS assets, update docker-compose file and run it. + +### Deposit + +Storage node holder should deposit assets because it generates a bit of +sidechain GAS for node's wallet. Sidechain GAS used to send bootstrap tx. + +To make a deposit invoke `deposit` method of NeoFS contract in testnet-preview4. +There are three arguments in this method: +- scripthash of the wallet +- amount of GAS (in decimal) +- scripthash of the storage node wallet. + + +NeoFS contract scripthash in NEO testnet-preview4 is `121da848e5239d24353c7b567a719d27e0fe7c06` + +Last argument can be empty if you want to use +wallet key as storage node key. See a deposit example with `neo-go`: + +``` +neo-go contract invokefunction -r http://neo3-preview.go.nspcc.ru:20332 \ +-w wallet.json -a NcrE6C1mvScQpAnFctK1Mw7P7i1buLCKav \ +121da848e5239d24353c7b567a719d27e0fe7c06 \ +deposit \ +0cbd9d3c3e3a3d12ff5b8bd0d3a0548c6eeac4b9 \ +int:1 \ +bytes: \ +-- 0cbd9d3c3e3a3d12ff5b8bd0d3a0548c6eeac4b9 +``` + +### Configure + +Then configure docker-compose.yml file. Change endpoints values. Both of them +should contain your public IP. + +```yaml + environment: + - NEOFS_NODE_ADDRESS=192.168.140.1:36512 + - NEOFS_GRPC_ENDPOINT=192.168.140.1:36512 +``` + +It is recommended to pass node's key as a file. To do so convert your wallet +WIF to 32-byte hex (via `neofs-cli` for example) and save it in file. + +``` +// Print WIF in a 32-byte hex format +$ neofs-cli util keyer Kwp4Q933QujZLUCcn39tzY94itNQJS4EjTp28oAMzuxMwabm3p1s +PrivateKey 11ab917cd99170cb8d0d48e78fca317564e6b3aaff7f7058952d6175cdca0f56 +PublicKey 02be8b2e837cab232168f5c3303f1b985818b7583682fb49026b8d2f43df7c1059 +WIF Kwp4Q933QujZLUCcn39tzY94itNQJS4EjTp28oAMzuxMwabm3p1s +Wallet3.0 NVKYb9UHYv9mf6gY6CkBgR5ZYPhtx5d9sr +ScriptHash3.0 65d667398a35820f421630e49f73d7ea34952e67 +ScriptHash3.0BE 672e9534ead7739fe43016420f82358a3967d665 + +// Save 32-byte hex into a file +$ echo '11ab917cd99170cb8d0d48e78fca317564e6b3aaff7f7058952d6175cdca0f56' | xxd -r -p > my_wallet.key +``` + +Then specify path to this file in docker-compose +```yaml + volumes: + - neofs_storage:/storage + - ./my_wallet.key:/node.key +``` + +You also can provide WIF directly with +`NEOFS_NODE_KEY=Kwp4Q933QujZLUCcn39tzY94itNQJS4EjTp28oAMzuxMwabm3p1s` +env in docker-compose. + +### Start + +Run node with `docker-compose up` command and stop it with `docker-compose down`. \ No newline at end of file diff --git a/config/testnet/config.yml b/config/testnet/config.yml new file mode 100644 index 000000000..c8051c50c --- /dev/null +++ b/config/testnet/config.yml @@ -0,0 +1,51 @@ +logger: + level: info + +morph: + rpc_endpoint: + - http://rpc1-morph.preview4.nspcc.ru:24333 + - http://rpc2-morph.preview4.nspcc.ru:24333 + - http://rpc3-morph.preview4.nspcc.ru:24333 + - http://rpc4-morph.preview4.nspcc.ru:24333 + - http://rpc5-morph.preview4.nspcc.ru:24333 + - http://rpc6-morph.preview4.nspcc.ru:24333 + - http://rpc7-morph.preview4.nspcc.ru:24333 + notification_endpoint: + - ws://rpc1-morph.preview4.nspcc.ru:24333/ws + - ws://rpc2-morph.preview4.nspcc.ru:24333/ws + - ws://rpc3-morph.preview4.nspcc.ru:24333/ws + - ws://rpc4-morph.preview4.nspcc.ru:24333/ws + - ws://rpc5-morph.preview4.nspcc.ru:24333/ws + - ws://rpc6-morph.preview4.nspcc.ru:24333/ws + - ws://rpc7-morph.preview4.nspcc.ru:24333/ws + dial_timeout: 20s + +bootstrap: + periodic: + enabled: true + +accounting: + scripthash: b9af268168b1546d8b1e0c25dece3faa31153058 +container: + scripthash: 31761cba924830bfce2662a39fc7f830b90adbef +netmap: + scripthash: 7b383bc5a385859469f366b08b04b4fcd9a41f55 +node: + key: /node.key + attribute: + 0: /external:true + +storage: + shard: + 0: + use_write_cache: false + metabase: + path: /storage/metabase + perm: 0777 + blobstor: + path: /storage/blobstor + perm: 0777 + blobovnicza: + opened_cache_size: 32 + shallow_depth: 1 + shallow_width: 1 diff --git a/config/testnet/docker-compose.yml b/config/testnet/docker-compose.yml new file mode 100644 index 000000000..c933049ff --- /dev/null +++ b/config/testnet/docker-compose.yml @@ -0,0 +1,19 @@ +--- + +version: "2.4" +services: + storage01: + image: nspccdev/neofs-storage-testnet:0.14.1 + container_name: neofs-testnet + network_mode: host + restart: always + volumes: + - neofs_storage:/storage + - :/node.key + stop_signal: SIGINT + environment: + - NEOFS_NODE_ADDRESS= + - NEOFS_GRPC_ENDPOINT= + +volumes: + neofs_storage: