-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
fix: resolve false positive constructor arguments #1875
Conversation
d2c1ef4
to
5c85efa
Compare
Are you really sure there can't be any false positives after the |
Pull Request Test Coverage Report for Build 25fc482d-5f11-4b03-bb82-c87979d3fcfb
💛 - Coveralls |
@zachdaniel @goodsoft Here is an example of a false positive where we would run into an issue: https://etherscan.io/address/0x64d14595152b430cf6940da15c6e39545c7c5b7e#code Please see the constructor arguments and the |
@goodsoft definitely not really sure. I only just started looking into it this morning, and had a similar thought myself, but I figured I would get the bare bones solution for that specific contract up in front of people. |
Okay, so the swarm source starts with a known value, I think. So perhaps what we do is skip to the swarm source and split there? |
Yes, that's correct. Are you able to identify the swarm source without the |
Nice! That should work. |
We could use the length + |
I think it looks reliable enough for now. If they "support other ways to retrieve contract metadata in the future", this can be updated. |
{ |
Comparing now against these addresses:
|
The two contracts that failed above don't seem to have a swarm source hash. Looks like they were created prior to when swarm source was created. |
Do they also have constructor arguments? If so, then we'll need another heuristic for those. I'm almost done with the code to use the swarm hash. |
No constructor arguments. They fail when trying to verify them but probably for some other reason. Looks like an edge case. |
Well for now, if we don't find a swarm hash I'll have it use the whole thing. |
5c85efa
to
a2ebe94
Compare
@@ -181,13 +181,29 @@ defmodule Explorer.SmartContract.VerifierTest do | |||
swarm_source = "3c381c1b48b38d050c54d7ef296ecd411040e19420dfec94772b9c49ae106a0b" | |||
|
|||
bytecode = | |||
"0x608060405234801561001057600080fd5b5060df8061001f6000396000f3006080604052600436106049576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff16806360fe47b114604e5780636d4ce63c146078575b600080fd5b348015605957600080fd5b5060766004803603810190808035906020019092919050505060a0565b005b348015608357600080fd5b50608a60aa565b6040518082815260200191505060405180910390f35b8060008190555050565b600080549050905600a165627a7a72305820" |
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.
It was asserting that part of the swarm metadata hash would come back, but that would be incorrect.
Alright @vbaranov @acravenho @goodsoft this should be ready to go for real now. |
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.
LGTM 👍
<<>> -> | ||
String.reverse(extracted) | ||
|
||
"a165627a7a72305820" <> <<_::binary-size(64)>> <> "0029" <> _constructor_arguments -> |
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.
what is a165627a7a72305820
?
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.
It’s what the swarm hash starts with.
7437644
to
54a3c99
Compare
06f5fe7
to
91c0011
Compare
apps/explorer/lib/explorer/smart_contract/verifier/constructor_arguments.ex
Outdated
Show resolved
Hide resolved
41022d1
to
09446f6
Compare
09446f6
to
c3a5218
Compare
Resolves #1873
Changelog
Bug Fixes
CHANGELOG.md
with this PR