The DMQ node allows for client peers to communicate efficiently by publishing and consuming messages which are diffused over a P2P network to other nodes.
This repository provides the dmq-node executable to participate in the DMQ
network.
The dmq-node is developed with respect to the CIP#137.
NOTE: This is still an early version of DMQ node, which comes with some quirks:
- issue#6 - experimental support for ledger peers see Ledger Peers below.
We use cabal to build our project, potentially inside a Nix shell (nix develop or nix-shell). It should suffice with:
> cabal build dmq-node:exe:dmq-nodeThe executable can be run with:
> cabal run dmq-nodeTo build the executable using Nix, one can use:
> nix build .#dmq-nodeTo get a statically linked executable using musl library, use:
> nix build .#dmq-node-staticTo build a docker image:
> nix build .#docker-dmqUsage: dmq-node [--host-addr IPv4] [--host-ipv6-addr IPv6]
[-p|--port Port Number] [--local-socket FILENAME]
[-c|--configuration-file FILENAME] [-t|--topology-file FILENAME]
[--cardano-node-socket Cardano node socket path]
[--cardano-network-magic Cardano node network magic]
[--dmq-network-magic dmq node network magic] [-v|--version]
Run the DMQ-Node
Available options:
--host-addr IPv4 IPv4 that the node will bind to
--host-ipv6-addr IPv6 IPv6 that the node will bind to
-p,--port Port Number Port Number that the node will bind to
(default: 3141)
--local-socket FILENAME Unix socket for node-to-client communication
(default: "dmq-node.socket")
-c,--configuration-file FILENAME
Configuration file for DMQ Node
(default: "dmq.config.json")
-t,--topology-file FILENAME
Topology file for DMQ Node
(default: "dmq.topology.json")
--cardano-node-socket Cardano node socket path
Used for local connections to Cardano node
(default: "cardano-node.socket")
--cardano-network-magic Cardano node network magic
The network magic of cardano-node client for local
connections
(default: 764824073)
--dmq-network-magic dmq node network magic
The network magic of the dmq network
(default: 3141592)
-v,--version Show dmq-node version
-h,--help Show this help text
dmq-node has default options for allmost all configuration values,
ref. You only need to create a configuration file if
you want to modify one of the options. To get a json key for
a configuration option just remove the dmqc prefix from a Configuration
record field (e.g. dmqcLedgerPeers → LedgerPeers).
Topology file has the same syntax as for cardano-node, see the original
documentation. However, the fields: bootstrapPeers and
peerSnapshotFile are not supported.
dmq-node requires node-to-client V23, available since cardano-node 10.7,
to fetch stake data for signature validation. By default, it also fetches a
ledger peer snapshot on each stake refresh. Set "LedgerPeers": false in the
DMQ configuration file to skip the snapshot query.
The topology field useLedgerAfterSlot controls when DMQ uses ledger peers.
Set it to 0 to allow them immediately, or to a positive slot number to use
snapshots from that slot onward. Set it to -1 or omit it to disable ledger
peer selection.
To advertise a DMQ relay, publish a DNS SRV record at
_dmq._mithril._cardano._tcp.<domain>, where <domain> is registered as an
SRV relay for your stake pool. See CIP#155.
With a positive useLedgerAfterSlot, DMQ currently uses the big ledger peer
snapshot even for ordinary peer requests. To bootstrap when only smaller
pools advertise DMQ relays, add a reachable DMQ relay to the localRoots
group in your topology. See the example topology.
dmq-node is using trace-dispatcher framework for logging (i.e. the same as
the new tracing system for cardano-node).
The Prometheus requires a different port number than cardano-node's
Prometheus.
{
"CardanoNodeSocket": "/var/run/cardano-node.socket",
"TraceOptions": {
"": {
"backends": [
"Stdout MachineFormat",
"PrometheusSimple suffix 127.0.0.1 12800"
],
"severity": "Info"
}
}
}DMQ metrics use the prefix dmq_node_ by default. To change it, set
TraceOptionMetricsPrefix in the configuration file, e.g.
{
"TraceOptionMetricsPrefix": "dmq_aggregator."
}The flake exports nixosModules.dmq-node, which configures
services.dmq-node. It reads the Shelley genesis and the cardano network magic
from the attached node's flat configuration. dmq-node connects to the node
socket through the node's group, so that socket must be group-writable; the
example uses socket activation for this, and the cardanoNodeSocketGroup
option lists the alternatives. In a flake's nixosSystem:
nixpkgs.lib.nixosSystem {
modules = [
inputs.dmq-node.nixosModules.dmq-node
({ config, ... }: {
services.cardano-node.systemdSocketActivation = true;
services.dmq-node = {
enable = true;
networkMagic = 2912307721;
cardanoNodeConfig = config.services.cardano-node.nodeConfig;
cardanoNodeSocketPath = config.services.cardano-node.socketPath 0;
hostAddr = "0.0.0.0";
openFirewall = true;
topology = { localRoots = [ ]; publicRoots = [ ]; useLedgerAfterSlot = -1; };
traceOptions."" = {
backends = [ "Stdout MachineFormat" "PrometheusSimple suffix 127.0.0.1 12800" ];
severity = "Info";
};
};
})
];
}With this configuration, a Prometheus instance on the same host can scrape
127.0.0.1:12800 at its default path, /metrics. To inspect it directly:
curl -fsS http://127.0.0.1:12800/metricsdmq_node_peerSelection_ActivePeers_int reports the current active peer count.
For messages received from peers, look for dmq_node_txSubmission_txsReceived_int,
dmq_node_txSubmission_txsAccepted_int and dmq_node_txSubmission_txsRejected_int.
The V2 submission worker checks for changed totals every seven seconds, so these
series can be absent from an early scrape. The NixOS service enables GHC runtime
statistics with +RTS -T -RTS, including rts_gc_bytes_allocated and
rts_gc_num_gcs.
nix/nixos/dmq-node-service.nix holds the module with no reference to this
flake, so it can be imported by path. There package defaults to
pkgs.dmq-node, which overlays.default adds; set package instead to pin
another build.
To enter a development shell with all dependencies available, use:
> nix developTo run the test suite, one can use:
> cabal run dmq-node:dmq-testsThis project comes with a CDDL specification for the DMQ protocols
(node-to-client and node-to-node). To check changes against the CDDL
specification, use:
cabal run dmq-node:dmq-cddlThe contributing guide is available here. The style guide is available here. The code of conduct is available here.