foundry-rs / foundry

Foundry is a blazing fast, portable and modular toolkit for Ethereum application development written in Rust.
https://getfoundry.sh
Apache License 2.0
8.34k stars 1.77k forks source link

bug: `cast run` does not decode events on local node with chain id `1337` #9255

Closed drortirosh closed 1 week ago

drortirosh commented 3 weeks ago

Component

Cast

Describe the feature you would like

doing cast run <tx> doesn't always fully decode calls and events. When executed against local node, it does parse methodIds, but not events. However, when decoding transaction on external chains (event testnet, like sepolia), it parses both methods and events.

Apparently, it depends on the "chainId" of the local node, and when chainId is "1337", it fails to decode some information. with Anvil, I can add --chain-id, but some of my tests require geth, which can't easily change the chainid.

suggestion Either should be able to "push" symbol information to chain-id specific, or add a fallback, that if methodid/topicid are missing for a specific chain, then use them from another (after all, they can't differ much, the methodid/topicid depend on the method name and parameter types. the only thing that can differ between networks is the parameter names)

Additional context

No response

grandizzy commented 2 weeks ago

I think we're fetching that from etherscan API that is mapped to chain id (https://github.com/alloy-rs/chains/blob/main/src/named.rs#L1047), what you could try is to map the dev chainId "1337" (https://github.com/alloy-rs/chains/blob/main/src/named.rs#L170) to an Etherscan url / api, see https://book.getfoundry.sh/reference/config/etherscan Pls lmk if this helps, thank you

le: sorry, just noticed that's cast run so no foundry.toml config. maybe we can make etherscan url option available in cast run

grandizzy commented 2 weeks ago

possible related https://github.com/foundry-rs/foundry/issues/3473

grandizzy commented 1 week ago

marking as dupe of https://github.com/foundry-rs/foundry/issues/8606 and going to track impl there. thank you!