@@ -66,6 +66,7 @@ impl<const IS_CREATE2: bool> Opcode for Create<IS_CREATE2> {
6666
6767        let  callee_account = & state. sdb . get_account ( & address) . 1 . clone ( ) ; 
6868        let  callee_exists = !callee_account. is_empty ( ) ; 
69+         let  is_address_collision = callee_account. code_hash  != CodeDB :: empty_code_hash ( ) ; 
6970        if  !callee_exists && callee. value . is_zero ( )  { 
7071            state. sdb . get_account_mut ( & address) . 1 . storage . clear ( ) ; 
7172        } 
@@ -170,7 +171,7 @@ impl<const IS_CREATE2: bool> Opcode for Create<IS_CREATE2> {
170171        // operation happens in evm create() method before checking 
171172        // ErrContractAddressCollision 
172173        let  code_hash_previous = if  callee_exists { 
173-             if  is_precheck_ok { 
174+             if  is_precheck_ok && is_address_collision  { 
174175                // CREATE2 may cause address collision error. And for a tricky 
175176                // case of CREATE, it could also cause this error. e.g. the `to` 
176177                // field of transaction is set to the calculated contract 
@@ -198,12 +199,12 @@ impl<const IS_CREATE2: bool> Opcode for Create<IS_CREATE2> {
198199            code_hash_previous. to_word ( ) , 
199200        ) ; 
200201
201-         if  is_precheck_ok && !callee_exists  { 
202+         if  is_precheck_ok && !is_address_collision  { 
202203            state. transfer ( 
203204                & mut  exec_step, 
204205                callee. caller_address , 
205206                callee. address , 
206-                 true , 
207+                 true ,   // since `must_create` is true, the `receiver_exists` is unused 
207208                true , 
208209                callee. value , 
209210            ) ?; 
@@ -311,7 +312,7 @@ impl<const IS_CREATE2: bool> Opcode for Create<IS_CREATE2> {
311312        state. block . sha3_inputs . push ( keccak_input) ; 
312313        state. block . sha3_inputs . push ( initialization_code) ; 
313314
314-         if  length == 0  || callee_exists  { 
315+         if  length == 0  || is_address_collision  { 
315316            for  ( field,  value)  in  [ 
316317                ( CallContextField :: LastCalleeId ,  0 . into ( ) ) , 
317318                ( CallContextField :: LastCalleeReturnDataOffset ,  0 . into ( ) ) , 
0 commit comments