@@ -63,12 +63,11 @@ const STACK_SIZE_ENTRY_OVERHEAD: usize = 100 * 1024;
63
63
const STACK_SIZE_ENTRY_OVERHEAD : usize = 20 * 1024 ;
64
64
65
65
#[ cfg( any( test, feature = "test-helpers" ) ) ]
66
- /// RIPEMD160 was removed in mainnet block #2686351. See security Security alert [11/24/2016].
67
- /// This is only applies in tests, since all precompile accounts are now non-empty in mainnet.
66
+ /// Precompile that can never be prunned from state trie (0x3, only in tests)
68
67
const UNPRUNABLE_PRECOMPILE_ADDRESS : Option < Address > = Some ( ethereum_types:: H160 ( [ 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 3 ] ) ) ;
69
68
70
69
#[ cfg( not( any( test, feature = "test-helpers" ) ) ) ]
71
- /// EIP161 - By default all empty accounts can be prunned.
70
+ /// Precompile that can never be prunned from state trie (none)
72
71
const UNPRUNABLE_PRECOMPILE_ADDRESS : Option < Address > = None ;
73
72
74
73
/// Returns new address created from address, nonce, and code hash
@@ -422,7 +421,6 @@ impl<'a> CallCreateExecutive<'a> {
422
421
Self :: check_static_flag ( & params, self . static_flag , self . is_create ) ?;
423
422
state. checkpoint ( ) ;
424
423
425
- let initial_builtin_balance = state. balance ( & params. code_address ) ?;
426
424
Self :: transfer_exec_balance ( & params, self . schedule , state, substate) ?;
427
425
428
426
let default = [ ] ;
@@ -451,13 +449,14 @@ impl<'a> CallCreateExecutive<'a> {
451
449
} )
452
450
}
453
451
} else {
454
- // EIP161 - reverted calls cancels state trie cleaning
455
- if initial_builtin_balance. is_zero ( ) {
456
- let prune = UNPRUNABLE_PRECOMPILE_ADDRESS
457
- . map_or ( true , |addr| addr != params. code_address ) ;
458
- if prune {
452
+ // Openethereum needs balance > 0 in precompiles to be EIP161 compliant, see PR#11597.
453
+ // Since RIPEMD160 was removed in mainnet block #2686351,
454
+ // this is activated only in tests to check this specific irregular estate transition.
455
+ if let Some ( unprunable_addr) = UNPRUNABLE_PRECOMPILE_ADDRESS {
456
+ if unprunable_addr != params. code_address
457
+ && state. balance ( & params. code_address ) ?. is_zero ( ) {
459
458
substate. touched . remove ( & params. code_address ) ;
460
- }
459
+ }
461
460
}
462
461
// just drain the whole gas
463
462
state. revert_to_checkpoint ( ) ;
0 commit comments