EOSIO / eosio.system

Reference system contract for an EOSIO based chain
MIT License
9 stars 6 forks source link

eosio::buyrambytes doesn't provide the exact amount requested #30

Open aaroncox opened 3 years ago

aaroncox commented 3 years ago

We recently discovered that when trying to buy precise amounts of RAM, the amount of RAM actually provided from eosio::buyrambytes is less than what was requested.

Based on the comment here, I assume the intention is to provide a precise way to purchase a specific amount of RAM:

https://github.com/EOSIO/eosio.contracts/blob/d7bc0a5cc8c0c2edd4dc61b0126517d0cb46fd94/contracts/eosio.system/src/delegate_bandwidth.cpp#L22-L25

This transaction:

https://bloks.io/transaction/44d1367ce6918fcff4c7b0ef8905aafc2aea0ce4f2e0730d32799fe01a84a004

{
  "account": "eosio",
  "name": "buyrambytes",
  "authorization": [
    {
      "actor": "test.gm",
      "permission": "active"
    }
  ],
  "data": {
    "bytes": 400,
    "payer": "test.gm",
    "receiver": "test.gm"
  }
}

Resulted in the purchase of 396 bytes of RAM. I am assuming this has to do both with the token precision (4,EOS) and potentially the 0.5% system fee from purchasing.

We very recently have begun systematically purchasing precise amounts of RAM for use as a Resource Provider (before and after account creation) and the inability to accurately purchase amounts of RAM has caused a few problems.

If there's an upcoming system contract upgrade that a fix for this could be included in - it would be appreciated!

deckb commented 3 years ago

Transferring to new repo.

Also found this little nugget.

https://github.com/EOSIO/eosio.system/blob/d7a897611cf7f947c19f37c77b93c7249204b1cd/tests/eosio.system_tests.cpp#L3810