Skip to content

Commit

Permalink
test(blockifier): add class hash (if set) to cairo1 revert trace
Browse files Browse the repository at this point in the history
  • Loading branch information
dorimedini-starkware committed Oct 19, 2024
1 parent 16e16d5 commit df2cd9d
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 27 deletions.
7 changes: 6 additions & 1 deletion crates/blockifier/src/execution/stack_trace.rs
Original file line number Diff line number Diff line change
Expand Up @@ -159,8 +159,13 @@ pub fn extract_trailing_cairo1_revert_trace(root_callinfo: &CallInfo) -> String
.tail_iter()
.map(|callinfo| {
format!(
"Error in contract (contract address: {:#064x}, selector: {:#064x}):\n{}",
"Error in contract (contract address: {:#064x}, class hash: {}, selector: \
{:#064x}):\n{}",
callinfo.call.storage_address.0.key(),
match callinfo.call.class_hash {
Some(class_hash) => format!("{:#064x}", class_hash.0),
None => "_".to_string(),
},
callinfo.call.entry_point_selector.0,
format_panic_data(&callinfo.execution.retdata.0)
)
Expand Down
55 changes: 30 additions & 25 deletions crates/blockifier/src/execution/stack_trace_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -215,17 +215,17 @@ An ASSERT_EQ instruction failed: 1 != 0.
0: Error in the called contract (contract address: {account_address_felt:#064x}, class hash: \
{account_contract_hash:#064x}, selector: {execute_selector_felt:#064x}):
Execution failed. Failure reason:
Error in contract (contract address: {account_address_felt:#064x}, selector: \
{execute_selector_felt:#064x}):
Error in contract (contract address: {account_address_felt:#064x}, class hash: \
{account_contract_hash:#064x}, selector: {execute_selector_felt:#064x}):
(0x6661696c ('fail'), 0x454e545259504f494e545f4641494c4544 ('ENTRYPOINT_FAILED'), \
0x454e545259504f494e545f4641494c4544 ('ENTRYPOINT_FAILED'))
Error in contract (contract address: {test_contract_address_felt:#064x}, selector: \
{external_entry_point_selector_felt:#064x}):
Error in contract (contract address: {test_contract_address_felt:#064x}, class hash: \
{test_contract_hash:#064x}, selector: {external_entry_point_selector_felt:#064x}):
(0x6661696c ('fail'), 0x454e545259504f494e545f4641494c4544 ('ENTRYPOINT_FAILED'))
Error in contract (contract address: {test_contract_address_2_felt:#064x}, selector: \
{inner_entry_point_selector_felt:#064x}):
Error in contract (contract address: {test_contract_address_2_felt:#064x}, class hash: \
{test_contract_hash:#064x}, selector: {inner_entry_point_selector_felt:#064x}):
0x6661696c ('fail').
"
);
Expand Down Expand Up @@ -343,17 +343,17 @@ Unknown location (pc=0:{expected_pc1})
0: Error in the called contract (contract address: {account_address_felt:#064x}, class hash: \
{account_contract_hash:#064x}, selector: {execute_selector_felt:#064x}):
Execution failed. Failure reason:
Error in contract (contract address: {account_address_felt:#064x}, selector: \
{execute_selector_felt:#064x}):
Error in contract (contract address: {account_address_felt:#064x}, class hash: \
{account_contract_hash:#064x}, selector: {execute_selector_felt:#064x}):
({expected_error}, 0x454e545259504f494e545f4641494c4544 ('ENTRYPOINT_FAILED'), \
0x454e545259504f494e545f4641494c4544 ('ENTRYPOINT_FAILED'))
Error in contract (contract address: {contract_address_felt:#064x}, selector: \
{invoke_call_chain_selector_felt:#064x}):
Error in contract (contract address: {contract_address_felt:#064x}, class hash: \
{test_contract_hash:#064x}, selector: {invoke_call_chain_selector_felt:#064x}):
({expected_error}, 0x454e545259504f494e545f4641494c4544 ('ENTRYPOINT_FAILED'))
Error in contract (contract address: {contract_address_felt:#064x}, selector: \
{invoke_call_chain_selector_felt:#064x}):
Error in contract (contract address: {contract_address_felt:#064x}, class hash: \
{test_contract_hash:#064x}, selector: {invoke_call_chain_selector_felt:#064x}):
{expected_error}.
"
)
Expand Down Expand Up @@ -501,23 +501,23 @@ Unknown location (pc=0:{expected_pc3})
0: Error in the called contract (contract address: {account_address_felt:#064x}, class hash: \
{account_contract_hash:#064x}, selector: {execute_selector_felt:#064x}):
Execution failed. Failure reason:
Error in contract (contract address: {account_address_felt:#064x}, selector: \
{execute_selector_felt:#064x}):
Error in contract (contract address: {account_address_felt:#064x}, class hash: \
{account_contract_hash:#064x}, selector: {execute_selector_felt:#064x}):
({expected_error}, 0x454e545259504f494e545f4641494c4544 ('ENTRYPOINT_FAILED'), \
0x454e545259504f494e545f4641494c4544 ('ENTRYPOINT_FAILED'), \
0x454e545259504f494e545f4641494c4544 ('ENTRYPOINT_FAILED'))
Error in contract (contract address: {address_felt:#064x}, selector: \
{invoke_call_chain_selector_felt:#064x}):
Error in contract (contract address: {address_felt:#064x}, class hash: {test_contract_hash:#064x}, \
selector: {invoke_call_chain_selector_felt:#064x}):
({expected_error}, 0x454e545259504f494e545f4641494c4544 ('ENTRYPOINT_FAILED'), \
0x454e545259504f494e545f4641494c4544 ('ENTRYPOINT_FAILED'))
Error in contract (contract address: {address_felt:#064x}, selector: \
{invoke_call_chain_selector_felt:#064x}):
Error in contract (contract address: {address_felt:#064x}, class hash: {test_contract_hash:#064x}, \
selector: {invoke_call_chain_selector_felt:#064x}):
({expected_error}, 0x454e545259504f494e545f4641494c4544 ('ENTRYPOINT_FAILED'))
Error in contract (contract address: {address_felt:#064x}, selector: \
{last_func_selector_felt:#064x}):
Error in contract (contract address: {address_felt:#064x}, class hash: {test_contract_hash:#064x}, \
selector: {last_func_selector_felt:#064x}):
{expected_error}.
"
)
Expand Down Expand Up @@ -617,8 +617,10 @@ An ASSERT_EQ instruction failed: 1 != 0.
),
CairoVersion::Cairo1 => format!(
"The `validate` entry point panicked with:
Error in contract (contract address: {contract_address:#064x}, selector: {selector:#064x}):
0x496e76616c6964207363656e6172696f ('Invalid scenario')."
Error in contract (contract address: {contract_address:#064x}, class hash: {:#064x}, selector: \
{selector:#064x}):
0x496e76616c6964207363656e6172696f ('Invalid scenario').",
class_hash.0
),
};

Expand Down Expand Up @@ -685,10 +687,11 @@ An ASSERT_EQ instruction failed: 1 != 0.
.to_string(),
CairoVersion::Cairo1 => format!(
"Execution failed. Failure reason:
Error in contract (contract address: {expected_address:#064x}, selector: \
Error in contract (contract address: {expected_address:#064x}, class hash: {:#064x}, selector: \
{expected_selector:#064x}):
0x496e76616c6964207363656e6172696f ('Invalid scenario').
"
",
class_hash.0
)
.to_string(),
};
Expand Down Expand Up @@ -818,11 +821,13 @@ Error at pc=0:{}:
Error at pc=0:{}:
{frame_2}
Execution failed. Failure reason:
Error in contract (contract address: {expected_address:#064x}, selector: {:#064x}):
Error in contract (contract address: {expected_address:#064x}, class hash: {:#064x}, selector: \
{:#064x}):
0x496e76616c6964207363656e6172696f ('Invalid scenario').
",
execute_offset + 205,
deploy_offset + 194,
faulty_class_hash.0,
ctor_selector.0
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ fn test_syscall_failure_format() {
error.to_string(),
format!(
"Execution failed. Failure reason:
Error in contract (contract address: {:#064x}, selector: {:#064x}):
Error in contract (contract address: {:#064x}, class hash: _, selector: {:#064x}):
\"Execution failure\".",
ContractAddress::default().0.key(),
EntryPointSelector::default().0
Expand Down

0 comments on commit df2cd9d

Please sign in to comment.