Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Utility to estimate RAM #67

Open
jafri opened this issue Jul 1, 2022 · 4 comments
Open

Utility to estimate RAM #67

jafri opened this issue Jul 1, 2022 · 4 comments

Comments

@jafri
Copy link
Collaborator

jafri commented Jul 1, 2022

Would be interesting to be able to estimate on-chain RAM bytes size from Packer+Table

@learnforpractice
Copy link
Contributor

learnforpractice commented Jul 1, 2022

The following code may help measuring ram usage:

test_account = 'hello'
args = {
    'payer': test_account,
    'receiver': test_account,
    'bytes': 1024*1024*2,
}
chain.push_action('eosio', 'buyrambytes', args, {test_account: 'active'})

info = chain.api.get_account('hello')
before = info['ram_usage']

args = dict()
r = chain.push_action('hello', 'testmi2', args, {'hello': 'active'})

info = chain.api.get_account('hello')
after = info['ram_usage']
logger.error('ram usage by action: %s', after - before)

@jafri
Copy link
Collaborator Author

jafri commented Jul 1, 2022

Right, I mean measuring how much RAM a table row would take inside the contract itself, to automatically buy that much RAM

@learnforpractice
Copy link
Contributor

The ram costs by store a value in a table the first time is much more than other times.

So it need a test I think.

@jafri
Copy link
Collaborator Author

jafri commented Jul 2, 2022

The first time extra cost is because of the scope creation I believe

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants