EOS技术爱好者区块链技术eos开发

ubuntu16.04运行EOS3.0

2018-04-26  本文已影响110人  剑有偏锋

上文《ubuntu16.04编译eos3.0》已编译好了EOS的程序

一 运行nodeos用于同步区块节点程序

./nodeos -e -p eosio --plugin eosio::wallet_api_plugin --plugin eosio::chain_api_plugin --plugin eosio::account_history_api_plugin 

-e 启用区块生成,即使链比较陈旧
-p 由该节点控制的生产者的ID
--plugin 启用插件
eosio::wallet_api_plugin 启用了钱包api接口
eosio::chain_api_plugin 启用区块api插件接口
eosio::account_history_api_plugin 启用账户历史api插件接口

运行日志如下

 ./nodeos -e -p eosio --plugin eosio::wallet_api_plugin --plugin eosio::chain_api_plugin --plugin eosio::account_history_api_plugin 
2567461ms thread-0   wallet_plugin.cpp:41          plugin_initialize    ] initializing wallet plugin
2567461ms thread-0   http_plugin.cpp:141           plugin_initialize    ] host: 127.0.0.1 port: 8888 
2567462ms thread-0   http_plugin.cpp:144           plugin_initialize    ] configured http to listen on 127.0.0.1:8888
2567462ms thread-0   chain_plugin.cpp:99           plugin_initialize    ] initializing chain plugin
2567462ms thread-0   net_plugin.cpp:2622           plugin_initialize    ] Initialize net plugin
2567462ms thread-0   net_plugin.cpp:2644           plugin_initialize    ] Setting net_plugin logging level to info
2567462ms thread-0   net_plugin.cpp:2672           plugin_initialize    ] host: 0.0.0.0 port: 9876 
2567462ms thread-0   net_plugin.cpp:2748           plugin_initialize    ] my node_id is c409889e9990c1c70684e7e10da1cb8270224d7d97ec6a5be05e12e7f834044a
2567462ms thread-0   main.cpp:90                   main                 ] nodeos version d9ad8eec
2567462ms thread-0   main.cpp:91                   main                 ] eosio root is /home/li/.local/share
2567462ms thread-0   http_plugin.cpp:213           plugin_startup       ] start listening for http requests
2567462ms thread-0   wallet_api_plugin.cpp:70      plugin_startup       ] starting wallet_api_plugin
2567462ms thread-0   http_plugin.cpp:242           add_handler          ] add api url: /v1/wallet/create
2567462ms thread-0   http_plugin.cpp:242           add_handler          ] add api url: /v1/wallet/get_public_keys
2567462ms thread-0   http_plugin.cpp:242           add_handler          ] add api url: /v1/wallet/import_key
2567462ms thread-0   http_plugin.cpp:242           add_handler          ] add api url: /v1/wallet/list_keys
2567462ms thread-0   http_plugin.cpp:242           add_handler          ] add api url: /v1/wallet/list_wallets
2567462ms thread-0   http_plugin.cpp:242           add_handler          ] add api url: /v1/wallet/lock
2567462ms thread-0   http_plugin.cpp:242           add_handler          ] add api url: /v1/wallet/lock_all
2567462ms thread-0   http_plugin.cpp:242           add_handler          ] add api url: /v1/wallet/open
2567463ms thread-0   http_plugin.cpp:242           add_handler          ] add api url: /v1/wallet/set_timeout
2567463ms thread-0   http_plugin.cpp:242           add_handler          ] add api url: /v1/wallet/sign_transaction
2567463ms thread-0   http_plugin.cpp:242           add_handler          ] add api url: /v1/wallet/unlock
2567463ms thread-0   chain_plugin.cpp:178          plugin_startup       ] 
 generating default genesis file /home/li/.local/share/eosio/nodeos/config/genesis.json
