EOS发起交易时,提示ram,net或cpu资源不足问题分析与解决(Error 3080001: account using more than allotted RAM usage)
一般创建账号,或者三方购买的账号都是最低的资源创建的 (cleos system newaccount 消耗最少的EOS资源)
基本账号下CPU和NET都是零,RAM 3kb以下,因为RAM收费逻辑(EOS零手续费免费?你不知道的EOS收费细节)
- 只要action中执行了持久化存储相关的逻辑就需要收取ram使用费,比如系统合约的newaccount ,updateauth, setcode, setabi, schedule_deferred_transaction, eosio.token的transfer
所以在账号资源不足的情况下,转账操作会提示以下错误
surou@surou-C-H110M-K-Pro:~/.local/share/eosio/nodeos/config$ cleos push action eosio.token transfer '["eosio", "bcskillsurou","100.0000 EOS","vote"]' -p eosio
executed transaction: e233ccc335b833ac9d7746a43e3b4e591795151c95f989a36976f8ceb98a08c7 136 bytes 562 us
# eosio.token <= eosio.token::transfer {"from":"eosio","to":"bcskillsurou","quantity":"100.0000 EOS","memo":"vote"}
# eosio <= eosio.token::transfer {"from":"eosio","to":"bcskillsurou","quantity":"100.0000 EOS","memo":"vote"}
# bcskillsurou <= eosio.token::transfer {"from":"eosio","to":"bcskillsurou","quantity":"100.0000 EOS","memo":"vote"}
warning: transaction executed locally, but may not be confirmed by the network yet
surou@surou-C-H110M-K-Pro:~/.local/share/eosio/nodeos/config$ cleos get currency balance eosio.token bcskillsurou
100.0000 EOS
surou@surou-C-H110M-K-Pro:~/.local/share/eosio/nodeos/config$ cleos push action eosio.token transfer '["bcskillsurou", "eosio","1.0000 EOS","vote"]' -p bcskillsurou
Error 3080001: account using more than allotted RAM usage
提示RAM不足已支持转账
如果自己给自己直接购买RAM的话
surou@surou-C-H110M-K-Pro:~/.local/share/eosio/nodeos/config$ cleos system buyram bcskillsurou bcskillsurou "0.1000 EOS"
3536793ms thread-0 main.cpp:429 create_action ] result: {"binargs":"a0e9d5384607313aa0e9d5384607313ae80300000000000004454f5300000000"} arg: {"code":"eosio","action":"buyram","args":{"payer":"bcskillsurou","receiver":"bcskillsurou","quant":"0.1000 EOS"}}
Error 3080002: transaction exceeded the current network usage limit imposed on the transaction
提示NET不足
如果自己给自己抵押换取NET和CPU时
surou@surou-C-H110M-K-Pro:~/.local/share/eosio/nodeos/config$ cleos system delegatebw bcskillsurou bcskillsurou '0.1000 EOS' '0.1000 EOS' -p bcskillsurou
48402ms thread-0 main.cpp:1084 operator() ] act_payload: {"from":"bcskillsurou","receiver":"bcskillsurou","stake_net_quantity":"0.1000 EOS","stake_cpu_quantity":"0.1000 EOS","transfer":false}
48403ms thread-0 main.cpp:429 create_action ] result: {"binargs":"a0e9d5384607313aa0e9d5384607313ae80300000000000004454f5300000000e80300000000000004454f530000000000"} arg: {"code":"eosio","action":"delegatebw","args":{"from":"bcskillsurou","receiver":"bcskillsurou","stake_net_quantity":"0.1000 EOS","stake_cpu_quantity":"0.1000 EOS","transfer":false}}
Error 3080001: account using more than allotted RAM usage
又提示RAM不足...先有鸡还是先有蛋,死循环。所以只能让其他RAM资源充足的账号例如 eosio
帮此账号bcskillsurou
购买
surou@surou-C-H110M-K-Pro:~/.local/share/eosio/nodeos/config$ cleos system buyram eosio bcskillsurou "0.1000 EOS"
177473ms thread-0 main.cpp:429 create_action ] result: {"binargs":"0000000000ea3055a0e9d5384607313ae80300000000000004454f5300000000"} arg: {"code":"eosio","action":"buyram","args":{"payer":"eosio","receiver":"bcskillsurou","quant":"0.1000 EOS"}}
executed transaction: f5aa4dd7f6a850b65884174a4f86285414ca5c50ba1ab6ddc2a7f9ba5b65c051 128 bytes 1814 us
# eosio <= eosio::buyram {"payer":"eosio","receiver":"bcskillsurou","quant":"0.1000 EOS"}
# eosio.token <= eosio.token::transfer {"from":"eosio","to":"eosio.ram","quantity":"0.0995 EOS","memo":"buy ram"}
# eosio <= eosio.token::transfer {"from":"eosio","to":"eosio.ram","quantity":"0.0995 EOS","memo":"buy ram"}
# eosio.ram <= eosio.token::transfer {"from":"eosio","to":"eosio.ram","quantity":"0.0995 EOS","memo":"buy ram"}
# eosio.token <= eosio.token::transfer {"from":"eosio","to":"eosio.ramfee","quantity":"0.0005 EOS","memo":"ram fee"}
# eosio <= eosio.token::transfer {"from":"eosio","to":"eosio.ramfee","quantity":"0.0005 EOS","memo":"ram fee"}
# eosio.ramfee <= eosio.token::transfer {"from":"eosio","to":"eosio.ramfee","quantity":"0.0005 EOS","memo":"ram fee"}
warning: transaction executed locally, but may not be confirmed by the network yet
当bcskillsurou
RAM足够后,就可以自己或者其他账号抵押购买CPU和NET了
surou@surou-C-H110M-K-Pro:~/.local/share/eosio/nodeos/config$ cleos system delegatebw bcskillsurou bcskillsurou '0.1000 EOS' '0.1000 EOS' -p bcskillsurou
214840ms thread-0 main.cpp:1084 operator() ] act_payload: {"from":"bcskillsurou","receiver":"bcskillsurou","stake_net_quantity":"0.1000 EOS","stake_cpu_quantity":"0.1000 EOS","transfer":false}
214841ms thread-0 main.cpp:429 create_action ] result: {"binargs":"a0e9d5384607313aa0e9d5384607313ae80300000000000004454f5300000000e80300000000000004454f530000000000"} arg: {"code":"eosio","action":"delegatebw","args":{"from":"bcskillsurou","receiver":"bcskillsurou","stake_net_quantity":"0.1000 EOS","stake_cpu_quantity":"0.1000 EOS","transfer":false}}
executed transaction: b57bad80a397c6fee9aab0519600b9c063f6084fadd542402fe07ce93d2643bb 144 bytes 1720 us
# eosio <= eosio::delegatebw {"from":"bcskillsurou","receiver":"bcskillsurou","stake_net_quantity":"0.1000 EOS","stake_cpu_quanti...
# eosio.token <= eosio.token::transfer {"from":"bcskillsurou","to":"eosio.stake","quantity":"0.2000 EOS","memo":"stake bandwidth"}
# bcskillsurou <= eosio.token::transfer {"from":"bcskillsurou","to":"eosio.stake","quantity":"0.2000 EOS","memo":"stake bandwidth"}
# eosio.stake <= eosio.token::transfer {"from":"bcskillsurou","to":"eosio.stake","quantity":"0.2000 EOS","memo":"stake bandwidth"}
warning: transaction executed locally, but may not be confirmed by the network yet
此时再次转账的话
surou@surou-C-H110M-K-Pro:~/.local/share/eosio/nodeos/config$ cleos get currency balance eosio.token bcskillsurou
99.8000 EOS
surou@surou-C-H110M-K-Pro:~/.local/share/eosio/nodeos/config$ cleos push action eosio.token transfer '["bcskillsurou", "eosio","1.0000 EOS","vote"]' -p bcskillsurou
executed transaction: cd9a0780b51db71a0efd096578dc453d26a528af6fa4e4e7ab0b139e9d9753ae 136 bytes 548 us
# eosio.token <= eosio.token::transfer {"from":"bcskillsurou","to":"eosio","quantity":"1.0000 EOS","memo":"vote"}
# bcskillsurou <= eosio.token::transfer {"from":"bcskillsurou","to":"eosio","quantity":"1.0000 EOS","memo":"vote"}
# eosio <= eosio.token::transfer {"from":"bcskillsurou","to":"eosio","quantity":"1.0000 EOS","memo":"vote"}
warning: transaction executed locally, but may not be confirmed by the network yet
surou@surou-C-H110M-K-Pro:~/.local/share/eosio/nodeos/config$ cleos get currency balance eosio.token bcskillsurou
98.8000 EOS
就一切OK了
cleos system newaccount 消耗最少的EOS资源
surou@surou-C-H110M-K-Pro:~/.local/share/eosio/nodeos/config$ cleos system newaccount eosio bcskillsurou EOS7uvrLaTGsRH8BujfjjjJChXLzZhUQqbvTasoN1rFvGJD68kJf9 EOS7uvrLaTGsRH8BujfjjjJChXLzZhUQqbvTasoN1rFvGJD68kJf9 --stake-net '0.00 EOS' --stake-cpu '0.00 EOS' --buy-ram-kbytes 3
2341780ms thread-0 main.cpp:429 create_action ] result: {"binargs":"0000000000ea3055a0e9d5384607313a000c0000"} arg: {"code":"eosio","action":"buyrambytes","args":{"payer":"eosio","receiver":"bcskillsurou","bytes":3072}}
executed transaction: 0a582d07bde12299a178b066aed6489ea3abc6a5369f2d48afe79f96b7f9512e 248 bytes 2182 us
# eosio <= eosio::newaccount {"creator":"eosio","name":"bcskillsurou","owner":{"threshold":1,"keys":[{"key":"EOS7uvrLaTGsRH8Bujfj...
# eosio <= eosio::buyrambytes {"payer":"eosio","receiver":"bcskillsurou","bytes":3072}
# eosio.token <= eosio.token::transfer {"from":"eosio","to":"eosio.ram","quantity":"0.4573 EOS","memo":"buy ram"}
# eosio <= eosio.token::transfer {"from":"eosio","to":"eosio.ram","quantity":"0.4573 EOS","memo":"buy ram"}
# eosio.ram <= eosio.token::transfer {"from":"eosio","to":"eosio.ram","quantity":"0.4573 EOS","memo":"buy ram"}
# eosio.token <= eosio.token::transfer {"from":"eosio","to":"eosio.ramfee","quantity":"0.0023 EOS","memo":"ram fee"}
# eosio <= eosio.token::transfer {"from":"eosio","to":"eosio.ramfee","quantity":"0.0023 EOS","memo":"ram fee"}
# eosio.ramfee <= eosio.token::transfer {"from":"eosio","to":"eosio.ramfee","quantity":"0.0023 EOS","memo":"ram fee"}
warning: transaction executed locally, but may not be confirmed by the network yet
surou@surou-C-H110M-K-Pro:~/.local/share/eosio/nodeos/config$ cleos get account bcskillsurou
permissions:
owner 1: 1 EOS7uvrLaTGsRH8BujfjjjJChXLzZhUQqbvTasoN1rFvGJD68kJf9
active 1: 1 EOS7uvrLaTGsRH8BujfjjjJChXLzZhUQqbvTasoN1rFvGJD68kJf9
memory:
quota: 2.982 KiB used: 2.926 KiB
net bandwidth:
delegated: 0.0000 EOS (total staked delegated to account from others)
used: 0 bytes
available: 0 bytes
limit: 0 bytes
cpu bandwidth:
delegated: 0.0000 EOS (total staked delegated to account from others)
used: 0 us
available: 0 us
limit: 0 us
最少需要RAM 3kb,具体等于多少EOS需要根据当前RAM的价格来定
EOS enable mongodb
git clone -b release/1.1 https://github.com/EOSIO/eos.git
cd eos
git fetch –all –tags –prune
git merge -m “merge” –commit origin/gh#3030-enable-mongodb
git submodule update –init –recursive
./eosio_build.sh
cd build
make install
修改config.ini配置文件,添加如下两行:
plugin = eosio::mongo_db_plugin
mongodb-uri = mongodb://localhost:27017/eosmain
其中,eosmain是要写入的MongoDB数据库名。
好了,万事俱备,开始启动
进入~/opt/mongodb/bin目录,启动MongoDB服务。
cd ~/opt/mongodb/bin
./mongod
这时MongoDB服务会默认监听27017端口,如下图所示。
新开一个小窗,重启nodeos,需要加上–replay-blockchain,以使历史交易数据同步到MongoDB。
如果没有意外的话,此时MongoDB应该开始写入相关记录了。
执行mongo程序进入MongoDB控制台,查询相应数据库和记录,如下图。
参考:github issues eosdata.io
EOS 1.1.0 版本以上请参考 https://www.bcskill.com/index.php/archives/290.html
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