Skip to content
This repository has been archived by the owner on Mar 25, 2024. It is now read-only.

feat: linting CI job #40

Merged
merged 26 commits into from
Oct 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
f8cd3d7
feat: linting
benceharomi Oct 9, 2023
4ad22aa
chore: PR template updated
benceharomi Oct 9, 2023
cf7cac2
fix: import order
benceharomi Oct 9, 2023
bc33fea
lint: solidity compiler-version 0.8.0
benceharomi Oct 9, 2023
b36232d
lint: solidity lint config updated to ignore constructors
benceharomi Oct 9, 2023
a0569ca
docs(readme): updated
benceharomi Oct 9, 2023
6619db8
lint(*.ts): fixes
benceharomi Oct 10, 2023
bef688b
fix: accidental change
benceharomi Oct 10, 2023
3b77cf6
chore: include js files in formatting
benceharomi Oct 10, 2023
288bcc1
chore: change command name back to compile-yul
benceharomi Oct 10, 2023
48fa243
Merge branch 'dev' into bh-evm-293-linting-ci-for-era-system-contracts
benceharomi Oct 10, 2023
7c94600
chore: typescript rollback
benceharomi Oct 10, 2023
b793e97
ci: test_bootloader needs linting
benceharomi Oct 10, 2023
28fe95e
lint: new files linted
benceharomi Oct 10, 2023
f032b69
chore(0.json): code formatting
benceharomi Oct 10, 2023
a5b28ae
chore: unneeded prettierignore
benceharomi Oct 10, 2023
61a60af
docs(bootloader-test): updated to use new command
benceharomi Oct 10, 2023
2188336
chore: test:bootloader
benceharomi Oct 10, 2023
8d13a76
lint: markdown linting added
benceharomi Oct 10, 2023
8a9d569
chore: downgraded markdownlint to avoid dependency with unwanted license
benceharomi Oct 10, 2023
3df144a
chore: lint:fix command added
benceharomi Oct 10, 2023
6df074e
docs: lint fix added PR template
benceharomi Oct 12, 2023
2e2cfdd
lint: reverted formatting of openzeppelin contracts
benceharomi Oct 12, 2023
60a154f
fix: yarn command fixes
benceharomi Oct 12, 2023
913ddc5
lint: openzeppelin dir ignored from formatting/linting
benceharomi Oct 12, 2023
0221969
lint: newline at EOF of ignore files
benceharomi Oct 16, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"extends": ["eslint:recommended", "plugin:@typescript-eslint/recommended"],
"parser": "@typescript-eslint/parser",
"plugins": ["@typescript-eslint"],
"root": true
}
2 changes: 1 addition & 1 deletion .github/pull_request_template.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@
- [ ] PR title corresponds to the body of PR (we generate changelog entries from PRs).
- [ ] Tests for the changes have been added / updated.
- [ ] Documentation comments have been added / updated.
- [ ] Code has been formatted via `zk fmt` and `zk lint`.
- [ ] Code has been formatted via `yarn prettier:write` and `yarn lint:fix`.
31 changes: 22 additions & 9 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,9 @@ jobs:
- name: Install dependencies
run: yarn

- name: Build Solidity artifacts
- name: Build artifacts
run: yarn build

- name: Build yul artifacts
run: yarn preprocess && yarn compile-yul

- name: Create cache
uses: actions/cache/save@v3
with:
Expand All @@ -36,8 +33,27 @@ jobs:
contracts/precompiles/artifacts
bootloader/build

lint:
runs-on: ubuntu-latest

steps:
- name: Checkout the repository
uses: actions/checkout@v3

- name: Use Node.js
uses: actions/setup-node@v3
with:
node-version: 18.18.0
cache: yarn

- name: Install dependencies
run: yarn

- name: Run lint
run: yarn lint
benceharomi marked this conversation as resolved.
Show resolved Hide resolved

test:
needs: [build]
needs: [build, lint]
runs-on: ubuntu-latest

steps:
Expand Down Expand Up @@ -69,13 +85,11 @@ jobs:
contracts/precompiles/artifacts
bootloader/build


- name: Run tests
run: yarn test


test_bootloader:
needs: [build]
needs: [build, lint]
runs-on: ubuntu-latest

