-
Notifications
You must be signed in to change notification settings - Fork 1.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(cast/forge): add label addresses in foundry config #6680
feat(cast/forge): add label addresses in foundry config #6680
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
supportive. nits:
crates/cheatcodes/src/inspector.rs
Outdated
pub fn get_labels(&self) -> HashMap<Address, String> { | ||
let mut labels = self.labels.clone(); | ||
labels.extend(self.config.labels.clone().into_iter()); | ||
labels | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
any chance we could just return a reference here so we don't have to copy on every access? this can get expensive
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think much better way to solve this is passing a label getter closure or object to its usages such as Error::encode(err.to_error_msg(...))
or InspectorData::labels
because most of the time we don't need the entire hashmap of labels... but I will try to fix this to return a reference for this time.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Assuming config does not change over program lifecycle, just copied labels from config on cheatcodes creation and used it as single source of truth. 4621127
jail.create_file( | ||
"foundry.toml", | ||
r#" | ||
[labels] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
shouldn't the labels in config be chain specific though?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought that most address labels for evm chains can be safely reused because contract addresses created using CREATE2
and externally owned accounts created from same private key or seed phrase share the same address over all chains. Tagging Uniswap V3: Factory
over all chains would be cumbersome. I think it would be much better if there is chain-specific label section and globally shared label section to keep chain-specific labels from universally used addresses, but I just kept this PR's scope into global labels only.
clippy is failing only on CI and it is also failing in master branch. Is there anything I can do to solve this? |
Nope, it's a bug in Clippy |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
seems reasonable.
having them globally not chain specific should be good enough, we could add chain info if this turns out to be an issue
pending @mds1
Motivation
Inspecting & testing transactions that require multiple address labels is quite painful at this point because it makes the cast command or test script unnecessarily verbose.
Solution
Add
labels
section in foundry config that allows to pre-label frequently used addresses. Most evm addresses are used as the same purpose across multiple chains, so the config is considered standalone section. The config is then merged with given cli argument incast run
/ given cheatcode labeled addresses inforge test
and the merged labels collection is used to label the final trace.