-
Notifications
You must be signed in to change notification settings - Fork 428
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
Update to Solc 0.5 #67
Conversation
shall we also decide on a standard as to whether to return anonymous or named variables? |
Easy question for me - named variables everytime (unless we're talking point-free - but that's a different & more fun kettle of fish!). That whole:
thing is dumb. Naming is explicit and useful and enlightening. |
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.
Overall changes look good and definitely increased quality of code.
Can you confirm these have been run through your ethereum-examples testing suite @gskapka ?
Some changes recommended, clarifications, and points needing discussion, and acceptable for merge thereafter. Some points need @bertani feedback.
struct buffer { | ||
bytes buf; | ||
uint capacity; | ||
} | ||
|
||
function init(buffer memory buf, uint _capacity) internal pure { | ||
function init(buffer memory _buf, uint _capacity) internal pure { |
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.
I much prefer this as well. It may be worth actually seeing about pushing these updates towards: https://github.com/smartcontractkit/solidity-cborutils
So we can stay consistent with that repo. Additonally may be useful to ensure there haven't been some bugfixes to that cbor library since?
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.
I assume the reason Nick did not go this route, is the functions are pure anyways, and it's a library, so they won't themselves have any side effects(at least from a state perspective, it will affect memory in certain functions).
oraclizeAPI_0.5.sol
Outdated
mapping(bytes32=>bool) oraclize_randomDS_sessionKeysHashVerified; | ||
|
||
function verifySig(bytes32 tosignh, bytes dersig, bytes pubkey) internal returns (bool){ | ||
function verifySig(bytes32 _tosignh, bytes memory _dersig, bytes memory _pubkey) internal returns (bool) { |
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.
safe to set to view or pure even?
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.
Ibid. re compiler warnings. Plus gives bonus extra compiler warnings about needing to set either payable
or non-payable
on it. Sigh.
oraclizeAPI_0.5.sol
Outdated
} | ||
} | ||
|
||
function oraclize_randomDS_proofVerify__sessionKeyValidity(bytes proof, uint sig2offset) internal returns (bool) { | ||
function oraclize_randomDS_proofVerify__sessionKeyValidity(bytes memory _proof, uint _sig2offset) internal returns (bool) { |
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.
could be view or pure again?
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.
Ibid. re compiler warnings.
oraclizeAPI_0.5.sol
Outdated
The following function has been written by Alex Beregszaszi (@axic), use it under the terms of the MIT license | ||
Duplicate Solidity's ecrecover, but catching the CALL return value | ||
*/ | ||
function safer_ecrecover(bytes32 _hash, uint8 _v, bytes32 _r, bytes32 _s) internal returns (bool, address) { |
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.
pure?
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.
Ibid. re compiler warnings & whole slew of new ones re payable
etc.
oraclizeAPI_0.5.sol
Outdated
/* | ||
The following function has been written by Alex Beregszaszi (@axic), use it under the terms of the MIT license | ||
*/ | ||
function ecrecovery(bytes32 _hash, bytes memory _sig) internal returns (bool, address) { |
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.
pure
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.
Ibid. re all the other ibids.
Update:Okay so I've done anything from the above review that I can & pushed it. I've also compiled anything I couldn't do into this one post to make it easier to see & address. Done:✔️ Naming return params (and adding underscores to go along with current practices) I can confirm that all tests are passing on all examples that have test-suites per my tool on gitlab using this current iteration of the API. Stuff that needs discussing/addressing:📟 Paging @bertani & @D-Nice, whose relevance to issues at hand are marked after the issues:
|
Responses to above from @bertani
Next:⚖️ Just need you to weigh in now @D-Nice please! |
ok, based on those replies, let's remove coupon. Also, based on our earlier discussion, and me diving into safeMemoryCleaner, I think it's best we still leave it in, because as mentioned, it can be useful for any other assembly that works on memory, but doesn't necessarily zero it out, so the safeMemoryCleaner can be re-used there. |
Done & done. |
Oh wow, this is great! :) |
Solc 0.5.0 Version of the API
Here it is, the API upgraded to the latest Solidity compiler, and (hopefully) following all the best practices. Rather than simply getting it to compile, many other changes have been made and so hence the need for a thorough review. Amongst those changes:
memory
keywords &c.)parseInt()
(original remains incase anyone using its behaviour)/* ... */
for multilines instead of multiple//
's)snake_case
are nowcamelCased
)if/while/for
conditionals{
sNotes:
Re which latter bullet point: It turns out that with the new recasting rules we must first cast to types of the same size. So to go from
bytes(1)
touint
we first need to go via eitheruint8
orbytes32
:The two casts pad differently hence the new explicitness ruling. As such, I broke (and then fixed) the proof verification thusly:
To Do
@D-Nice & @riccardopersiani please can you go over this PR with a fine tooth comb and make sure I haven't goofed anything? Also tell me if any of the above listed changes are a step too far/pointless/terrible/should be burnt with fire &c., &c.
Also, I have a private repo elsewhere with some (unpolished but passing) tests for some of the parsing helpers we offer in this API, plus all the
truffle examples
in theethereum-examples
repo have been updated to als use this API and all tests therein are also passing.So it should be all good w/r/t it working, now it's just a case of arguing over the changes I've made.