Skip to content
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

sourceList should preserve its original ordering #112

Closed
ggrieco-tob opened this issue Oct 4, 2020 · 1 comment
Closed

sourceList should preserve its original ordering #112

ggrieco-tob opened this issue Oct 4, 2020 · 1 comment

Comments

@ggrieco-tob
Copy link
Member

The sourceList field does not always preserve its original order:

source_list = [x.absolute for x in crytic_compile.filenames]
# Create our root object to contain the contracts and other information.
output = {"sources": sources, "sourceList": source_list, "contracts": contracts}

This is caused because crytic_compile.filenames is a Set and converting it to a list won't always preserve its original ordering. Unfortunately, some external software like hevm relies on this to match code in different sources.

@ggrieco-tob
Copy link
Member Author

For some reason, #120 failed to fix this. This was my workaround:

diff --git a/crytic_compile/platform/solc.py b/crytic_compile/platform/solc.py
index 395f48e..1793658 100644
--- a/crytic_compile/platform/solc.py
+++ b/crytic_compile/platform/solc.py
@@ -61,6 +61,7 @@ def export_to_solc(crytic_compile: "CryticCompile", **kwargs: str) -> Union[str,
     # Create additional informational objects.
     sources = {filename: {"AST": ast} for (filename, ast) in crytic_compile.asts.items()}
     source_list = [x.absolute for x in crytic_compile.filenames]
+    source_list.sort()
 
     # Create our root object to contain the contracts and other information.
     output = {"sources": sources, "sourceList": source_list, "contracts": contracts}

but I don't know if the PR is wrong or just my original idea about this issue is wrong.

montyly added a commit that referenced this issue Nov 9, 2020
montyly added a commit that referenced this issue Nov 9, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant