Skip to content

Commit

Permalink
Introduce BASEFEE opcode (#1469)
Browse files Browse the repository at this point in the history
  • Loading branch information
begmaroman authored May 24, 2023
1 parent 40c5cfd commit 1f16cbc
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ contract TestWriteBlockMetadata {
data.push(block.gaslimit);
data.push(block.chainid);
coinbase = block.coinbase;
// data.push(block.basefee);
data.push(block.basefee);
// hash = blockhash(block.number);
}
}
1 change: 1 addition & 0 deletions state/runtime/evm/dispatch_table.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ func init() {
register(NUMBER, handler{opNumber, 0, 2})
register(DIFFICULTY, handler{opDifficulty, 0, 2})
register(GASLIMIT, handler{opGasLimit, 0, 2})
register(BASEFEE, handler{opBaseFee, 0, 2})

register(SELFDESTRUCT, handler{opSelfDestruct, 1, 0})

Expand Down
10 changes: 10 additions & 0 deletions state/runtime/evm/instructions.go
Original file line number Diff line number Diff line change
Expand Up @@ -907,6 +907,16 @@ func opGasLimit(c *state) {
c.push1().SetInt64(c.host.GetTxContext().GasLimit)
}

func opBaseFee(c *state) {
if !c.config.London {
c.exit(errOpCodeNotFound)

return
}

c.push(c.host.GetTxContext().BaseFee)
}

func opSelfDestruct(c *state) {
if c.inStaticCall() {
c.exit(errWriteProtection)
Expand Down
4 changes: 4 additions & 0 deletions state/runtime/evm/opcodes.go
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,9 @@ const (
// SELFBALANCE returns the balance of the current account
SELFBALANCE = 0x47

// BASEFEE returns the current base fee value
BASEFEE = 0x48

// POP pops a (u)int256 off the stack and discards it
POP = 0x50

Expand Down Expand Up @@ -308,6 +311,7 @@ var opCodeToString = map[OpCode]string{
NUMBER: "NUMBER",
DIFFICULTY: "DIFFICULTY",
GASLIMIT: "GASLIMIT",
BASEFEE: "BASEFEE",
POP: "POP",
MLOAD: "MLOAD",
MSTORE: "MSTORE",
Expand Down

0 comments on commit 1f16cbc

Please sign in to comment.