aptos-core icon indicating copy to clipboard operation
aptos-core copied to clipboard

[Bug] Gas schedule disincentivizes global storage deallocation

Open alnoki opened this issue 3 years ago • 3 comments

Presently, storage_gas.move charges for creating, reading, and overwriting items in global storage, but offers no refund, rebate, etc. for deallocation. Similarly, instr.rs charges for move_from() operations and borrow operations. Hence:

  • Users are strictly charged for deallocating table entries,
  • Users are strictly charged for deallocating vector elements, including options, and
  • Users are strictly charged for deallocating resources having the key attribute,

Which means that a rational economic actor will never deallocate from global storage.

@lightmark @vgao1996 @davidiw @wrwg @CapCap @chen-robert @runtian-zhou

alnoki avatar Sep 29 '22 00:09 alnoki

@msmouse

grao1991 avatar Sep 29 '22 00:09 grao1991

Yeah I agree with you in principle. Been wondering if we can at least set the gas costs of move_from to 0, but still need to think a little bit harder about potential attack vectors.

vgao1996 avatar Sep 30 '22 23:09 vgao1996

Summary of our follow-up discussion from yesterday:

Refunding storage costs to the extent of negative gas fees introduces:

  1. Inflationary events: if enough storage were to be freed up, then the result would be a negative gas cost on the transaction, which would require the generation of new APT.
  2. Land grab incentivization: if storage costs increase with utilization, the rational economic actor will buy storage when cheap then sell it back once utilization has hit a threshold.

Hence paying out negative transaction fees is impractical.

Refunding storage costs to the point where transaction gas drops to 0 is practical, however, because actors are incentivized to free storage, as it may diminish the cost per transaction to 0. E.g. move_from<T>() pays a rebate of 100 gas, for instance, but if the transaction would otherwise only cost 80 gas, the transaction cost simply becomes 0 rather than -20.

Notably, this incentive may result in amortized deallocations: if an actor will get a rebate of 2000 total, they will save more by deallocating over the course of 5 transactions that would otherwise cost 400 gas units, rather than during one transaction that would otherwise cost 600 gas units.

alnoki avatar Oct 01 '22 18:10 alnoki

This issue is stale because it has been open 45 days with no activity. Remove the stale label or comment - otherwise this will be closed in 15 days.

github-actions[bot] avatar Dec 23 '22 01:12 github-actions[bot]

We have these high level efforts road mapped wrt gas costs https://medium.com/aptoslabs/the-path-to-10x-lower-gas-fees-on-aptos-with-community-driven-feedback-7cca875a513f And details for storage specifically will come out in the coming months.

msmouse avatar Jan 06 '23 01:01 msmouse