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

eosio.wrap 多签使用

Test eosio.wrap on Kylin Testnet

准备测试账户

Kylin 测试网络新建了两个账户用于 wrap 合约测试,分别为 updatemyauthtransmytoken,两个账户的 active 和 owner key 均为 EOS1111111111111111111111111111111114T1Anm,如下所示:

cleos -u https://api-kylin.eoslaomao.com get account updatemyauth
permissions:
     owner     1:    1 EOS1111111111111111111111111111111114T1Anm
        active     1:    1 EOS1111111111111111111111111111111114T1Anm
memory:
     quota:     40.91 KiB    used:     2.926 KiB

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

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

cleos -u https://api-kylin.eoslaomao.com get account transmytoken
permissions:
     owner     1:    1 EOS1111111111111111111111111111111114T1Anm
        active     1:    1 EOS1111111111111111111111111111111114T1Anm
memory:
     quota:     40.91 KiB    used:     2.926 KiB

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

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

EOS balances:
     liquid:          100.0000 EOS
     staked:            0.0000 EOS
     unstaking:         0.0000 EOS
     total:           100.0000 EOS

其中 transmytoken 账户有 100 EOS 的余额,用于 CASE 3 测试。

在线查看 Kylin 网络中的上述账户,请访问:

https://tools.cryptokylin.io/#/tx/updatemyauth

https://tools.cryptokylin.io/#/tx/transmytoken

CASE 1. wrap 变更 updatemyauth 账户的 active key

第一步,生成变更 active key 的 transaction 数据

我们将 updatemyauth 账户的 active key 改为 EOS6GR1JqeNmp5d7FGRt3Rx1BGQ1QxUk65nkfcnuprAs1BVNNWqSD

首先,我们生成 updateauth 数据:

cleos set account permission -s -j -d updatemyauth active EOS6GR1JqeNmp5d7FGRt3Rx1BGQ1QxUk65nkfcnuprAs1BVNNWqSD owner > updatemyauth.json

cat updatemyauth.json

{
  "expiration": "2018-08-09T09:40:33",
  "ref_block_num": 8064,
  "ref_block_prefix": 90673647,
  "max_net_usage_words": 0,
  "max_cpu_usage_ms": 0,
  "delay_sec": 0,
  "context_free_actions": [],
  "actions": [{
      "account": "eosio",
      "name": "updateauth",
      "authorization": [{
          "actor": "updatemyauth",
          "permission": "active"
        }
      ],
      "data": "d0b2365eaa6c52d500000000a8ed32320000000080ab26a701000000010002b57ac63750eca19d2e7a36ba46057e4d8a6a981849f883b5c731c33b86fdc82a01000000"
    }
  ],
  "transaction_extensions": [],
  "signatures": [],
  "context_free_data": []
}

将上述文件中的 ref_block_num 和 ref_block_prefix 改为 0,将 expiration 改为 1970-01-01T00:00:00

第二步,调用 wrap 合约执行上述命令,生成最终的 transaction data

生成 sudo_update_updatemyauth_active_trx.json 文件:

cleos wrap exec -s -j -d BP_ACCOUNT updatemyauth.json > sudo_update_updatemyauth_active_trx.json

cat sudo_update_updatemyauth_active_trx.json

{
  "expiration": "2018-08-09T09:43:33",
  "ref_block_num": 8424,
  "ref_block_prefix": 3790583261,
  "max_net_usage_words": 0,
  "max_cpu_usage_ms": 0,
  "delay_sec": 0,
  "context_free_actions": [],
  "actions": [{
      "account": "eosio.wrap",
      "name": "exec",
      "authorization": [{
          "actor": "eoslaomaocom",
          "permission": "active"
        },{
          "actor": "eosio.sudo",
          "permission": "active"
        }
      ],
      "data": "2029a246521331550000000000000000000000000000010000000000ea30550040cbdaa86c52d501d0b2365eaa6c52d500000000a8ed323243d0b2365eaa6c52d500000000a8ed32320000000080ab26a701000000010002b57ac63750eca19d2e7a36ba46057e4d8a6a981849f883b5c731c33b86fdc82a0100000000"
    }
  ],
  "transaction_extensions": [],
  "signatures": [],
  "context_free_data": []
}

将上述文件中的 ref_block_num 和 ref_block_prefix 设置为 0,将 expiration 的日期向后推迟一定的时间(比如 1 天后),这个时间表示 transaction 的过期时间。由于这个 transaction 最终需要等待 BP 多签生效,因此过期时间不能太短。

第三步,生成 producer_permissions.json 文件

假设网络中有 21 个 BP,名字分别为,blkproducera,blkproducerb,......,blkproduceru。则 producer_permissions.json 的文件内容如下所示:

