Skip to content

Storage deposit refunds not working happening in sub frame #213

@TorstenStueber

Description

@TorstenStueber

Assume a contract whose storage is empty. If a frame A sets a storage slot in this contract and then calls another frame B for the same contract that then clears that storage slot, then the origin will not get the refund.

The reason is that the any changes in contract storage is first stored in the storage meter of the frame and is only copied over to the ContractInfo of a particular contract when the frame returns.

That means that the ContractInfo used for frame B still indicates that the complete storage of the contract is empty and the refund is calculated to be zero.

Possible Solution

We could call update_contract in the storage meter not just when a frame ends but also when a frame calls another frame. However, we would be need to be very careful and ensure that the ContractInfo is then also correctly copied to subsequent frames, i.e., we would need to store it in AccountInfoOf but do it in a way that works correctly with reverting frames.

Tests

The tests max_consumed_deposit_integration_refunds_subframes check whether this works correctly.

Metadata

Metadata

Assignees

Labels

EVMProblem occurs at the execution stage for EVMPVMProblem occurs at the execution stage for PVMerror: gasgas mapping issue

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions