foundry-rs / starknet-foundry

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

Make errors thrown during data transformation more descriptive #2554

Open integraledelebesgue opened 2 weeks ago

integraledelebesgue commented 2 weeks ago

Component the issue is related to

Cast - data transformer

Issue

Before introducing calldata transformation, commands used to throw quite verbose errors concerning e.g. absence of the requested class hash. They originated from blockifier. Since transformer was introduced, such errors are thrown earlier in the execution process and are less descriptive

I added a workaround for preserving old error messages despite throwing them from completely different place. ContractErrors normally obtained after sending transaction to chain are created here and here to mimic the old behaviour.

This isn't a nice solution though. Maybe we should rethink our error propagation logic and perform a revamp.

cptartur commented 1 week ago

@integraledelebesgue please update this

cptartur commented 1 week ago

I think we could at least retain behavior similar to older errors we had.

E.g. (as of writing this) instead of an error like that error: An error occurred in the called contract[..]Class with hash[..]is not declared[..] we now throw "Error: Couldn't retrieve contract class with hash:.

However, the RPC endpoint used to get contract class (and so an ABI) is throwing a very descriptive error https://github.com/starkware-libs/starknet-specs/blob/6d88b7399f56260ece3821c71f9ce53ec55f830b/api/starknet_api_openrpc.json#L522 in a case where contract is missing: We could handle that and show an information to the user that the contract is not declared to the network at all.

integraledelebesgue commented 1 week ago

See #2572