$ cat producer_permissions.json
[
   {"actor": "blkproducera", "permission": "active"},
   {"actor": "blkproducerb", "permission": "active"},
   {"actor": "blkproducerc", "permission": "active"},
   {"actor": "blkproducerd", "permission": "active"},
   {"actor": "blkproducere", "permission": "active"},
   {"actor": "blkproducerf", "permission": "active"},
   {"actor": "blkproducerg", "permission": "active"},
   {"actor": "blkproducerh", "permission": "active"},
   {"actor": "blkproduceri", "permission": "active"},
   {"actor": "blkproducerj", "permission": "active"},
   {"actor": "blkproducerk", "permission": "active"},
   {"actor": "blkproducerl", "permission": "active"},
   {"actor": "blkproducerm", "permission": "active"},
   {"actor": "blkproducern", "permission": "active"},
   {"actor": "blkproducero", "permission": "active"},
   {"actor": "blkproducerp", "permission": "active"},
   {"actor": "blkproducerq", "permission": "active"},
   {"actor": "blkproducerr", "permission": "active"},
   {"actor": "blkproducers", "permission": "active"},
   {"actor": "blkproducert", "permission": "active"},
   {"actor": "blkproduceru", "permission": "active"}
]

第四步,发起多签 proposal,approve 并执行

发起 proposal:

$ cleos multisig propose_trx updateactive producer_permissions.json sudo_update_updatemyauth_active_trx.json PROPOSER_ACCOUNT

BP 分别 approve

cleos multisig approve PROPOSER_ACCOUNT updateactive '{"actor": "BP_ACCOUNT", "permission": "active"}' -p BP_ACCOUNT

approval 达到 15/21 之后,执行该 proposal:

cleos multisig exec PROPOSER_ACCOUNT updateactive ANY_ACCOUNT

*注意,任何账户都可以执行 approval 达到 15/21 的 proposal,即使该账户不是 BP。

Kylin 测试网络中已经提交 updateactive proposal:https://tools.cryptokylin.io/#/msig?proposer=eoslaomaocom&proposal=updateactive

CASE 2. wrap 变更 updatemyauth 账户的 owner key

我们将 updatemyauth 账户的 owner key 改为 EOS6GR1JqeNmp5d7FGRt3Rx1BGQ1QxUk65nkfcnuprAs1BVNNWqSD

CASE 2 和 CASE 1 类似,唯一的不同在于第一步骤的时候,生成 updatemyauth.json 的命令稍有不同。

更改 owner key 的命令不需要指定 parent permission:

cleos set account permission -s -j -d updatemyauth owner EOS6GR1JqeNmp5d7FGRt3Rx1BGQ1QxUk65nkfcnuprAs1BVNNWqSD > updatemyauth.json

其余步骤请参考 CASE1。

Kylin 测试网络中已经提交 updateowner proposal:https://tools.cryptokylin.io/#/msig?proposer=eoslaomaocom&proposal=updateowner

CASE 3. wrap 转移 transmytoken 账户中的 EOS

第一步,生成 transfer data

我们将 transmytoken 账户的 1 EOS 转移给 eosio 账户,命令如下:

cleos transfer -s -j -d transmytoken eosio "1 EOS" "steal 1 EOS from you!" > transmytoken.json

cat transmytoken.json
{
  "expiration": "2018-08-09T09:52:27",
  "ref_block_num": 25799,
  "ref_block_prefix": 1477572235,
  "max_net_usage_words": 0,
  "max_cpu_usage_ms": 0,
  "delay_sec": 0,
  "context_free_actions": [],
  "actions": [{
      "account": "eosio.token",
      "name": "transfer",
      "authorization": [{
          "actor": "transmytoken",
          "permission": "active"
        }
      ],
      "data": "3015a4d94b3ccdcd0000000000ea3055102700000000000004454f530000000015737465616c203120454f532066726f6d20796f7521"
    }
  ],
  "transaction_extensions": [],
  "signatures": [],
  "context_free_data": []
}

将上述文件中的 ref_block_num 和 ref_block_prefix 改为 0,将 expiration 改为 1970-01-01T00:00:00

其余步骤请参考 CASE1。

Kylin 测试网络中已经提交 transtoken proposal:https://tools.cryptokylin.io/#/msig?proposer=eoslaomaocom&proposal=transtoken

转载自:https://github.com/cryptokylin/contract-upgrade-manual/blob/master/test-sudo-contract.md

Error 3010014: Invalid symbol

问题复现

新建账号 bcskillsurou,并部署eosio.token合约,此账号创建代币EOS,并发行后

cleos set contract bcskillsurou /mnt/c/github/eos/build/contracts/eosio.token/ -p bcskillsurou
cleos push action bcskillsurou create '["eosio","1500000000.00000000 BSC",0,0,0]' -p bcskillsurou
cleos push action bcskillsurou issue '["eosio","150000000.00000000 BSC","issue"]' -p bcskillsurou

当使用cleos执行transfer时

cleos -u  https://www.bcskill.com transfer bcskillsurou xxxxxxxxxxxx "10 BSC"

提示

Error 3010014: Invalid symbol
Error Details:
Symbol BSC is not supported by token contract bcskillsurou

但使用push action

cleos -u https://dev-api-chain.valicn.com push action bcskillsurou transfer '["bcskillsurou", "xxxxxxxxxxxx","100000000.0000 BSC","vote"]' -p bcskillsurou

是发送正常的.说明问题判断条件不在合约.

