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

Increase the cost of storage opcodes by the gas per byte fee in addition to the execution cost #602

Closed
xgreenx opened this issue Oct 5, 2023 · 0 comments · Fixed by #634
Assignees

Comments

@xgreenx
Copy link
Collaborator

xgreenx commented Oct 5, 2023

Problem overview

Some opcodes store data in storage, allowing the user to blow up the footprint.

Solution

The solution is to charge the user for the storage in addition to the execution. Because multi-dimensional resources require much adoption work, we will charge the user in terms of additional gas for now.

While we work on FuelLabs/fuel-core#1404 to find what value we need to charge, we also need to update opcodes and benchmarks to use gas_per_byte.

Implementation details

We need to find all opcodes that modify the storage first. For that, we can find all places where we use methods from the InterpreterStorage trait.
It's okay to charge the user for deploy_contract_with_id, because we store the contract's bytecode in two tables(transactions and contracts).
We need to charge the user only for adding new information. If the user overrides the already existing value, we only need to charge for newly added bytes(so if the size of the final value is the same or less, we don't charge).

Note

Inserting a new K/V into a state or asset into balances also has Sparse Merkle Tree storage overhead. You don't need to worry about that right now. Maybe later, we will have a separate functionality that charges for this overhead.

As a temporary solution, we may try to include this into gas_per_byte.

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

Successfully merging a pull request may close this issue.

2 participants