core

module
v0.5.7 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 12, 2021 License: Apache-2.0

README

 

Full-node software implementing the Terra protocol

Explore the Docs »

Terra Core reference · Go API · Rest API · Python SDK · Terra.js · Finder · Station


Table of Contents

What is Terra?

Terra is a blockchain protocol that provides fundamental infrastructure for a decentralized economy and enables open participation in the creation of new financial primitives to power the innovation of money.

The Terra blockchain is secured by distributed consensus on staked asset Luna, and natively supports the issuance of price-tracking stablecoins (TerraKRW, TerraUSD, etc.) algorithmically pegged to major world currencies. Smart contracts on Terra run on WebAssembly and can take advantage of core modules like on-chain swaps, price oracle, and staking rewards to power modern DeFi apps. Through dynamic fiscal policy managed by community governance, Terra is an evolving, democratized economy directed by its users.

Terra Core is the reference implementation of the Terra protocol, written in Golang. Terra Core is built atop Cosmos SDK and uses Tendermint BFT consensus. If you intend to work on Terra Core source, it is recommended that you familiarize yourself with the concepts in those projects.

Installation

Binaries

The easiest way to get started is by downloading a pre-built binary for your operating system. You can find the latest binaries on the releases page.

From Source

Step 1. Install Golang

Go v1.16+ or higher is required for Terra Core.

If you haven't already, install Golang by following the official docs. Make sure that your GOPATH and GOBIN environment variables are properly set up.

Step 2: Get Terra Core source code

Use git to retrieve Terra Core from the official repo, and checkout the master branch, which contains the latest stable release. That should install the terrad binary.

git clone https://github.com/terra-money/core/
cd core
git checkout main

Step 3: Build from source

You can now build Terra Core. Running the following command will install executable terrad (Terra node daemon and CLI for interacting with the node) to your GOPATH.

make install

Step 4: Verify your installation

Verify that everything is OK. If you get something like the following, you've successfully installed Terra Core on your system.

terrad version --long
name: terra
server_name: terrad
version: 0.5.0-rc0-9-g640fd0ed
commit: 640fd0ed921d029f4d1c3d88435bd5dbd67d14cd
build_tags: netgo,ledger
go: go version go1.16.5 darwin/amd64

terrad

NOTE: terracli has been deprecated and all of its functionalities have been merged into terrad.

terrad is the all-in-one command for operating and interacting with a running Terra node. You can find comprehensive coverage on each of the available functions on our official docs. The various subcommands and their expected arguments can also be interactively discovered by issuing the following command:

        
$ terrad --help Stargate Terra App Usage: terrad [command] Available Commands: add-genesis-account Add a genesis account to genesis.json collect-gentxs Collect genesis txs and output a genesis.json file debug Tool for helping with debugging your application export Export state to JSON gentx Generate a genesis tx carrying a self delegation help Help about any command init Initialize private validator, p2p, genesis, and application configuration files keys Manage your application's keys migrate Migrate genesis to a specified target version query Querying subcommands rosetta spin up a rosetta server start Run the full node status Query remote node for status tendermint Tendermint subcommands testnet Initialize files for a terrad testnet tx Transactions subcommands unsafe-reset-all Resets the blockchain database, removes address book files, and resets data/priv_validator_state.json to the genesis state validate-genesis validates the genesis file at the default location or at the location passed as an arg version Print the application binary version information Flags: -h, --help help for terrad --home string directory for config and data (default "/Users/$HOME/.terra") --log_format string The logging format (json|plain) (default "plain") --log_level string The logging level (trace|debug|info|warn|error|fatal|panic) (default "info") --trace print out full stack trace on errors Use "terrad [command] --help" for more information about a command.

Node Setup

Once you have the node software installed, you will need to set up your node to be part of a network.

Joining the mainnet

If you want to join the columbus-5 mainnet, we strongly recommend the following:

  • 4 or more CPU cores
  • At least 2TB of disk storage
  • At least 100mbps network bandwidth

The mainnet repo contains configuration and migration instructions for setting up a Columbus-5 mainnet node.

Joining a testnet

NOTE: There may be several testnets that exist simultaneously. Make sure that your version of terrad is compatible for the network you wish to join.

The testnet repo contains configuration instructions for setting a node for the latest testnet.

Running a local testnet

NOTE: The easiest way to set get started with a local Terra network for testing is with LocalTerra, which automatically orchestrates a whole environment suited for development with zero configuration.

You can also set up a local testnet with just a single node. You will create one account and be the sole validator signing blocks for the network.

Step 1. Create network and account

First, initialize your genesis file that will bootstrap the network. Set a name for your local testnet, and provide a moniker to refer to your node.

terrad init --chain-id=<testnet_name> <node_moniker>

You will need a Terra account to start. You can generate one with:

terrad keys add <account_name>

Step 2. Add account to genesis

Next, you need to add your account to the genesis. The following commands add your account and set the initial balance:

terrad add-genesis-account $(terrad keys show <account_name> -a) 100000000uluna,1000usd
terrad gentx --name my_account --amount 10000000uluna
terrad collect-gentxs

