Bases: Spec
Parameters from the EIP-7918 specifications.
Extends EIP-4844 spec with the new reserve price constant and functionality.
Source code in tests/osaka/eip7918_blob_reserve_price/spec.py
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55 | @dataclass(frozen=True)
class Spec(EIP4844Spec):
"""
Parameters from the EIP-7918 specifications.
Extends EIP-4844 spec with the new reserve price constant and functionality.
"""
BLOB_BASE_COST = 2**14
@classmethod
def get_reserve_price(
cls,
base_fee_per_gas: int,
) -> int:
"""Calculate the reserve price for blob gas given the blob base fee."""
return (cls.BLOB_BASE_COST * base_fee_per_gas) // cls.GAS_PER_BLOB
@classmethod
def is_reserve_price_active(
cls,
base_fee_per_gas: int,
blob_base_fee: int,
) -> bool:
"""Check if the reserve price mechanism should be active."""
reserve_price = cls.get_reserve_price(base_fee_per_gas)
return reserve_price > blob_base_fee
@classmethod
def calc_effective_blob_base_fee(
cls,
base_fee_per_gas: int,
blob_base_fee: int,
) -> int:
"""Calculate the effective blob base fee considering the reserve price."""
reserve_price = cls.get_reserve_price(base_fee_per_gas)
return max(reserve_price, blob_base_fee)
|