Skip to content

Commit

Permalink
chore: address comments partially
Browse files Browse the repository at this point in the history
  • Loading branch information
LHerskind committed Sep 27, 2024
1 parent 7c1735f commit 96a1938
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 5 deletions.
28 changes: 26 additions & 2 deletions l1-contracts/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,29 @@ Currently not running any proofs _nor_ access control so blocks can be submitted

---

# Branching Tree Technique

For writing tests we will be using the [Branching Tree Technique](https://www.youtube.com/watch?v=0-EmbNVgFA4).
The approach is simple, for a function that is to be tested (all functions) you should write a `.tree` file first.
Then the tree file can be used to generate a solidity tests file using [Bulloak](https://github.com/alexfertel/bulloak) by running the `scaffold` command.

```bash
bulloak scaffold -w **/*.tree
```

To check that the tests are following the expected format, you can run the `check` command.

```bash
bulloak check **/*.tree
```

We assume that you already have `bulloak` installed, if not you can install it as `cargo install bulloak`.
Also, we suggest using [Ascii Tree Generator](https://marketplace.visualstudio.com/items?itemName=aprilandjan.ascii-tree-generator), since the pipes can be a bit of a pain otherwise.

For examples, see the tests for the registry.

---

# Linter

We use an extended version of solhint (https://github.com/LHerskind/solhint) to include custom rules. These custom rules relate to how errors should be named, using custom errors instead of reverts etc, see `.solhint.json` for more specifics about the rules.
Expand All @@ -73,12 +96,13 @@ yarn lint
# Slither & Slitherin

We use slither as an automatic way to find blunders and common vulnerabilities in our contracts. It is not part of the docker image due to its slowness, but it can be run using the following command to generate a markdown file with the results:

```bash
yarn slither
```

When this command is run in CI, it will fail if the markdown file generated in docker don't match the one in the repository.
When this command is run in CI, it will fail if the markdown file generated in docker don't match the one in the repository.

We assume that you already have slither installed. You can install it with `pip3 install slither-analyzer==0.10.0 slitherin==0.5.0`. It is kept out of the bootstrap script as it is not a requirement for people who just want to run tests or are uninterested in the contracts.

> We are not running the `naming-convention` detector because we have our own rules for naming which is enforced by the linter.
> We are not running the `naming-convention` detector because we have our own rules for naming which is enforced by the linter.
4 changes: 2 additions & 2 deletions l1-contracts/src/governance/Registry.sol
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ contract Registry is IRegistry, Ownable {
}

/**
* @notice Returns the rollup contract
* @return The rollup contract (of type IRollup)
* @notice Returns the address of the rollup contract
* @return The rollup address
*/
function getRollup() external view override(IRegistry) returns (address) {
return currentSnapshot.rollup;
Expand Down
2 changes: 1 addition & 1 deletion l1-contracts/src/governance/libraries/DataStructures.sol
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ pragma solidity >=0.8.18;
/**
* @title Data Structures Library
* @author Aztec Labs
* @notice Library that contains data structures used throughout the Aztec protocol
* @notice Library that contains data structures used throughout Aztec governance
*/
library DataStructures {
// docs:start:registry_snapshot
Expand Down

0 comments on commit 96a1938

Please sign in to comment.