2567565ms thread-0   chain_plugin.cpp:208          plugin_startup       ] starting chain in read/write mode
2567565ms thread-0   chain_plugin.cpp:213          plugin_startup       ] Blockchain started; head block is #0, genesis timestamp is 2018-03-01T12:00:00.000
2567565ms thread-0   chain_api_plugin.cpp:62       plugin_startup       ] starting chain_api_plugin
2567565ms thread-0   http_plugin.cpp:242           add_handler          ] add api url: /v1/chain/abi_bin_to_json
2567565ms thread-0   http_plugin.cpp:242           add_handler          ] add api url: /v1/chain/abi_json_to_bin
2567565ms thread-0   http_plugin.cpp:242           add_handler          ] add api url: /v1/chain/get_account
2567565ms thread-0   http_plugin.cpp:242           add_handler          ] add api url: /v1/chain/get_block
2567565ms thread-0   http_plugin.cpp:242           add_handler          ] add api url: /v1/chain/get_code
2567565ms thread-0   http_plugin.cpp:242           add_handler          ] add api url: /v1/chain/get_currency_balance
2567565ms thread-0   http_plugin.cpp:242           add_handler          ] add api url: /v1/chain/get_currency_stats
2567566ms thread-0   http_plugin.cpp:242           add_handler          ] add api url: /v1/chain/get_info
2567566ms thread-0   http_plugin.cpp:242           add_handler          ] add api url: /v1/chain/get_required_keys
2567566ms thread-0   http_plugin.cpp:242           add_handler          ] add api url: /v1/chain/get_table_rows
2567566ms thread-0   http_plugin.cpp:242           add_handler          ] add api url: /v1/chain/push_block
2567566ms thread-0   http_plugin.cpp:242           add_handler          ] add api url: /v1/chain/push_transaction
2567566ms thread-0   http_plugin.cpp:242           add_handler          ] add api url: /v1/chain/push_transactions
2567566ms thread-0   account_history_api_plugin.cpp:45 plugin_startup       ] starting account_history_api_plugin
2567566ms thread-0   http_plugin.cpp:242           add_handler          ] add api url: /v1/account_history/get_controlled_accounts
2567566ms thread-0   http_plugin.cpp:242           add_handler          ] add api url: /v1/account_history/get_key_accounts
2567566ms thread-0   http_plugin.cpp:242           add_handler          ] add api url: /v1/account_history/get_transaction
2567566ms thread-0   http_plugin.cpp:242           add_handler          ] add api url: /v1/account_history/get_transactions
2567566ms thread-0   net_plugin.cpp:2760           plugin_startup       ] starting listener, max clients is 25
2567566ms thread-0   producer_plugin.cpp:161       plugin_startup       ] producer plugin:  plugin_startup() begin
2567566ms thread-0   producer_plugin.cpp:166       plugin_startup       ] Launching block production for 1 producers.

*******************************
*                             *
*   ------ NEW CHAIN ------   *
*   -  Welcome to EOSIO!  -   *
*   -----------------------   *
*                             *
*******************************

Your genesis seems to have an old timestamp
Please consider using the --genesis-timestamp option to give your genesis a recent timestamp

2567566ms thread-0   producer_plugin.cpp:176       plugin_startup       ] producer plugin:  plugin_startup() end
eosio generated block 893d20e0... #1 @ 2018-04-26T09:42:48.000 with 0 trxs, lib: 0
eosio generated block 1dd3c44f... #2 @ 2018-04-26T09:42:48.500 with 0 trxs, lib: 1
eosio generated block e7ea6789... #3 @ 2018-04-26T09:42:49.000 with 0 trxs, lib: 2
eosio generated block d1f3fefc... #4 @ 2018-04-26T09:42:49.500 with 0 trxs, lib: 3
2569795ms thread-0   net_plugin.cpp:2774           plugin_shutdown      ] shutdown..
2569795ms thread-0   net_plugin.cpp:2777           plugin_shutdown      ] close acceptor
2569795ms thread-0   net_plugin.cpp:2780           plugin_shutdown      ] close 0 connections
2569795ms thread-0   net_plugin.cpp:2788           plugin_shutdown      ] exit shutdown