steps:
Expand All @@ -100,6 +114,5 @@ jobs:
contracts/precompiles/artifacts
bootloader/build


- name: Run bootloader tests
run: "cd bootloader/test_infra && cargo run"
1 change: 1 addition & 0 deletions .markdownlintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node_modules
9 changes: 9 additions & 0 deletions .markdownlintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"default": true,
"header-increment": false,
"no-duplicate-header": false,
"no-inline-html": false,
"line-length": false,
"fenced-code-language": false,
"no-multiple-blanks": false
}
1 change: 1 addition & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
contracts/openzeppelin
63 changes: 63 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
{
"plugins": ["prettier-plugin-solidity"],
"overrides": [
{
"files": "*.js",
"options": {
"tabWidth": 4,
"printWidth": 120,
"singleQuote": true,
"trailingComma": "none",
"bracketSpacing": true
}
},
{
"files": "*.json",
"options": {
"tabWidth": 2,
"printWidth": 120,
"bracketSpacing": true
}
},
{
"files": "*.md",
"options": {
"tabWidth": 2,
"printWidth": 120,
"parser": "markdown",
"singleQuote": true,
"trailingComma": "none",
"bracketSpacing": true,
"proseWrap": "always"
}
},
{
"files": "*.sol",
"options": {
"printWidth": 120,
"tabWidth": 4,
"useTabs": false,
"singleQuote": false,
"bracketSpacing": false
}
},
{
"files": "*.ts",
"options": {
"tabWidth": 4,
"printWidth": 120,
"parser": "typescript",
"singleQuote": true,
"trailingComma": "none",
"bracketSpacing": true
}
},
{
"files": "*.yaml",
"options": {
"tabWidth": 2,
"printWidth": 120
}
}
]
}
20 changes: 20 additions & 0 deletions .solhint.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"extends": "solhint:recommended",
"rules": {
"state-visibility": "off",
"func-visibility": ["warn", { "ignoreConstructors": true }],
"var-name-mixedcase": "off",
"avoid-call-value": "off",
"no-empty-blocks": "off",
"not-rely-on-time": "off",
"avoid-low-level-calls": "off",
"no-inline-assembly": "off",
"const-name-snakecase": "off",
"no-complex-fallback": "off",
"reason-string": "off",
"func-name-mixedcase": "off",
"no-unused-vars": "off",
"max-states-count": "off",
"compiler-version": ["warn", "^0.8.0"]
}
}
1 change: 1 addition & 0 deletions .solhintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
contracts/openzeppelin
62 changes: 35 additions & 27 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,57 +10,65 @@ write smart contracts in C++, Rust and other popular languages.
## system-contracts

To keep the zero-knowledge circuits as simple as possible and enable simple extensions, we created the system contracts.
These are privileged special-purpose contracts that instantiate some recurring actions on the protocol level. Some of the
most commonly used contracts:
These are privileged special-purpose contracts that instantiate some recurring actions on the protocol level. Some of
the most commonly used contracts:

`ContractDeployer` This contract is used to deploy new smart contracts. Its job is to make sure that the bytecode for each deployed
contract is known. This contract also defines the derivation address. Whenever a contract is deployed, a ContractDeployed
event is emitted.
`ContractDeployer` This contract is used to deploy new smart contracts. Its job is to make sure that the bytecode for
each deployed contract is known. This contract also defines the derivation address. Whenever a contract is deployed, a
ContractDeployed event is emitted.

`L1Messenger` This contract is used to send messages from zkSync to Ethereum. For each message sent, the L1MessageSent event is emitted.
`L1Messenger` This contract is used to send messages from zkSync to Ethereum. For each message sent, the L1MessageSent
event is emitted.

`NonceHolder` This contract stores account nonces. The account nonces are stored in a single place for efficiency (the tx nonce and
the deployment nonce are stored in a single place) and also for the ease of the operator.
`NonceHolder` This contract stores account nonces. The account nonces are stored in a single place for efficiency (the
tx nonce and the deployment nonce are stored in a single place) and also for the ease of the operator.

`Bootloader` For greater extensibility and to lower the overhead, some parts of the protocol (e.g. account abstraction rules) were
moved to an ephemeral contract called a bootloader.
`Bootloader` For greater extensibility and to lower the overhead, some parts of the protocol (e.g. account abstraction
rules) were moved to an ephemeral contract called a bootloader.

