Questions after installing a mirror node (debian package)

Hi !

I installed a mirror node using the Debian package. I have some questions.

I intend to write a tutorial on “howto setup a public mirror node” and “howto setup a smith node”, so I would like to understand these points before.

  1. I could not guess which value to set for DUNITER_LISTEN_ADDR. The comments states :
If SMITH NODE: `/ip4/0.0.0.0/tcp/<port>` and `/ip6/[::]/tcp/<port>`. Otherwise: `/ip4/0.0.0.0/tcp/<port>/ws` and `/ip6/[::]/tcp/<port>/ws`.

but I have no idea if <port> should remain 30333 or if it should be 9944 for non-smith (since there is the path /ws), or if it can be any port I like. Maybe there should be two example lines in the config files, if they should be different for smith or mirror nodes ?

  1. I could access the RPC endpoint after setting DUNITER_RPC_CORS to all. Is it the right way to go for a public mirror node ? Should a smith node keep the default value ?

  2. I understood that smith nodes should not expose an RPC endpoint, right ?

    1. So, for smith nodes, all the communication is p2p ?
    2. Maintainers of a smith node should not setup any reverse proxy ?
    3. Should the smith node be associated (in any way) with a unique mirror node that would be its exposure to RPC requests ? (I think the answer is ‘no’, but I want a confirmation)
  3. I let the ORACLE default values… I even don’t know if I launched an oracle node or not (I know it would not work anyway). If some conf values are only useful for specific cases, it may be nice to separate the conf file in parts, like

################
## Oracle part
## All following values can remain commented if you don't run an oracle
################

I join the conf files for the node and for the reverse-proxy, for more context.

env_file
# Sets the name of the node.
# This should be a unique identifier for your node within the network.
DUNITER_NODE_NAME=Matograine

# Specifies the blockchain network to connect to.
DUNITER_CHAIN_NAME=gdev

# Defines the address and port for node communication.
# The format is /ip4/[IP address]/tcp/[port]/[protocol].
# If SMITH NODE: `/ip4/0.0.0.0/tcp/<port>` and `/ip6/[::]/tcp/<port>`. Otherwise: `/ip4/0.0.0.0/tcp/<port>/ws` and `/ip6/[::]/tcp/<port>/ws`.
# ICI il faudrait des exemples commentés, je ne sais pas quelle est la valeur de <port>.
DUNITER_LISTEN_ADDR=/ip4/0.0.0.0/tcp/30333/ws
#DUNITER_LISTEN_ADDR=/ip4/0.0.0.0/tcp/9944/ws

# Specify browser origins allowed to access the HTTP & WS RPC servers.
# A comma-separated list with no space of origins.
# Value of `all` will disable origin validation. Default is to allow localhost and
#<https://polkadot.js.org> origins.
# Default: "http://localhost:*,http://127.0.0.1:*,https://localhost:*,https://127.0.0.1:*,https://polkadot.js.org"
#DUNITER_RPC_CORS=http://localhost:*,http://127.0.0.1:*,https://localhost:*,https://127.0.0.1:*,https://polkadot.js.org
DUNITER_RPC_CORS=all

# Configures the pruning profile to manage how old blockchain data is stored.
# This setting can only be set on the first creation of the database.
# Options:
# - 'archive': Keep the state of all blocks.
# - 'archive-canonical': Keep only the state of finalized blocks.
# - [number]: Keep the state of the last specified number of finalized blocks.
# Default: 256 for a balanced pruning strategy.
DUNITER_PRUNING_PROFILE=256

# Sets the directory for storing Duniter data.
# This should be a writable path on your system by the duniter user where the node can store its data.
# Default: /home/duniter/.local/share/duniter
BASE_PATH=/home/duniter/.local/share/duniter

# URL for the Oracle RPC server.
# This should point to the RPC endpoint that the oracle will use to communicate with the blockchain.
# Default: ws://127.0.0.1:9944 for a local WebSocket RPC server.
ORACLE_RPC_URL=ws://127.0.0.1:9944

