This repository was archived by the owner on Apr 18, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +13
-8
lines changed
bus-mapping/src/circuit_input_builder Expand file tree Collapse file tree 1 file changed +13
-8
lines changed Original file line number Diff line number Diff line change @@ -90,15 +90,20 @@ impl<'a> CircuitInputStateRef<'a> {
9090 let mut gas_left = prev_step. gas_left . 0 - prev_step. gas_cost . 0 ;
9191 // handling for contract creation tx
9292 let call = self . tx . calls ( ) [ 0 ] . clone ( ) ;
93- if call. is_create ( ) {
93+ if call. is_create ( )
94+ && call. is_success ( )
95+ && prev_step. exec_state == ExecState :: Op ( OpcodeId :: RETURN )
96+ {
9497 let code_hash = self . sdb . get_account ( & call. address ) . 1 . code_hash ;
95- let bytecode_len = self . code ( code_hash) . unwrap ( ) . len ( ) as u64 ;
96- let deposit_cost = bytecode_len * GasCost :: CODE_DEPOSIT_BYTE_COST . as_u64 ( ) ;
97- assert ! (
98- gas_left >= deposit_cost,
99- "gas left {gas_left} is not enough for deposit cost {deposit_cost}"
100- ) ;
101- gas_left -= deposit_cost;
98+ if code_hash != CodeDB :: empty_code_hash ( ) {
99+ let bytecode_len = self . code ( code_hash) . unwrap ( ) . len ( ) as u64 ;
100+ let deposit_cost = bytecode_len * GasCost :: CODE_DEPOSIT_BYTE_COST . as_u64 ( ) ;
101+ assert ! (
102+ gas_left >= deposit_cost,
103+ "gas left {gas_left} is not enough for deposit cost {deposit_cost}"
104+ ) ;
105+ gas_left -= deposit_cost;
106+ }
102107 }
103108
104109 Gas ( gas_left)
You can’t perform that action at this time.
0 commit comments