Marketplace RAM use analysis
Summary --
RAM usage was examined from a high level perspective to try to understand if the RAM bumps used In the marketplace actions are adequate.
Pending Work Required to complete RAM analysis for release--
Code needs to be added to list domain, and set marketplace config, calls and tests need to be run to record the memory used by each call.
Limitations --
No code was added to the actions (no tests were run) to determine actual memory use of each call.
listdomain Action
Parameters —
name &actor
string &fio_domain
uint64_t &sale_price
uint64_t &max_fee
string &tpid
Tables affected —
Owner of domain updated in domains table (fio.address) no RAM impact.
Entry added into domain sales containing
d.id
d.owner
d.ownerhash
d.domain
d.domainhash
d.sale_price
d.commission_fee
d.date_listed
d.date_updated
d.status
Recommendation — Since a record containing the above data is added to a table. Consider to increase RAM bump on this command from the present 512 which seems in-adequate, Add print statements and get the TX size, (1.5 X this for the RAM bump)…
RAM Analysis by Thomas
I used cryptonym to execute a transaction and looked at the "account_ram_delta"
key
"account_ram_deltas": [
{
"account": "wjeo4abnk4c2",
"delta": 755
}
],
Based on this output the account wjeo4abnk4c2
requires 755 bytes of RAM. Using the standard formula of usage x 1.5 I am increasing the ram by 1140
bytes rounding up a little from 755x1.5.
cxlistdomain Action
Parameters —
name &actor,
string &fio_domain,
int64_t &max_fee,
string &tpid
Tables updated
Domain sales status updated to “cancelled”.
Recommendation — reduce RAM bump to be 256 on this call.
RAM Analysis by Thomas
Looking at the "account_ram_deltas"
from the tx response of cxlistdomain:
"account_ram_deltas": [
{
"account": "fio.escrow",
"delta": 463
},
{
"account": "wjeo4abnk4c2",
"delta": -463
}
],
This removes the RAM from the user account and increases on fio.escrow
so it seems like no RAM bump is required at all.
buydomain Action
Parameters —
name &actor, const int64_t &sale_id,
string &fio_domain, const int64_t &max_buy_price,
int64_t &max_fee, const string &tpid
Tables updated
Domain sales status updated to “sold”.
Recommendation — reduce RAM bump to be 256 on this call.
Ram Analysis by Thomas
Similar to cxlistdoman ram usage is removed from the user and added to the fio.escrow account:
"account_ram_deltas": [
{
"account": "fio.escrow",
"delta": 466
},
{
"account": "wjeo4abnk4c2",
"delta": -466
}
],
Set Marketplace config (setmrkplcfg) Action
Tables updated
mrkplconfigs row added
row.id
row.owner = actor.value;
row.ownerhash = ownerHash;
row.commission_fee = commission_fee;
row.listing_fee = listing_fee;
row.e_break = e_break;
Recommendation — increase RAM bump on this command from the present 512 which seems in-adequate, Add print statements and get the TX size, (1.5 X this for the RAM bump)…
RAM Analysis by Thomas
When looking at the response object of a setmrkplcfg
action, there are no ram_deltas even though I am changing settings.
cxburned action
Only called by a FIO system contract (with unlimited resources) no ram bump needed….
Summary of RAM use analysis for marketplace --
IT is recommended that RAM bumps be modified as indicated in this document, tests that verify RAM bumps should also be modified and performed again after these changes are made.
estimated time to implement findings --
1 day for dev (including print statements and recording of actual RAM use for indicated calls) and PR into develop
1 day for QA testing .