More Resource on EOS Mainnet with ONE-LINE Code Change
Background
As EOS dapps gaining more and more traction and usage, we see a surging demand of EOS resources such as CPU, NET and RAM.
And that's why EOSLaoMao team decided to build Bank of Staked, an EOS resource (CPU&NET) vending machine, to lower the resource cost of both EOS developers and users.
While we building Bank of Staked, we have taken detailed examinations and tests to system contract(eosio.system). Things like customizing refund duration from 3 days to 1 minute to test auto-refund functionality for Bank of Staked.
The unstaking EOS
Reusing Feature
During this process, we(and many others) have found a behavior or a feature that current system contract provides:
If you use delegatebw
to stake for yourself, it will reuse unstaking EOS
(EOS that will auto refund to your account in 3 days) to stake for your account first. It will use EOS in your balance
only if unstaking EOS
is inadequate for your staking operation.
Lets see an example:
Say we have an EOS account eoslaomaocom
with 200 EOS in balance
and another 300 EOS unstaking
, something like this:
$ cleos get account eoslaomaocom
EOS balances:
liquid: 200.0000 EOS
staked: 0.0000 EOS
unstaking: 300.0000 EOS
total: 500.0000 EOS
Now lets stake 400 EOS
for CPU to eoslaomaocom
:
cleos system delegatebw eoslaomaocom eoslaomaocom "0 EOS" "400 EOS"
Here is the output we gonna get:
executed transaction: xxxxxxxxxxxxxxxx 144 bytes 893 us
# eosio <= eosio::delegatebw {"from":"eoslaomaocom","receiver":"eoslaomaocom","stake_net_quantity":"0.0000 EOS","stake_cpu_quantity":"400.0000 EOS", "transfer": 0}
# eosio.token <= eosio.token::transfer {"from":"eoslaomaocom","to":"eosio.stake","quantity":"100.0000 EOS","memo":"stake bandwidth"}
# voter1 <= eosio.token::transfer {"from":"eoslaomaocom","to":"eosio.stake","quantity":"100.0000 EOS","memo":"stake bandwidth"}
# eosio.stake <= eosio.token::transfer {"from":"eoslaomaocom","to":"eosio.stake","quantity":"100.0000 EOS","memo":"stake bandwidth"}
And here is the final state of account eoslaomaocom
:
$ cleos get account eoslaomaocom
EOS balances:
liquid: 100.0000 EOS
staked: 400.0000 EOS
unstaking: 0.0000 EOS
total: 500.0000 EOS
As we can see, it reused unstaking EOS
first, which has 300 EOS, then the other 100 EOS was transferred from account balance.
This is a pretty great feature, which allows everyone to reuse their unstaking EOS
instead of waiting for 3 days. That means users are not subject to
this 3 days refunding period in terms of EOS resource.
The sad news is, this unstaking EOS
reusing feature only applies when you are trying to stake to yourself. If the beneficiary is others, it will use EOS in your balance only.
And here is the actual code of this feature and limit: eosio.system/src/delegate_bandwidth.cpp
ONE-LINE Code Change to Enable Staking unstaking EOS
to Others
We have changed this feature to apply to other beneficiaries instead of limiting to the account itself.
And here is this simple ONE-LINE Code Change of system contracts:
eosio.system/src/delegate_bandwidth.cpp code diff
We have did a thorough test of this change on our local testnet, it worked as expected. We are planning to test it on CryptoKylin test pretty soon. And we are happy to hear feedbacks of your test results.
If further tests and discussions are all good, we are looking to submit a PR to deploy this change to EOS Mainnet.
We believe this change will release more resource to EOS Mainnet and lower the resource cost eventually, or at least in a short term.
by EOSLaoMao Tech Team.