您正在查看: 2018年7月

cleos system newaccount 消耗最少的EOS资源

surou@surou-C-H110M-K-Pro:~/.local/share/eosio/nodeos/config$ cleos system newaccount eosio bcskillsurou EOS7uvrLaTGsRH8BujfjjjJChXLzZhUQqbvTasoN1rFvGJD68kJf9  EOS7uvrLaTGsRH8BujfjjjJChXLzZhUQqbvTasoN1rFvGJD68kJf9  --stake-net '0.00 EOS' --stake-cpu '0.00 EOS'  --buy-ram-kbytes 3
2341780ms thread-0   main.cpp:429                  create_action        ] result: {"binargs":"0000000000ea3055a0e9d5384607313a000c0000"} arg: {"code":"eosio","action":"buyrambytes","args":{"payer":"eosio","receiver":"bcskillsurou","bytes":3072}} 
executed transaction: 0a582d07bde12299a178b066aed6489ea3abc6a5369f2d48afe79f96b7f9512e  248 bytes  2182 us
#         eosio <= eosio::newaccount            {"creator":"eosio","name":"bcskillsurou","owner":{"threshold":1,"keys":[{"key":"EOS7uvrLaTGsRH8Bujfj...
#         eosio <= eosio::buyrambytes           {"payer":"eosio","receiver":"bcskillsurou","bytes":3072}
#   eosio.token <= eosio.token::transfer        {"from":"eosio","to":"eosio.ram","quantity":"0.4573 EOS","memo":"buy ram"}
#         eosio <= eosio.token::transfer        {"from":"eosio","to":"eosio.ram","quantity":"0.4573 EOS","memo":"buy ram"}
#     eosio.ram <= eosio.token::transfer        {"from":"eosio","to":"eosio.ram","quantity":"0.4573 EOS","memo":"buy ram"}
#   eosio.token <= eosio.token::transfer        {"from":"eosio","to":"eosio.ramfee","quantity":"0.0023 EOS","memo":"ram fee"}
#         eosio <= eosio.token::transfer        {"from":"eosio","to":"eosio.ramfee","quantity":"0.0023 EOS","memo":"ram fee"}
#  eosio.ramfee <= eosio.token::transfer        {"from":"eosio","to":"eosio.ramfee","quantity":"0.0023 EOS","memo":"ram fee"}
warning: transaction executed locally, but may not be confirmed by the network yet
surou@surou-C-H110M-K-Pro:~/.local/share/eosio/nodeos/config$ cleos get account bcskillsurou
permissions: 
     owner     1:    1 EOS7uvrLaTGsRH8BujfjjjJChXLzZhUQqbvTasoN1rFvGJD68kJf9
        active     1:    1 EOS7uvrLaTGsRH8BujfjjjJChXLzZhUQqbvTasoN1rFvGJD68kJf9
memory: 
     quota:     2.982 KiB    used:     2.926 KiB  

net bandwidth: 
     delegated:       0.0000 EOS           (total staked delegated to account from others)
     used:                 0 bytes
     available:            0 bytes
     limit:                0 bytes

cpu bandwidth:
     delegated:       0.0000 EOS           (total staked delegated to account from others)
     used:                 0 us   
     available:            0 us   
     limit:                0 us   

最少需要RAM 3kb,具体等于多少EOS需要根据当前RAM的价格来定

EOS enable mongodb

git clone -b release/1.1 https://github.com/EOSIO/eos.git
cd eos
git fetch –all –tags –prune
git merge -m “merge” –commit origin/gh#3030-enable-mongodb
git submodule update –init –recursive
./eosio_build.sh
cd build
make install

修改config.ini配置文件,添加如下两行:

plugin = eosio::mongo_db_plugin
mongodb-uri = mongodb://localhost:27017/eosmain

其中,eosmain是要写入的MongoDB数据库名。
好了,万事俱备,开始启动
进入~/opt/mongodb/bin目录,启动MongoDB服务。

cd ~/opt/mongodb/bin
./mongod

这时MongoDB服务会默认监听27017端口,如下图所示。

新开一个小窗,重启nodeos,需要加上–replay-blockchain,以使历史交易数据同步到MongoDB。
如果没有意外的话,此时MongoDB应该开始写入相关记录了。
执行mongo程序进入MongoDB控制台,查询相应数据库和记录,如下图。

参考:github issues eosdata.io

EOS 1.1.0 版本以上请参考 https://www.bcskill.com/index.php/archives/290.html

boost::interprocess::bad_alloc

由于解决 cleos get transaction 返回空的信息
此问题,导致运行 nodeos 提示以下错误

terminate called after throwing an instance of 'boost::interprocess::bad_alloc'
  what():  boost::interprocess::bad_alloc

