@@ -74,7 +74,6 @@ class MiningHeaderAPI(ABC):
74
74
gas_used : int
75
75
timestamp : int
76
76
extra_data : bytes
77
- base_fee_per_gas : int # EIP-1559, set to None in pre-London header
78
77
79
78
@property
80
79
@abstractmethod
@@ -123,8 +122,47 @@ def as_dict(self) -> Dict[Hashable, Any]:
123
122
"""
124
123
...
125
124
125
+ @property
126
+ @abstractmethod
127
+ def base_fee_per_gas (self ) -> Optional [int ]:
128
+ """
129
+ Return the base fee per gas of the block.
130
+
131
+ Set to None in pre-EIP-1559 (London) header.
132
+ """
133
+ ...
134
+
135
+
136
+ class BlockHeaderSedesAPI (ABC ):
137
+ """
138
+ Serialize and deserialize RLP for a header.
126
139
127
- class BlockHeaderAPI (MiningHeaderAPI ):
140
+ The header may be one of several definitions, like a London (EIP-1559) or
141
+ pre-London header.
142
+ """
143
+
144
+ @classmethod
145
+ @abstractmethod
146
+ def deserialize (cls , encoded : List [bytes ]) -> 'BlockHeaderAPI' :
147
+ """
148
+ Extract a header from an encoded RLP object.
149
+
150
+ This method is used by rlp.decode(..., sedes=TransactionBuilderAPI).
151
+ """
152
+ ...
153
+
154
+ @classmethod
155
+ @abstractmethod
156
+ def serialize (cls , obj : 'BlockHeaderAPI' ) -> List [bytes ]:
157
+ """
158
+ Encode a header to a series of bytes used by RLP.
159
+
160
+ This method is used by rlp.encode(obj).
161
+ """
162
+ ...
163
+
164
+
165
+ class BlockHeaderAPI (MiningHeaderAPI , BlockHeaderSedesAPI ):
128
166
"""
129
167
A class derived from :class:`~eth.abc.MiningHeaderAPI` to define a block header after it is
130
168
sealed.
@@ -327,9 +365,6 @@ class TransactionFieldsAPI(ABC):
327
365
"""
328
366
A class to define all common transaction fields.
329
367
"""
330
- max_fee_per_gas : int
331
- max_priority_fee_per_gas : int
332
-
333
368
@property
334
369
@abstractmethod
335
370
def nonce (self ) -> int :
@@ -339,7 +374,23 @@ def nonce(self) -> int:
339
374
@abstractmethod
340
375
def gas_price (self ) -> int :
341
376
"""
342
- Will raise :cls:`AttributeError` if get or set on a 1559 transaction.
377
+ Will raise :class:`AttributeError` if get or set on a 1559 transaction.
378
+ """
379
+ ...
380
+
381
+ @property
382
+ @abstractmethod
383
+ def max_fee_per_gas (self ) -> int :
384
+ """
385
+ Will default to gas_price if this is a pre-1559 transaction.
386
+ """
387
+ ...
388
+
389
+ @property
390
+ @abstractmethod
391
+ def max_priority_fee_per_gas (self ) -> int :
392
+ """
393
+ Will default to gas_price if this is a pre-1559 transaction.
343
394
"""
344
395
...
345
396
@@ -1020,9 +1071,12 @@ class ChainDatabaseAPI(HeaderDatabaseAPI):
1020
1071
# Header API
1021
1072
#
1022
1073
@abstractmethod
1023
- def get_block_uncles (self , uncles_hash : Hash32 ) -> Tuple [BlockHeaderAPI , ...]:
1074
+ def get_block_uncles (self , niece_header : BlockHeaderAPI ) -> Tuple [BlockHeaderAPI , ...]:
1024
1075
"""
1025
- Return an iterable of uncle headers specified by the given ``uncles_hash``
1076
+ Return an iterable of uncle headers, specified by the header's ``uncles_hash``.
1077
+
1078
+ The header class is used to specify the RLP deserialization used when
1079
+ decoding the uncle headers from the binary blob.
1026
1080
"""
1027
1081
...
1028
1082
@@ -1072,10 +1126,15 @@ def persist_unexecuted_block(self,
1072
1126
"""
1073
1127
1074
1128
@abstractmethod
1075
- def persist_uncles (self , uncles : Tuple [BlockHeaderAPI ]) -> Hash32 :
1129
+ def persist_uncles (
1130
+ self ,
1131
+ uncles : Tuple [BlockHeaderAPI ],
1132
+ header_sedes : BlockHeaderSedesAPI ) -> Hash32 :
1076
1133
"""
1077
1134
Persist the list of uncles to the database.
1078
1135
1136
+ Use header_sedes to decode the rlp-encoded uncle headers.
1137
+
1079
1138
Return the uncles hash.
1080
1139
"""
1081
1140
...
@@ -2619,6 +2678,15 @@ def gas_limit(self) -> int:
2619
2678
"""
2620
2679
...
2621
2680
2681
+ @abstractmethod
2682
+ def get_gas_price (self , transaction : SignedTransactionAPI ) -> int :
2683
+ """
2684
+ Return the gas price of the given transaction.
2685
+
2686
+ Factor in the current block's base gase price, if appropriate. (See EIP-1559)
2687
+ """
2688
+ ...
2689
+
2622
2690
#
2623
2691
# Access to account db
2624
2692
#
@@ -2994,36 +3062,6 @@ def get_fee_recipient(cls, header: BlockHeaderAPI) -> Address:
2994
3062
...
2995
3063
2996
3064
2997
-
2998
- class BlockHeaderSedesAPI (ABC ):
2999
- """
3000
- Serialize and deserialize RLP for a header.
3001
-
3002
- The header may be one of several definitions, like a London (EIP-1559) or
3003
- pre-London header.
3004
- """
3005
-
3006
- @classmethod
3007
- @abstractmethod
3008
- def deserialize (cls , encoded : List [bytes ]) -> BlockHeaderAPI :
3009
- """
3010
- Extract a header from an encoded RLP object.
3011
-
3012
- This method is used by rlp.decode(..., sedes=TransactionBuilderAPI).
3013
- """
3014
- ...
3015
-
3016
- @classmethod
3017
- @abstractmethod
3018
- def serialize (cls , obj : BlockHeaderAPI ) -> List [bytes ]:
3019
- """
3020
- Encode a header to a series of bytes used by RLP.
3021
-
3022
- This method is used by rlp.encode(obj).
3023
- """
3024
- ...
3025
-
3026
-
3027
3065
class VirtualMachineAPI (ConfigurableAPI ):
3028
3066
"""
3029
3067
The :class:`~eth.abc.VirtualMachineAPI` class represents the Chain rules for a
@@ -3322,7 +3360,8 @@ def create_genesis_header(cls, **genesis_params: Any) -> BlockHeaderAPI:
3322
3360
"""
3323
3361
Create a genesis header using this VM's rules.
3324
3362
3325
- This is currently equivalent to create_header_from_parent(None, **genesis_params)
3363
+ This is equivalent to calling :meth:`create_header_from_parent`
3364
+ with ``parent_header`` set to None.
3326
3365
"""
3327
3366
...
3328
3367
0 commit comments