Docker Reference

Overview

It's always recommended to use Docker to setup the everiToken node, using the wallet program and CLI program. Because it's convenient and require no need to build at all. docker_ops.py is the official script we provided to help you setup the environment and make it ease to use and maintain.

Get the Script

Source code of docker_ops.py can be view at github.com. And you can get it to your current folder using the command below

wget https://raw.githubusercontent.com/everitoken/evt/master/scripts/docker_ops.py
chmod +x ./docker_ops.py

python3 is needed for this script, and these python packages is also needed: click and docker. If you're using Ubuntu, you can install required packages like this:

DEBIAN_FRONTEND=noninteractive apt-get install -y python3-pip && pip3 install click docker

Now you can try to get the help!

./docker_ops.py --help

It will output like this:

Usage: docker_ops.py [OPTIONS] COMMAND [ARGS]...

Options:
  --help  Show this message and exit.

Commands:
  detail
  evtc
  evtd
  evtwd
  logs
  mongo
  network
  postgres
  start
  stop

Setup Network

In order to make it possible to be connected between evtd and evtc, containers should be in the same Docker network. So first we need to create a network in Docker. You can simply called like:

./docker_ops.py network init

This will output:

Network: evt-net network is created

An default evt-net network will be created. If you'd like other name, you can add --name or -n option.

Setup Postgres

If you want to setup a wallet node, which enables postgres_plugin, history_plugin and history_api_plugin, PostgreSQL is need to setup first. Otherwise you can ignore this part.

Here are the all the commands supported in postgres section.

Usage: docker_ops.py postgres [OPTIONS] COMMAND [ARGS]...

Options:
  -n, --name TEXT  Name of the postgres container
  --help           Show this message and exit.

Commands:
  clear
  create
  createdb
  detail
  init
  logs
  start
  stop
  updpass

First use ./docker_ops.py postgres init to fetch postgres Docker image and create postgres data volume. And then use

./docker_ops.py postgres create

to create postgres container. And default name for postgres container is pg. You can also use another name by using --name or -n option.

This will create the postgres container with exposing 5432 port listening on 127.0.0.1 in this host. If you want to change this behavior, you can use --host and --port options. For more options, please use --help option.

By default, postgres will not use password, which means anyone can access the database. If you want to set a password, use --password or -x option. This option is only work when you first create the container with this option. Otherwise, password will not change, you can always use postgres updpass to update the password.

If you don't set password, not even postgres will not require password when connect, but also when you've set a password it still don't require. It's because the option in pg_hba.conf. For more details about this file, you can view here. And you can edit this file at /opt/bitnami/postgresql/conf.

Now you can use ./docker_ops.py postgres start to start it! You can also view the latest logs of postgres using ./docker_ops.py postgres logs.

If you use another name like pg-2, you should always add --name or -n option like this:

./docker_ops.py postgres -n pg-2 start
./docker_ops.py postgres -n pg-2 logs

Then depending on how many nodes you want to setup, you need to create a database for each node with difference names. You can create a database named evt by:

./docker_ops.py postgres createdb evt

Setup Block Producer Node

For setup a everiToken node, you need to use evtd sub commands.

Usage: docker_ops.py evtd [OPTIONS] COMMAND [ARGS]...

Options:
  -n, --name TEXT  Name of the container running evtd
  --help           Show this message and exit.

Commands:
  clear
  create
  detail
  export  Export reversible blocks to one backup file
  import  Import reversible blocks from backup file
  init
  logs
  snapshot
  start
  stop

First of all you need to pull the latest everiToken image manually. For test purpose please use docker pull everitoken/evt:latest, and for mainnet, please use docker pull everitoken/evt-mainnet:latest.

Before create containers, you need to initialize first: ./docker_ops.py evtd init, it will create necessary volumes. Also the default name is evtd, please use --name or -n to specify another name.

Then use create to create container. Here are all the options:

Usage: docker_ops.py evtd create [OPTIONS] [ARGUMENTS]...

Options:
  -t, --type [testnet|mainnet]  Type of the image
  -n, --net TEXT                Name of the network for the environment
  -p, --http-port INTEGER       Expose port for rpc request, set 0 for not
                                expose
  --p2p-port INTEGER            Expose port for p2p network, set 0 for not
                                expose
  -h, --host TEXT               Host address for evtd
  -g, --postgres-name TEXT      Container name or host address of postgres
  --postgres-db TEXT            Name of database in postgres, if set, postgres
                                and history plugins will be enabled
  --postgres-pass TEXT          Password for postgres
  --help                        Show this message and exit.

