HugoTrentesaux

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.

Docker

We chose docker as the standard way to deploy a node. Distribution packages are not yet provided. First install docker on your platform. 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                       # <----
    command:
      # disable pruning for an archive node
      - "--pruning=14400"

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.

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.

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.