Use artifact_id instead of file_id#7536
Closed
wtdcode wants to merge 1 commit into
Closed
Conversation
Member
|
Nice catch! This logic def should be revisited, I'm also not sure about the contract names values we are operating on here I believe the current impl is incorrect as we are dependent on foundry/crates/debugger/src/tui/draw.rs Lines 361 to 365 in 0578aae and this would not be true for internal indexes this PR introduces |
Member
|
This should probably be solvable by having pub struct ContractSources {
/// Map over artifacts' contract names -> vector of file IDs
pub ids_by_name: HashMap<String, Vec<u32>>,
/// Map over file_id -> source code
pub sources_by_id: FxHashMap<u32, String>,
/// Map over file_id -> contract name -> bytecode
pub artifacts_by_id: FxHashMap<u32, HashMap<String, ContractBytecodeSome>>,
} |
Member
|
Closing in favor of #7550 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
There is a design flaw with
ContractSources, that always assumes 1 file_id only has 1 artifact. However, It can often happen like:In this case, 1 file_id would have two artifacts. As a result, the
sourcemapofTwould be overwritten byAifTis iterated earlier in this loop:foundry/crates/common/src/compile.rs
Lines 296 to 319 in bd56eef
This currently breaks my
forge test --debugby showingno source map from contract xxxx.Solution
This PR fixes it by using
artifact_idinstead offile_id. I carefully checked the API exposed byContractSources, and I think currently no other component seems to be using it so it should be safe to make this change. I'm not very sure if this is the best solution but I'm open to discussion.