您正在查看: EOS-新手问答 分类下的文章

owner account does not exist

执行

cleos push action eosio init '[0,"4,SYS"]' -p eosio@active

报错

Error 3050003: eosio_assert_message assertion failure
Error Details:
assertion failure with message: owner account does not exist
pending console output:

原因

https://github.com/EOSIO/eosio.contracts/blob/52fbd4ac7e6c38c558302c48d00469a4bed35f7c/contracts/eosio.system/src/eosio.system.cpp#L365

token::open_action open_act{ token_account, { {get_self(), active_permission} } };
      open_act.send( rex_account, core, get_self() );

https://github.com/EOSIO/eosio.contracts/blob/52fbd4ac7e6c38c558302c48d00469a4bed35f7c/contracts/eosio.token/src/eosio.token.cpp#L133
没有创建 rex_account eosio.rex账户

解决方案

创建 eosio.rex 账户,在执行

Unable to locate package eosio

安装eosio deb包时报错

sudo apt install eosio_1.6.6-1-ubuntu-18.04_amd64.deb
[sudo] password for surou:
Reading package lists... Done
Building dependency tree
Reading state information... Done
E: Unable to locate package eosio_1.6.6-1-ubuntu-18.04_amd64.deb
E: Couldn't find any package by glob 'eosio_1.6.6-1-ubuntu-18.04_amd64.deb'
E: Couldn't find any package by regex 'eosio_1.6.6-1-ubuntu-18.04_amd64.deb'

解决方案,使用sudo dpkg -i安装

$ sudo dpkg -i eosio_1.6.6-1-ubuntu-18.04_amd64.deb
Selecting previously unselected package eosio.
(Reading database ... 57664 files and directories currently installed.)
Preparing to unpack eosio_1.6.6-1-ubuntu-18.04_amd64.deb ...
Unpacking eosio (1.6.6-1) ...
Setting up eosio (1.6.6-1) ...

Invalid cast from type 'string_type' to Object

查询交易返回

clfsc -u https://beta-api-chain.xxx.com get transaction_id 784886dbbc6cbbbfd2a223e1fc91a7b87231718aa94efdf39ec1e085331d9490
Error 3010006: Invalid transaction
Ensure that your transaction JSON follows the right transaction format!
You can refer to contracts/fsciolib/transaction.hpp for reference
Error Details:
Fail to parse transaction JSON '784886dbbc6cbbbfd2a223e1fc91a7b87231718aa94efdf39ec1e085331d9490'
Invalid cast from type 'string_type' to Object

查看数据

{
"timestamp": "2019-07-31T09:47:28.000",
"producer": "peacock15chy",
"confirmed": 0,
"previous": "006174d7444f5590416508b2cc03991549a9163ef8cf96dab4a5ce00f0f5ebf2",
"transaction_mroot": "d5cf5dc8b315844c92b625c3ff25ffb62766cdc6cb86ff69c64f4d0c927bd3cb",
"action_mroot": "3fbfdf22745803b79bd90022c9308775a1b6296beee81987efce8ef877dac543",
"schedule_version": 1,
"new_producers": null,
"header_extensions": [],
"producer_signature": "SIG_K1_KfnTYbdhByrtGbHrdNStbhYo2MQakmoweyBeQcRMmpXcgdPKB66yGnGAfT1g1rPfK3SVXFXAULU2CexRCoEqxdg6wSYUii",
"transactions": [
{
"status": "executed",
"cpu_usage_us": 419,
"net_usage_words": 0,
"trx": "784886dbbc6cbbbfd2a223e1fc91a7b87231718aa94efdf39ec1e085331d9490"
}
],
"block_extensions": [],
"id": "006174d85cf3afe91baaca598413f4395e412723ed9478eb6e797085dc6ab391",
"block_num": 6386904,
"ref_block_prefix": 1506454043
}

发现trx非object导致,查看本地代码

get_transaction_id_subcommand(CLI::App* actionRoot) {
      auto get_transaction_id = actionRoot->add_subcommand("transaction_id", localized("Get transaction id given transaction object"));
      get_transaction_id->add_option("transaction", trx_to_check, localized("The JSON string or filename defining the transaction which transaction id we want to retrieve"))->required();

      get_transaction_id->set_callback([&] {
         try {
            auto trx_var = json_from_file_or_string(trx_to_check);
            auto trx = trx_var.as<transaction>();
            std::cout << string(trx.id()) << std::endl;
         } EOS_RETHROW_EXCEPTIONS(transaction_type_exception, "Fail to parse transaction JSON '${data}'", ("data",trx_to_check))
      });
   }
};

