Run a mirror nodeπ
The utility of a mirror node is to expose a RPC endpoint to submit extrinsincs and get blockchain data. It can be an archive node if it keeps a copy of the whole storage for each block or a standard node if it enables storage pruning and only keeps state transitions. Both can be used for synchronization but only archive nodes can be used to retreive blockchain information at any given block.
Table of contents
Dockerπ
We chose docker as the standard way to deploy a node. Distribution packages are not yet provided. First install docker on your platform.
Compose fileπ
Then use the following docker-compose.yml
example file:
version: "3.5"
services:
duniter-rpc:
image: duniter/duniter-v2s:xxx # <----
restart: unless-stopped
ports:
# Prometheus endpoint
- 9615:9615
# rpc via http
- 9933:9933
# rpc via websocket
- 9944:9944
# p2p
- 30333:30333
volumes:
- data-rpc:/var/lib/duniter/
environment:
- DUNITER_CHAIN_NAME=yyy # <----
- DUNITER_NODE_NAME=zzz # <----
volumes:
data-rpc:
Replace xxx
by the Duniter version you want to use. For example, to join gdev
development network, you can use sha-latest
version which includes embeded chainspecs. If you are using ARM architecture (raspberry pi for example), ask on the forum which image should be used.
Replace yyy
by the name of the chain you want to use. Only gdev
, gtest
and g1
are available at the moment and only gdev
will work since no chainspec exist for the other yet.
Replace zzz
by the name of your node on chain. It is useful to include your name for other people to recognize you easily and an identifier of the node if you run multiple.
For more info about how to configure your node using Docker, read configure (docker).
Start nodeπ
When done, in the folder of this docker-compose.yml
file, run docker compose up
to start your node. You should see logs like this:
[+] Running 6/6
β Ώ duniter-rpc Pulled 18.1s
β Ώ 548fcab5fe88 Pull complete 14.2s
β Ώ a6cb4a21b40a Pull complete 14.4s
β Ώ c1e8b5464c78 Pull complete 15.6s
β Ώ abff9d6e5a19 Pull complete 15.7s
β Ώ 0bce2fe9b911 Pull complete 15.7s
[+] Running 3/3
β Ώ Network hugo_default Created 0.0s
β Ώ Volume "hugo_data-rpc" Created 0.0s
β Ώ Container hugo-duniter-rpc-1 Created 0.1s
Attaching to hugo-duniter-rpc-1
hugo-duniter-rpc-1 | Generating node key file '/var/lib/duniter/node.key'...
hugo-duniter-rpc-1 | 12D3KooWBcWNStGCq1WwWCsfTYKcc76CQ94FYUwbcsPzDWFWToub
hugo-duniter-rpc-1 | Node peer ID is '12D3KooWBcWNStGCq1WwWCsfTYKcc76CQ94FYUwbcsPzDWFWToub'.
hugo-duniter-rpc-1 | Starting duniter with parameters: --name hugo-trentesaux-rpc-albatros --node-key-file /var/lib/duniter/node.key --rpc-cors all --chain gdev -d /var/lib/duniter --unsafe-rpc-external --unsafe-ws-external
hugo-duniter-rpc-1 | 2023-01-23 16:09:41 Duniter
hugo-duniter-rpc-1 | 2023-01-23 16:09:41 βοΈ version 0.3.0-3189d769f70
hugo-duniter-rpc-1 | 2023-01-23 16:09:41 β€οΈ by Axiom-Team Developers <https://axiom-team.fr>, 2021-2023
hugo-duniter-rpc-1 | 2023-01-23 16:09:41 π Chain specification: Δdev
hugo-duniter-rpc-1 | 2023-01-23 16:09:41 π· Node name: hugo-trentesaux-rpc-albatros
hugo-duniter-rpc-1 | 2023-01-23 16:09:41 π€ Role: FULL
hugo-duniter-rpc-1 | 2023-01-23 16:09:41 πΎ Database: ParityDb at /var/lib/duniter/chains/gdev/paritydb/full
hugo-duniter-rpc-1 | 2023-01-23 16:09:41 β Native runtime: gdev-400 (duniter-gdev-1.tx1.au1)
hugo-duniter-rpc-1 | 2023-01-23 16:09:43 π¨ Initializing Genesis block/state (state: 0x4096β¦cfd1, header-hash: 0xf9bbβ¦0dfc)
hugo-duniter-rpc-1 | 2023-01-23 16:09:43 π΄ Loading GRANDPA authority set from genesis on what appears to be first startup.
hugo-duniter-rpc-1 | 2023-01-23 16:09:44 πΆ Creating empty BABE epoch changes on what appears to be first startup.
hugo-duniter-rpc-1 | 2023-01-23 16:09:44 π· Local node identity is: 12D3KooWBcWNStGCq1WwWCsfTYKcc76CQ94FYUwbcsPzDWFWToub
hugo-duniter-rpc-1 | 2023-01-23 16:09:44 π» Operating system: linux
hugo-duniter-rpc-1 | 2023-01-23 16:09:44 π» CPU architecture: x86_64
hugo-duniter-rpc-1 | 2023-01-23 16:09:44 π» Target environment: gnu
hugo-duniter-rpc-1 | 2023-01-23 16:09:44 π» CPU: Intel(R) Core(TM) i7-8565U CPU @ 1.80GHz
hugo-duniter-rpc-1 | 2023-01-23 16:09:44 π» CPU cores: 4
hugo-duniter-rpc-1 | 2023-01-23 16:09:44 π» Memory: 15713MB
hugo-duniter-rpc-1 | 2023-01-23 16:09:44 π» Kernel: 5.15.85-1-MANJARO
hugo-duniter-rpc-1 | 2023-01-23 16:09:44 π» Linux distribution: Debian GNU/Linux 10 (buster)
hugo-duniter-rpc-1 | 2023-01-23 16:09:44 π» Virtual machine: no
hugo-duniter-rpc-1 | 2023-01-23 16:09:44 π¦ Highest known block at #0
hugo-duniter-rpc-1 | 2023-01-23 16:09:44 γ½οΈ Prometheus exporter started at 127.0.0.1:9615
hugo-duniter-rpc-1 | 2023-01-23 16:09:44 Running JSON-RPC HTTP server: addr=0.0.0.0:9933, allowed origins=None
hugo-duniter-rpc-1 | 2023-01-23 16:09:44 Running JSON-RPC WS server: addr=0.0.0.0:9944, allowed origins=None
hugo-duniter-rpc-1 | 2023-01-23 16:09:44 ***** Duniter has fully started *****
hugo-duniter-rpc-1 | 2023-01-23 16:09:44 creating instance on iface 172.18.0.2
hugo-duniter-rpc-1 | 2023-01-23 16:09:45 π Discovered new external address for our node: /ip4/78.199.27.8/tcp/30333/ws/p2p/12D3KooWBcWNStGCq1WwWCsfTYKcc76CQ94FYUwbcsPzDWFWToub
hugo-duniter-rpc-1 | 2023-01-23 16:09:49 βοΈ Syncing, target=#587673 (4 peers), best: #3683 (0x3ca6β¦af6c), finalized #3584 (0x847fβ¦6d18), β¬ 391.2kiB/s β¬ 6.3kiB/s
hugo-duniter-rpc-1 | 2023-01-23 16:09:54 βοΈ Syncing 724.6 bps, target=#587674 (5 peers), best: #7307 (0x8165β¦f519), finalized #7168 (0xca18β¦8675), β¬ 238.2kiB/s β¬ 2.9kiB/s
hugo-duniter-rpc-1 | 2023-01-23 16:09:59 βοΈ Syncing 689.6 bps, target=#587674 (5 peers), best: #10755 (0x0993β¦d78e), finalized #10752 (0xd01dβ¦8d6b), β¬ 237.8kiB/s β¬ 2.5kiB/s
hugo-duniter-rpc-1 | 2023-01-23 16:10:02 on_idty_change: pallet_authority_members.change_owner_key(): <wasm:stripped>
hugo-duniter-rpc-1 | 2023-01-23 16:10:04 βοΈ Syncing 706.1 bps, target=#587675 (5 peers), best: #14288 (0x12e1β¦c95e), finalized #13824 (0xf539β¦7329), β¬ 237.8kiB/s β¬ 2.5kiB/s
It downloaded the good docker image, started the node, and started synchronization.
βοΈ Syncing 706.1 bps, target=#587675 (5 peers), best: #14288 (0x12e1β¦c95e), finalized #13824 (0xf539β¦7329), β¬ 237.8kiB/s β¬ 2.5kiB/s
The line above tells you the state of the synchronization. You get the target block of the network, the block your are currently at, and the average sychronization speed (here 706 blocks per second).
Once you are happy with the result, you can safely interrupt Duniter (with Ctrl+C
) and start it again in background with:
docker compose up --detach
Then you can inspect your node in polkadotjs app locally or remotely depending on where you started your node.
For more info about how to interact with Duniter through Docker, read configure (docker).
Binaryπ
You can download a pre-build binary (no official support yet) or compile Duniter with:
# choose the branch containing the embeded chainspec you need
# if you do not want to use custom ones
git clone https://git.duniter.org/nodes/rust/duniter-v2s.git \
--branch BRANCH --depth 1
cargo build --release
This can take ~1h or so depending on your internet connexion and computing power. Then you get a binary in ./target/release/duniter
.
duniter --help
will give you all you need to start and configure your node.
Other methodsπ
Currently there is no other supported method, but contributions are welcome to package for:
- debian
- yunohost
- fedora
- archlinux
- ...
Expose the RPC API publiclyπ
Once you are happy with your node, you can expose publicly its RPC API using a nginx reverse proxy for example (here /http
and /ws
):
server {
server_name DOMAIN;
listen 443 ssl http2;
listen [::]:443 ssl http2;
ssl_certificate /etc/nginx/ssl/DOMAIN.cert;
ssl_certificate_key /etc/nginx/ssl/DOMAIN.key;
root /nowhere;
add_header X-Frame-Options SAMEORIGIN;
add_header X-XSS-Protection "1; mode=block";
proxy_redirect off;
proxy_buffering off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Forwarded-Port $server_port;
proxy_read_timeout 90;
location /http {
proxy_pass http://localhost:9933;
proxy_http_version 1.1;
}
location /ws {
proxy_pass http://localhost:9944;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_http_version 1.1;
proxy_read_timeout 1200s;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $host;
}
}
with the appropriate certificates. See duniter doc examples for detail.