您正在查看: EOS 分类下的文章

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

EOS资源系统

EOS资源系统由RAM,CPU,NET组成。数据存储需要消耗RAM,账号交易需要使用CPU和NET。一个EOS账号创建的时候可以通过购买和抵押来获取资源,费用由主账号支付。如果创建账号时并未购买资源,则需要通过其他账号购买或者进行抵押,因为购买和抵押本身就是一种交易行为需要消耗资源。

RAM

RAM是运行时的内存。在EOSIO系统中,数据存储在区块链中要消耗该资源,是DApp开发时必须的资源。

RAM的交易方式
  1. RAM 的买卖,实质上是抵押 eos 到系统账户,而不是买方和卖方直接的交易。
  2. 不论是购买ram(即抵押eos,获取ram),还是卖出ram(即取回抵押的eos,释放ram),都是参与者与系统账户之间的交互,该过程将会收取1%的手续费。
  3. 买入RAM有两种计价方式: 买多少字节的RAM;买多少EOS的RAM。
  4. 卖出RAM只有一种方式:多少字节的RAM。
    RAM相关网站
  5. RMA价格实时查询:https://eosmeta.io/statisticsram,https://eos.feexplorer.io/
  6. RAM购买:https://eostoolkit.io/account/undelegate

NET 带宽

网络带宽以过去3天的平均消耗量为单位进行测量,单位是字节如KB。每次发送操作或事务时都会暂时消耗网络带宽,但随着时间的推移会减少到0。抵押的EOS越多,网络带宽可以使用得越多。 可以随时赎回EOS,但是有三天左右的赎回期。

CPU 带宽

CPU带宽以过去3天的平均消耗(以微秒ms为单位)来衡量。 当您发送操作或事务时,CPU带宽会暂时消耗,但随着时间的推移会减少到0。事务运行时间越长,它将消耗的CPU带宽就越多。 可以随时赎回EOS,但是有三天左右的赎回期。

三者区别

  1. RAM是自由市场买卖模式,由市场价格来决定。CPU、NET是抵押模式,抵押多少取消多少。
  2. RAM是随时可以交易,但CPU、NET有三天等待期。
  3. CPU和NET可用于出租给其他账户,取消抵押后,EOS可以回到自己的账户。RAM可帮助其他账户购买,但卖出时的EOS归其他账户所有。

资源操作

//账号资源查看
cleos get account ${account}

//${account1}为支付账号,${account2}获得账号
//ram购买
cleos system buyram ${account1} ${account2}  "0.0001 EOS" 
//ram销售,最多能售出的数量limit - used
cleos system sellram ${account1} 68718 -p ${account1}

//抵押EOS,获得CPU带宽和NET带宽
cleos system delegatebw ${account1} ${account2} '0.1000 EOS'  '0.1000 EOS'  -p ${account1}
//取消抵押
cleos system undelegatebw ${account1} ${account2} '1 EOS' '1 EOS' -p ${account1}

转载自:blockflow.net

EOS主网账户名交易

这里主要是要教会大家如果将自己公钥里面的账户名转给其他人。能转出给另外一个公钥就可以实现线下交易,线上转账户名了。
代码如下:

#转移active权限
cleos push action eosio updateauth '{"permission":"active","parent":"owner","account":"你要转移的帐号","auth": {"accounts": [], "waits": [], "keys": [{"key": "EOS开头的对方的公钥", "weight": 1}], "threshold": 1}}' -p 你要转移的帐号@active

#转移owner权限
cleos push action eosio updateauth '{"permission":"owner","parent":"","account":"你要转移的帐号","auth": {"accounts": [], "waits": [], "keys": [{"key": "EOS开头的对方的公钥", "weight": 1}], "threshold": 1}}' -p 你要转移的帐号@owner

如果是网络情况报错可能是没有连接上主网,则改为:
#转移active权限
cleos -u http://mainnet.eoswz.com push action eosio updateauth '{"permission":"active","parent":"owner","account":"你要转移的帐号","auth": {"accounts": [], "waits": [], "keys": [{"key": "EOS开头的对方的公钥", "weight": 1}], "threshold": 1}}' -p 你要转移的帐号@active

#转移owner权限
cleos -u http://mainnet.eoswz.com push action eosio updateauth '{"permission":"owner","parent":"","account":"你要转移的帐号","auth": {"accounts": [], "waits": [], "keys": [{"key": "EOS开头的对方的公钥", "weight": 1}], "threshold": 1}}' -p 你要转移的帐号@owner

注意!

这里可能会提示一些报错。例如:

#CPU不够
Error 3080004: transaction exceeded the current CPU usage limit imposed on the transaction
Error Details:
billed CPU time (574 us) is greater than the maximum billable CPU time for the transaction (0 us)
#.NET不够
Error 3080002: transaction exceeded the current network usage limit imposed on the transaction
Error Details:
net usage of transaction is too high: 160 > 0

这是因为你在建立这个账户名的时候,账户名下没有足够的资源导致。所以只需要其他有资源的账户给这个账户转入一些资源就可以了。