Skip to content

Commit

Permalink
Implement EIP-7516
Browse files Browse the repository at this point in the history
  • Loading branch information
gurukamath committed Jan 23, 2024
1 parent b0ae995 commit b20e5a4
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 2 deletions.
2 changes: 2 additions & 0 deletions src/ethereum/cancun/vm/instructions/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ class Ops(enum.Enum):
SELFBALANCE = 0x47
BASEFEE = 0x48
BLOBHASH = 0x49
BLOBBASEFEE = 0x4A

# Control Flow Ops
STOP = 0x00
Expand Down Expand Up @@ -271,6 +272,7 @@ class Ops(enum.Enum):
Ops.SELFBALANCE: environment_instructions.self_balance,
Ops.BASEFEE: environment_instructions.base_fee,
Ops.BLOBHASH: environment_instructions.blob_hash,
Ops.BLOBBASEFEE: environment_instructions.blob_base_fee,
Ops.SSTORE: storage_instructions.sstore,
Ops.JUMP: control_flow_instructions.jump,
Ops.JUMPI: control_flow_instructions.jumpi,
Expand Down
27 changes: 26 additions & 1 deletion src/ethereum/cancun/vm/instructions/environment.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,16 @@
from ..exceptions import OutOfBoundsRead
from ..gas import (
GAS_BASE,
GAS_BLOBHASH_OPCODE,
GAS_COLD_ACCOUNT_ACCESS,
GAS_COPY,
GAS_FAST_STEP,
GAS_BLOBHASH_OPCODE,
GAS_RETURN_DATA_COPY,
GAS_VERY_LOW,
GAS_WARM_ACCESS,
calculate_gas_extend_memory,
charge_gas,
get_blob_gasprice,
)
from ..stack import pop, push

Expand Down Expand Up @@ -563,3 +564,27 @@ def blob_hash(evm: Evm) -> None:

# PROGRAM COUNTER
evm.pc += 1


def blob_base_fee(evm: Evm) -> None:
"""
Pushes the blob base fee on to the stack.
Parameters
----------
evm :
The current EVM frame.
"""
# STACK
pass

# GAS
charge_gas(evm, GAS_BASE)

# OPERATION
blob_base_fee = get_blob_gasprice(evm.env)
push(evm.stack, U256(blob_base_fee))

# PROGRAM COUNTER
evm.pc += 1
3 changes: 2 additions & 1 deletion whitelist.txt
Original file line number Diff line number Diff line change
Expand Up @@ -413,4 +413,5 @@ KZG
BLOBHASH
eth2spec
Bytes48
BLS
BLS
BLOBBASEFEE

0 comments on commit b20e5a4

Please sign in to comment.