--http-port and --p2p-port is the exposing ports to host network and if set them to 0, then no exposing. --host is the listening address on the host network, default value is 127.0.0.1.

--type is the type of the node you want to setup, testnet is for testing purpose, and mainnet is for our mainnet node. Be aware you need to fetch the images manually.

If you want to setup a wallet node, you need to specify the --postgres-db option, it's the name of database you created previously. And the if you've set a different name of postgres container, you also need to specify the --postgres-name option. And if you've set postgres password, you need to pass the password via --postgres-pass option.

Other arguments you want to set to the evtd program should be append after a string --. Here are an example:

./docker_ops.py evtd -n test-node-1 create -t testnet --http-port=8888 --p2p-port=7888 --host=0.0.0.0 --postgres-db=evt -- --http-validate-host=false --verbose-http-errors --agent-name="EVT-Test-1" --plugin=evt::evt_link_plugin --producer-name=evt -e --delete-all-blocks

This will create a container named test-node-1, which is a test wallet node and has exposed rpc port at 7888 and p2p port at 9888, both are all listening on 0.0.0.0 address in the host network. Options after -- characters will bypass to the evtd program. For more details, you can check evtd Reference page.

export and import commands are used to manage reversible blocks, in some situations when the compiler or boost library has changed, the reversible blocks cannot be load directly. So when you're upgrading a node to new version and it warns you need to export and import reversible blocks, you need to run export command after stopped the old version container. And after creating new container using the new version, you need to run import command then.

Starting the node is simple, run ./docker_ops.py evtd start to start the node container. After starting, you can use ./docker_ops.py evtd logs to fetch the latest logs. If you see this:

