Skip to content

Commit

Permalink
Updated the coding standards as per the discussion with DT
Browse files Browse the repository at this point in the history
  • Loading branch information
AntoineRondelet committed Apr 28, 2021
1 parent 7ddb60e commit 1620e44
Show file tree
Hide file tree
Showing 28 changed files with 164 additions and 520 deletions.
7 changes: 4 additions & 3 deletions CODING_STANDARDS.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,14 @@ We adhere to the `pep8` standard, using `flake8`, `pylint` and `mypy` to catch f
## Solidity

Solidity code must adhere to the [solidity coding standards](https://docs.soliditylang.org/en/develop/style-guide.html), with the following amendments:
- Test functions must end with the suffix `Test` (e.g. `reverseBytesTest`)
- Test functions must have a `test` prefix (e.g. `testReverseBytes`)
- Private/internal state variables and functions must have an underscore prefix (e.g. `_myInternalFunction`)
- Virtual functions in abstract contracts must be written last and located at the end of the contract source
- The order in which contract members are written must driven by their scope (i.e. `public/external` functions must appear first in the contract code, `internal/private` functions must appear last). Additionally, `virtual` functions in abstract contracts must be written last in their visibility group.
- Function parameters must not be prefixed with an underscore
- Interface names must have a capital I prefix (e.g. `IERC20`)
- Library names must have a capital L prefix (e.g. `LPairing`)
- Library names must have a capital L prefix (e.g. `LibPairing`)
- Test contract names must have a `Test` prefix (e.g. `TestMyContract`)
- Abstract contract names must have an `Abstract` prefix (e.g. `AbstractMyContract`)
- 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
- Event names must be prefixed by `Log` (e.g. `LogDeposit`)

Expand Down
265 changes: 0 additions & 265 deletions client/test_contracts/test_base_mixer_altbn128_contract.py

This file was deleted.

8 changes: 4 additions & 4 deletions client/test_contracts/test_bls12_377_contract.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,14 +96,14 @@ def test_bls12_ecadd(self) -> None:
"""
Check that [6] == [2] + [4]
"""
result = BLS12_INSTANCE.functions.ecAddTest(G1_2 + G1_4).call()
result = BLS12_INSTANCE.functions.testECAdd(G1_2 + G1_4).call()
self.assertEqual(G1_6, result)

def test_bls12_ecmul(self) -> None:
"""
Check that [-8] == -2 * [4]
"""
result = BLS12_INSTANCE.functions.ecMulTest(G1_4 + FR_MINUS_2).call()
result = BLS12_INSTANCE.functions.testECMul(G1_4 + FR_MINUS_2).call()
self.assertEqual(G1_MINUS_8, result)

def test_bls12_ecpairing(self) -> None:
Expand All @@ -113,9 +113,9 @@ def test_bls12_ecpairing(self) -> None:
# Note, return result here is uint256(1) or uint256(0) depending on the
# pairing check result.
points = G1_6 + G2_4 + G1_3 + G2_8 + G1_4 + G2_4 + G1_MINUS_8 + G2_8
result = BLS12_INSTANCE.functions.ecPairingTest(points).call()
result = BLS12_INSTANCE.functions.testECPairing(points).call()
self.assertEqual(1, result)

points = G1_6 + G2_4 + G1_3 + G2_8 + G1_4 + G2_4 + G1_MINUS_8 + G2_4
result = BLS12_INSTANCE.functions.ecPairingTest(points).call()
result = BLS12_INSTANCE.functions.testECPairing(points).call()
self.assertEqual(0, result)
8 changes: 4 additions & 4 deletions client/test_contracts/test_bw6_761_contract.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,14 +102,14 @@ def test_bw6_ecadd(self) -> None:
"""
Check that [6] == [2] + [4]
"""
result = BW6_INSTANCE.functions.ecAddTest(G1_2 + G1_4).call()
result = BW6_INSTANCE.functions.testECAdd(G1_2 + G1_4).call()
self.assertEqual(G1_6, result)

def test_bw6_ecmul(self) -> None:
"""
Check that [-8] == -2 * [4]
"""
result = BW6_INSTANCE.functions.ecMulTest(G1_4 + FR_MINUS_2).call()
result = BW6_INSTANCE.functions.testECMul(G1_4 + FR_MINUS_2).call()
self.assertEqual(G1_MINUS_8, result)

def test_bw6_ecpairing(self) -> None:
Expand All @@ -119,9 +119,9 @@ def test_bw6_ecpairing(self) -> None:
# Note, return result here is uint256(1) or uint256(0) depending on the
# pairing check result.
points = G1_6 + G2_4 + G1_3 + G2_8 + G1_4 + G2_4 + G1_MINUS_8 + G2_8
result = BW6_INSTANCE.functions.ecPairingTest(points).call()
result = BW6_INSTANCE.functions.testECPairing(points).call()
self.assertEqual(1, result)

points = G1_6 + G2_4 + G1_3 + G2_8 + G1_4 + G2_4 + G1_MINUS_8 + G2_4
result = BW6_INSTANCE.functions.ecPairingTest(points).call()
result = BW6_INSTANCE.functions.testECPairing(points).call()
self.assertEqual(0, result)
2 changes: 1 addition & 1 deletion client/test_contracts/test_groth16_bls12_377_contract.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ def _invoke_groth16_bls12_377_verify(
vk, BLS12_377_PAIRING)
proof_evm = Groth16.proof_to_contract_parameters(proof, BLS12_377_PAIRING)
inputs_evm = hex_list_to_uint256_list(inputs)
return CONTRACT_INSTANCE.functions.verifyTest(
return CONTRACT_INSTANCE.functions.testVerify(
vk_evm, proof_evm, inputs_evm).call()

def test_groth16_bls12_377_valid(self) -> None:
Expand Down
Loading

0 comments on commit 1620e44

Please sign in to comment.