查看cleos代码
问题代码所在(cleos/main.cpp)
因为cleos 执行transfer时会先执行rpc get_currency_stats_func,拿到代币的精度,然后补齐.但默认是从系统主代币token合约(eosio.token)获取,如果是自定义合约的话,需要单独参数(["--contract,-c"](https://github.com/EOSIO/eos/blob/448287d520f5f8c282139ecc60f227c218d42e82/programs/cleos/main.cpp#L3033 ""--contract,-c""))指定.
所以正确的transfer 命令为

cleos -u  https://www.bcskill.com transfer bcskillsurou xxxxxxxxxxxx "10 BSC" -c bcskillsurou

"RdKafka::rdkafka" but the target was not found

今天看到BOS更新了PBFT 3s进LIB的release 3.0版本,编译试试,遇到以下问题

CMake Error at plugins/kafka_plugin/CMakeLists.txt:2 (add_library):
Target "kafka_plugin" links to target "RdKafka::rdkafka" but the target was
not found. Perhaps a find_package() call is missing for an IMPORTED
target, or an ALIAS target is missing?

CMake Error at programs/nodeos/CMakeLists.txt:1 (add_executable):
Target "nodeos" links to target "RdKafka::rdkafka" but the target was not
found. Perhaps a find_package() call is missing for an IMPORTED target, or
an ALIAS target is missing?

解决方案

删除/usr/local/include/cppkafka , /usr/local/include/librdkafka两个目录
重新开始bos编译(会自动下载安装适配的kafka版本)

参考

https://github.com/boscore/bos/issues/37
https://github.com/boscore/bos/tree/master/plugins/kafka_plugin

get_block_header_state Error 3200006: invalid http request

surou@DESKTOP-444S803:/mnt/c/Users/Surou$ cleos -u https://api.eosnewyork.io:443 get block --header-state 56529797
Error 3200006: invalid http request
Error Details:
The server has rejected the request as invalid!
Please verify this url is valid: https://api.eosnewyork.io:443/v1/chain/get_block_header_state
If the condition persists, please contact the RPC server administrator for api.eosnewyork.io!

意思是只能查看未被确认的区块头信息,可以先get info下,查看下未被确认的块,然后再查下

surou@DESKTOP-444S803:/mnt/c/Users/Surou$ cleos -u https://api.eosnewyork.io:443 get block --header-state 56530363
{
  "id": "035e95bbad1f6416a3ec1941fa80cac5033a0ef23d8b2c353aab780a7a14924f",
  "block_num": 56530363,
  "header": {
    "timestamp": "2019-05-05T10:11:06.500",
    "producer": "eossv12eossv",
    "confirmed": 0,
    "previous": "035e95ba91496b25ee9838a880c58e0a74d3926ae08ab427b12f97982d859487",
    "transaction_mroot": "14775b6209578bcf6e5e0a96dbefe10a2de85c7c462ba6598f8cfe97478a246d",
    "action_mroot": "92c989a247da29209e2070c18f9fb906e78bb644179882a546ba5f6d969b7e95",
    "schedule_version": 810,
    "header_extensions": [],
    "producer_signature": "SIG_K1_K3GYP3PMPKG35ezgMoyzq1Jwe4QtkhPPzkdo86GLkaiSWCpPyEhKLqsiSdB4sVjze4ZDa2G2nTMeFumuQ3WoLo3NZ8vhgn"
  },
  "dpos_proposed_irreversible_blocknum": 56530205,
  "dpos_irreversible_blocknum": 56530037,
  "bft_irreversible_blocknum": 0,
  "pending_schedule_lib_num": 56179346,
  "pending_schedule_hash": "92fda11e5856b17176368caa18db5e88c169d5e35f44b8292e53003bc91dfb08",
  "pending_schedule": {
    "version": 810,
    "producers": []
  },
  "active_schedule": {

参考地址:https://github.com/EOSIO/eos/issues/4485

recipe for target 'all' failed appbase_version

详细错误如下

[  6%] Built target chainbase
fatal: No names found, cannot describe anything.
CMake Error at version.cmake:11 (message):
  git describe failed


libraries/appbase/CMakeFiles/appbase_version.dir/build.make:57: recipe for target 'libraries/appbase/CMakeFiles/appbase_version' failed
make[2]: *** [libraries/appbase/CMakeFiles/appbase_version] Error 1
CMakeFiles/Makefile2:1746: recipe for target 'libraries/appbase/CMakeFiles/appbase_version.dir/all' failed
make[1]: *** [libraries/appbase/CMakeFiles/appbase_version.dir/all] Error 2
make[1]: *** Waiting for unfinished jobs....
[ 29%] Built target softfloat
[ 31%] Built target libc++
[ 35%] Built target fc
Makefile:162: recipe for target 'all' failed
make: *** [all] Error 2

    >>>>>>>>>>>>>>>>>>>> MAKE building EOSIO has exited with the above error.

解决方案
由于当时是直接复制的项目,所以没有tag。(CMakeLists.txt)编译时至少需要有一个tag,appbase会以最新的tag作为版本信息。
最终会写入 build\libraries\appbase\version.cpp 中
所以新建一个tag就好了
参考:https://github.com/EOSIO/eos/issues/5345