Docker Reference

Overview

It's always recommended to use Docker to set up an everiToken node, run the wallet program, and play with the CLI program. It's convenient and is not required to build at all. docker_ops.py is the official script we provided to help set up the environment and make it easier to use and maintain.

Get the Script

Source code of docker_ops.py can be view at github.com. 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 are also required: click and docker. If you're using Ubuntu, you can install the required packages using:

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

If you need to view the help resources:

./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 establish a connection between evtd and evtc, the containers need to be in the same Docker network. First a new network needs to be created in Docker. For example:

./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 another name, you can add --name or -n option.

Setup Postgres

If you want to set up a wallet node, enabling postgres_plugin, history_plugin and history_api_plugin, then PostgreSQL is required for setup. Otherwise, you can ignore this section.

Here are all of the commands supported in the 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 the postgres Docker image and create postgres data volume. Then use:

./docker_ops.py postgres create

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

This will create a postgres container which exposes 5432 port and is listening on 127.0.0.1 in the host network. 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 a password, meaning anyone can access the database. If you want to set a password, use --password or -x option. This option will only work when it’s the first time to creating the container. Otherwise, the password will not be replaced, but you can use postgres updpass to update the password.

No matter if you’ve set a password or not, it’s not required when you interact with it inside the container because of a setting in pg_hba.conf file. For more details about this file, you can view here. You can edit this file at /opt/bitnami/postgresql/conf.

Now you can use ./docker_ops.py postgres start to begin! 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 different names. You can create a database named evt by:

./docker_ops.py postgres createdb evt

Setup Block Producer Node

To set up an everiToken node, you need to useevtd 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 purposes please use docker pull everitoken/evt:latest, and for mainnet, please use docker pull everitoken/evt-mainnet:latest.

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

Then use create to create container. Here are 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 options control the exposed ports in the host network, and if it’s set to 0, then they will be not exposed. --host iis the listening address of the host network; it has a default value of 127.0.0.1.

--type is the type of node you want to set up. testnet is for testing purposes, and mainnet is used to set up mainnet nodes. Be aware that you need to fetch these images manually.

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

Other arguments passed to the evtd program should be written 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 with an exposed rpc port of 7888 and p2p port of 9888, both are all listening on 0.0.0.0 address in the host network. Arguments after -- characters will pass to the evtd program directly. For more details, you can view the 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 loaded directly. So, when you're upgrading a node to a new version, and it warns that you need to export and import reversible blocks, then you need to run the export command after stopping the old version container. After creating a new container using the new version, you need to run the import command.

Starting the node is simple. Run ./docker_ops.py evtd start to start the node container. After beginning, you can use ./docker_ops.py evtd logs to fetch the latest logs. For instance:

Click to see full code example
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!

setup a mainnet node

get mainnet image docker pull everitoken / evt-mainnet:latest.

initialize

./docker_ops.py evtd init

create a container named mainnet-node:

./docker_ops.py evtd -n mainnet-node create -t mainnet --http-port=8888 --p2p-port=7888 --host=0.0.0.0 -- --http-validate-host=false --verbose-http-errors --plugin=evt::evt_link_plugin --delete-all-blocks

start the node:

./docker_ops.py evtd -n mainnet-node start

启动后,您可以使用./docker_ops.py evtd -n mainnet-node logs来获取最新的日志

Global Commands

There are several commands that are available in both first and second level commands: 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:

Click to see full code example
      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 a wallet program together with the CLI program, you need to set up a wallet container first.

Click to see full code example
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

Use ./docker_ops.py evtwd init to create necessary volumes. Then use ./docker_ops.py evtwd create to create a container. After you have created the container, use ./docker_ops.py evtwd start to start the wallet container.

The logs will show:

Click to see full code example
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

Using the evtc program is simple if you have started a wallet container. For instance:

./docker_ops.py evtc --help

This will print the help information of evtc.

Create a new wallet:

./docker_ops.py evtc wallet create

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