Skip to content

Hash linker #5145

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

Merged
merged 7 commits into from
Oct 12, 2018
Merged

Hash linker #5145

merged 7 commits into from
Oct 12, 2018

Conversation

chriseth
Copy link
Contributor

@chriseth chriseth commented Oct 4, 2018

Fixes #3918
Fixes #4429

@chriseth chriseth requested a review from axic October 4, 2018 13:00
@codecov
Copy link

codecov bot commented Oct 4, 2018

Codecov Report

Merging #5145 into develop will decrease coverage by 59.25%.
The diff coverage is 5.26%.

Impacted file tree graph

@@             Coverage Diff              @@
##           develop    #5145       +/-   ##
============================================
- Coverage    87.92%   28.66%   -59.26%     
============================================
  Files          321      318        -3     
  Lines        31979    31775      -204     
  Branches      3783     3770       -13     
============================================
- Hits         28118     9109    -19009     
- Misses        2576    21986    +19410     
+ Partials      1285      680      -605
Flag Coverage Δ
#all ?
#syntax 28.66% <5.26%> (+0.03%) ⬆️

@chriseth
Copy link
Contributor Author

chriseth commented Oct 4, 2018

It seems this needs an implementation of the linker in solc-js and for that we need a keccak256 dependency.

@chriseth
Copy link
Contributor Author

chriseth commented Oct 4, 2018

Needs ethereum/solc-js#266

@axic
Copy link
Member

axic commented Oct 4, 2018

I think standard json output should contain the hash for the unlinked references or at least the documentation be extended to explain that.

@chriseth
Copy link
Contributor Author

chriseth commented Oct 5, 2018

@axic standard json contains offset references - I don't think we need to list the hashes in addition to that.

@erak
Copy link
Collaborator

erak commented Oct 5, 2018

This looks very good. I'd consider some more testing around compiling and linking multiple libraries. Even though conflicts should not happen anymore in theory. I feel like having some kind of proof with regards to the audit.

@axic I also think that we do not need to add extra hashes for unlinked references to the standard json output. But I'd test the bytecode format more extensively and then cover the offsets.

Copy link
Collaborator

@erak erak left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After going through this again, I think that we should have enough test coverage. But: the documentation needs an update.

@chriseth
Copy link
Contributor Author

chriseth commented Oct 8, 2018

Added documentation - I actually already had it, just forget to check it in.

If your contracts use :ref:`libraries <libraries>`, you will notice that the bytecode contains substrings of the form ``__LibraryName______``. You can use ``solc`` as a linker meaning that it will insert the library addresses for you at those points:
If your contracts use :ref:`libraries <libraries>`, you will notice that the bytecode contains substrings of the form ``__53aea86b7d70b31448b230b20ae141a537e5__``. These are placeholders for the actual library addresses.
The placeholder is a 36 character prefix of the hex encoding of the keccak256 hash of the fully qualified library name.
The bytecode file will also contain lines of the form ``// <placeholder> -> <library name>`` at the end to help
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't this be // <placeholder> -> <library path>:<library name>?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will change it to "fully qualified library name".

@@ -905,8 +905,10 @@ void CommandLineInterface::handleCombinedJSON()
if (requests.count("metadata"))
contractData["metadata"] = m_compiler->metadata(contractName);
if (requests.count(g_strBinary))
// Do we want to change it here or not?
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you mean with this comment? Is this a left-over?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is a question to the reviewers.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, I wasn't sure :) I'd prefer to add such questions as regular comments to the pull request. In that case, I'd say yes, let's be consistent and also add the reference hints to the combined-json output.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, perhaps I should give the reason why I did not add it here: I would assume some tools to be confused when a json string suddenly starts containing newlines, and several tools might not be prepared for that.

@erak
Copy link
Collaborator

erak commented Oct 8, 2018

Restarted the failing Linux test.

@chriseth
Copy link
Contributor Author

chriseth commented Oct 9, 2018

The driveby-bugfixes inside this PR are getting out of hand...

@chriseth chriseth force-pushed the hashLinker branch 2 times, most recently from 1e5b321 to a017c02 Compare October 10, 2018 13:25
erak
erak previously approved these changes Oct 10, 2018
@chriseth chriseth deleted the hashLinker branch November 13, 2018 18:38
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

Successfully merging this pull request may close these issues.

3 participants