<1 产生了nodeid
“my node_id is dedbb9ce492b3c20f2a2bdc70a3679b891fd3cd0f3cd62a3ce40b8050ad2198a”
<2 产生了区块创世状态文件
" generating default genesis file /home/li/.local/share/eosio/nodeos/config/genesis.json"

二 运行 cleos命令行交互程序

./cleos -p 8888 get info
-p 制定要链接的nodeos端口
get 从区块链中检索各项和信息

显示了当前最近区块的状态信息

{
  "server_version": "d9ad8eec",
  "head_block_num": 28,
  "last_irreversible_block_num": 27,
  "head_block_id": "0000001c4eb61c1d8c5f6232ae3588f478717f470878a2a2adc8715d47b6c25f",
  "head_block_time": "2018-04-26T09:52:06",
  "head_block_producer": "eosio"
}

8888开放的http端口,已经在config.ini中,配置好了(见附加的config.ini内容)
“http-server-address = 127.0.0.1:8888”

三 引用

http://liyuechun.org/2018/04/04/eos-dev/ 《第一篇 - 手把手教你理清EOS各种开发环境搭建来龙去脉》

https://github.com/EOSIO/eos/wiki/Local-Environment#4-creating-and-launching-a-single-node-testnet 《Creating and Launching a Single Node Testnet》

四总结

《1 学会了nodeos,cleos的命令行基本参数
《2 了解创世文件genesis.json,和config.ini结构

五 附加

<1 创世文件genesis.json内容

{
  "initial_timestamp": "2018-03-01T12:00:00.000",
  "initial_key": "EOS6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV",
  "initial_configuration": {
    "base_per_transaction_net_usage": 100,
    "base_per_transaction_cpu_usage": 500,
    "base_per_action_cpu_usage": 1000,
    "base_setcode_cpu_usage": 2097152,
    "per_signature_cpu_usage": 100000,
    "per_lock_net_usage": 32,
    "context_free_discount_cpu_usage_num": 20,
    "context_free_discount_cpu_usage_den": 100,
    "max_transaction_cpu_usage": 10485760,
    "max_transaction_net_usage": 104857,
    "max_block_cpu_usage": 104857600,
    "target_block_cpu_usage_pct": 1000,
    "max_block_net_usage": 1048576,
    "target_block_net_usage_pct": 1000,
    "max_transaction_lifetime": 3600,
    "max_transaction_exec_time": 0,
    "max_authority_depth": 6,
    "max_inline_depth": 4,
    "max_inline_action_size": 4096,
    "max_generated_transaction_count": 16
  },
  "initial_chain_id": "0000000000000000000000000000000000000000000000000000000000000000"
}

<2 config.ini内容

cat config.ini 
# Track only transactions whose scopes involve the listed accounts. Default is to track all transactions. (eosio::account_history_plugin)
# filter_on_accounts = 

# Limits the maximum time (in milliseconds) processing a single get_transactions call. (eosio::account_history_plugin)
get-transactions-time-limit = 3

# File to read Genesis State from (eosio::chain_plugin)
genesis-json = "genesis.json"

# override the initial timestamp in the Genesis State file (eosio::chain_plugin)
# genesis-timestamp = 

# the location of the block log (absolute path or relative to application data dir) (eosio::chain_plugin)
block-log-dir = "blocks"

# Pairs of [BLOCK_NUM,BLOCK_ID] that should be enforced as checkpoints. (eosio::chain_plugin)
# checkpoint = 

# Limits the maximum time (in milliseconds) that a reversible block is allowed to run before being considered invalid (eosio::chain_plugin)
max-reversible-block-time = -1

# Limits the maximum time (in milliseconds) that is allowed a pushed transaction's code to execute before being considered invalid (eosio::chain_plugin)
max-pending-transaction-time = -1

# Limits the maximum time (in milliseconds) that is allowed a to push deferred transactions at the start of a block (eosio::chain_plugin)
max-deferred-transaction-time = 20

# Override default WASM runtime (eosio::chain_plugin)
# wasm-runtime = 

# Time to wait, in milliseconds, between creating next faucet created account. (eosio::faucet_testnet_plugin)
faucet-create-interval-ms = 1000

