BEP-227: Implement EIP-3198: BASEFEE opcode #227
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
BEP-227: Add BASEFEE opcode
1. Summary
Adds an opcode that gives the EVM access to the block's base fee. This BEP is dependent on BEP-226 (EIP-1559 with base fee of 0).
2. Abstract
Add a
BASEFEE (0x48)
that returns the value of the base fee of the current block it is executing in.The code for this BEP has already been merged from upstream go-ethereum codebase into BSC node codebase. The work entails enabling EIP-3198 (this BEP) for BSC network configurations and performing a hard fork.
3. Motivation
The intended use case would be for contracts to get the value of the base fee (introduced by EIP-1559 (BEP-226)).
4. Specification
Add a
BASEFEE
opcode at(0x48)
, with gas costG_base
.5. Gas cost
The value of the base fee is needed to process transactions. That means it's value is already available before running the EVM code.
The opcode does not add extra complexity and additional read/write operations, hence the choice of
G_base
gas cost.6. Backwards Compatibility
There are no known backward compatibility issues with this opcode.
7. Test Cases
7.1 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
)Output: 0x
Consumed gas:
2
8. Security Considerations
The value of the base fee is not sensitive and is publicly accessible in the block header. There are no known security implications with this opcode.
9. License
The content is licensed under CC0.