core

module
v0.5.0-rc1 Latest Latest
Warning

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

Go to latest
Published: Aug 10, 2021 License: Apache-2.0

README

 

Full-node software implementing the Terra protocol

Explore the Docs »

Dev Guide · Go API · REST API · SDKs · Finder · Station


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 through distributed consensus over native staked asset Luna, and supports the issuance of price-tracking stablecoins (TerraKRW, TerraUSD, etc.) that are 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 fiscal policy managed by community governance, Terra is a democratized economy regulated 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

You can find the latest binaries on our releases page.

From Source

We recommend the following for running Terra Core:

  • 2 or more CPU cores
  • At least 300GB of disk storage
  • At least 2.5 - 5mbps network bandwidth
Step 1. Install Golang

Go v1.14+ 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 master
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

CLI

terrad provides you a command-line interface to a running node, communicating over RPC. You can find comprehensive coverage on how to use the CMD on our official docs. The various subcommands and their expected arguments can also be discovered by issuing:

        
$ terrad --help Command line interface for interacting with terrad 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/yeoyunseog/.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 "terracli [command] --help" for more information about a command.

Node Setup

Active Networks
Chain ID Description Public Node (LCD)
columbus-4 Mainnet https://lcd.terra.dev
tequila-0004 Columbus-4 Testnet https://tequila-lcd.terra.dev
bombay-0008 Columbus-5 Testnet https://bombay-lcd.terra.dev

Running a Local Testnet

The simplest Terra network you can set up will be 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!

Joining the mainnet

The mainnet repo contains snapshot of the launch as well as network updates.

Joining a testnet

Our testnet repo contains latest configuration files for the testnet.

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

We are currently finalizing contribution standards and guidelines. In the meanwhile, if you are interested in contributing to the Terra Project, please contact our admin.

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/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