Skip to main content

Step 1: Run an Octez node

The first thing you need is a Tezos layer 1 node, which is an instance of the octez-node program and part of the Octez suite of programs.

Installing Octez

The version of Octez to use depends on the Tezos network that you are using.

  • For Mainnet or Shadownet, install the most recent release of Octez, including octez-client, octez-node, octez-dal-node, octez-baker, and octez-accuser:

    • On MacOS, we provide a Homebrew formula to install Octez. First, make sure Homebrew is installed on your system. (If you ever get errors during the steps below, you may need to reinstall Homebrew using its latest official installation script.) Then, run the following commands (replacing, if you want, octez-user and octeztap with the desired user name and tap name, respectively):

      # Download formula:
      curl -q "https://packages.nomadic-labs.com/homebrew/Formula/octez.rb" -O
      # Create a local tap:
      brew tap-new octez-user/octeztap
      # Move formula to the newly created tap:
      mv octez.rb $(brew --repository)/Library/Taps/octez-user/homebrew-octeztap/Formula/
      # Install formula from tap
      brew install octez-user/octeztap/octez
    • On Linux and Windows WSL, download and install the built binaries from the Octez release page, as in this example for Ubuntu:

      wget https://octez.tezos.com/releases/octez-v23.2/binaries/x86_64/octez-v23.2.tar.gz
      tar xf octez-v23.2.tar.gz
      sudo cp octez/octez* /usr/local/bin/

    Check the dedicated Octez release page for other binaries built for other architectures.

  • For Weeklynet, look up the necessary version of Octez at https://teztnets.com/weeklynet-about and install it with the instructions there.

For more installation options, see Installing Octez in the Octez documentation.

If you build from source, you can use the latest-release branch to work with Shadownet.

Data directories and configuration file locations

The Octez node, DAL node, baker, and some other Octez daemons store data in two places:

  • A data directory, which stores raw information, such as the context (for the Octez node) or the DAL data (for the DAL node).
  • A configuration file, which lists details about the daemon's configuration, such as the network and bootstrap peers that it connects to. By default, the configuration file is stored in the data directory.

For example, by default, the Octez node stores its data directory at $HOME/.tezos-node/ and its configuration file at $HOME/.tezos-node/config.json.

When you run daemons, you must ensure that each command points the daemon to the correct locations. For example, if you initialize the Octez node with the config init command and specify one location and then run it with the run command with a different location, the node might not not run as you intend.

There are multiple ways to manage these locations:

  • Use the default locations
  • Pass the locations in the --data-dir and/or --config-file arguments in each command that you run
  • In some cases, you can set environment variables to point to data directory locations

You can also set the location of the data directory in the data-dir field of the configuration file and use only the --config-file argument. Similarly, you can set the location of the data directory with the --data-dir argument or environment variable and the daemon stores the configuration file in that directory by default.

This table shows the defaults and the ways to set these locations for the main daemons that you use in this tutorial:

DaemonDataDefaultCommand-line argumentEnvironment variable
Data directory$HOME/.tezos-client--data-dirTEZOS_CLIENT_DIR
Octez clientConfiguration file$HOME/.tezos-client/config--config-fileN/A
Data directory$HOME/.tezos-node--data-dirTEZOS_NODE_DIR
Octez nodeConfiguration file$HOME/.tezos-node/config.json--config-fileN/A
Data directory$HOME/.tezos-dal-node--data-dirN/A
Octez DAL nodeConfiguration file$HOME/.tezos-dal-node/config.json--config-fileN/A
Data directory$HOME/.tezos-client (Shared with the Octez client)--data-dirTEZOS_CLIENT_DIR
Octez bakerConfiguration file$HOME/.tezos-client/config (Shared with the Octez client)--config-fileN/A
important

Throughout this tutorial, make sure that you are consistent with the locations of the configuration file and data directory for each daemon.

Running the layer 1 node

  1. Ensure that the port on which the node listens for connections from peer nodes (by default, 9732) is accessible from outside its system. You may need to adapt your firewall rules or set up network address translation (NAT) to direct external traffic to the node.

  2. Initialize the Octez node for the network. For example, to initialize it for Shadownet, run this command:

    octez-node config init --network https://teztnets.com/shadownet

    Remember to be aware of the locations described in Data directories and configuration file locations.

  3. Download a rolling snapshot of the network from https://snapshot.tzinit.org based on the instructions on that site. For example, the command to download a Shadownet snapshot from the European servers might look like this:

    wget -O snapshot_file https://snapshots.eu.tzinit.org/shadownet/rolling
  4. Load the snapshot in the node by running this command:

    octez-node snapshot import snapshot_file

    If you get an error that says that the data directory is invalid, you have selected a data directory that has been used. Delete the files in the directory or use a new directory.

  5. Install the Zcash parameters as described Install Zcash Parameters in the Octez documentation.

  6. Start the node:

    octez-node run --rpc-addr 127.0.0.1:8732

    You can add the argument --log-output="$HOME/octez-node.log" to redirect its output in a log file.

    At first launch, the node generates a fresh identity file used to identify itself on the network. Then it bootstraps the chain, which takes a variable amount of time depending on how many blocks need to be loaded.

  7. Make sure the Octez client uses your node by running this command:

    octez-client -E http://localhost:8732 config update

    If you see an error that says "Failed to acquire the protocol version from the node," ensure that your node is running and verify that the host name and port in the config update command are correct.

  8. Wait for your node to bootstrap by running this command:

    octez-client bootstrapped

    The client waits until it is connected and the node is running at the current level. When it is connected and the node is updated, the command prints the message Node is bootstrapped. The time it takes depends on how many blocks the node must retrieve to catch up from the snapshot to the current head block.

  9. Optional: Hide the Octez client's network warning message by running this command:

    export TEZOS_CLIENT_UNSAFE_DISABLE_DISCLAIMER=y

    This command suppresses the message that your instance of the Octez client is not using Mainnet.

  10. Ensure that the node runs persistently. Look up how to run programs persistently in the documentation for your operating system. You can also refer to Setting up Octez Services in the Octez documentation.

    For example, if your operating system uses the systemd software suite, your service file might look like this example:

    /etc/systemd/system/octez-node.service
    [Unit]
    Description=Octez node
    Wants=network-online.target
    After=network-online.target

    [Install]
    WantedBy=multi-user.target

    [Service]
    Type=simple
    User=tezos
    ExecStart=octez-node run --rpc-addr 127.0.0.1:8732 --data-dir $HOME/.tezos-node
    WorkingDirectory=/opt/octez-node
    Restart=on-failure
    RestartSec=5
    StandardOutput=append:/opt/octez-node.log
    StandardError=append:/opt/octez-node.log
    SyslogIdentifier=%n

    If you name this service file /etc/systemd/system/octez-node.service, you can start it by running these commands:

    sudo systemctl daemon-reload
    sudo systemctl start octez-node.service

    You can stop it by running this command:

    sudo systemctl stop octez-node.service

    The systemd software suite uses the journalctl program for logging, so you can use it to monitor the node and the other Octez daemons you run. For example, this command prints the log of the Octez node service as it is updated, similar to the tail -f command:

    journalctl --follow --unit=octez-node.service

    The journalctl program has options that let you search logs during time periods. For example, this command shows log entries between two times:

    journalctl --unit=octez-node.service --since "20 minutes ago" --until "60 seconds ago"

    For more information about logging, see the documentation for the journalctl program.

  11. Optional: When the node has bootstrapped and caught up with the current head block, you can delete the snapshot file to save space.

In the meantime, you can continue the baking infrastructure while the node is bootstrapping. Continue to Step 2: Set up baker accounts.