@@ -273,6 +273,14 @@ def fixture_vm_class(fixture_data):
273273 raise ValueError ("Unknown Fork Name: {0}" .format (fork_name ))
274274
275275
276+ PRE_STATE_CLEARING_VMS = (
277+ FrontierVMForTesting ,
278+ HomesteadVMForTesting ,
279+ TangerineWhistleVMForTesting ,
280+ SpuriousDragonVMForTesting ,
281+ )
282+
283+
276284def test_state_fixtures (fixture , fixture_vm_class ):
277285 header = BlockHeader (
278286 coinbase = fixture ['env' ]['currentCoinbase' ],
@@ -320,26 +328,30 @@ def test_state_fixtures(fixture, fixture_vm_class):
320328 r = r ,
321329 s = s ,
322330 )
331+ else :
332+ raise Exception ("Invariant: No transaction specified" )
323333
324334 try :
325335 header , receipt , computation = vm .apply_transaction (vm .block .header , transaction )
326- transactions = vm .block .transactions + (transaction , )
327- receipts = vm .block .get_receipts (chaindb ) + (receipt , )
328- block = vm .set_block_transactions (vm .block , header , transactions , receipts )
329336 except ValidationError as err :
330- # This feels terribly wrong
331- coinbase_balance = state . account_db . get_balance ( vm . block . header . coinbase )
332- if coinbase_balance == 0 :
333- state .account_db .set_balance (vm .block .header .coinbase , 0 )
337+ # Transaction is fully invalid....
338+ # INSANITY: https://github.com/ethereum/go-ethereum/commit/32f28a9360d26a661d55915915f12fd3c70f012b#diff-f53696be8527ac422b8d4de7c8e945c1R149
339+ if isinstance ( vm , PRE_STATE_CLEARING_VMS ) :
340+ state .account_db .touch_account (vm .block .header .coinbase )
334341 state .account_db .persist ()
335342 vm .block = vm .block .copy (header = vm .block .header .copy (state_root = state .state_root ))
336343
344+ logger .warning ("Got transaction error" , exc_info = True )
337345 block = vm .block
346+
338347 transaction_error = err
339- logger .warning ("Got transaction error" , exc_info = True )
340348 else :
341349 transaction_error = False
342350
351+ transactions = vm .block .transactions + (transaction , )
352+ receipts = vm .block .get_receipts (chaindb ) + (receipt , )
353+ block = vm .set_block_transactions (vm .block , header , transactions , receipts )
354+
343355 if not transaction_error :
344356 log_entries = computation .get_log_entries ()
345357 actual_logs_hash = hash_log_entries (log_entries )
0 commit comments