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

Adjust all benchmark to charge the user properly based on the amount of work in worst scenario #1306

Closed
xgreenx opened this issue Aug 16, 2023 · 1 comment
Assignees

Comments

@xgreenx
Copy link
Collaborator

xgreenx commented Aug 16, 2023

After the audit report(and based on our observation and block_target_gas.rs benchmark) it is clear that many of our benchmarks are wildly inaccurate and undercharge user. It creates situations where the bad actor may send transactions consuming all available node resources and paying almost nothing.

Some of the benchmark doesn't use the worst possible scenario. Some of them don't take into account the arbitrary data. Some of them have been miswritten.

We must go through each opcode and think about the worst possible scenario. We added a new benchmark block_target_gas.rs, that runs the same opcode in the infinite loop. The idea is to write a benchmark with the worst case for each opcode. If our benchmarks are accurate enough, the average execution time per benchmark should be almost the same for the same block gas limit.

Setting the worst scenario requires knowing how some opcodes work inside. For example, the TR opcode updates the balance of the contract, but if the contract has 1M of asset entries, the insertion into the database causes modification of the Sparse Merkle tree that may be slow for 1M entries.

@xgreenx xgreenx self-assigned this Aug 16, 2023
@xgreenx xgreenx added the SDK team The issue is ready to be addressed by SDK team label Aug 16, 2023
@xgreenx xgreenx removed their assignment Aug 25, 2023
@xgreenx xgreenx removed the SDK team The issue is ready to be addressed by SDK team label Sep 28, 2023
@xgreenx
Copy link
Collaborator Author

xgreenx commented Nov 22, 2023

All sub-issues are resolved, closing this master issue=)

@xgreenx xgreenx closed this as completed Nov 22, 2023
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

3 participants