-
Notifications
You must be signed in to change notification settings - Fork 2
Description
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.