Skip to content

Latest commit

 

History

History
1129 lines (622 loc) · 14.1 KB

templates.md

File metadata and controls

1129 lines (622 loc) · 14.1 KB

Capsule templating docs

Capsule allows templating for genesis file and node-set configurations like Vega, Tendermint, and Nomad. This is useful for generating configurations specific to a network, or for using one configuration for all node sets.

Capsule uses Go's text/template templating engine, extended by useful functions from the Sprig library.

Every template has a template context - a set of (usually runtime generated) variables passed to the template by Capsule and then used in the template. These template contexts are documented below.

There are some basic templates provided by Capsule and used by some of the provided configurations in the net_confs folder in the Vega Capsule GitHub repo.

Template tool

Capsule includes a tool to test these templates before they get used in network config. Plese check vegacapsule template --help for more information.

You can test the template tool by using some of the provided default templates after the network has been generated.

For example, run command below and compare the outcome with the template.

vegacapsule template node-sets --type vega --path net_confs/node_set_templates/default/vega_validators.tmpl --nodeset-name testnet-nodeset-validators-0-validator

Template contexts

config.NodeConfigTemplateContext

Fields

NodeNumber int - required

Absolute index of the generated node.


datanode.ConfigTemplateContext

Fields

NodeHomeDir string - required
NodeNumber int - required
NodeSet types.NodeSet - required

faucet.ConfigTemplateContext

Fields

HomeDir string - required

Path to home directory of the Faucet.

PublicKey string - required

Public key of the Faucet.


genesis.TemplateContext

Template context also includes functions:

  • .GetEthContractAddr "contract_name" - returns contract address based on name.
  • .GetVegaContractID "contract_name" - returns contract vega ID based on name.

Fields

Addresses map[string]genesis.SmartContract - required

Ethereum smart contract addresses created by Vega. These can represent bridges or ERC20 tokens.

NetworkID string - required

Ethereum network ID.

ChainID string - required

Ethereum chain ID.


tendermint.ConfigTemplateContext

Fields

TendermintNodePrefix string - required
VegaNodePrefix string - required
NodeNumber int - required
NodesCount int - required
NodeSet types.NodeSet - required

vega.ConfigTemplateContext

Fields

TendermintNodePrefix string - required
VegaNodePrefix string - required
DataNodePrefix string - required
ETHEndpoint string - required
NodeMode string - required
FaucetPublicKey string - required
NodeNumber int - required
NodeSet types.NodeSet - required
NodeHomeDir string - required

visor.ConfigTemplateContext

Fields

NodeSet types.NodeSet - required

wallet.ConfigTemplateContext

Fields

TendermintNodePrefix string - required
VegaNodePrefix string - required
DataNodePrefix string - required
WalletPrefix string - required
Validators []types.NodeSet - required
NonValidators []types.NodeSet - required

types.NodeSet

Fields

GroupName string - required

Name that represents a group of the same node sets.

Name string - required

Name of a specific node set in a node sets group.

Mode string - required

Mode of the node set. Can be validator or full (full means a non validating node).

Index int - required

Index is a position and order in which the node set has been generated respective to all other created node sets. It goes from 0-N where N is the total number of node sets.

RelativeIndex int - required

RelativeIndex is a counter relative to current node set group. Related to GroupName.

GroupIndex int - required

GroupIndex is an index of the group that this node set belongs to. Related to GroupName.

Vega types.VegaNode - required

Information about generated Vega node.

Tendermint types.TendermintNode - required

Information about generated Tendermint node.

DataNode types.DataNode - optional

Information about generated Data node.

Visor types.Visor - optional

Information about generated Visor instance.

PreGenerateJobs []types.NomadJob - required

Jobs that have been started before the nodes were generated.

PreStartProbe types.ProbesConfig - optional

Pre start probes.

NomadJobRaw string - optional

Stores custom Nomad job definition of this node set.


genesis.SmartContract

Fields

Ethereum string - required

Ethereum address.

Vega string - required

Vega contract ID.


types.VegaNode

Represents generated Vega node.

Fields

GeneratedService types.GeneratedService - required

General information about the node.

Mode string - required

Mode of the node - validator or full.

NodeWalletPassFilePath string - required

Path to generated node wallet passphrase file.

Only present if `mode = validator`.
NodeWalletInfo types.NodeWalletInfo - optional

Information about generated/imported node wallets.

Only present if `mode = validator`.
BinaryPath string - required

Path to binary used to generate and run the node.


types.TendermintNode

Represents generated Tendermint node.

Fields

GeneratedService types.GeneratedService - required

General information about the node.

NodeID string - required

ID of the Tendermint node.

GenesisFilePath string - required

File path of the genesis file used to bootstrap the network.

BinaryPath string - required

Path to binary used to generate and run the node.

ValidatorPublicKey string - required

Generated public key of the Tendermint validator.


types.DataNode

Fields

GeneratedService types.GeneratedService - required

General information about the node.

BinaryPath string - required

Path to binary used to generate and run the node.

UniqueSwarmKey string - required

Unique IPFS swarm key for this network


types.Visor

Fields

GeneratedService types.GeneratedService - required

General information about Visor.

BinaryPath string - required

Path to binary used to generate and run the node.


types.NomadJob

Represents a raw Nomad job.

Fields

ID string - required

Custom selected ID - name of the job.

NomadJobRaw string - required

Nomad job definition.


types.ProbesConfig

Allows the user to define pre start probes on external services.

Fields

HTTP types.HTTPProbe - optional

Allows the user to probe HTTP endpoint.

TCP types.TCPProbe - optional

Allows the user to probe TCP socker.

Postgres types.PostgresProbe - optional

Allows the user to probe Postgres database with a query.

Complete example

pre_start_probe {
  ...
}

types.GeneratedService

Represents any generated Capsule service.

Fields

Name string - required

Name of the service.

HomeDir string - required

Path to home directory of the service.

ConfigFilePath string - required

Path to service configuration.


types.NodeWalletInfo

Information about node wallets.

Fields

EthereumAddress string - required

Ethereum account address.

Only available when Key Store wallet is used.
EthereumPrivateKey string - required
EthereumPassFilePath string - required

Path to file where Ethereum wallet key is stored.

EthereumClefRPCAddress string - required

Address of Clef wallet.

Only available when Clef wallet is used.
VegaWalletName string - required

Name of the Vega wallet.

VegaWalletID string - required

ID of Vega wallet.

VegaWalletPublicKey string - required

Public key used from the Vega wallet.

VegaWalletRecoveryPhrase string - required

Recovery phrase from the Vega wallet.

VegaWalletPassFilePath string - required

File path of the Vega wallet passphrase.


types.HTTPProbe

Allows the user to probe HTTP endpoint.

Fields

URL string - required

URL of the HTTP endpoint.

Complete example

http {
  url = "http://localhost:8002"
}

types.TCPProbe

Allows the user to probe TCP socket.

Fields

Address string - required

Address of the TCP socket.

Complete example

tcp {
  address = "localhost:9009"
}

types.PostgresProbe

Allows the user to probe Postgres database.

Fields

Connection string - required

Postgres connection string.

Query string - required

Test query.

Complete example

postgres {
  connection = "user=vega dbname=vega password=vega port=5232 sslmode=disable"
  query      = "select 10 + 10"
}