并未做判断,怀疑版本太旧,查看github 最新代码
https://github.com/EOSIO/eos/blob/eb88d033c0abbc481b8a481485ef4218cdaa033a/programs/cleos/main.cpp#L1316

 get_transaction_id->set_callback([&] {
         try {
            fc::variant trx_var = json_from_file_or_string(trx_to_check);
            if( trx_var.is_object() ) {  // 增加了判断
               fc::variant_object& vo = trx_var.get_object();
               // if actions.data & actions.hex_data provided, use the hex_data since only currently support unexploded data
               if( vo.contains("actions") ) {
                  if( vo["actions"].is_array() ) {
                     fc::mutable_variant_object mvo = vo;
                     fc::variants& action_variants = mvo["actions"].get_array();
                     for( auto& action_v : action_variants ) {
                        if( !action_v.is_object() ) {
                           std::cerr << "Empty 'action' in transaction" << endl;
                           return;
                        }
                        fc::variant_object& action_vo = action_v.get_object();
                        if( action_vo.contains( "data" ) && action_vo.contains( "hex_data" ) ) {
                           fc::mutable_variant_object maction_vo = action_vo;
                           maction_vo["data"] = maction_vo["hex_data"];
                           action_vo = maction_vo;
                           vo = mvo;
                        } else if( action_vo.contains( "data" ) ) {
                           if( !action_vo["data"].is_string() ) {
                              std::cerr << "get transaction_id only supports un-exploded 'data' (hex form)" << std::endl;
                              return;
                           }
                        }
                     }
                  } else {
                     std::cerr << "transaction json 'actions' is not an array" << std::endl;
                     return;
                  }
               } else {
                  std::cerr << "transaction json does not include 'actions'" << std::endl;
                  return;
               }
               auto trx = trx_var.as<transaction>();
               transaction_id_type id = trx.id();
               if( id == transaction().id() ) {
                  std::cerr << "file/string does not represent a transaction" << std::endl;
               } else {
                  std::cout << string( id ) << std::endl;
               }
            } else {
               std::cerr << "file/string does not represent a transaction" << std::endl;
            }
         } EOS_RETHROW_EXCEPTIONS(transaction_type_exception, "Fail to parse transaction JSON '${data}'", ("data",trx_to_check))
      });

所以解决方案就是更新对应的代码,或者直接升级版本。

compile failed in 1.6.1 when using [[eosio::on_notify("*::transfer")]]

error: else expression without matching if
000035b: error: OnElseExpr callback failed

but if I use [[eosio::on_notify("eosio.token::transfer")]], compilation is success

解决

升级 eosio.cdt v1.6.2+

参考

https://github.com/EOSIO/eosio.cdt/issues/497
https://github.com/EOSIO/eosio.cdt/blob/796ff8bee9a0fc864f665a0a4d018e0ff18ac383/tests/unit/test_contracts/simple_tests.cpp
https://github.com/EOSIO/eosio.cdt/blob/796ff8bee9a0fc864f665a0a4d018e0ff18ac383/docs/upgrading/1.5-to-1.6.md

关于节点IP配置问题

问题

如果我要加入一个EOS网络并且要参与出块,那么我的config.ini中p2p-peer-address配置了目前出块节点的p2p-listen-endpoint地址中的至少一个,此时我还是无法出块,必须在目前出块节点中至少一个config.ini中添加我的p2p-listen-endpoint才可以。这个和ETH的P2P貌似不太一样,麻烦大佬解释一下这个原理,谢谢!

解答

经过测试,EOS的节点连接都走 P2P为双向,不存在单独的处理方式

主要代码在net_plugin插件中

https://github.com/EOSIO/eos/blob/master/plugins/net_plugin/net_plugin.cpp

代码分析就不细说了,之前有相关发帖

https://www.bcskill.com/index.php/archives/625.html

https://my.oschina.net/u/4069047/blog/3005068

目前涉及 4个参数

  • p2p-server-address
  • p2p-listen-endpoint
  • p2p-peer-address
  • p2p-max-nodes-per-host 限制来自相同IP的P2P连接数

参数讲解参考
https://developers.eos.io/eosio-nodeos/docs/net_plugin

https://techterms.com/definition/p2p

虽然P2P对等网络,最终实现还是socket

客户端connect

https://github.com/EOSIO/eos/blob/5082391c60b0fa5e68157c385cd402bf25aea934/plugins/net_plugin/net_plugin.cpp#L1847

服务端listen

https://github.com/EOSIO/eos/blob/5082391c60b0fa5e68157c385cd402bf25aea934/plugins/net_plugin/net_plugin.cpp#L1901

p2p-peer-address 为connect 使用
p2p-listen-endpoint为 listen使用
p2p-server-address 同上,并且优先覆盖

https://github.com/EOSIO/eos/blob/5082391c60b0fa5e68157c385cd402bf25aea934/plugins/net_plugin/net_plugin.cpp#L2995

只要同时有一个连接存在,则能正常工作。
比如节点A (BP)设置了p2p-listen-endpoint(作为P2P Server),并且开放链接,节点B(同步)只要设置 p2p-peer-address(作为P2P Client) 就可以完成链接。A,B反过来也一样。
但对于P2P既是客户端,也是服务端,所以可以的话,互相加下最稳妥。

小白的主要问题在,他在同一台机器上跑了多个节点,但p2p-max-nodes-per-host用的默认值1,BP节点的p2p-listen-endpoint已经被占用了,然后测试节点再连接,由于IP相同,导致无法通过。

先粗略写下,不清楚再补充把

问题转载自:http://wiki.bcskill.com/?thread-21.htm