Skip to content

Latest commit

 

History

History
193 lines (155 loc) · 6 KB

tutorial.md

File metadata and controls

193 lines (155 loc) · 6 KB

Gantree Configuration - Tutorial

Document information

GANTREE CONFIG VERSION LAST UPDATED
2.0 2020/04/15

Important Note

It is highly recommended that you create your own configurations based on existing samples. This tutorial serves as a step-by-step explanation of alternatively creating a config from scratch in an effort to cover each aspect required.

For the average user, everything you need should be covered by basics and samples. If you're having issues however, this document may help.

Polkadot Example

We're going to create a Gantree config, so we need to create a new .json file. In this tutorial, we're going to call it polkadot_tutorial.json.

Inside our file, we're first going to want to specify which schema version our Gantree config will be under the metadata root-level key.

{
  "metadata": {
    "version": "2.0"
  }
}

We also want to add the name of our project here. This will be used as a unique identifier in Gantree's logic, and be used as a name base for nodes with various operations.

{
  "metadata": {
    "version": "2.0",
    "project": "polkadot_tutorial"
  }
}

Next we want to specify everything regarding the binary we'll be running on our nodes. This will all be under a root-level key, "binary": {}.

We're going to specify whether this binary should use a specific value for it's --chain argument, or whether it should not use a --chain argument. We're going to use the default chain, so we specify "chain": false.

We also need to specify the method which Gantree should use to get the binary. We're going to be compiling from a repository, so we add the key "repository": {}.

Note: If you would rather use a different method, such as downloading an already compiled binary (fetch method), please consult the basics documentation.

Inside the repository object, we specify the url of the repository we want to use (url), and the version of the repository to use (version).

In our case, we'll use the url https://github.com/paritytech/polkadot for the polkadot repository, and the version head so we're compiling the latest commit from the default branch.

{
  "metadata": {
    "version": "2.0",
    "project": "s-r-do-pol-kus"
  },
  "binary": {
    "chain": false,
    "repository": {
      "url": "https://github.com/paritytech/polkadot",
      "version": "HEAD"
    }
  }
}

Now we need to specify what the name of the binary will be once it's compiled, and whether we should use the binary's default chainspec, or our own.

We'll set our filename to polkadot, and useBinChainSpec to true.

{
  "metadata": {
    "version": "2.0",
    "project": "s-r-do-pol-kus"
  },
  "binary": {
    "chain": false,
    "repository": {
      "url": "https://github.com/paritytech/polkadot",
      "version": "HEAD"
    },
    "filename": "polkadot",
    "useBinChainSpec": "true"
  }
}

Lastly, we need to specify a "nodes": [] root-level key in the form of an array. Inside this array we'll specify an object for each of the nodes in our network.

{
  "metadata": {
    "version": "2.0",
    "project": "s-r-do-pol-kus"
  },
  "binary": {
    "chain": false,
    "repository": {
      "url": "https://github.com/paritytech/polkadot",
      "version": "HEAD"
    },
    "filename": "polkadot",
    "useBinChainSpec": "true"
  },
  "nodes": []
}

We'll create a new item in this array in the form of an object, and start adding keys.

Our node object isn't going to be a validator, so we specify "validator": "false".

Now we need to specify the infrastructure the node will be created on, so we add an "instance": {} key to our node object.

In our case, we're going to use the provider Digital Ocean, so we'll add a "provider" key to the instance object with the value "do".

{
  "metadata": {
    "version": "2.0",
    "project": "s-r-do-pol-kus"
  },
  "binary": {
    "chain": false,
    "repository": {
      "url": "https://github.com/paritytech/polkadot",
      "version": "HEAD"
    },
    "filename": "polkadot",
    "useBinChainSpec": "true"
  },
  "nodes": [
    {
      "validator": false,
      "instance": {
        "provider": "do"
      }
    }
  ]
}

The rest of the keys in "instance": {}" are dependent on the provider specified, so if you wanted to use a different provider you would need to specify its specific keys. Consult basics for more information.

Next, we'll specify the size and region of the droplet we're creating, in addition to the path to the private key that will be used to access the instance during operations or debugging.

{
  "metadata": {
    "version": "2.0",
    "project": "s-r-do-pol-kus"
  },
  "binary": {
    "chain": false,
    "repository": {
      "url": "https://github.com/paritytech/polkadot",
      "version": "HEAD"
    },
    "filename": "polkadot",
    "useBinChainSpec": "true"
  },
  "nodes": [
    {
      "validator": false,
      "instance": {
        "provider": "do",
        "dropletSize": "s-6vcpu-16gb",
        "region": "nyc3",
        "sshPrivateKeyPath": "$env:GANTREE_INSTANCE_PRIVATE_KEY_PATH"
      }
    }
  ]
}

Here we've specified the path to our private key as a reference to an environment variable, so we need to ensure it's been exported before running any Gantree operations.

You should now have a working Gantree configuration for a polkadot node!

Feedback

If you have any critical questions that were not addressed here, or in any other documentation, please don't hesitate to open a GitHub issue titled in this format.

Issue title: DOCS (question): [context here]

Substitute [context here] with your own terse description of what's missing, and in the issue's description please provide as much detail as you feasibly can.