info  2018-11-28T08:02:12.123 thread-0  chain_plugin.cpp:419          plugin_initialize    ] Deleting state database and blocks
warn  2018-11-28T08:02:12.124 thread-0  chain_plugin.cpp:561          plugin_initialize    ] Starting up fresh blockchain with default genesis state.
info  2018-11-28T08:02:12.176 thread-0  postgres_plugin.cpp:529       plugin_initialize    ] initializing postgres_plugin
info  2018-11-28T08:02:12.176 thread-0  postgres_plugin.cpp:534       plugin_initialize    ] Deleted all blocks: wiping postgres database on startup
info  2018-11-28T08:02:12.176 thread-0  postgres_plugin.cpp:551       plugin_initialize    ] connecting to postgresql://postgres@pg:5432/evt
info  2018-11-28T08:02:12.179 thread-0  postgres_plugin.cpp:404       wipe_database        ] wipe database
NOTICE:  relation "block_num_index" already exists, skipping
NOTICE:  relation "creator_index" already exists, skipping
NOTICE:  relation "creator_index" already exists, skipping
info  2018-11-28T08:02:12.427 thread-0  http_plugin.cpp:536           plugin_initialize    ] configured http to listen on 0.0.0.0:8888
info  2018-11-28T08:02:12.427 thread-0  net_plugin.cpp:3018           plugin_initialize    ] Initialize net plugin
info  2018-11-28T08:02:12.427 thread-0  net_plugin.cpp:3045           plugin_initialize    ] host: 0.0.0.0 port: 7888 
info  2018-11-28T08:02:12.427 thread-0  net_plugin.cpp:3112           plugin_initialize    ] my node_id is afebf7970df1b69d49f9f8d448008b381d2e332eafcad251e3a33662574cc7ab
Logging config file is not avaiable: /opt/evt/etc/evtd/logging.json
info  2018-11-28T08:02:12.427 thread-0  main.cpp:151                  main                 ] evtd version evt-v2.2-61-g6470938b
info  2018-11-28T08:02:12.427 thread-0  main.cpp:152                  main                 ] evt root is /root/.local/share
warn  2018-11-28T08:02:12.427 thread-0  controller.cpp:1167           startup              ] No head block in fork db, perhaps we need to replay
warn  2018-11-28T08:02:12.494 thread-0  token_database.cpp:1294       load_savepoints      ] No savepoints log in token database
warn  2018-11-28T08:02:12.494 thread-0  controller.cpp:497            initialize_fork_db   ]  Initializing new blockchain with genesis state
info  2018-11-28T08:02:12.528 thread-0  chain_plugin.cpp:665          plugin_startup       ] starting chain in read/write mode
info  2018-11-28T08:02:12.528 thread-0  chain_plugin.cpp:670          plugin_startup       ] Blockchain started; head block is #1, genesis timestamp is 2018-05-31T12:00:00.000
info  2018-11-28T08:02:12.538 thread-0  http_plugin.cpp:614           plugin_startup       ] start listening for http requests
info  2018-11-28T08:02:12.538 thread-0  history_api_plugin.cpp:69     plugin_startup       ] starting history_api_plugin
info  2018-11-28T08:02:12.538 thread-0  http_plugin.cpp:723           add_deferred_handler ] add deferred api url: /v1/history/get_actions
info  2018-11-28T08:02:12.538 thread-0  http_plugin.cpp:723           add_deferred_handler ] add deferred api url: /v1/history/get_domains
info  2018-11-28T08:02:12.538 thread-0  http_plugin.cpp:723           add_deferred_handler ] add deferred api url: /v1/history/get_fungible_actions
info  2018-11-28T08:02:12.538 thread-0  http_plugin.cpp:723           add_deferred_handler ] add deferred api url: /v1/history/get_fungible_ids
info  2018-11-28T08:02:12.538 thread-0  http_plugin.cpp:723           add_deferred_handler ] add deferred api url: /v1/history/get_fungibles
info  2018-11-28T08:02:12.538 thread-0  http_plugin.cpp:723           add_deferred_handler ] add deferred api url: /v1/history/get_groups
info  2018-11-28T08:02:12.538 thread-0  http_plugin.cpp:723           add_deferred_handler ] add deferred api url: /v1/history/get_tokens
info  2018-11-28T08:02:12.538 thread-0  http_plugin.cpp:723           add_deferred_handler ] add deferred api url: /v1/history/get_transaction
info  2018-11-28T08:02:12.538 thread-0  http_plugin.cpp:723           add_deferred_handler ] add deferred api url: /v1/history/get_transactions
info  2018-11-28T08:02:12.538 thread-0  evt_link_plugin.cpp:225       plugin_startup       ] starting evt_link_plugin
info  2018-11-28T08:02:12.538 thread-0  http_plugin.cpp:723           add_deferred_handler ] add deferred api url: /v1/evt_link/get_trx_id_for_link_id
info  2018-11-28T08:02:12.538 thread-0  net_plugin.cpp:3133           plugin_startup       ] starting listener, max clients is 25
info  2018-11-28T08:02:12.538 thread-0  producer_plugin.cpp:710       plugin_startup       ] producer plugin:  plugin_startup() begin
info  2018-11-28T08:02:12.538 thread-0  producer_plugin.cpp:733       plugin_startup       ] Launching block production for 1 producers at 2018-11-28T08:02:12.538.
info  2018-11-28T08:02:12.538 thread-0  producer_plugin.cpp:745       plugin_startup       ] producer plugin:  plugin_startup() end
info  2018-11-28T08:02:13.001 thread-0  producer_plugin.cpp:1440      produce_block        ] Produced block 000000024909b869... #2 @ 2018-11-28T08:02:13.000 signed by evt [trxs: 0, lib: 0, confirmed: 0]
info  2018-11-28T08:02:13.501 thread-0  producer_plugin.cpp:1440      produce_block        ] Produced block 000000035a52a036... #3 @ 2018-11-28T08:02:13.500 signed by evt [trxs: 0, lib: 2, confirmed: 0]
info  2018-11-28T08:02:14.000 thread-0  producer_plugin.cpp:1440      produce_block        ] Produced block 000000046ef8c6d6... #4 @ 2018-11-28T08:02:14.000 signed by evt [trxs: 0, lib: 3, confirmed: 0]
info  2018-11-28T08:02:14.501 thread-0  producer_plugin.cpp:1440      produce_block        ] Produced block 000000053969d9fc... #5 @ 2018-11-28T08:02:14.500 signed by evt [trxs: 0, lib: 4, confirmed: 0]

Bang! You have a test node producing blocks now!

Global Commands

There're some commands are both available in first level and second level: init, logs, start, stop, clear and detail.

If you want to check the detail information of a specific container, you can use detail command. Both commands below are valid:

./docker_ops.py detail test-node-1
./docker_ops.py evtd -n test-node-1 detail

You will get the detail like:

      id: 48d6a7179e7bf77e3f6534c5377d3135e5ee8ffbfd645a306230ce5e162f5efa
   image: everitoken/evt:latest
