Skip to content
This repository has been archived by the owner on Jan 18, 2023. It is now read-only.

Upgrade solidity version to 0.5.4 #393

Merged
merged 17 commits into from
Feb 26, 2019

Conversation

justinkchen
Copy link
Contributor

@justinkchen justinkchen commented Feb 23, 2019

Running yarn compile and gradually fixing changes.

There are a lot of breaking changes with https://solidity.readthedocs.io/en/v0.5.0/050-breaking-changes.html

Following this guide:
https://hackernoon.com/compile-solidity-smart-contracts-faster-in-truffle-projects-eb8bebb61ec3

Example new errors:
https://ethereum.stackexchange.com/questions/8959/solidity-compile-expected-token-comma-got-identifier
https://ethereum.stackexchange.com/questions/63426/running-out-of-gas-during-a-deploy-due-to-a-large-number-of-require-statements
sc-forks/solidity-parser#18
https://hackernoon.com/compile-solidity-smart-contracts-faster-in-truffle-projects-eb8bebb61ec3
Data location must be "calldata" for parameter in external function, but none was given.
Data location must be "storage" or "memory" for parameter in function, but none was given
Data location must be "memory" for return parameter in function, but none was given.

@justinkchen justinkchen force-pushed the justin_chen-upgrade-solidity-version branch from f0330d9 to a2d4556 Compare February 23, 2019 20:25
@coveralls
Copy link

coveralls commented Feb 24, 2019

Pull Request Test Coverage Report for Build 4405

  • 66 of 66 (100.0%) changed or added relevant lines in 19 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage remained the same at 100.0%

Totals Coverage Status
Change from base Build 4402: 0.0%
Covered Lines: 811
Relevant Lines: 811

💛 - Coveralls

Copy link
Contributor

@felix2feng felix2feng left a comment

Choose a reason for hiding this comment

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

Good job getting this done. Do have a few questions and generally feel a little bit nervous about changing the external dependencies

package.json Outdated
@@ -18,10 +18,10 @@
"test": "test"
},
"scripts": {
"chain": "yarn clean-chain && ganache-cli --db blockchain --networkId 50 --accounts 20 -l 19000000 -e 10000000000 -m 'concert load couple harbor equip island argue ramp clarify fence smart topic'",
"chain": "yarn clean-chain && ganache-cli --db blockchain --networkId 50 --accounts 20 -l 19000000 -e 10000000000 -m 'concert load couple harbor equip island argue ramp clarify fence smart topic' --allowUnlimitedContractSize",
Copy link
Contributor

Choose a reason for hiding this comment

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

Before we merge... let's try to do a test deploy on Kovan and check the gas costs and whether Core could be deployed. This way we can validate whether this flag interferes with deployment

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes i wanted to get this done too, need to make sure we can use the optimizer i think as mentioned here: https://ethereum.stackexchange.com/questions/63426/running-out-of-gas-during-a-deploy-due-to-a-large-number-of-require-statements

"clean": "rm -rf build; rm -rf transpiled; rm -rf types/generated",
"clean-chain": "rm -rf blockchain && cp -r snapshots/0x-Kyber blockchain",
"compile": "truffle compile --all",
"compile": "./node_modules/.bin/truffle compile --all",
Copy link
Contributor

Choose a reason for hiding this comment

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

any reason for this?

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 think this was to use the upgraded version of solc compiler as specified in the truffle.js

https://hackernoon.com/compile-solidity-smart-contracts-faster-in-truffle-projects-eb8bebb61ec3

i think before this, it was still trying to use the old version since truffle v5 by default still uses 0.4.25

"solc": "^0.4.25",
"solidity-coverage": "^0.5.11",
"solc": "^0.5.4",
"solidity-coverage": "https://github.com/leapdao/solidity-coverage#master",
Copy link
Contributor

Choose a reason for hiding this comment

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

Any reason for changing to this?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

sc-forks/solidity-parser#18 coverage was failing because of _ in variable names and some other weird stuff that the current version of solidity parser doesn't handle still. we can maybe fork leapdaos too if we want to keep it under us for now

@@ -127,7 +127,8 @@ contract SetToken is

// Figure out which of the components has the minimum decimal value
/* solium-disable-next-line security/no-low-level-calls */
if (currentComponent.call(bytes4(keccak256("decimals()")))) {
(bool success, ) = currentComponent.call(abi.encodeWithSignature("decimals()"));
Copy link
Contributor

Choose a reason for hiding this comment

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

Interesting new return of .call

_naturalUnit,
_name.bytes32ToString(),
_symbol.bytes32ToString()
return address(
Copy link
Contributor

Choose a reason for hiding this comment

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

why do we need to wrap this in address?

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 forget the exact error message, but basically it was saying that we were returning an instance of a contract instead of an address and a lot of the solc 0.5 changes are all about being more explicit so have to convert to address i think

@@ -34,8 +34,13 @@ contract DSNote {
bar := calldataload(36)
}

emit LogNote(msg.sig, msg.sender, foo, bar, msg.value, msg.data);
Copy link
Contributor

Choose a reason for hiding this comment

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

This is a breaking change? Can't get msg.value directly?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yea can't use msg.value directly, needs to be in an internal function

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Using msg.value in non-payable functions (or introducing it via a modifier) is disallowed as a security feature.

/**
* @dev Total number of tokens in existence
*/
function totalSupply() external view returns (uint256) {
Copy link
Contributor

Choose a reason for hiding this comment

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

any reason this was removed?

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 already defined as a public variable on line 15 here, so the getter should automatically be generated. it was giving me an error about shadowing variables here

@felix2feng felix2feng force-pushed the justin_chen-upgrade-solidity-version branch from 77c250e to 2757cb3 Compare February 25, 2019 23:49
@felix2feng felix2feng merged commit f9c9a22 into master Feb 26, 2019
@felix2feng felix2feng deleted the justin_chen-upgrade-solidity-version branch February 26, 2019 00:33
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants