File tree 1 file changed +13
-8
lines changed
bus-mapping/src/circuit_input_builder
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> {
90
90
let mut gas_left = prev_step. gas_left . 0 - prev_step. gas_cost . 0 ;
91
91
// handling for contract creation tx
92
92
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
+ {
94
97
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
+ }
102
107
}
103
108
104
109
Gas ( gas_left)
You can’t perform that action at this time.
0 commit comments