image-id: sha256:28ada975d35aadfccd1d95c1ade41cf1cfb2cd129c2c0418d5020f50547467f2
 command: evtd.sh --http-server-address=0.0.0.0:8888 --p2p-listen-endpoint=0.0.0.0:7888 --plugin=evt::postgres_plugin --plugin=evt::history_plugin --plugin=evt::history_api_plugin --postgres-uri=postgresql://postgres@pg:5432/evt --http-validate-host=false --verbose-http-errors --agent-name=EVT-Test-1 --plugin=evt::evt_link_plugin --producer-name=evt -e --delete-all-blocks
 network: evt-net
   ports: 0.0.0.0:9888->7888/tcp(p2p), 0.0.0.0:7888->8888/tcp(http)
 volumes: evtd-data-volume->/opt/evt/data, evtd-snapshots-volume->/opt/evt/snapshots
  status: Up 32 seconds

Setup Wallet Container: evtwd

If you want to use wallet program together with CLI program, you need to setup a wallet container first.

Usage: docker_ops.py evtwd [OPTIONS] COMMAND [ARGS]...

Options:
  -n, --name TEXT  Name of the container running evtwd
  --help           Show this message and exit.

Commands:
  clear
  create
  detail
  init
  logs
  start
  stop

As the same, we use ./docker_ops.py evtwd init to create necessary volumes. Then use ./docker_ops.py evtwd create to create container.

After creating the container, use ./docker_ops.py evtwd start to start the wallet container.

If you get the logs, you will get:

info  2018-11-28T09:50:57.252 thread-0  wallet_plugin.cpp:46          plugin_initialize    ] initializing wallet plugin
info  2018-11-28T09:50:57.252 thread-0  http_plugin.cpp:706           add_handler          ] add local only api url: /v1/evtwd/stop
info  2018-11-28T09:50:57.252 thread-0  wallet_api_plugin.cpp:77      plugin_startup       ] starting wallet_api_plugin
info  2018-11-28T09:50:57.252 thread-0  http_plugin.cpp:706           add_handler          ] add local only api url: /v1/wallet/create
info  2018-11-28T09:50:57.252 thread-0  http_plugin.cpp:706           add_handler          ] add local only api url: /v1/wallet/create_key
info  2018-11-28T09:50:57.252 thread-0  http_plugin.cpp:706           add_handler          ] add local only api url: /v1/wallet/get_my_signatures
info  2018-11-28T09:50:57.252 thread-0  http_plugin.cpp:706           add_handler          ] add local only api url: /v1/wallet/get_public_keys
info  2018-11-28T09:50:57.252 thread-0  http_plugin.cpp:706           add_handler          ] add local only api url: /v1/wallet/import_key
info  2018-11-28T09:50:57.252 thread-0  http_plugin.cpp:706           add_handler          ] add local only api url: /v1/wallet/list_keys
info  2018-11-28T09:50:57.252 thread-0  http_plugin.cpp:706           add_handler          ] add local only api url: /v1/wallet/list_wallets
info  2018-11-28T09:50:57.252 thread-0  http_plugin.cpp:706           add_handler          ] add local only api url: /v1/wallet/lock
info  2018-11-28T09:50:57.252 thread-0  http_plugin.cpp:706           add_handler          ] add local only api url: /v1/wallet/lock_all
info  2018-11-28T09:50:57.252 thread-0  http_plugin.cpp:706           add_handler          ] add local only api url: /v1/wallet/open
info  2018-11-28T09:50:57.252 thread-0  http_plugin.cpp:706           add_handler          ] add local only api url: /v1/wallet/remove_key
info  2018-11-28T09:50:57.252 thread-0  http_plugin.cpp:706           add_handler          ] add local only api url: /v1/wallet/set_timeout
info  2018-11-28T09:50:57.252 thread-0  http_plugin.cpp:706           add_handler          ] add local only api url: /v1/wallet/sign_digest
info  2018-11-28T09:50:57.252 thread-0  http_plugin.cpp:706           add_handler          ] add local only api url: /v1/wallet/sign_transaction
info  2018-11-28T09:50:57.252 thread-0  http_plugin.cpp:706           add_handler          ] add local only api url: /v1/wallet/unlock

Use CLI program evtc

Use evtc program is simple if you have started one wallet container. Like:

./docker_ops.py evtc --help

will output the help text from evtc.

Create new wallet:

./docker_ops.py evtc wallet create

All the arguments appended in the evtc will be passed to the program. There's only on except: --evtwd option. It's used to specify the name of wallet container. The default name is evtwd, but if you use another name, you can specify this option.