Skip to main content

SNARK Workers Getting Started

The Mina protocol is unique because nodes are not required to maintain the full history of the blockchain like other cryptocurrency protocols. By recursively using cryptographic proofs, the Mina protocol effectively compresses the blockchain to constant size. This compression reduces terabytes of data to a few kilobytes.

However, this isn't data encoding or compression in the traditional sense. Mina nodes compress data in the network by generating cryptographic proofs. Node operators play a crucial role in this process by designating themselves as SNARK workers that generate zk-SNARKs for transactions that have been added to blocks.

You can connect a SNARK worker to the network or use a SNARK coordinator. SNARK coordinators can be used to coordinate and distribute work to any SNARK workers that you are running. If you are running a SNARK coordinator, connect the SNARK coordinator to the network, then connect SNARK workers to the SNARK coordinator.

SNARK Coordinator Requirements

Software: Supported environments include macOS, Linux (Debian 10, 11, 12 and Ubuntu 20.04 LTS), and any host machine with Docker.

Processor: Only x86-64 CPU architecture is supported.

Hardware: Sending and receiving MINA does not require any special hardware.

Running a SNARK coordinator on the Mina network requires at least:

  • 8-core processor
  • 32 GB of RAM
  • 64 GB of free storage

Network: At least 1 Mbps connection

SNARK Worker Requirements

Software: Supported environments include macOS, Linux (Debian 10, 11, 12 and Ubuntu 20.04 LTS), and any host machine with Docker.

Processor: Only x86-64 CPU architecture is supported.

Hardware: Sending and receiving MINA does not require any special hardware.

Running a SNARK worker on the Mina network requires at least:

  • 16-core processor with 32 threads
  • 32 GB of RAM
  • 64 GB of free storage

Network: At least 1 Mbps connection

Running a SNARK coordinator

To start a SNARK coordinator, run a mina daemon with these additional flags:

--run-snark-coordinator <PUBLICKEY>\ --snark-worker-fee <FEE> --work-selection seq

Running a SNARK worker connected to a SNARK coordinator

To start a SNARK-worker connected to a SNARK-coordinator, run mina with these flags:

internal snark-worker --proof-level full --shutdown-on-disconnect false --daemon-address <snark coordinator IP and port - IP:port>

Running a SNARK-worker

To start a SNARK-worker, run mina daemon with these flags:

--run-snark-worker <PUBLICKEY>\ --snark-worker-fee <FEE> --work-selection <seq|rand|roffset>

Use the --snark-worker-parallelism flag to set the number of threads used in snark working, this does not affect block production.

Setting a Node to be a SNARK-worker

To make a node a SNARK-worker, run these commands:

mina client set-snark-work-fee <FEE>
mina client set-snark-worker --address $MINA_PUBLIC_KEY

If your daemon is already running, restart the daemon with these flags:

args={["-run-snark-worker $MINA_PUBLIC_KEY", "-snark-worker-fee <fee>"]}

As a SNARK-worker, you get to share some of the block rewards for each block that include your compressed transactions. The block producer is responsible for gathering compressed transactions before including them into a block and is incentivized by the protocol to reward SNARK-workers.

SNARK-workers can be fairly compute intensive. If you need to limit their CPU usage, specify the number of threads that SNARK-workers use with the -snark-worker-parallelism flag. This can be especially useful if you're trying to run a block producer and SNARK-worker on the same machine and having issues producing blocks in time.

The roles and responsibilities of a Mina node operator offer you incentives to participate in block production through staking or delegation. Mina is a permissionless peer-to-peer network, so everything is managed and run in a decentralized manner by nodes all over the world.

Configure your mina daemon in daemon.json

By creating a file at ~/.mina-config/daemon.json, you can configure your mina daemon without providing options on the command line. This can be useful for running mina as a service and to avoiding repetitive typing.

Most of the options that can be passed to mina daemon on the command line can also be provided as options in the config file. See mina daemon -help for more details.

The following example file includes usage of the configuration parameters:

{
"daemon": {
"client-port": 1000,
"external-port": 1001,
"rest-port": 1002,
"block-producer-key": "/path/to/privkey-file",
"block-producer-password": "mypassword",
"block-producer-pubkey": "<MY PUBLICKEY>",
"coinbase-receiver": "<MY PUBLICKEY>",
"log-block-creation": false,
"log-received-blocks": false,
"log-snark-work-gossip": false,
"log-txn-pool-gossip": false,
"peers": ["seed-one.o1test.net", "seed-two.o1test.net"],
"run-snark-worker": "<MY PUBLICKEY>",
"snark-worker-fee": 10,
"snark-worker-parallelism": 1,
"work-reassignment-wait": 420000,
"work-selection": "seq"
}
}

In the ~/.mina-config/daemon.json file, include only the options you want to change.