EIPs/EIPS/eip-3322.md
Pandapip1 9e393a79d9
Force usage of included LICENSE file (#5055)
* Include LICENCE in the Jekyll build

* Replace old licence link with new and improved licence link

* Add note to EIP-1 mandating the new link

* Maybe this fixes it?

* Rename LICENCE so that jekyll picks it up

* Add original LICENCE file back

* Delete the markdown file

* Add Jekyll header

Hopefully the tooling still detects it as CC0

* Remove Jekyll header

* Maybe this will trick Jekyll and satisfy github?

* Remove config changes

* Enable incremental build

* Will it work if I rename it?

* I'll just paste the content of the licence into the file...

* Perhaps this will work

* Replace the licence file

* Fix false positive

Co-authored-by: Micah Zoltu <micah@zoltu.net>

* Resolve feedback

* Perhaps this might work

* It didn't work

This reverts commit 55116e15168fb20ae57dea97388bb260c0941465.

* Will licencee still detect this correctly?

* Jekyll Preamble in licence file

* Include it?

* Licence -> License, get rid of CC0.md

* Force wording of copyright waiver

* Formatting consistent with the rest of the list

* Spelling

* Escape

* Task failed successfully

* Fix two more links

* Will this render it?

* Perhaps this will work too

* .md essential

* Fix the issues Micah noted

Co-authored-by: Micah Zoltu <micah@zoltu.net>
2022-05-06 00:29:09 -07:00

2.8 KiB

eip title author discussions-to status type category created
3322 Account gas storage opcodes William Morriss (@wjmelements) https://ethereum-magicians.org/t/eip-3322-efficient-gas-storage/5470 Stagnant Standards Track Core 2020-03-04

Simple Summary

Allows contract accounts to store gas that can be transferred to the refund counter.

Abstract

Contracts can persist gas for later transfer to the refund counter. Three opcodes are introduced to read, add to, and use this gas counter.

Motivation

The refund mechanism is currently being used by gas tokens to arbitrage gas price. This brings gas supply elasticity and price stability by moving gas from blocks with less demand to blocks with more demand. Unfortunately this rewards unnecessary state growth. By introducing a superior gas storage mechanism, the gas market will require less storage and computation.

Specification

Contract accounts gain an unsigned gas refund counter, initially zero.

Three new opcodes are introduced to manage this state.

  • SELFGAS (0x49): Pushes the current account's gas refund counter onto the stack. Shares gas pricing with SELFBALANCE.
  • USEGAS (0x4a): Pops amount from the stack. The minimum of amount and the current account's gas refund counter is transferred to the execution context's refund counter. Costs 5000 gas.
  • STOREGAS (0x4b): Pops amount from the stack. Costs 5000 + amount gas. Increases the current account's gas refund counter by amount.

Rationale

By reusing the execution context's refund counter we can reuse its 50% DoS protection, which limits its block elasticity contribution to 2x.

The gas costs are based on similar opcodes SELFBALANCE and SSTORE.

Most accounts will store no gas, so the per-account storage overhead should be minimal or even zero in the normal case.

The opcode numbers chosen are in the same 0x4X range as SELFBALANCE and GASLIMIT.

Backwards Compatibility

Because the gas is added to the refund counter, no compatibility issues are anticipated.

Test Cases

Code Used Gas Refund Original Final
0x60004900 5003 0 0 0
0x60034900 5003 2 2 0
0x60034900 5003 3 3 0
0x60034900 5003 3 4 1
0x60034960034900 10006 4 4 0
0x60034960034900 10006 6 6 0
0x484900 5010 100000 100000 0
0x61ffff4a00 70538 0 0 65535

Security Considerations

DoS is already limited by the 50% refund limit.

Copyright and related rights waived via CC0.