53
53
from eth2 .beacon .validation import (
54
54
validate_slot ,
55
55
)
56
- from eth2 .configs import Eth2Config
56
+ from eth2 .configs import (
57
+ Eth2GenesisConfig ,
58
+ )
57
59
58
60
if TYPE_CHECKING :
59
61
from eth2 .beacon .state_machines .base import ( # noqa: F401
@@ -87,7 +89,7 @@ def from_genesis(cls,
87
89
base_db : BaseAtomicDB ,
88
90
genesis_state : BeaconState ,
89
91
genesis_block : BaseBeaconBlock ,
90
- config : Eth2Config ) -> 'BaseBeaconChain' :
92
+ genesis_config : Eth2GenesisConfig ) -> 'BaseBeaconChain' :
91
93
pass
92
94
93
95
#
@@ -111,6 +113,11 @@ def get_state_machine_class_for_block_slot(
111
113
slot : Slot ) -> Type ['BaseBeaconStateMachine' ]:
112
114
pass
113
115
116
+ @classmethod
117
+ @abstractmethod
118
+ def get_genesis_state_machine_class (self ) -> Type ['BaseBeaconStateMachine' ]:
119
+ pass
120
+
114
121
#
115
122
# Block API
116
123
#
@@ -172,7 +179,7 @@ class BeaconChain(BaseBeaconChain):
172
179
173
180
chaindb_class = BeaconChainDB # type: Type[BaseBeaconChainDB]
174
181
175
- def __init__ (self , base_db : BaseAtomicDB , config : Eth2Config ) -> None :
182
+ def __init__ (self , base_db : BaseAtomicDB , genesis_config : Eth2GenesisConfig ) -> None :
176
183
if not self .sm_configuration :
177
184
raise ValueError (
178
185
"The Chain class cannot be instantiated with an empty `sm_configuration`"
@@ -182,7 +189,7 @@ def __init__(self, base_db: BaseAtomicDB, config: Eth2Config) -> None:
182
189
# validate_sm_configuration(self.sm_configuration)
183
190
pass
184
191
185
- self .chaindb = self .get_chaindb_class ()(base_db , config )
192
+ self .chaindb = self .get_chaindb_class ()(base_db , genesis_config )
186
193
187
194
#
188
195
# Helpers
@@ -201,7 +208,7 @@ def from_genesis(cls,
201
208
base_db : BaseAtomicDB ,
202
209
genesis_state : BeaconState ,
203
210
genesis_block : BaseBeaconBlock ,
204
- config : Eth2Config ) -> 'BaseBeaconChain' :
211
+ genesis_config : Eth2GenesisConfig ) -> 'BaseBeaconChain' :
205
212
"""
206
213
Initialize the ``BeaconChain`` from a genesis state.
207
214
"""
@@ -214,21 +221,21 @@ def from_genesis(cls,
214
221
)
215
222
)
216
223
217
- chaindb = cls .get_chaindb_class ()(db = base_db , config = config )
224
+ chaindb = cls .get_chaindb_class ()(db = base_db , genesis_config = genesis_config )
218
225
chaindb .persist_state (genesis_state )
219
- return cls ._from_genesis_block (base_db , genesis_block , config )
226
+ return cls ._from_genesis_block (base_db , genesis_block , genesis_config )
220
227
221
228
@classmethod
222
229
def _from_genesis_block (cls ,
223
230
base_db : BaseAtomicDB ,
224
231
genesis_block : BaseBeaconBlock ,
225
- config : Eth2Config ) -> 'BaseBeaconChain' :
232
+ genesis_config : Eth2GenesisConfig ) -> 'BaseBeaconChain' :
226
233
"""
227
234
Initialize the ``BeaconChain`` from the genesis block.
228
235
"""
229
- chaindb = cls .get_chaindb_class ()(db = base_db , config = config )
236
+ chaindb = cls .get_chaindb_class ()(db = base_db , genesis_config = genesis_config )
230
237
chaindb .persist_block (genesis_block , genesis_block .__class__ )
231
- return cls (base_db , config )
238
+ return cls (base_db , genesis_config )
232
239
233
240
#
234
241
# StateMachine API
@@ -268,6 +275,10 @@ def get_state_machine(self, at_block: BaseBeaconBlock=None) -> 'BaseBeaconStateM
268
275
block = block ,
269
276
)
270
277
278
+ @classmethod
279
+ def get_genesis_state_machine_class (cls ) -> Type ['BaseBeaconStateMachine' ]:
280
+ return cls .sm_configuration [0 ][1 ]
281
+
271
282
#
272
283
# Block API
273
284
#
0 commit comments