-
Notifications
You must be signed in to change notification settings - Fork 281
Support Solidity 0.5.x #318
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
Conversation
truffle v5, leapdao/solidity-parser
We can't run them, but there here for if we ever figure it out!
Codecov Report
@@ Coverage Diff @@
## master #318 +/- ##
==========================================
- Coverage 95.38% 92.07% -3.31%
==========================================
Files 6 6
Lines 368 366 -2
Branches 84 79 -5
==========================================
- Hits 351 337 -14
- Misses 17 29 +12
Continue to review full report at Codecov.
|
|
Noticed one issue. If I have a line within a function like this: address payable owner = msg.sender;It seems to fail with: I debugged and found that it's the coverage-generated line just before that source line which fails. Specifically, it's unable to fetch function call arguments: emit __CoverageDeployer('/home/user/dev/contracts/Deployer.sol',31);
emit __StatementCoverageDeployer('/home/user/dev/contracts/Deployer.sol',1); // <-- this line fails!
address payable owner = msg.sender; |
|
Hm, I'm not able to reproduce it with a contract with just that line in... can you provide more context? |
|
@area Sure. Here is the full code: pragma solidity ^0.5.4;
import './zeppelin/lifecycle/Destructible.sol';
import './Conference.sol';
contract Deployer is Destructible {
event NewParty(
address indexed deployedAddress,
address indexed deployer
);
function deploy(
string calldata _name,
uint256 _deposit,
uint _limitOfParticipants,
uint _coolingPeriod
) external {
address payable owner = msg.sender;
Conference c = new Conference(
_name,
_deposit,
_limitOfParticipants,
_coolingPeriod,
owner
);
emit NewParty(address(c), owner);
}
}I'm fairly sure the code for |
|
Ah, just an additional note that the code above is new code that's not yet tested in the wild - I'm trying to upgrade our contracts to 0.5+, hence why I'm trying out this beta version of solidity-coverage. Thanks for the working on this, btw :) |
…compatible - also fixes this for Yarn-based projects
|
I've re-coded it to get it working (I removed the offending line and simply used |
Fix the decoder version since future beta releases are not backwards …
lib/coverageMap.js
Outdated
| * from data generated by `instrumentSolidity.js` | ||
| */ | ||
| const SolidityCoder = require('web3/lib/solidity/coder.js'); | ||
| const SolidityCoder = require('web3-eth-abi'); |
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.
@area It looks like the API for this package has changed. I got it working as follows:
| const SolidityCoder = require('web3-eth-abi'); | |
| const { AbiCoder } = require('web3-eth-abi'); | |
| const SolidityCoder = AbiCoder(); |
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.
Oh I guess this is related to @hiddentao's comment. I'm not sure if this is the only fix needed, but for me it is generating the reports correctly.
Also, are there plans to update testrpc-sc? There are things like eth_signTypedData that are present in ganache but not in the sc fork.
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.
Hm, this change definitely breaks for me, with TypeError: AbiCoder is not a function - indeed AbiCoder is not defined at all. Are you working with the beta release or this branch?
I agree an update for testrpc-sc would be good. I'm going to concentrate on this solidity 0.5.x support for now though.
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.
Beta release 46 changes the API, hence why the current code breaks if you install the latest web3 abi beta. Unfortunately the web3 team's current release versioning usage breaks semantic versioning. Hence why my PR to fix the dependency version specifically.
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.
Oh derp, I understand now. I could have sworn your PR fixed the version of web3, not web3-eth-abi.
|
@hiddentao I have seen the behaviour locally, but am unable to get a test to fail along those lines, which is quite frustrating. I agree this should be fixed though, so will be holding off a non-beta release until I track it down. |
|
@hiddentao It looks like your error is something to do with |
|
So the reason the setup transaction reverted is because ZOS are very cutting-edge, and have already introduced the I have published a new beta which should work for you, @JirkaChadima. I think you also need to add For everyone else:
|
|
You, sir, are awesome! Outstanding work and it's now running as expected in our repo. Thank you very much! |
|
Hello @area Thanks |
|
Hello @area, thank you very much for the effort put into this project. I'm facing an issue with this contract: https://github.com/GoodDollar/GoodContracts/blob/master/contracts/BancorFormula.sol The error: To reproduce: Thanks! |
|
Hey @area, thanks for updating everything! We're currently using the beta and we've been running into a compilation issue related to calling internal functions from a constructor (I think this used to be an issue in The error that the compiler gives is: We've noticed that moving the internal call to a Two other things to note:
|
|
Hey @area, The respective code can be found here: https://github.com/IoBuilders/holdable-token/tree/5a7bfac9bd55ffe91724fbeb06da4cfab5818255 After executing Thanks for any hints, how I could correct the code coverage report to be created correctly. |
|
@daniel-iobuilders Is this the function? function _getBlockTimeStamp() internal view returns (uint256) {
/* solium-disable-next-line security/no-block-members */
return block.timestamp;
}It's possible the method is getting optimized out by solc. Is there a reason why you've encapsulated |
The encapsulation is done to overwrite it in the mock implementation of the contract and use it in the unit tests to manipulate the returned block timestamp. The smart contract has a concept of expiration and in order to test if the expiration logic I need to manipulate the returned timestamp. I've deactivated the optimizer in truffle-config.js, but get the same result. I will do some more tests to check if it could be related to the compiler. |
|
@daniel-iobuilders, re:
There is an alternative way of doing this with ganache which has extension RPC endpoints that let you increase the block time. OpenZeppelin publishes a library of test helpers you might find helpful for this purpose. |
|
Is there a way to keep both the support of Solidity 0.5 and 0.4? While the newer version of Solidity is mandatory, would be great if the old stable version 0.4 can be retained until 0.6 is out. |
Does this mean you'd like a version of the stable which has a newer ganache client? |
|
Not only that. @cgewecke The PR description says that the modification in this PR breaks support of Solidity 0.4 at all. This indicates that upon merging this PR, all subsequent improvements to |
|
@yxliang01 I've just created a branch from the current master called This PR is getting merged today because it is the improvement that's necessary. Let's continue discussion about v5 at #331. |
cgewecke
left a comment
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.
This is fantastic. Thanks @area and @pinkiebell.
Merging. Am going to add some CI stuff in separate PR and publish shortly.
|
@cgewecke , this merge you're doing will end up with a new tag release and is going to be update on npmjs.org? My doubt is: when you finish, I can just execute 'npm install solidity-coverage' to get the merged package? |
|
@fabianorodrigo Yes. It's not published to npm yet, but will ping this PR when it is. |
I received the following message when I tried to run solidity-coverage@beta on the project http://github.com/leapdao/solEVM-enforcer |
|
@fabianorodrigo That bug was fixed on master by #333. Am running the solEVM-enforcer tests rn on my box and they look ok (they instrumented fine and have passed a few hundred tests without problems). Hoping to publish 6.0 today or tomorrow, just waiting to see if the parser is going to get a new version tonight. |
|
@fabianorodrigo 0.6.0 is published. |
Based on the leapdao fork, with a nod to #311 as well. Also trying to get dependencies up-to-date.
This branch is currently published under the beta tag; you can try it out by
npm install --save --dev solidity-coverage@beta. Bug reports would be very welcome before I release properly. You must be using solidity 0.5.1 or higher (0.5.0 will not work).