Step 3. Run Terra daemon

Now, you can start your private Terra network:

terrad start

Your terrad node should now be running a node on tcp://localhost:26656, listening for incoming transactions and signing blocks. You've successfully set up your local Terra network!

Production Environment

NOTE: This guide only covers general settings for a production-level full node. You can find further details on considerations for operating a validator node in our Validator Guide

For the moment, this guide has only been tested against RPM-based Linux distributions.

Increase Maximum Open Files

terrad can open more than 1024 files (which is default maximum) concurrently. You will want to increase this limit.

Modify /etc/security/limits.conf to raise the nofile capability.

*                soft    nofile          65535
*                hard    nofile          65535

Create a Dedicated User

terrad does not require the super user account. We strongly recommend using a normal user to run terrad. However, during the setup process you'll need super user permission to create and modify some files.

Firewall Configuration

terrad uses several TCP ports for different purposes.

  • 26656 is the default port for the P2P protocol. This port is opened in order to communicate with other nodes, and must be open to join a network. However, it does not have to be open to the public. For validator nodes, we recommend configuring persistent_peers and closing this port to the public.

  • 26657 is the default port for the RPC protocol. This port is used for querying / sending transactions. In other words, this port needs to be opened for serving queries from terracli. It is safe to NOT to open this port to the public unless you are planning to run a public node.

  • 1317 is the default port for Lite Client Daemon (LCD), which can be enabled at ~/.terra/config/app.toml. LCD provides HTTP RESTful API layer to allow applications and services to interact with your terrad instance through RPC. Check the Terra REST API for usage examples. You don't need to open this port unless you have use of it.

  • 26660 is the default port for interacting with the Prometheus database which can be used for monitoring the environment. This port is not opened in the default configuration.

Running Server as a Daemon

It is important to keep terrad running at all times. There are several ways to achieve this, and the simplest solution we recommend is to register terrad as a systemd service so that it will automatically get started upon system reboots and other events.

Register terrad as a service

First, create a service definition file in /etc/systemd/system.

Sample file: /etc/systemd/system/terrad.service

[Unit]
Description=Terra Daemon
After=network.target

[Service]
Type=simple
User=terra
ExecStart=/data/terra/go/bin/terrad start
Restart=on-abort

[Install]
WantedBy=multi-user.target

[Service]
LimitNOFILE=65535

Modify the Service section from the given sample above to suit your settings. Note that even if we raised the number of open files for a process, we still need to include LimitNOFILE.

After creating a service definition file, you should execute systemctl daemon-reload.

Controlling the service

Use systemctl to control (start, stop, restart)

# Start
systemctl start terrad
# Stop
systemctl stop terrad
# Restart
systemctl restart terrad

Accessing logs

# Entire log
journalctl -t terrad
# Entire log reversed
journalctl -t terrad -r
# Latest and continuous
journalctl -t terrad -f

Resources

Community

Contributing

If you are interested in contributing to Terra Core source, please review our code of conduct.

License

This software is licensed under the Apache 2.0 license. Read more about it here.

© 2020 Terraform Labs, PTE LTD


 

Powering the innovation of money.

Directories

Path Synopsis
app
params
Package params defines the simulation parameters in the gaia.
Package params defines the simulation parameters in the gaia.
client
docs/statik
Package statik contains static assets.
Package statik contains static assets.
cmd
custom
auth/legacy/v040
Package v040 creates in-place store migrations for fixing multisig pubkey migration problem ref: https://github.com/terra-money/core/issues/562
Package v040 creates in-place store migrations for fixing multisig pubkey migration problem ref: https://github.com/terra-money/core/issues/562
auth/tx
Package tx is a reverse proxy.
Package tx is a reverse proxy.
gov
Package types nolint autogenerated code using github.com/rigelrozanski/multitool aliases generated for the following subdirectories: ALIASGEN: github.com/terra-money/core/types/assets/ ALIASGEN: github.com/terra-money/core/types/util/
Package types nolint autogenerated code using github.com/rigelrozanski/multitool aliases generated for the following subdirectories: ALIASGEN: github.com/terra-money/core/types/assets/ ALIASGEN: github.com/terra-money/core/types/util/
x
market/exported
DONTCOVER
DONTCOVER
market/legacy/v04
DONTCOVER nolint
DONTCOVER nolint
market/types
Package types is a reverse proxy.
Package types is a reverse proxy.
oracle/exported
DONTCOVER
DONTCOVER
oracle/keeper
nolint
nolint
oracle/legacy/v04
DONTCOVER nolint
DONTCOVER nolint
oracle/types
Package types is a reverse proxy.
Package types is a reverse proxy.
treasury/exported
DONTCOVER
DONTCOVER
nolint
treasury/legacy/v04
DONTCOVER nolint
DONTCOVER nolint
treasury/types
Package types is a reverse proxy.
Package types is a reverse proxy.
wasm/exported
nolint
nolint
wasm/legacy/v04
DONTCOVER nolint
DONTCOVER nolint
wasm/types
noalias Package types is a reverse proxy.
noalias Package types is a reverse proxy.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL