BCSkill (Block chain skill ) 技术社区
社区QQ群:791420381
推荐论坛:https://eosfans.io
Telegram: https://t.me/bcskill

print_floats.cpp:**undefined reference to `boost::program_options

编译EOS时出现以下错误

Scanning dependencies of target print_floats
......
[ 76%] Linking CXX executable print_floats
CMakeFiles/print_floats.dir/print_floats.cpp.o: In function `boost::program_options::typed_value<unsigned int, char>::name[abi:cxx11]() const':
print_floats.cpp: **undefined reference to `boost::program_options::arg[abi:cxx11]'**
......
print_floats.cpp:**undefined reference to `boost::program_options::validation_error::get_template[abi:cxx11]**(boost::program_options::validation_error::kind_t)'
print_floats.cpp:**undefined reference to `boost::program_options::options_description::m_default_line_length'**
print_floats.cpp:**undefined reference to `boost::program_options::options_description::options_description(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, unsigned int, unsigned int)'**
print_floats.cpp:**undefined reference to `boost::program_options::options_description::add_options()'**
print_floats.cpp:**undefined reference to `boost::program_options::options_description_easy_init::operator()(char const*, char const*)'**
print_floats.cpp:**undefined reference to `boost::program_options::options_description_easy_init::operator()(char const*, boost::program_options::value_semantic const*, char const*)'**
......
collect2: error: ld returned 1 exit status
make[2]: *** [tools/print_floats] Error 1
make[1]: *** [tools/CMakeFiles/print_floats.dir/all] Error 2
make[1]: *** Waiting for unfinished jobs....
[ 76%] Building CXX object libraries/fc/CMakeFiles/fc.dir/src/crypto/sha512.cpp.o
[ 76%] Building CXX object libraries/fc/CMakeFiles/fc.dir/src/crypto/dh.cpp.o
[ 76%] Building CXX object libraries/fc/CMakeFiles/fc.dir/src/crypto/blowfish.cpp.o

原因是之前手动安装过boost,但安装的不正确,或者文件缺失

解决方案,清理掉所有本地的boost文件,重新运行编译EOS,会自动下载依赖

cd ~/opt/
rm -rf boost*
cd eos_dir
rm -rf build

问题收集自 eosfans

自定义nodeos数据路径

--config-dir 自定义 config.ini 路径
--data-dir 自定义区块数据路径
--genesis-json 自定义genesis.json路径

nodeos 启动参数--checkpoint 作用

问题

看nodeos的启动参数的时候,看到这么一项: --checkpoint arg Pairs of [BLOCK_NUM,BLOCK_ID] that should be enforced as checkpoints.
这checkpoint是什么,主要用来干嘛的?
问题来自:eosfans

解答

查看config中的注释
Pairs of [BLOCK_NUM,BLOCK_ID] that should be enforced as checkpoints. (eosio::chain_plugin)
多对区块高度+区块id,用来作为检查点。默认注释掉,不设置检查点

大概的意思就是,接收区块时,根据区段的高度,查看当前区块的id与预期的一样不一样,防止数据出错。

撸一遍代码
eos\plugins\chain_plugin\chain_plugin.cpp

if( options.count("checkpoint") ) {
         auto cps = options.at("checkpoint").as<vector<string>>();
         my->loaded_checkpoints.reserve(cps.size());
         for( const auto& cp : cps ) {
            auto item = fc::json::from_string(cp).as<std::pair<uint32_t,block_id_type>>();
            auto itr = my->loaded_checkpoints.find(item.first);
            if( itr != my->loaded_checkpoints.end() ) {
               EOS_ASSERT( itr->second == item.second,
                           plugin_config_exception,
                          "redefining existing checkpoint at block number ${num}: original: ${orig} new: ${new}",
                          ("num", item.first)("orig", itr->second)("new", item.second)
               );
            } else {
               my->loaded_checkpoints[item.first] = item.second;
            }
         }
      }

先将config中配置的,或者命令行传入的,多对区块高度+区块id存入my->loaded_checkpoints,并去重。

接收区块时,进行对比验证

// relay signals to channels
      my->pre_accepted_block_connection = my->chain->pre_accepted_block.connect([this](const signed_block_ptr& blk) {
         auto itr = my->loaded_checkpoints.find( blk->block_num() );
         if( itr != my->loaded_checkpoints.end() ) {
            auto id = blk->id();
            EOS_ASSERT( itr->second == id, checkpoint_exception,
                        "Checkpoint does not match for block number ${num}: expected: ${expected} actual: ${actual}",
                        ("num", blk->block_num())("expected", itr->second)("actual", id)
            );
         }

         my->pre_accepted_block_channel.publish(blk);
      });

当接收的区块的高度与预定中的某高度一致,比较当前区块id与预定的id,如果不一致,则报错Checkpoint does not match for block number...

Error 3200006: invalid http request (please contact the RPC server administrator for 127.0.0.1!)

  • 执行cleos get transaction出现以下错误

    root@iZj6cbx3duprxf6dasczbpZ:~/eosio-wallet# cleos get transaction 17b8e633dbdc3988fcec671b96ae1ce473bc432568a417a416901b9c01184a72
    Error 3200006: invalid http request
    Error Details:
    The server has rejected the request as invalid!
    Please verify this url is valid: http://127.0.0.1:8888/v1/history/get_transaction
    If the condition persists, please contact the RPC server administrator for 127.0.0.1!
  • 换在eosjs下执行

      const wif = '私钥'
      eos = Eos({
              httpEndpoint: '上面cleos所在服务器提供的Rpc地址',
              chainId: 'aca376f206b8fc25a6ed44dbdc66547c36c6c33e3a119ffbeaef943642f0e906',
              keyProvider: wif,
              verbose: true
            })
      eos.getTransaction("17b8e633dbdc3988fcec671b96ae1ce473bc432568a417a416901b9c01184a72").then(result => {
          console.log(result);
      })
  • 返回结果如下

    {
      "code": 400, 
      "message": "Bad Request", 
      "error": {
          "code": 3040011, 
          "name": "tx_not_found", 
          "what": "The transaction can not be found", 
          "details": [
              {
                  "message": "Transaction 17b8e633dbdc3988fcec671b96ae1ce473bc432568a417a416901b9c01184a72 not found in history and no block hint was given", 
                  "file": "history_plugin.cpp", 
                  "line_number": 396, 
                  "method": "get_transaction"
              }
          ]
      }
    }

    这个17b8e633dbdc3988fcec671b96ae1ce473bc432568a417a416901b9c01184a72并不存在。

  • 在eosjs中执行

    eos.getActions("bcskillsurou").then(result => {
      console.log(result);
    })
  • 再返回的数据中

    {"actions":[{"global_action_seq":2569366,"account_action_seq":304,"block_num":2568738,"block_time":"2018-08-02T10:32:46.500","action_trace":{"receipt":{"receiver":"dapp.exec","act_digest":"b6902e4919fe2e03e5be0bd8dd01659a5e6dca58fc4d6c9e873de56c54f75a36","global_sequence":2569366,"recv_sequence":101,"auth_sequence":[["dapp.exec",288]],"code_sequence":1,"abi_sequence":1},"act":{"account":"eosio.token","name":"transfer","authorization":[{"actor":"dapp.exec","permission":"active"}],"data":{"from":"dapp.exec","to":"eosio.ram","quantity":"0.9950 EOS","memo":"buy ram"},"hex_data":"000040aa2b50ab49000090e602ea3055de2600000000000004454f5300000000076275792072616d"},"elapsed":62,"cpu_usage":0,"console":"","total_cpu_usage":0,"trx_id":"c7b8e633dbdc3988fcec671b96ae1ce473bc432568a417a416901b9c01184a7d","inline_traces":[]}},
  • 随便找一个trx_id

    "trx_id":"c7b8e633dbdc3988fcec671b96ae1ce473bc432568a417a416901b9c01184a7d"
  • 然后在终端执行

    root@iZj6cbx3duprxf6dasczbpZ:~/eosio-wallet# cleos get transaction c7b8e633dbdc3988fcec671b96ae1ce473bc432568a417a416901b9c01184a7d
    {
    "id": "c7b8e633dbdc3988fcec671b96ae1ce473bc432568a417a416901b9c01184a7d",
    "trx": {
      "receipt": {
        "status": "executed",
        "cpu_usage_us": 3077,
        "net_usage_words": 16,
        "trx": [
          1,{
            "signatures": [
              "SIG_K1_KbeYYa3kW3izWvmHoRjUSCSSckGWzwuRi3ZJ8pPKnjJigGsUSE3aRKnmZDNhgULCou7aYTgyYeTs95f9RMKik7LTMPHX3p"
            ],
            "compression": "none",
            "packed_context_free_data": "",
            "packed_trx": "08de625bf43153f4344400000000010000000000ea3055000000004873bd3e01000040aa2b50ab4900000000a8ed323220000040aa2b50ab49000040aa2b50ab49102700000000000004454f530000000000"
          }
        ]
      },
      "trx": {

    正确返回交易信息。

结论

至此得出结论,在终端中cleos get transaction 本地数据不存在的trx_id,出现Error 3200006 错误,
此错误信息并不准确,建议EOSIO能和eosjs返回的错误一致,方便分析问题。

EOS修改非owner私钥

本文只为简单的描述下当非owner私钥丢失后,如何重置

一般利用三方App创建账号,为了程序内好处理,并且减少用户的记录成本,都是owner和active共用一对公钥和私钥,这种只能第一时间赶紧将剩余的EOS转走,减少损失。并第一时间找社区提交仲裁。
所以建议用一些支持owner和active 单独设置公钥私钥的程序创建账号(在此不做推荐,避免不必要的风险)。在不需要owner的情况下,单独冷备份,平时只用active权限的账号进行操作。

下面开始演示,如何更换active私钥

查询账户
root@iZj6c1ho98e6b4nz3ulirvZ:~# cleos -u https://api.eosnewyork.io get account bcskillsurou

permissions: 
     owner     1:    1 EOS8Sq9MXKiop4J1PX3xfyDkzqaRpWp2tEqkBL4LiT3cvXmtc2yh4
     active     1:    1 EOS72Uoinz7Dgm4GpdhfoPUQx6NfosoyacvLsk7z2E9Y7z5DBsKjv
提前已创建好一对新的公钥私钥
5J4MbkkZHtroTW3FZQa3cEZFFr9EFPDm75yPFTuuS2B
EOS6zxf2t9qkgYYpjNWXy91edeVFjeWmaH7JQeQAn9SRiRefqMQ6W
开始更换active 公钥
root@iZj6c1ho98e6b4nz3ulirvZ:~# cleos -u https://api.eosnewyork.io set account permission bcskillsurou active '{"threshold": 1, "keys": [{"key": "EOS6zxf2t9qkgYYpjNWXy91edeVFjeWmaH7JQeQAn9SRiRefqMQ6W", "weight": 1}], "accounts": []}' active
Error 3050000: Action validate exception
Error Details:
Cannot set an authority as its own parent
pending console output:
需要active的父级权限
cleos wallet import
输入 EOS8Sq9MXKiop4J1PX3xfyDkzqaRpWp2tEqkBL4LiT3cvXmtc2yh4 的私钥
更换owner 权限,重新执行
root@iZj6c1ho98e6b4nz3ulirvZ:~# cleos -u https://api.eosnewyork.io set account permission bcskillsurou active '{"threshold": 1, "keys": [{"key": "EOS6zxf2t9qkgYYpjNWXy91edeVFjeWmaH7JQeQAn9SRiRefqMQ6W", "weight": 1}], "accounts": []}' owner
executed transaction: 31a9bf9448b3d9882f27767c427a6ece406319036b3d62e7a04d001f272365a2  160 bytes  1254 us
#         eosio <= eosio::updateauth            {"account":"bcskillsurou","permission":"active","parent":"owner","auth":{"threshold":1,"keys":[{"key...
再次查看账户
root@iZj6c1ho98e6b4nz3ulirvZ:~# cleos -u https://api.eosnewyork.io get account bcskillsurou

permissions: 
     owner     1:    1 EOS8Sq9MXKiop4J1PX3xfyDkzqaRpWp2tEqkBL4LiT3cvXmtc2yh4
     active     1:    1 EOS6zxf2t9qkgYYpjNWXy91edeVFjeWmaH7JQeQAn9SRiRefqMQ6W

active权限已更改

参考

EOS账户权限介绍以及增删改查