From b20e5a476efdeb68cca7a0fd17c11a481689e59a Mon Sep 17 00:00:00 2001 From: Guruprasad Kamath Date: Tue, 23 Jan 2024 16:14:03 +0100 Subject: [PATCH] Implement EIP-7516 --- .../cancun/vm/instructions/__init__.py | 2 ++ .../cancun/vm/instructions/environment.py | 27 ++++++++++++++++++- whitelist.txt | 3 ++- 3 files changed, 30 insertions(+), 2 deletions(-) diff --git a/src/ethereum/cancun/vm/instructions/__init__.py b/src/ethereum/cancun/vm/instructions/__init__.py index 2ab718e3f4..fed9e73b6e 100644 --- a/src/ethereum/cancun/vm/instructions/__init__.py +++ b/src/ethereum/cancun/vm/instructions/__init__.py @@ -98,6 +98,7 @@ class Ops(enum.Enum): SELFBALANCE = 0x47 BASEFEE = 0x48 BLOBHASH = 0x49 + BLOBBASEFEE = 0x4A # Control Flow Ops STOP = 0x00 @@ -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, diff --git a/src/ethereum/cancun/vm/instructions/environment.py b/src/ethereum/cancun/vm/instructions/environment.py index f9d50daad6..dd70f3ccc1 100644 --- a/src/ethereum/cancun/vm/instructions/environment.py +++ b/src/ethereum/cancun/vm/instructions/environment.py @@ -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 @@ -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 diff --git a/whitelist.txt b/whitelist.txt index ec10877ddd..79a2e4bcb2 100644 --- a/whitelist.txt +++ b/whitelist.txt @@ -413,4 +413,5 @@ KZG BLOBHASH eth2spec Bytes48 -BLS \ No newline at end of file +BLS +BLOBBASEFEE \ No newline at end of file