Skip to content

Commit faf5038

Browse files
blockifier: box ExecutionError in ctor error
1 parent 4a22ed4 commit faf5038

File tree

4 files changed

+25
-28
lines changed

4 files changed

+25
-28
lines changed

crates/apollo_rpc_execution/src/execution_test.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -785,7 +785,7 @@ fn blockifier_error_mapping() {
785785

786786
let blockifier_err = BlockifierTransactionExecutionError::ContractConstructorExecutionFailed(
787787
ConstructorEntryPointExecutionError::ExecutionError {
788-
error: child,
788+
error: Box::new(child),
789789
class_hash,
790790
contract_address: storage_address,
791791
constructor_selector: None,

crates/blockifier/src/execution/errors.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ pub enum ConstructorEntryPointExecutionError {
121121
)]
122122
ExecutionError {
123123
#[source]
124-
error: EntryPointExecutionError,
124+
error: Box<EntryPointExecutionError>,
125125
class_hash: ClassHash,
126126
contract_address: ContractAddress,
127127
constructor_selector: Option<EntryPointSelector>,
@@ -135,7 +135,7 @@ impl ConstructorEntryPointExecutionError {
135135
selector: Option<EntryPointSelector>,
136136
) -> Self {
137137
Self::ExecutionError {
138-
error,
138+
error: Box::new(error),
139139
class_hash: ctor_context.class_hash,
140140
contract_address: ctor_context.storage_address,
141141
constructor_selector: selector,

crates/blockifier/src/test_utils.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,7 @@ macro_rules! check_tx_execution_error_inner {
253253
TransactionExecutionError::ContractConstructorExecutionFailed(
254254
ConstructorEntryPointExecutionError::ExecutionError { error, .. },
255255
) => {
256-
$crate::check_entry_point_execution_error!(&error, $expected_hint)
256+
$crate::check_entry_point_execution_error!(&*(error.as_ref()), $expected_hint)
257257
}
258258
_ => panic!("Unexpected structure for error: {:?}", $error),
259259
}

crates/blockifier/src/transaction/transactions_test.rs

Lines changed: 21 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -2168,13 +2168,11 @@ fn test_deploy_account_tx(
21682168
assert_matches!(
21692169
error,
21702170
TransactionExecutionError::ContractConstructorExecutionFailed(
2171-
ConstructorEntryPointExecutionError::ExecutionError {
2172-
error: EntryPointExecutionError::StateError(
2173-
StateError::UnavailableContractAddress(_)
2174-
),
2175-
..
2176-
}
2171+
ConstructorEntryPointExecutionError::ExecutionError { error, .. }
21772172
)
2173+
if matches!(*error, EntryPointExecutionError::StateError(
2174+
StateError::UnavailableContractAddress(_)
2175+
))
21782176
);
21792177
}
21802178

@@ -2208,14 +2206,13 @@ fn test_fail_deploy_account_undeclared_class_hash(
22082206
assert_matches!(
22092207
error,
22102208
TransactionExecutionError::ContractConstructorExecutionFailed(
2211-
ConstructorEntryPointExecutionError::ExecutionError {
2212-
error: EntryPointExecutionError::StateError(
2213-
StateError::UndeclaredClassHash(class_hash)
2214-
),
2215-
..
2216-
}
2209+
ConstructorEntryPointExecutionError::ExecutionError { error, .. }
2210+
)
2211+
if matches!(
2212+
*error,
2213+
EntryPointExecutionError::StateError(StateError::UndeclaredClassHash(class_hash))
2214+
if class_hash == undeclared_hash
22172215
)
2218-
if class_hash == undeclared_hash
22192216
);
22202217
}
22212218

@@ -2231,21 +2228,21 @@ fn check_native_validate_error(
22312228
..
22322229
} => {
22332230
assert!(!validate_constructor);
2234-
*boxed_syscall_error
2231+
boxed_syscall_error
22352232
}
22362233
TransactionExecutionError::ContractConstructorExecutionFailed(
2237-
ConstructorEntryPointExecutionError::ExecutionError {
2238-
error: EntryPointExecutionError::NativeUnrecoverableError(boxed_syscall_error),
2239-
..
2240-
},
2241-
) => {
2242-
assert!(validate_constructor);
2243-
*boxed_syscall_error
2244-
}
2245-
_ => panic!("Unexpected error: {:?}", error),
2234+
ConstructorEntryPointExecutionError::ExecutionError { error: boxed_error, .. },
2235+
) => match *boxed_error {
2236+
EntryPointExecutionError::NativeUnrecoverableError(boxed_syscall_error) => {
2237+
assert!(validate_constructor);
2238+
boxed_syscall_error
2239+
}
2240+
_ => panic!("Unexpected error: {:?}", boxed_error),
2241+
},
2242+
_ => panic!("Unexpected error: {:?}", &error),
22462243
};
22472244
assert_matches!(
2248-
syscall_error,
2245+
*syscall_error,
22492246
SyscallExecutionError::SyscallExecutorBase(
22502247
SyscallExecutorBaseError::InvalidSyscallInExecutionMode { .. }
22512248
)

0 commit comments

Comments
 (0)