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
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73 | @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**13
@classmethod
def get_reserve_price(
cls,
*,
fork: Fork,
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
) // fork.blob_gas_per_blob()
@classmethod
def is_reserve_price_active(
cls,
*,
fork: Fork,
base_fee_per_gas: int,
blob_base_fee: int,
) -> bool:
"""Check if the reserve price mechanism should be active."""
return (
cls.BLOB_BASE_COST * base_fee_per_gas
> blob_base_fee * fork.blob_gas_per_blob()
)
@classmethod
def calc_effective_blob_base_fee(
cls,
*,
fork: Fork,
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(
fork=fork, base_fee_per_gas=base_fee_per_gas
)
return max(reserve_price, blob_base_fee)
|