@@ -953,22 +953,22 @@ impl Cheatcodes {
953953 let mut zk_tx = if self . use_zk_vm {
954954 to = Some ( TxKind :: Call ( CONTRACT_DEPLOYER_ADDRESS . to_address ( ) ) ) ;
955955 nonce = foundry_zksync_core:: nonce ( broadcast. new_origin , ecx_inner) as u64 ;
956- let contract = self
956+ let init_code = input. init_code ( ) ;
957+ let find_contract = self
957958 . dual_compiled_contracts
958- . find_by_evm_bytecode ( & input. init_code ( ) . 0 )
959- . unwrap_or_else ( || {
960- panic ! ( "failed finding contract for {:?}" , input. init_code( ) )
961- } ) ;
959+ . find_bytecode ( & init_code. 0 )
960+ . unwrap_or_else ( || panic ! ( "failed finding contract for {init_code:?}" ) ) ;
961+
962+ let constructor_args = find_contract. constructor_args ( ) ;
963+ let contract = find_contract. contract ( ) ;
964+
962965 let factory_deps =
963966 self . dual_compiled_contracts . fetch_all_factory_deps ( contract) ;
964967
965- let constructor_input =
966- call_init_code[ contract. evm_bytecode . len ( ) ..] . to_vec ( ) ;
967-
968968 let create_input = foundry_zksync_core:: encode_create_params (
969969 & input. scheme ( ) . unwrap_or ( CreateScheme :: Create ) ,
970970 contract. zk_bytecode_hash ,
971- constructor_input ,
971+ constructor_args . to_vec ( ) ,
972972 ) ;
973973 call_init_code = Bytes :: from ( create_input) ;
974974
@@ -1107,20 +1107,30 @@ impl Cheatcodes {
11071107 }
11081108 }
11091109
1110- if input. init_code ( ) . 0 == DEFAULT_CREATE2_DEPLOYER_CODE {
1110+ let init_code = input. init_code ( ) ;
1111+ if init_code. 0 == DEFAULT_CREATE2_DEPLOYER_CODE {
11111112 info ! ( "running create in EVM, instead of zkEVM (DEFAULT_CREATE2_DEPLOYER_CODE)" ) ;
11121113 return None
11131114 }
11141115
11151116 info ! ( "running create in zkEVM" ) ;
11161117
1117- let zk_contract = self
1118+ let find_contract = self
11181119 . dual_compiled_contracts
1119- . find_by_evm_bytecode ( & input. init_code ( ) . 0 )
1120- . unwrap_or_else ( || panic ! ( "failed finding contract for {:?}" , input. init_code( ) ) ) ;
1120+ . find_bytecode ( & init_code. 0 )
1121+ . unwrap_or_else ( || panic ! ( "failed finding contract for {init_code:?}" ) ) ;
1122+
1123+ let constructor_args = find_contract. constructor_args ( ) ;
1124+ let contract = find_contract. contract ( ) ;
11211125
1122- let factory_deps = self . dual_compiled_contracts . fetch_all_factory_deps ( zk_contract) ;
1123- tracing:: debug!( contract = zk_contract. name, "using dual compiled contract" ) ;
1126+ let zk_create_input = foundry_zksync_core:: encode_create_params (
1127+ & input. scheme ( ) . unwrap_or ( CreateScheme :: Create ) ,
1128+ contract. zk_bytecode_hash ,
1129+ constructor_args. to_vec ( ) ,
1130+ ) ;
1131+
1132+ let factory_deps = self . dual_compiled_contracts . fetch_all_factory_deps ( contract) ;
1133+ tracing:: debug!( contract = contract. name, "using dual compiled contract" ) ;
11241134
11251135 let ccx = foundry_zksync_core:: vm:: CheatcodeTracerContext {
11261136 mocked_calls : self . mocked_calls . clone ( ) ,
@@ -1129,22 +1139,15 @@ impl Cheatcodes {
11291139 persisted_factory_deps : Some ( & mut self . persisted_factory_deps ) ,
11301140 paymaster_data : self . paymaster_params . take ( ) ,
11311141 } ;
1132- let create_inputs = CreateInputs {
1133- scheme : input. scheme ( ) . unwrap_or ( CreateScheme :: Create ) ,
1134- init_code : input. init_code ( ) ,
1135- value : input. value ( ) ,
1136- caller : input. caller ( ) ,
1137- gas_limit : input. gas_limit ( ) ,
1142+ let zk_create = foundry_zksync_core:: vm:: ZkCreateInputs {
1143+ value : input. value ( ) . to_u256 ( ) ,
1144+ msg_sender : input. caller ( ) ,
1145+ create_input : zk_create_input,
1146+ factory_deps,
11381147 } ;
11391148
11401149 let mut gas = Gas :: new ( input. gas_limit ( ) ) ;
1141- match foundry_zksync_core:: vm:: create :: < _ , DatabaseError > (
1142- & create_inputs,
1143- zk_contract,
1144- factory_deps,
1145- ecx,
1146- ccx,
1147- ) {
1150+ match foundry_zksync_core:: vm:: create :: < _ , DatabaseError > ( zk_create, ecx, ccx) {
11481151 Ok ( result) => {
11491152 if let Some ( recorded_logs) = & mut self . recorded_logs {
11501153 recorded_logs. extend ( result. logs . clone ( ) . into_iter ( ) . map ( |log| Vm :: Log {
@@ -1161,8 +1164,8 @@ impl Cheatcodes {
11611164 state : self ,
11621165 ecx : & mut ecx. inner ,
11631166 precompiles : & mut ecx. precompiles ,
1164- gas_limit : create_inputs . gas_limit ,
1165- caller : create_inputs . caller ,
1167+ gas_limit : input . gas_limit ( ) ,
1168+ caller : input . caller ( ) ,
11661169 } ,
11671170 decoded_log,
11681171 ) ;
@@ -1436,19 +1439,20 @@ impl Cheatcodes {
14361439 call. bytecode_address = DEFAULT_CREATE2_DEPLOYER_ZKSYNC ;
14371440
14381441 let ( salt, init_code) = call. input . split_at ( 32 ) ;
1439- let contract = self
1442+ let find_contract = self
14401443 . dual_compiled_contracts
1441- . find_by_evm_bytecode ( init_code)
1444+ . find_bytecode ( init_code)
14421445 . unwrap_or_else ( || panic ! ( "failed finding contract for {init_code:?}" ) ) ;
14431446
1444- factory_deps = self . dual_compiled_contracts . fetch_all_factory_deps ( contract) ;
1447+ let constructor_args = find_contract. constructor_args ( ) ;
1448+ let contract = find_contract. contract ( ) ;
14451449
1446- let constructor_input = init_code [ contract . evm_bytecode . len ( ) .. ] . to_vec ( ) ;
1450+ factory_deps = self . dual_compiled_contracts . fetch_all_factory_deps ( contract ) ;
14471451
14481452 let create_input = foundry_zksync_core:: encode_create_params (
14491453 & CreateScheme :: Create2 { salt : U256 :: from_be_slice ( salt) } ,
14501454 contract. zk_bytecode_hash ,
1451- constructor_input ,
1455+ constructor_args . to_vec ( ) ,
14521456 ) ;
14531457
14541458 call. input = create_input. into ( ) ;
0 commit comments