11pub use crate :: ic:: * ;
22use crate :: {
3- backend:: DatabaseExt , constants:: DEFAULT_CREATE2_DEPLOYER , precompiles:: ALPHANET_P256 ,
3+ backend:: DatabaseExt , constants:: DEFAULT_CREATE2_DEPLOYER_CODEHASH , precompiles:: ALPHANET_P256 ,
44 InspectorExt ,
55} ;
66use alloy_consensus:: BlockHeader ;
@@ -149,12 +149,16 @@ pub fn gas_used(spec: SpecId, spent: u64, refunded: u64) -> u64 {
149149 spent - ( refunded) . min ( spent / refund_quotient)
150150}
151151
152- fn get_create2_factory_call_inputs ( salt : U256 , inputs : CreateInputs ) -> CallInputs {
152+ fn get_create2_factory_call_inputs (
153+ salt : U256 ,
154+ inputs : CreateInputs ,
155+ deployer : Address ,
156+ ) -> CallInputs {
153157 let calldata = [ & salt. to_be_bytes :: < 32 > ( ) [ ..] , & inputs. init_code [ ..] ] . concat ( ) ;
154158 CallInputs {
155159 caller : inputs. caller ,
156- bytecode_address : DEFAULT_CREATE2_DEPLOYER ,
157- target_address : DEFAULT_CREATE2_DEPLOYER ,
160+ bytecode_address : deployer ,
161+ target_address : deployer ,
158162 scheme : CallScheme :: Call ,
159163 value : CallValue :: Transfer ( inputs. value ) ,
160164 input : calldata. into ( ) ,
@@ -165,7 +169,7 @@ fn get_create2_factory_call_inputs(salt: U256, inputs: CreateInputs) -> CallInpu
165169 }
166170}
167171
168- /// Used for routing certain CREATE2 invocations through [DEFAULT_CREATE2_DEPLOYER] .
172+ /// Used for routing certain CREATE2 invocations through CREATE2_DEPLOYER .
169173///
170174/// Overrides create hook with CALL frame if [InspectorExt::should_use_create2_factory] returns
171175/// true. Keeps track of overridden frames and handles outcome in the overridden insert_call_outcome
@@ -190,8 +194,10 @@ pub fn create2_handler_register<I: InspectorExt>(
190194
191195 let gas_limit = inputs. gas_limit ;
192196
197+ // Get CREATE2 deployer.
198+ let create2_deployer = ctx. external . create2_deployer ( ) ;
193199 // Generate call inputs for CREATE2 factory.
194- let mut call_inputs = get_create2_factory_call_inputs ( salt, * inputs) ;
200+ let mut call_inputs = get_create2_factory_call_inputs ( salt, * inputs, create2_deployer ) ;
195201
196202 // Call inspector to change input or return outcome.
197203 let outcome = ctx. external . call ( & mut ctx. evm , & mut call_inputs) ;
@@ -202,12 +208,21 @@ pub fn create2_handler_register<I: InspectorExt>(
202208 . push ( ( ctx. evm . journaled_state . depth ( ) , call_inputs. clone ( ) ) ) ;
203209
204210 // Sanity check that CREATE2 deployer exists.
205- let code_hash = ctx. evm . load_account ( DEFAULT_CREATE2_DEPLOYER ) ?. info . code_hash ;
211+ let code_hash = ctx. evm . load_account ( create2_deployer ) ?. info . code_hash ;
206212 if code_hash == KECCAK_EMPTY {
207213 return Ok ( FrameOrResult :: Result ( FrameResult :: Call ( CallOutcome {
208214 result : InterpreterResult {
209215 result : InstructionResult :: Revert ,
210- output : "missing CREATE2 deployer" . into ( ) ,
216+ output : format ! ( "missing CREATE2 deployer: {create2_deployer}" ) . into ( ) ,
217+ gas : Gas :: new ( gas_limit) ,
218+ } ,
219+ memory_offset : 0 ..0 ,
220+ } ) ) )
221+ } else if code_hash != DEFAULT_CREATE2_DEPLOYER_CODEHASH {
222+ return Ok ( FrameOrResult :: Result ( FrameResult :: Call ( CallOutcome {
223+ result : InterpreterResult {
224+ result : InstructionResult :: Revert ,
225+ output : "invalid CREATE2 deployer bytecode" . into ( ) ,
211226 gas : Gas :: new ( gas_limit) ,
212227 } ,
213228 memory_offset : 0 ..0 ,
0 commit comments