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

Support retrieving storage growth of block/transaction #3038

Open
crystalin opened this issue Nov 9, 2024 · 2 comments
Open

Support retrieving storage growth of block/transaction #3038

crystalin opened this issue Nov 9, 2024 · 2 comments

Comments

@crystalin
Copy link
Collaborator

[Feature request]
What is an easy way to retrieve the storage growth (related to MBIP5) of a given block or transaction ?

@RomarQ
Copy link
Contributor

RomarQ commented Nov 9, 2024

@noandrea created an excel where we can check the MBIP5 behaviour.

For example, in this transaction, the PoV cost was higher than the standard evm execution.

image

let WEIGHT_TO_GAS_RATIO = 25_000;
let GAS_LIMIT_STORAGE_GROWTH_RATIO = 366;
let GAS_PER_POV_BYTES = 8;

let transaction_proof_size = 234669; // can be obtained from polkadot.js
let transaction_ref_time = 46933800000; // can be obtained from polkadot.js
let gas_by_ref_time = transaction_ref_time / WEIGHT_TO_GAS_RATIO; // 1_877_352

// curl -H "Content-Type: application/json" -d '{"jsonrpc": "2.0", "method":"debug_traceTransaction","params":["0x279f4c7fa5cf7f1920dcdcacd48e3782931bc833e1637762e597f7b7ff07ad90",{"tracer":"callTracer"}]}' https://trace.api.moonbeam.network
let gas_used = 310_489; // Obtained from tracing the transaction;

let bytes_used = if (gas_by_ref_time != gas_used) {
   gas_by_ref_time / GAS_LIMIT_STORAGE_GROWTH_RATIO // 5_129
} else { 0 };

let pov = transaction_proof_size * GAS_PER_POV_BYTES;
let mbip5 = bytes_used * GAS_LIMIT_STORAGE_GROWTH_RATIO;

let effective_gas = max(gas_used, max(mbip5, pov));

@crystalin
Copy link
Collaborator Author

crystalin commented Nov 9, 2024

Thank you @RomarQ but I don't think it works. This only reports the "extra" storage that is not covered by the gas paid for the transaction.
Ex:
If a transaction cost 100k gas of computation and has 100B storage used, it will appear as 100k gas used (because 100B cost < 100k gas)

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