-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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(forge compile): print compiled contract names #682
Conversation
Related: #588 |
Supportive of table view + forge size + forge build --size. Would be enough to close 588 |
dd690ab
to
bc613e1
Compare
@tynes fyi, you can now subscribe to the socl |
b88a9c1
to
25b41b2
Compare
I've updated this PR to only print the names of contracts that were compiled + the compiler version for simplicity, since that seems like the lower hanging feature for now. Do you still want this to be behind a flag? |
25b41b2
to
236108b
Compare
Yep let's always have this behind a flag if possible @tynes? |
Will add it behind a flag, thinking |
Yeah |
right, this will conflict since test also includes a hmm this is a bit tricky, we could change the actual build command to struct Build {
#[clap(flatten)]
opts: BuildArgs,
verbosity: u8 so that build and test have separate verbosity flags, but then the question is should we print build info in or we use a different flag? I'd lean towards also printing build info with |
@tynes think we have all the helper functions in, so can move this PR forward? |
Definitely, I have some changes locally but have been bikeshedding on the exact flag to use for printing this information. I'm currently leaning towards a new flag that isn't |
Ah I see. What about |
Sounds good to me, will use this for the table: |
@tynes wanna push over your local changes? I'm happy to help to get this PR over the line today |
Print the names of the compiled contracts after running `forge compile`. Its useful to know which contracts were compiled and the compiler version that was used. The output looks like this: ```bash $ forge build --hardhat compiling... compiled contracts: compiler version: 0.5.17+commit.d19bba13.Linux.gcc - WETH9 compiler version: 0.8.11+commit.d7f03943.Linux.gcc - AddressDictator - ChugSplashDictator - IL1CrossDomainMessenger - IL1ERC20Bridge - IL1StandardBridge - L1CrossDomainMessenger - L1StandardBridge - CanonicalTransactionChain - ChainStorageContainer - ICanonicalTransactionChain - IChainStorageContainer - IStateCommitmentChain - StateCommitmentChain success. ```
236108b
to
256561d
Compare
for (_, contracts) in compiled_contracts.into_iter() { | ||
for (name, contract) in contracts { | ||
let bytecode: CompactContractBytecode = contract.into(); | ||
let size = if let Some(code) = bytecode.bytecode { |
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.
This seems to always be 0 for libraries
} | ||
} | ||
if print_sizes { | ||
let compiled_contracts = output.compiled_contracts_by_compiler_version(); |
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.
This code could be modularized and reused in the future for foundry sizes
Motivation
I want to know which contracts were compiled when running
forge build
and the compiler version that was used.Solution
Print the names of the compiled contracts after
running
forge compile
. Its useful to know whichcontracts were compiled and the compiler version
that was used.
The output looks like this:
Not sure how much I like the output of
--sizes
when usingfoundry_utils::to_table
. I think iterating and printing similarly to--names
could look better. Thoughts?