-
Notifications
You must be signed in to change notification settings - Fork 27
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
Refined coding standards and cascaded changes to the code base #366
Refined coding standards and cascaded changes to the code base #366
Conversation
2e1322e
to
265c5ec
Compare
8c79f27
to
1a68347
Compare
uint256[] memory /* proof */, | ||
uint256[NUM_INPUTS] memory /* inputs */ |
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.
By refining the inheritance here it seemed that overloading verifyZkProof
was useless in the past (because it was already defined in the former parent which was already concrete). Moreover, the signature of the function wasn't matching the signature of the abstract parent class (which tool a uint256
for the input instead of an array of uints..)
- Event names must be prefixed by `Log` (e.g. `LogDeposit`) | ||
- Contract names may not be PascalCase if using PascalCase is introducing confusions in the name (e.g. `BLS12377.sol` vs `BLS12_377.sol`). PascalCase should be used whenever possible | ||
|
||
**Note:** Some of the files of the current code base may not fully comply with the coding standards above. Old code will progressively be updated to converge towards the recommended style. |
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.
More precisely, the snake_case
convention remains broadly used in function bodies (we still have mixed styles there). The function signatures and contract's state variables/constants however should be all fine now
/// selected SNARK. | ||
function _verifyZkProof( | ||
uint256[] memory proof, | ||
uint256 publicInputsHash |
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.
Real minor details regarding the naming, so feel free to ignore. Probably not worth the effort of renaming, but just to give my thoughts:
I'd put test at the beginning of the method names. It sounds like an action (i.e. Conversely, (and again a real minor detail) having test class names end with
Although the ... or alternatively, we could consider Again, feel free to skip this. |
I'm not sure I fully understand |
Thanks @dtebbs
No problem, renaming isn't really painful once everything is consistent -> you know what patterns to search for - the real pain is when things aren't consistent ;)
Good point, let's switch to that.
FYI, the code base wasn't consistent w.r.t to the location of the "Base" in the name. In fact, if you check
We see that we have a little bit of everything... The rationale behind using
Many libraries are named as "lib" (e.g. libfuzzer, libff, etc.) -> it seems natural to follow this prefix convention for the library names in solidity - instead of So, here's what we can do:
How does that sound to you? |
Hum.. IIRC, the tool raised flags about "unused state variables" in the PGHR mixer. Such flags weren't raised for the Groth16 mixers, which seemed to imply that the inheritance structure could be refined |
Ah ... I see the point now. Thanks. |
Overall that sounds good. For (2), yes, I'd be in favour of Re (3), tbh I could see an argument for either way. Given that we use prefixes elsewhere I'm happy to keep the For (4), moving tests to another directory, like in the other components, makes a lot of sense to me if that's not a huge problem. For other things, I'd be tempted to keep it simple for now - dividing up by type, rather than by functionality, seems like a slightly different approach than we use elsewhere. From that point of view it might be more natural to divide into |
f49d13d
to
d4b140a
Compare
Ok sounds good let's use
I have no strong preferences as per my comments above. In the absence of justification to change, let's stick to what we have now and use
Hum... |
498b183
to
5ec6e75
Compare
This will be one for another PR because this requires to touch the python code (beyond renaming) in order to modify the path to the contracts to deploy in
|
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 with one comment.
Co-authored-by: Duncan Tebbs <dtebbs@users.noreply.github.com>
@dtebbs - when you have a moment, please have a look at this PR.
As the name indicates, the PR fixes some inconsistencies in our contracts code, and introduces new conventions that extend the "standard set of solidity conventions" + enforces them.
The rational is: Let's stick to solidity conventions where possible, however, small amendments are made as a way to improve smart contract dev and convey more information in the object names by following conventions exposed in the
CODING_STANDARDS
in this PR.The TL;DR:
MyContract_test.sol
-> I changed toTestMyContract.sol
to stick to PascalCase and remain compliant with solidity standards.testFunction
, some of the formfunctionTest
. I switched everything to the formfunctionTest
(arbitrary choice, could have gone the other way around - don't have strong opinion there, so happy to switch)_
to allprivate
/internal
members. This was inconsistent throughout the code baseOverall observation (for the sake of logging it):
Anyway, happy to discuss about the proposed conventions and keen to hear your opinion here.