Parameters from the EIP-7251 specifications as defined at
https://eips.ethereum.org/EIPS/eip-7251#execution-layer
Source code in tests/prague/eip7251_consolidations/spec.py
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83 | @dataclass(frozen=True)
class Spec:
"""
Parameters from the EIP-7251 specifications as defined at
https://eips.ethereum.org/EIPS/eip-7251#execution-layer
"""
CONSOLIDATION_REQUEST_PREDEPLOY_ADDRESS = 0x00B42DBF2194E931E80326D950320F7D9DBEAC02
SYSTEM_ADDRESS = 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFE
EXCESS_CONSOLIDATION_REQUESTS_STORAGE_SLOT = 0
CONSOLIDATION_REQUEST_COUNT_STORAGE_SLOT = 1
CONSOLIDATION_REQUEST_QUEUE_HEAD_STORAGE_SLOT = (
2 # Pointer to head of the consolidation request message queue
)
CONSOLIDATION_REQUEST_QUEUE_TAIL_STORAGE_SLOT = (
3 # Pointer to the tail of the consolidation request message queue
)
CONSOLIDATION_REQUEST_QUEUE_STORAGE_OFFSET = (
4 # The start memory slot of the in-state consolidation request message queue
)
MAX_CONSOLIDATION_REQUESTS_PER_BLOCK = (
1 # Maximum number of consolidation requests that can be de-queued into a block
)
TARGET_CONSOLIDATION_REQUESTS_PER_BLOCK = 1
MIN_CONSOLIDATION_REQUEST_FEE = 1
CONSOLIDATION_REQUEST_FEE_UPDATE_FRACTION = 17
EXCESS_INHIBITOR = 1181
@staticmethod
def fake_exponential(factor: int, numerator: int, denominator: int) -> int:
"""
Used to calculate the consolidation request fee.
"""
i = 1
output = 0
numerator_accumulator = factor * denominator
while numerator_accumulator > 0:
output += numerator_accumulator
numerator_accumulator = (numerator_accumulator * numerator) // (denominator * i)
i += 1
return output // denominator
@staticmethod
def get_fee(excess_consolidation_requests: int) -> int:
"""
Calculate the fee for the excess consolidation requests.
"""
return Spec.fake_exponential(
Spec.MIN_CONSOLIDATION_REQUEST_FEE,
excess_consolidation_requests,
Spec.CONSOLIDATION_REQUEST_FEE_UPDATE_FRACTION,
)
@staticmethod
def get_excess_consolidation_requests(previous_excess: int, count: int) -> int:
"""
Calculate the new excess consolidation requests.
"""
if previous_excess + count > Spec.TARGET_CONSOLIDATION_REQUESTS_PER_BLOCK:
return previous_excess + count - Spec.TARGET_CONSOLIDATION_REQUESTS_PER_BLOCK
return 0
|