解决方案:修改 config.ini 中 chain-state-db-size-mb调大些,默认1024,一般改为2048即可,当然服务器内存较大可以再多分些。
参考:github issues

EOS节点开启RPC访问

修改 config.ini

  1. access-control-allow-origin = * //解决跨域问题
  2. http-server-address = 0.0.0.0:8888 //接受任何IP的访问

cleos get transaction 返回空的信息

surou@surou-C-H110M-K-Pro:~$ cleos get transaction 75b70df41828c9585c2e7b690c2a481ef4bd5733e775305bbb7bc01f5aa058c8
{
  "id": "75b70df41828c9585c2e7b690c2a481ef4bd5733e775305bbb7bc01f5aa058c8",
  "trx": null,
  "block_time": "2000-01-01T00:00:00.000",
  "block_num": 0,
  "last_irreversible_block": 1314661,
  "traces": []
}

修改 config.ini中filter-on = * 或者 nodeos启动时添加参数--filter-on "*"
重新发起transaction获取新的transaction_id。之前旧的transaction_id无法获取

surou@surou-C-H110M-K-Pro:~$ cleos get transaction 6c0a755fc81eaa94baf679a2aced81ee913b2f4b98d939aeadce6f7889a7003e
{
  "id": "6c0a755fc81eaa94baf679a2aced81ee913b2f4b98d939aeadce6f7889a7003e",
  "trx": {
    "receipt": {
      "status": "executed",
      "cpu_usage_us": 1668,
      "net_usage_words": 17,
      "trx": [
        1,{
          "signatures": [
            "SIG_K1_KWDHq27a9rtwxerQi6TM5tDEerqbEcLiKJcL3hpBYHhGgtr5gKhsD91KskhCwPK6hH5jqhdbK2cn4tW7npwh5T7KmQtpEV"
          ],
          "compression": "none",
          "packed_context_free_data": "",
          "packed_trx": "60a53d5b45295d4bfb8f000000000100a6823403ea3055000000572d3ccdcd01000040aa2b50ab4900000000a8ed32322c000040aa2b50ab490000000000ea3055884600000000000004454f53000000000b68656c6c6f20776f726c6400"
        }
      ]
    },
    "trx": {
      "expiration": "2018-07-05T04:58:08",
      "ref_block_num": 10565,
      "ref_block_prefix": 2415610717,
      "max_net_usage_words": 0,
      "max_cpu_usage_ms": 0,
      "delay_sec": 0,
      "context_free_actions": [],
      "actions": [{
          "account": "eosio.token",
          "name": "transfer",
          "authorization": [{
              "actor": "dapp.exec",
              "permission": "active"
            }
          ],
          "data": {
            "from": "dapp.exec",
            "to": "eosio",
            "quantity": "1.8056 EOS",
            "memo": "hello world"
          },
          "hex_data": "000040aa2b50ab490000000000ea3055884600000000000004454f53000000000b68656c6c6f20776f726c64"
        }
      ],
      "transaction_extensions": [],
      "signatures": [
        "SIG_K1_KWDHq27a9rtwxerQi6TM5tDEerqbEcLiKJcL3hpBYHhGgtr5gKhsD91KskhCwPK6hH5jqhdbK2cn4tW7npwh5T7KmQtpEV"
      ],
      "context_free_data": []
    }
  },
  "block_time": "2018-07-05T04:57:09.000",
  "block_num": 1321304,
  "last_irreversible_block": 1321453,
  "traces": [{
      "receipt": {
        "receiver": "eosio.token",
        "act_digest": "243d8d4afdb3b52f610f27efa55efac1e600e50bb8bc488dd8651dca3c242f07",
        "global_sequence": 1321588,
        "recv_sequence": 73,
        "auth_sequence": [[
            "dapp.exec",
            111
          ]
        ],
        "code_sequence": 1,
        "abi_sequence": 1
      },
      "act": {
        "account": "eosio.token",
        "name": "transfer",
        "authorization": [{
            "actor": "dapp.exec",
            "permission": "active"
          }
        ],
        "data": {
          "from": "dapp.exec",
          "to": "eosio",
          "quantity": "1.8056 EOS",
          "memo": "hello world"
        },
        "hex_data": "000040aa2b50ab490000000000ea3055884600000000000004454f53000000000b68656c6c6f20776f726c64"
      },
      "elapsed": 1032,
      "cpu_usage": 0,
      "console": "",
      "total_cpu_usage": 0,
      "trx_id": "6c0a755fc81eaa94baf679a2aced81ee913b2f4b98d939aeadce6f7889a7003e",
      "inline_traces": [{
          "receipt": {
            "receiver": "dapp.exec",
            "act_digest": "243d8d4afdb3b52f610f27efa55efac1e600e50bb8bc488dd8651dca3c242f07",
            "global_sequence": 1321589,
            "recv_sequence": 38,
            "auth_sequence": [[
                "dapp.exec",
                112
              ]
            ],
            "code_sequence": 1,
            "abi_sequence": 1
          },
          "act": {
            "account": "eosio.token",
            "name": "transfer",
            "authorization": [{
                "actor": "dapp.exec",
                "permission": "active"
              }
            ],
            "data": {
              "from": "dapp.exec",
              "to": "eosio",
              "quantity": "1.8056 EOS",
              "memo": "hello world"
            },
            "hex_data": "000040aa2b50ab490000000000ea3055884600000000000004454f53000000000b68656c6c6f20776f726c64"
          },
          "elapsed": 445,
          "cpu_usage": 0,
          "console": "",
          "total_cpu_usage": 0,
          "trx_id": "6c0a755fc81eaa94baf679a2aced81ee913b2f4b98d939aeadce6f7889a7003e",
          "inline_traces": []
        },{
          "receipt": {
            "receiver": "eosio",
            "act_digest": "243d8d4afdb3b52f610f27efa55efac1e600e50bb8bc488dd8651dca3c242f07",
            "global_sequence": 1321590,
            "recv_sequence": 1321418,
            "auth_sequence": [[
                "dapp.exec",
                113
              ]
            ],
            "code_sequence": 1,
            "abi_sequence": 1
          },
          "act": {
            "account": "eosio.token",
            "name": "transfer",
            "authorization": [{
                "actor": "dapp.exec",
                "permission": "active"
              }
            ],
            "data": {
              "from": "dapp.exec",
              "to": "eosio",
              "quantity": "1.8056 EOS",
              "memo": "hello world"
            },
            "hex_data": "000040aa2b50ab490000000000ea3055884600000000000004454f53000000000b68656c6c6f20776f726c64"
          },
          "elapsed": 95,
          "cpu_usage": 0,
          "console": "",
          "total_cpu_usage": 0,
          "trx_id": "6c0a755fc81eaa94baf679a2aced81ee913b2f4b98d939aeadce6f7889a7003e",
          "inline_traces": []
        }
      ]
    },{
      "receipt": {
        "receiver": "dapp.exec",
        "act_digest": "243d8d4afdb3b52f610f27efa55efac1e600e50bb8bc488dd8651dca3c242f07",
        "global_sequence": 1321589,
        "recv_sequence": 38,
        "auth_sequence": [[
            "dapp.exec",
            112
          ]
        ],
        "code_sequence": 1,
        "abi_sequence": 1
      },
      "act": {
        "account": "eosio.token",
        "name": "transfer",
        "authorization": [{
            "actor": "dapp.exec",
            "permission": "active"
          }
        ],
        "data": {
          "from": "dapp.exec",
          "to": "eosio",
          "quantity": "1.8056 EOS",
          "memo": "hello world"
        },
        "hex_data": "000040aa2b50ab490000000000ea3055884600000000000004454f53000000000b68656c6c6f20776f726c64"
      },
      "elapsed": 445,
      "cpu_usage": 0,
      "console": "",
      "total_cpu_usage": 0,
      "trx_id": "6c0a755fc81eaa94baf679a2aced81ee913b2f4b98d939aeadce6f7889a7003e",
      "inline_traces": []
    },{
      "receipt": {
        "receiver": "eosio",
        "act_digest": "243d8d4afdb3b52f610f27efa55efac1e600e50bb8bc488dd8651dca3c242f07",
        "global_sequence": 1321590,
        "recv_sequence": 1321418,
        "auth_sequence": [[
            "dapp.exec",
            113
          ]
        ],
        "code_sequence": 1,
        "abi_sequence": 1
      },
      "act": {
        "account": "eosio.token",
        "name": "transfer",
        "authorization": [{
            "actor": "dapp.exec",
            "permission": "active"
          }
        ],
        "data": {
          "from": "dapp.exec",
          "to": "eosio",
          "quantity": "1.8056 EOS",
          "memo": "hello world"
        },
        "hex_data": "000040aa2b50ab490000000000ea3055884600000000000004454f53000000000b68656c6c6f20776f726c64"
      },
      "elapsed": 95,
      "cpu_usage": 0,
      "console": "",
      "total_cpu_usage": 0,
      "trx_id": "6c0a755fc81eaa94baf679a2aced81ee913b2f4b98d939aeadce6f7889a7003e",
      "inline_traces": []
    }
  ]
}

常见问题:boost::interprocess::bad_alloc