# Name to use as creator for faucet created accounts. (eosio::faucet_testnet_plugin)
faucet-name = faucet

# [public key, WIF private key] for signing for faucet creator account (eosio::faucet_testnet_plugin)
faucet-private-key = ["EOS6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV","5KQwrPbwdL6PhXujxW37FSSQZ1JiwsST4cqQzDeyXtP79zkvFD3"]

# The local IP and port to listen for incoming http connections. (eosio::http_plugin)
http-server-address = 127.0.0.1:8888

# Specify the Access-Control-Allow-Origin to be returned on each request. (eosio::http_plugin)
# access-control-allow-origin = 

# Specify the Access-Control-Allow-Headers to be returned on each request. (eosio::http_plugin)
# access-control-allow-headers = 

# Specify if Access-Control-Allow-Credentials: true should be returned on each request. (eosio::http_plugin)
access-control-allow-credentials = false

# The queue size between nodeos and MongoDB plugin thread. (eosio::mongo_db_plugin)
mongodb-queue-size = 256

# MongoDB URI connection string, see: https://docs.mongodb.com/master/reference/connection-string/. If not specified then plugin is disabled. Default database 'EOS' is used if not specified in URI. (eosio::mongo_db_plugin)
# mongodb-uri = 

# The actual host:port used to listen for incoming p2p connections. (eosio::net_plugin)
p2p-listen-endpoint = 0.0.0.0:9876

# An externally accessible host:port for identifying this node. Defaults to p2p-listen-endpoint. (eosio::net_plugin)
# p2p-server-address = 

# The public endpoint of a peer node to connect to. Use multiple p2p-peer-address options as needed to compose a network. (eosio::net_plugin)
# p2p-peer-address = 

# The name supplied to identify this node amongst the peers. (eosio::net_plugin)
agent-name = "EOS Test Agent"

# Can be 'any' or 'producers' or 'specified' or 'none'. If 'specified', peer-key must be specified at least once. If only 'producers', peer-key is not required. 'producers' and 'specified' may be combined. (eosio::net_plugin)
allowed-connection = any

# Optional public key of peer allowed to connect.  May be used multiple times. (eosio::net_plugin)
# peer-key = 

# Tuple of [PublicKey, WIF private key] (may specify multiple times) (eosio::net_plugin)
# peer-private-key = 

# Log level: one of 'all', 'debug', 'info', 'warn', 'error', or 'off' (eosio::net_plugin)
log-level-net-plugin = info

# Maximum number of clients from which connections are accepted, use 0 for no limit (eosio::net_plugin)
max-clients = 25

# number of seconds to wait before cleaning up dead connections (eosio::net_plugin)
connection-cleanup-period = 30

# True to require exact match of peer network version. (eosio::net_plugin)
network-version-match = 0

# number of blocks to retrieve in a chunk from any individual peer during synchronization (eosio::net_plugin)
sync-fetch-span = 100

# Enable block production, even if the chain is stale. (eosio::producer_plugin)
enable-stale-production = false

# Percent of producers (0-100) that must be participating in order to produce blocks (eosio::producer_plugin)
required-participation = 33

# ID of producer controlled by this node (e.g. inita; may specify multiple times) (eosio::producer_plugin)
# producer-name = 

# Tuple of [public key, WIF private key] (may specify multiple times) (eosio::producer_plugin)
private-key = ["EOS6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV","5KQwrPbwdL6PhXujxW37FSSQZ1JiwsST4cqQzDeyXtP79zkvFD3"]

# The path of the wallet files (absolute path or relative to application data dir) (eosio::wallet_plugin)
wallet-dir = "."

# Timeout for unlocked wallet in seconds. Wallets will automatically lock after specified number of seconds of inactivity. Activity is defined as any wallet command e.g. list-wallets. (eosio::wallet_plugin)
# unlock-timeout = 

# eosio key that will be imported automatically when a wallet is created. (eosio::wallet_plugin)
# eosio-key = 

# Plugin(s) to enable, may be specified multiple times
# plugin = 

上一篇下一篇

猜你喜欢

热点阅读