@@ -122,6 +122,27 @@ def funded_address_initial_balance():
122
122
return to_wei (1000 , 'ether' )
123
123
124
124
125
+ # wrapped in a method so that different callers aren't using (and modifying) the same dict
126
+ def _get_genesis_defaults ():
127
+ # values that are not yet customizeable (and will automatically be default) are commented out
128
+ return {
129
+ 'difficulty' : constants .GENESIS_DIFFICULTY ,
130
+ 'gas_limit' : 3141592 ,
131
+ 'coinbase' : constants .GENESIS_COINBASE ,
132
+ 'nonce' : constants .GENESIS_NONCE ,
133
+ 'mix_hash' : constants .GENESIS_MIX_HASH ,
134
+ 'extra_data' : constants .GENESIS_EXTRA_DATA ,
135
+ 'timestamp' : 1501851927 ,
136
+ # 'block_number': constants.GENESIS_BLOCK_NUMBER,
137
+ # 'parent_hash': constants.GENESIS_PARENT_HASH,
138
+ # "bloom": 0,
139
+ # "gas_used": 0,
140
+ # "uncles_hash": decode_hex("1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347") # noqa: E501
141
+ # "receipt_root": decode_hex("56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421"), # noqa: E501
142
+ # "transaction_root": decode_hex("56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421"), # noqa: E501
143
+ }
144
+
145
+
125
146
def _chain_with_block_validation (VM , base_db , genesis_state , chain_cls = Chain ):
126
147
"""
127
148
Return a Chain object containing just the genesis block.
@@ -134,32 +155,14 @@ def _chain_with_block_validation(VM, base_db, genesis_state, chain_cls=Chain):
134
155
importing arbitrarily constructe, not finalized blocks, use the
135
156
chain_without_block_validation fixture instead.
136
157
"""
137
- # values that are the same as the default are commented out
138
- genesis_params = {
139
- # "bloom": 0,
140
- "coinbase" : to_canonical_address ("8888f1f195afa192cfee860698584c030f4c9db1" ),
141
- "difficulty" : 131072 ,
142
- "extra_data" : b"B" ,
143
- "gas_limit" : 3141592 ,
144
- # "gas_used": 0,
145
- "mix_hash" : decode_hex ("56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421" ), # noqa: E501
146
- "nonce" : decode_hex ("0102030405060708" ),
147
- # "block_number": 0,
148
- # "parent_hash": decode_hex("0000000000000000000000000000000000000000000000000000000000000000"), # noqa: E501
149
- "receipt_root" : decode_hex ("56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421" ), # noqa: E501
150
- "timestamp" : 1422494849 ,
151
- "transaction_root" : decode_hex ("56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421" ), # noqa: E501
152
- # "uncles_hash": decode_hex("1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347") # noqa: E501
153
- }
154
-
155
158
klass = chain_cls .configure (
156
159
__name__ = 'TestChain' ,
157
160
vm_configuration = (
158
161
(constants .GENESIS_BLOCK_NUMBER , VM .configure (consensus_class = PowConsensus )),
159
162
),
160
163
chain_id = 1337 ,
161
164
)
162
- chain = klass .from_genesis (base_db , genesis_params , genesis_state )
165
+ chain = klass .from_genesis (base_db , _get_genesis_defaults () , genesis_state )
163
166
return chain
164
167
165
168
@@ -225,18 +228,7 @@ def _chain_without_block_validation(request, VM, base_db, genesis_state):
225
228
chain_id = 1337 ,
226
229
** overrides ,
227
230
)
228
- genesis_params = {
229
- 'block_number' : constants .GENESIS_BLOCK_NUMBER ,
230
- 'difficulty' : constants .GENESIS_DIFFICULTY ,
231
- 'gas_limit' : 3141592 ,
232
- 'parent_hash' : constants .GENESIS_PARENT_HASH ,
233
- 'coinbase' : constants .GENESIS_COINBASE ,
234
- 'nonce' : constants .GENESIS_NONCE ,
235
- 'mix_hash' : constants .GENESIS_MIX_HASH ,
236
- 'extra_data' : constants .GENESIS_EXTRA_DATA ,
237
- 'timestamp' : 1501851927 ,
238
- }
239
- chain = klass .from_genesis (base_db , genesis_params , genesis_state )
231
+ chain = klass .from_genesis (base_db , _get_genesis_defaults (), genesis_state )
240
232
return chain
241
233
242
234
0 commit comments