-
Notifications
You must be signed in to change notification settings - Fork 264
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
Require constant, view, and pure methods be invoked by .call
#146
Comments
This is because of a Truffle convenience that people have got used to, not Solidity/EVM, and has a workaround (though will require a modest buy-in from users). Normally, with the contract objects floating around truffle, if you call a function that is going to have an effect on the blockchain, you do something like TLDR: For function calls where you're testing against return variables, everyone should always be using EDIT: If I'm right, this change probably requires 0.4.0 (i.e. a version bump signifying a change in behaviour). |
Yes, agree - thanks for pressing for this. TBH I failed to register this was an issue at all when we did the view work a few weeks ago. And agree that .call is a better pattern anyway. |
constant
, view
, and pure
be invoked by .call
@area Closing, re-open if you wish. Thanks again. |
constant
, view
, and pure
be invoked by .call
.call
Can you explain why it will be needed to add |
@frangio Thank you, that would be wonderful. Also agree that this is annoying and ideally Quick overview of how SC currently works:
With Additionally: we have near term plans to refactor this project and abandon the event injection strategy because its quirks and bugs are piling up in an unsustainable fashion. @area Has proposed that we use If you (or anyone you know) is interested in working on this, we're open! We need new everything. Thanks again @frangio. |
Would it be possible to...? If I understand correctly, truffle contracts (or whichever library is used for calls) should just check the ABI for |
An alternative that doesn't involve compiling twice would be to compile without annotations, and then manually modify the generated schemas setting the |
@spalladino @frangio Yes! Smart!! The first idea is good and the single compilation refinement is even better. However, wondering if you'd be open to a short term (4 weeks?) compromise. This is the kind of change we prefer to test E2E on our Zeppelin fork because it adds several steps to the execution sequence and invariably there are issues we fail to catch with unit tests. If you temporarily go to If that doesn't work for you, I understand - no worries. The context for us is that this kind of fix is like giving antibiotics to a patient who needs a heart transplant. We probably need to do it to keep them alive - we also need to get moving on the main event. Open to other ideas, any suggestions. . . |
@cgewecke We're actually about to upgrade to the latest Truffle with Solidity 0.4.18. We're considering removing coverage temporarily (OpenZeppelin/openzeppelin-contracts#573), but 4 weeks until it's fixed might be too long. 😕 |
@frangio Well it's not the end of the world - just do whatever you think is best in the interim. As long as you upgrade to Byzantium we'll have a way to sanity check the implementation whenever it gets done. If someone wants to open a PR here they're welcome to as well. |
@frangio This likely makes no difference for your case because you probably want to use People who don't need to invoke their |
The branch Two tests fail to pass on that branch, and I can't spot why. I'm hoping @cgewecke can come to my rescue, there. They are
They appear to time out. Other issues with the branch that should be discussed:
I have not opened a PR yet, but if you want to move discussion there, I'm happy to do that too. |
@area Thank you, that looks good to me. If you open a PR I'll fix those tests and will update our Zeppelin fork to their latest / make sure it passes. [Edit] - My view re: other ABI properties is that the [Edit II] - I don't know of any non-truffle users except Melonport, and they're moving to DappHub which is non-testrpc anyway. |
Ironically, while this ABI rewrite idea will work for many projects, it's running into problems with Zeppelin. Example of the ABI modification strategy failing on recent Zeppelin in Travis. Possible I'm overlooking an obvious workaround here - in any case would welcome ideas from you about the best way forward. Or a correction if I've misunderstood what's wrong. Some possibilities:
|
Interesting.
Are you sure this is true? I don't think it assumes this, because Solidity test contracts need to be named like |
Nevermind, what I said about |
I think we can move the mocks into the |
@frangio Thanks, moving mocks to contracts is good here anyway - we'd just keep the current single-compilation solution and publish. Leaving this open for a bit for any other views.... [Edit - actually I think we'll still need to compile twice and substitute the original ABI, or have a dedicated instrumentation sweep for these mods]. |
How about manually creating a symlink to |
Very sorry for the delay getting this done. In the end this has been implemented using @spalladino's original idea - ABI swapping. Unfortunately was not able to get a symlink to work on our Zeppelin fork. Happy to discuss this further in our Gitter though. Closing here and will make additional notes at Zeppelin. Thank you @frangio @spalladino for thinking about this and coming up with a good solution :) |
That's great @cgewecke! And please, don't apologise about delays - getting this work done out of your own free time is awesome. Let's follow up in OpenZeppelin/openzeppelin-contracts#575 as you say. |
With
0.3.5
we've begun using atestrpc
that implements the Byzantium fork. Unfortunately we're also pushing up against the limits ofsolidity-coverage
's current design and there were some new bugs discovered while doing the upgrade:0.4.18
. Above that you will get compilation errors complaining that the non-state-changing nature ofconstant
andview
methods has been violated.pure
modifier compiles but returns a transaction object rather than a value. If your tests check / use that value they will fail.The text was updated successfully, but these errors were encountered: