您正在查看: 2019年9月

EOS1.8硬分叉升级后同步节点更新

由于1.8.*和之前的版本的数据不兼容,所以主网升级后,同步节点需要做以下调整

  1. 确保其现有节点正在运行最新的稳定版本(1.7)的nodeos,然后关闭nodeos。
  2. 进行备份并删除数据目录中的blocks/reversible目录,state-history目录和state目录。
  3. 用新版本替换其旧版本的nodeos。
  4. 启动新的Nodeos 1.8发行版,并使其完全从创世开始重播,并赶上与网络同步的步伐。该节点应接收块,并且LIB应该前进。在激活第一个协议升级功能之前,运行v1.8和v1.7的节点将继续在同一网络中共存。

将nodeos从v1.7升级到v1.8时,需要从创世重播。之后,v1.8节点可以照常快速启动和停止,而无需重播。v1.7节点生成的状态目录将与nodeos的v1.8不兼容。版本1便携式快照(由v1.7生成)将与要求版本2便携式快照的v1.8不兼容。

注意点

链程序 需要选用 1.8.1或者1.8.4,中间两个版本有问题,
发帖时,未找到有提供1.8 相关的离线数据包,所以目前只能自己hard-repaly,或者使用快照

感谢eos beijing BP的技术小伙伴回答

unable to find plugin: eosio::wallet_api_plugin

wallet_api_plugin is no longer supported as part of nodeos. Use keosd instead.
https://developers.eos.io/keosd/docs

参考

https://github.com/EOSIO/eos/issues/7833

eos 1.8 启动 mongo_db_plugin 插件 ENABLE_MONGO

./eosio_build.sh -m // 添加参数支持mongo

支持的参数

function usage() {
   printf "Usage: $0 OPTION...
  -P          Build with pinned clang and libcxx
  -o TYPE     Build <Debug|Release|RelWithDebInfo|MinSizeRel> (default: Release)
  -s NAME     Core Symbol Name <1-7 characters> (default: SYS)
  -b DIR      Use pre-built boost in DIR
  -i DIR      Directory to use for installing dependencies & EOSIO (default: $HOME)
  -y          Noninteractive mode (answers yes to every prompt)
  -c          Enable Code Coverage
  -d          Generate Doxygen
  -m          Build MongoDB dependencies
   \\n" "$0" 1>&2
   exit 1
}

https://github.com/EOSIO/eos/blob/51f6a070200c69eb4d82e21aa2f750d43e8491d1/scripts/eosio_build.sh#L35

EOS 合约中使用eosio::checksum256作为查询索引,查询不到问题

演示合约代码

合约中Table表结构

struct [[eosio::table, eosio::contract("bcskillsurou")]] extract_token {
    uint64_t id;
    eosio::checksum256 transaction_id;                   // 交易单id

    auto primary_key() const { return id; }
    eosio::checksum256 second_key() const { return transaction_id; } // 已hash作为二级索引

    EOSLIB_SERIALIZE(extract_token, (id)(transaction_id))
};
typedef eosio::multi_index<"xxxxtb"_n, extract_token, eosio::indexed_by<"bysubkey"_n, eosio::const_mem_fun<extract_token, eosio::checksum256, &extract_token::second_key>>> xxxx_table;

合约中查询代码

ACTION findtrxid(eosio::checksum256 trx_id){
    ....
    xxx_table xxxtb(_self, _self.value);
    auto sub_extract_index = xxxtb.get_index<"bysubkey"_n>();
    auto itr_xxx = sub_xxx_index.find(trx_id);

    eosio_assert(itr_extract != sub_xxx_index.end(), "Record not found");
    ....
}

使用Cleos 复现问题

cleos push action 合约账户 findtrxid '{"trx_id":0bb0e5901c3b627484c6a1a473ba8e3e3a3ffb4b96f849e08afb2d1e2671b88d}' -p 合约账户

返回

Error 3050003: eosio_assert_message assertion failure
Error Details:
assertion failure with message: {"code":102,"msg":"Record not found 563"}

经过测试发现是因为eosio::checksum256 trx_id传参最终打包不是已字符串打包导致,交易id上传后被识别成了

1116029241376226714100000000000000000000000000000000000000000000

解决方案

修改eosio::checksum256 trx_id为字符串即可

cleos push action 合约账户 findtrxid '{"trx_id":"0bb0e5901c3b627484c6a1a473ba8e3e3a3ffb4b96f849e08afb2d1e2671b88d"}' -p 合约账户

对于其他语言封装,处理eosio::checksum256 trx_id统一字符串打包即可

备注

特殊hash复现

参考

https://eosio.github.io/eosio.cdt/1.6.0/group__multiindex.html

received a go away message from xxxx, reason = authentication failure

主动连接方提示:

info  2019-09-03T07:20:45.197 thread-0  net_plugin.cpp:2293           handle_message       ] received a go away message from 17.1.0.9:7860, reason = authentication failure

被连接方提示:

error 2019-09-04T09:30:24.112 thread-0  net_plugin.cpp:2715           authenticate_peer    ] Peer web0_92:6886 - 5a05387 sent a handshake with a timestamp skewed by more than 1 second.
error 2019-09-04T09:30:24.112 thread-0  net_plugin.cpp:2251           handle_message       ] Peer not authenticated.  Closing connection.

由于BP节点config设置了对等网络验证

allowed-connection = producers
allowed-connection = specified

此时被链接方已经添加了主动连接方的peer-key

peer-key = "FSC71Uiuk23RACZ2PKDZQUeAgyA4w8g9DYurjtBktNes382zn1tMP"

跟下代码
https://github.com/EOSIO/eos/blob/be804bf63c5092a123c3e1a468559a8164bcd3be/plugins/net_plugin/net_plugin.cpp#L2788

namespace sc = std::chrono;
      sc::system_clock::duration msg_time(msg.time);
      auto time = sc::system_clock::now().time_since_epoch();
      if(time - msg_time > peer_authentication_interval) {
         fc_elog( logger, "Peer ${peer} sent a handshake with a timestamp skewed by more than ${time}.",
                  ("peer", msg.p2p_address)("time", "1 second")); // TODO Add to_variant for std::chrono::system_clock::duration
         return false;
      }

Peer clock may be no more than 1 second skewed from our clock, including network latency.
对等时钟与我们的时钟相差不超过1秒,包括网络延迟。

主动连接方发起连接时(当前机器本地时间)到被连接方处理时(被连方本地时间)不能超过1秒(peer_authentication_interval
如果超时就直接拒绝

解决方案

各节点开启定时同步时间服务

sudo apt-get install chrony

参考:https://blog.csdn.net/kinglyjn/article/details/53606791