-
Notifications
You must be signed in to change notification settings - Fork 796
Change artifact naming conventions #791
Comments
@gakonst @mattsse to what degree is the format of Dealing with artifact naming collisions wrt different version pragmas, we necessarily end up with artifacts arranged sth like:
But with only one entry for Seems like the 'correct' way to change it would be to have the (Could also key against artifact path, but I think that would add more complexity in how the cache is handled internally.) Do you guys see any issues deviating from format here? Also, if this is ok, do you think this would warrant / require bumping the |
thanks for the write-up. +1 on modifying the cache format, I've thought about that already and we should break with hh format regardless just because there might be footguns when switching between both of them. I think I'd rather flip it and do rn the cache's file entries is a map with the source path of the solidity files as key like So your suggestion makes sense to make I also don't really like that artifacts are only stored by name, because this way we need to resolve the artifact manually, perhaps it would make more sense to store the relative path to all file artifacts jsons there. definitely bumping the version slug |
If we're changing Storing relative paths in the cache, keeping the artifact folder flat & only versioning conflicting items sounds good:
That's a lot cleaner. Afaik (I'll look at it more closely) the only part of |
I wonder if we should then add the solc version and optimizer runs in the filename? That would also solve for etherscan verification |
Do you mean caching version + optimizer info or specifically adding it to filenames? Optimizer info is currently stored in |
|
@gakonst I'd have to check if there are any scenarios where the contents of Does anything in the cache need to be user accessible? I'm not sure if you're suggesting a specific use case here. |
the use case is etherscan verification which requires both solidity version and optimizer runs. Right now this Metadata is only stored at the cache file. My q is: is that the right place? Should that Metadata instead exist in the artifacts? Maybe it doesn't matter because it's likely that artifacts+cache always go together? |
Ah ok, I understand now, thanks @gakonst I'd suggested keeping it in the cache since artifacts don't carry any metadata currently. Writing artifacts and caching are separate flags internally, but afaik they're always used together apart from internal testing, so I don't think forge could ever see one written without the other. I can add in some convenience methods so forge (or anything downstream) can query the cache easily. I don't think those currently exist anywhere. Would that be helpful? |
Re the cache file, looks like Also, I don't think it makes sense to change Keeping a set of |
I'd try to group them if possible to avoid duplication, but that might be hard. Am OK with the suggested approach if @mattsse agrees |
Yeah, trying it out now -- I think storing a separate config per artifact is going to bloat the cache too much. I think I'll keep it as-is and store versions/artifact paths in a separate key. I was thinking the preprocessor will have to be modified to not only check for config changes, but also for version changes -- but I guess they should always be caught by source hash changes. Afaik there's no other way to specify multiple compilers per run (other than in pragma directives). |
@mattsse -- a lot of what I've done so far is version handling. I didn't realize this work was being done elsewhere. Feel free to cherry pick if yours isn't done yet. Right now I'm working on a bug in The only thing I've done to I'll push recent commits so you have them, though they're not really for public consumption (scattered todos, lack of docs) |
@rkrasiuk on second thought, I don't see why we can't finish part of this so you can ship your feature downstream. Matt could incorporate our changes into his rewrite if they overlap. High level what needs to get done:
If you want to help, you could start at #\4, I already know what has to get done for the other two. Depending on what you need there, we can change what's stored in the cache. |
@rkrasiuk this is mostly done now save for updating tests, if you can explain what info you need downstream I can put together #\4 for you, assuming you're not already working on it. |
@lattejed sure thing. i'd need 2 things to fix/improve etherscan verify: compiler version and number of optimizations runs. preliminary work on this was done in PR #755, but gakonst closed it as stale. the acceptance criteria would be:
|
@rkrasiuk so you need both artifacts (abi / bytecode) and metadata (compiler input / settings)? Do you know what the requirements are for compiler version? There are three formats used internally:
|
@lattejed etherscan accepts the expanded version format like |
@rkrasiuk I've added a couple things:
I'll assume wherever you're consuming this you won't have access to
If you want to change any of this let me know. |
@rkrasiuk ah, ok. If you have a |
@lattejed great work, thanks! looking through the PR rn |
This was prompted by the forge issue here: foundry-rs/foundry#392
Two overlapping issues:
Some tests are being executed but dropped by forge due to naming conventions (that are decided upstream here). This can be fixed w/in forge, however:
Contract names are under-specified here, where duplicate names across different files are presented ambiguously as filenames / paths are not retained.
Example, this is how dapptools presents test names:
<path>/<filename>:<name>
forge:
<filename>:<name>
Example test output:
dapptools:
forge:
^ both
Greeter
andGreeter_2
are run by forge, but one is dropped from presentation due to how result are collected internally.Using dapptools-style output is unambiguous. I'm proposing either changing naming conventions here to match dapptools. This would be a breaking change.
It may also make sense to keep things as-is but expose path, etc. so they can be consumed downstream.
--
As @mattsse has pointed out, currently artifacts from different compiler versions are not handled correctly. This is a caching, not a presentation issue, but can be addressed at the same time.
He also suggested having some / all of this configurable, tying in:
https://github.com/gakonst/foundry/blob/f9007fa8c238ffbb1365b26460a949ead303c046/config/README.md
@mattsse I'm not sure if you're thinking making output naming configurable or caching or both?
Any / all input welcome. I'll work on this myself.
The text was updated successfully, but these errors were encountered: