forked from ethereum/EIPs
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create BASEFEE opcode EIP (ethereum#3198)
Add a `BASEFEE (0x48)` that returns the value of the base fee of the current block it is executing in.
- Loading branch information
1 parent
b10b8fd
commit 8a05963
Showing
1 changed file
with
71 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
--- | ||
eip: 3198 | ||
title: BASEFEE opcode | ||
author: Abdelhamid Bakhta (@abdelhamidbakhta), Vitalik Buterin (@vbuterin) | ||
discussions-to: https://ethereum-magicians.org/t/eip-3198-basefeeopcode/5162 | ||
status: Draft | ||
type: Standards Track | ||
category: Core | ||
created: 2021-01-13 | ||
requires: 1559 | ||
--- | ||
|
||
## Simple Summary | ||
Add a `BASEFEE (0x48)` that returns the value of the base fee of the current block it is executing in. | ||
|
||
## Abstract | ||
|
||
|
||
## Motivation | ||
The intended use case would be for contracts to get the value of the base fee. This feature would enable or improve existing use cases, such as: | ||
- Contracts that need to set bounties for anyone to "poke" them with a transaction could set the bounty to be `BASEFEE + x`, or `BASEFEE * (1 + x)`. This makes the mechanism more reliable, because they will always pay "enough" regardless of market conditions. | ||
- Gas futures can be implemented based on it. This would be more precise than gastokens. | ||
- Improve the security for state channels, plasma, optirolls and other fraud proof driven solutions. Having the `BASEFEE` as an input allows you to lengthen the challenge period automatically if you see that the `BASEFEE` is high. | ||
|
||
## Specification | ||
Add a `BASEFEE` opcode at `(0x48)`, with gas cost `G_base`. | ||
|
||
| Op | Input | Output | Cost | | ||
|:----: |:-----: |:------: |:----: | | ||
| 0x48 | 0 | 1 | 2 | | ||
|
||
Attempted execution of a `BASEFEE` prior to `eip-1559` fork causes an _`abort`_: terminate execution with an `Invalid Operation` exception. | ||
|
||
## Rationale | ||
|
||
## Backwards Compatibility | ||
This EIP is backwards-compatible. | ||
|
||
## Test Cases | ||
|
||
### Nominal case | ||
Assuming current block base fee is `7 wei`. | ||
This should push the value `7` (left padded byte32) to the stack. | ||
|
||
Bytecode: `0x4800` (`BASEFEE, STOP`) | ||
|
||
| Pc | Op | Cost | Stack | RStack | | ||
|-------|-------------|------|-----------|-----------| | ||
| 0 | BASEFEE | 2 | [] | [] | | ||
| 1 | STOP | 0 | [7] | [] | | ||
|
||
Output: 0x | ||
Consumed gas: `2` | ||
|
||
### Failure 1: No base fee in current block | ||
Assuming a block header with no base fee (prior to `eip-1559` fork block). | ||
This should fail, since no base fee is present in current block header. | ||
|
||
Bytecode: `0x4800` (`BASEFEE, STOP`) | ||
|
||
| Pc | Op | Cost | Stack | RStack | | ||
|-------|-------------|------|-----------|-----------| | ||
| 0 | BASEFEE | 2 | [] | [] | | ||
| 1 | STOP | 0 | [] | [] | | ||
|
||
Expected behaviour: Terminate execution with an `Invalid Operation` exception. | ||
|
||
## Security Considerations | ||
|
||
## Copyright | ||
Copyright and related rights waived via [CC0](https://creativecommons.org/publicdomain/zero/1.0/). |