# Determines the log level for the Oracle.
# Options include 'error', 'warn', 'info', 'debug', 'trace'.
# 'info' is a good default that provides useful runtime information without too much detail.
# Default: info
ORACLE_LOG_LEVEL=info
nginx config
map $http_upgrade $connection_upgrade {
    default upgrade;
    ''      close;
}

server {
  server_name gdev.matograine.fr;

  listen 443 ssl http2;
  listen [::]:443 ssl http2;
  ssl_certificate /PATH/TO/fullchain.pem;
  ssl_certificate_key /PATH/TO/privkey.pem;

  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 / {
    proxy_pass http://localhost:9944;

    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection $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;
  }
}
2 Likes

@bgallois is on vacation, so I’ll try answer this :slight_smile:

Super nice!! Do you want to do it in english on the duniter.org website? Do you want to do it alone or with @joss.rendall and the smith team?

This variable lets the node announce its p2p listen endpoint. In the run smith doc, I give this example:

services:
  duniter-smith:
    ports:
      # rpc via websocket
      - 127.0.0.1:9944:9944
      # public p2p endpoint
      - 30333:30333 # <--- here is your public p2p port
    environment:
      - DUNITER_PUBLIC_ADDR=/dns/gdev.example.org/tcp/30333 # <--- your public p2p endpoint
      - DUNITER_LISTEN_ADDR=/ip4/0.0.0.0/tcp/30333

This reads as follows:

  1. DUNITER_LISTEN_ADDR=/ip4/0.0.0.0/tcp/30333 duniter will listen on port 30333 and bind to all available ipv4 addresses
  2. 30333:30333 docker will forward the port 30333 of the host network to the port 30333 of the container network, this implicitly means `0.0.0.0:30333:30333
  3. DUNITER_PUBLIC_ADDR=/dns/gdev.example.org/tcp/30333 duniter p2p layer will announce this address so that other nodes who want to connect to this peer know where to look (here dns resolution and tcp port)

The DUNITER_LISTEN_ADDR variable is in the multiaddress format, which is an alternative way of writing addresses, more explicit relative to the protocols used.

30333 is the default port for p2p tcp connections and 9944 is the default port for rpc api (http and ws). They are note the same :

  • P2P is node-to-node API
  • RPC is client-to-node API

Yes, I do not understand why they suggest exposing the p2p port through a websocket. We had a discussion about this here Fix #200 (!267) · Merge requests · nodes / rust / Duniter v2S · GitLab and I can not find the paritytech issue where they discuss this anymore.

Unless you known what you are doing, I suggest that you simply listen on tcp and make sure tutorial readers know that this port is supposed to be available externally in their network (for example firewall or port forwarding on their local network).

Mirror and smith nodes should have the same p2p config. The difference lie in the RPC API :

  • mirror node expose their safe RPC API (that’s why they are useful)
  • smith nodes do not expose their RPC API externally, because it is configured to include unsafe parts that are needed for node admin (example: rotate_keys), and because smith nodes’ attack surface should be minimized

Yes.

Yes, yes, yes, no. (all right :wink:)

Oracle is only for smith nodes, because only them can add the result of a distance computation to a block they forged. On debian package, it should work out of the box without config (see these discussion 267#note_43519 and the services and timers resources/debian · master · nodes / rust / Duniter v2S · GitLab).

We are at the beginning of the packaging process. Thanks for your feedback, it will help improve packaging to simplify things for the user!

2 Likes

@joss.rendall Est en travaux sur l’écriture de ce genre de doc, avec l’équipe de coordinationV2

4 Likes

Greetings dear @matograine.
With the “Smith” team, we’re writing documentation for those who want to implement mirror or smith nodes. Would you like to join the team? We’re starting the doc in French, then it will be translated. Do you speak French to ?

1 Like

French is my native language :wink: I would like to join the team.

3 Likes