foundry-rs / starknet-foundry

Blazing fast toolkit for developing Starknet contracts.
https://foundry-rs.github.io/starknet-foundry/
MIT License
317 stars 156 forks source link

Different errors when calling unknown entry point selector error from contract and from test #1812

Open drknzz opened 7 months ago

drknzz commented 7 months ago

Which components does the task require to be changed? (think hard pls)

snforge

Description

Calling inexistent entry point:

When calling from test this is the entered arm: https://github.com/foundry-rs/starknet-foundry/blob/b02aa0c7ef1aadc48a2d51467fdf55045387c695/crates/cheatnet/src/runtime_extensions/call_to_blockifier_runtime_extension/rpc.rs#L138

However when calling from another contract, this is the entered arm: https://github.com/foundry-rs/starknet-foundry/blob/b02aa0c7ef1aadc48a2d51467fdf55045387c695/crates/cheatnet/src/runtime_extensions/call_to_blockifier_runtime_extension/rpc.rs#L131 It enters try_extract_panic_data

One solution would be to match the entry point error message via a regex in there.


The use case for calling an inexistent entry point is testing entry points after calling replace_class.

Example error message:

Failure data:
    Got an exception while executing a hint: Hint Error: Error in the called contract (0x0480ddec869b0aa42b46971088ba8701df26fcabb2d3e9d324fd6fd3d013fef7):
Error at pc=0:927:
Got an exception while executing a hint.
Cairo traceback (most recent call last):
Unknown location (pc=0:358)
Unknown location (pc=0:739)

Error in the called contract (0x01f78e70f8b1e91ac2c327a35e451c1985ba46c4c8f4f19488e5a5e135e5be74):
Error at pc=0:1197:
Got an exception while executing a hint: Hint Error: Entry point EntryPointSelector(StarkFelt("0x0017c00f03de8b5bd58d2016b59d251c13056b989171c5852949903bc043bc27")) not found in contract.
Cairo traceback (most recent call last):
Unknown location (pc=0:475)
Unknown location (pc=0:926)
Arcticae commented 7 months ago

The same happens when you call a contract that is not deployed. It's not being able to handle the result, it panics immediately.

Arcticae commented 7 months ago

BTW: I would wonder if that's the behavior that is possible to replicate on contract-contract basis on starknet currently, before we implement it (for both of those cases)