We call it ephemeral because it is not physically deployed and cannot be called, but it has a formal address that is used
on msg.sender, when it calls other contracts.
We call it ephemeral because it is not physically deployed and cannot be called, but it has a formal address that is
used on msg.sender, when it calls other contracts.

## Building

This repository is used as a submodule of the [zksync-2-dev](https://github.com/matter-labs/zksync-2-dev).

Compile the solidity contracts: `yarn build`

Run the bootloader preprocessor: `yarn preprocess`

Compile the yul contracts: `yarn hardhat run ./scripts/compile-yul.ts`
Compile the solidity and yul contracts: `yarn build`

## Update Process

System contracts handle core functionalities and play a critical role in maintaining the integrity of our protocol. To ensure the highest level of security and reliability, these system contracts undergo an audit before any release.
System contracts handle core functionalities and play a critical role in maintaining the integrity of our protocol. To
ensure the highest level of security and reliability, these system contracts undergo an audit before any release.

Here is an overview of the release process of the system contracts which is aimed to preserve agility and clarity on the order of the upgrades:
Here is an overview of the release process of the system contracts which is aimed to preserve agility and clarity on the
order of the upgrades:

### `main` branch

The `main` branch contains the latest code that is ready to be deployed into production. It reflects the most stable and audited version of the protocol.
The `main` branch contains the latest code that is ready to be deployed into production. It reflects the most stable and
audited version of the protocol.

### `dev` branch
### `dev` branch

The `dev` branch is for active development & the latest code changes. Whenever a new PR with system contract changes is created it should be based on the `dev` branch.
The `dev` branch is for active development & the latest code changes. Whenever a new PR with system contract changes is
created it should be based on the `dev` branch.

### Creating a new release:
### Creating a new release

Whenever a new release is planned, a new branch named `release-vX-<name>` should be created off the `dev` branch, where `X` represents the release version, and `<name>` is a short descriptive name for the release. The PR with the new release should point to either the `main` branch or to the release branch with a lower version (in case the previous branch has not been merged into `main` for some reason).
Whenever a new release is planned, a new branch named `release-vX-<name>` should be created off the `dev` branch, where
`X` represents the release version, and `<name>` is a short descriptive name for the release. The PR with the new
release should point to either the `main` branch or to the release branch with a lower version (in case the previous
branch has not been merged into `main` for some reason).

Once the audit for the release branch is complete and all the fixes from the audit are applied, we need to merge the new changes into the `dev` branch. Once the release is final and merged into the `main` branch, the `main` branch should be merged back into the `dev` branch to keep it up-to-date.
Once the audit for the release branch is complete and all the fixes from the audit are applied, we need to merge the new
changes into the `dev` branch. Once the release is final and merged into the `main` branch, the `main` branch should be
merged back into the `dev` branch to keep it up-to-date.

### Updating Unaudited Code:
### Updating Unaudited Code

Since scripts, READMEs, etc., are code that is not subject to audits, these are to be merged directly into the `main` branch. The rest of the release branches as well as the `dev` branch should merge `main` to synchronize with these changes.
Since scripts, READMEs, etc., are code that is not subject to audits, these are to be merged directly into the `main`
branch. The rest of the release branches as well as the `dev` branch should merge `main` to synchronize with these
changes.

## License

Expand Down
2 changes: 1 addition & 1 deletion SystemConfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@
"KECCAK_ROUND_COST_GAS": 40,
"SHA256_ROUND_COST_GAS": 7,
"ECRECOVER_COST_GAS": 1112
}
}
6 changes: 3 additions & 3 deletions bootloader/test_infra/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@

This crate allows you to run the unittests against the bootloader code.

You should put your tests in ../tests/bootloader/bootloader_test.yul, then compile the yul with:
You should put your tests in `../tests/bootloader/bootloader_test.yul`, then compile the yul with:

```shell
yarn build && yarn preprocess && yarn compile-yul
yarn build
benceharomi marked this conversation as resolved.
Show resolved Hide resolved
```

And afterwards run the testing infrastructure:

```shell
cargo run
```
```
Loading