Skip to content

Latest commit

 

History

History
285 lines (200 loc) · 6.75 KB

[English] Nebulas 101 - 01 Installation.md

File metadata and controls

285 lines (200 loc) · 6.75 KB

Nebulas 101 - 01 Compile and Install Nebulas

YouTube Tutorial

The project code for Nebulas has been released in several versions and tested to run locally. You can download the Nebulas source code to compile the private chain locally.

To learn about Nebulas, please read the Nebulas Non-Technical White Paper.

To learn about the technology, please read the Nebulas Technical White Paper and the Nebulas github code.

Nebulas can only run on Mac and Linux at this stage. The Windows version is coming soon.

Golang Environment

Currently, Nebulas is implemented in Golang.

Components Version Description
Golang >= 1.12 The Go Programming Language

Mac OSX

Homebrew is recommended for installing golang on Mac.

# install
brew install go

# environment variables
export GOPATH=/path/to/workspace

Notice: GOPATH is a local golang working directory which could be decided by yourself. After GOPATH is configured, your go projects need to be placed in the GOPATH directory.

Linux

# download
wget https://dl.google.com/go/go1.12.linux-amd64.tar.gz

# extract
tar -C /usr/local -xzf go1.12.linux-amd64.tar.gz

# environment variables
export PATH=$PATH:/usr/local/go/bin
export GOPATH=/path/to/workspace

Compile Nebulas

Download

Clone the source code with the following commands:

# enter workspace
cd workspace

# download
git clone https://github.com/nebulasio/go-nebulas.git

# enter repository
cd go-nebulas

# master branch is the most stable
git checkout master

Install RocksDB

brew install rocksdb
  • Linux - Ubuntu
  • Install Dependencies
apt-get update
apt-get -y install build-essential libgflags-dev libsnappy-dev zlib1g-dev libbz2-dev liblz4-dev libzstd-dev
  • Install rocksdb by source code:
git clone https://github.com/facebook/rocksdb.git
cd rocksdb && make shared_lib && make install-shared
  • Linux - Centos
  • Install Dependencies
yum -y install epel-release && yum -y update
yum -y install gflags-devel snappy-devel zlib-devel bzip2-devel gcc-c++  libstdc++-devel
  • Install rocksdb by source code:
git clone https://github.com/facebook/rocksdb.git
cd rocksdb && make shared_lib && make install-shared

Nebulas's NVM (Nebulas Virtual Machine) depends on the V8 JavaScript engine. We've built the v8 dependencies for Mac/Linux. Run the following commands to install them.

cd workspace/go-nebulas
source setup.sh

Build Neb

You can now build the executable for Nebulas after golang dependencies and V8 dependency packages have been installed.

Build under the project root directory:

cd workspace/go-nebulas
make build

Once the building is complete there will be an executable file neb generated under the root directory. make build

Start NEB

Genesis Block

Before launching a new Nebulas chain, we have to define the configuration of genesis block.

Genesis Block Configuration

# Neb genesis text file. Scheme is defined in core/pb/genesis.proto.

meta {
# Chain identity
chain_id: 100
}

consensus {
dpos {
# Initial dynasty, including all initial miners
dynasty: [
[ miner address ],
...
]
}
}

# Pre-allocation of initial tokens
token_distribution [
{
address: [ allocation address ]
value: [ amount of allocation tokens ]
},
...
]

An example genesis.conf is located in conf/default/genesis.conf.

Configuration

Before getting a neb node started, we have to define the configuration of this node.

Neb Node Configuration

# Neb configuration text file. Scheme is defined in neblet/pb/config.proto:Config.

# Network Configuration
network {
# For the first node in a new Nebulas chain, `seed` is not need.
# Otherwise, every node needs some seed nodes to introduce it to the Nebulas chain.
# seed: ["/ip4/127.0.0.1/tcp/8680/ipfs/QmP7HDFcYmJL12Ez4ZNVCKjKedfE7f48f1LAkUc3Whz4jP"]

# P2p network service host. Support multiple IP and ports.
listen: ["0.0.0.0:8680"]

# The private key is used to generate a node ID. If you don't use the private key, the node will generate a new node ID.
# private_key: "conf/network/id_ed25519"
}

# Chain Configuration
chain {
# Network chain ID
chain_id: 100

# Database storage location
datadir: "data.db"

# Accounts' keystore files location
keydir: "keydir"

# The genesis block configuration
genesis: "conf/default/genesis.conf"

# Signature algorithm
signature_ciphers: ["ECC_SECP256K1"]

# Miner address
miner: "n1SAQy3ix1pZj8MPzNeVqpAmu1nCVqb5w8c"

# Coinbase address, all mining rewards received by the above miner will be sent to this address
coinbase: "n1FF1nz6tarkDVwWQkMnnwFPuPKUaQTdptE"

# The passphrase to the miner's keystore file
passphrase: "passphrase"
}

# API Configuration
rpc {
# GRPC API port
rpc_listen: ["127.0.0.1:8684"]

# HTTP API port
http_listen: ["127.0.0.1:8685"]

# The module opened
http_module: ["api", "admin"]
}

# Log Configuration
app {
# Log level: [debug, info, warn, error, fatal]
log_level: "info"

# Log location
log_file: "logs"

# Open crash log
enable_crash_report: false
}

# Metrics Configuration
stats {
# Open node metrics
enable_metrics: false

# Influxdb configuration
influxdb: {
host: "http://localhost:8086"
db: "nebulas"
user: "admin"
password: "admin"
}
}

A lot of examples can be found in workspace/go-nebulas/conf/

Run Nodes

The Nebulas chain you are running at this point is private and is different from the official Testnet and Mainnet.

Start your first Nebulas node with the following commands:

cd workspace/go-nebulas
./neb -c conf/default/config.conf

After starting, the following should be visible in the terminal: seed node start

By default, the node using conf/default/config.conf won't mine new blocks. Start your first Nebulas mining node with these commands:

cd workspace/go-nebulas
./neb -c conf/example/miner.conf

After the node starts, if the connection with the seed node is successful, you can see the following log which is in log file logs/miner/neb.log: node start

Note: You can start many nodes locally. Please make sure the ports in your node configurations won't conflict with each other.

Next step: Tutorial 2

Sending Transactions on Nebulas