Skip to content

Commit

Permalink
Merge branch 'sync-layer-stable' of ssh://github.com/matter-labs/era-…
Browse files Browse the repository at this point in the history
…contracts into kl/interop
  • Loading branch information
kelemeno committed Sep 19, 2024
2 parents f36129d + 6b1f483 commit 17a8300
Show file tree
Hide file tree
Showing 540 changed files with 20,006 additions and 9,802 deletions.
3 changes: 2 additions & 1 deletion .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
"no-console": "off"
},
"ignorePatterns": [
"**/lib/*"
"**/lib/*",
"lib/*"
]
}
58 changes: 56 additions & 2 deletions .github/workflows/l1-contracts-ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,57 @@ jobs:
working-directory: ./l1-contracts
run: FOUNDRY_PROFILE=default yarn test:foundry

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

steps:
- name: Checkout the repository
uses: actions/checkout@v4
with:
submodules: recursive

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

- name: Install dependencies
run: yarn

- name: Build system contract artifacts
run: yarn sc build

- name: Restore artifacts cache
uses: actions/cache/restore@v3
with:
fail-on-cache-miss: true
key: artifacts-l1-${{ github.sha }}
path: |
l1-contracts/artifacts
l1-contracts/artifacts-zk
l1-contracts/cache
l1-contracts/typechain
l2-contracts/artifacts-zk
l2-contracts/cache-zk
l2-contracts/typechain
l1-contracts/lib
- name: Install foundry zksync
run: |
wget https://github.com/matter-labs/foundry-zksync/releases/download/nightly-f908ce43834bc1ffb4de6576ea5600eaab49dddb/foundry_nightly_linux_amd64.tar.gz -O foundry-zksync.tar.gz
tar -xzf foundry-zksync.tar.gz
sudo mv forge /usr/local/bin/forge
sudo mv cast /usr/local/bin/cast
sudo chmod +x /usr/local/bin/forge
sudo chmod +x /usr/local/bin/cast
forge --version
- name: Run tests
working-directory: ./l1-contracts
run: FOUNDRY_PROFILE=default yarn test:zkfoundry

test-hardhat:
needs: [build, lint]
runs-on: ubuntu-latest
Expand Down Expand Up @@ -149,10 +200,13 @@ jobs:
l2-contracts/typechain
l1-contracts/lib
- name: Build L2 contracts
run: yarn l2 build

- name: Run tests
run: yarn l1 test --no-compile

check-verifier-generator:
check-verifier-generator-l1:
runs-on: ubuntu-latest

steps:
Expand Down Expand Up @@ -226,7 +280,7 @@ jobs:
- name: Filter directories
run: |
sudo apt update && sudo apt install -y lcov
lcov --remove lcov.info 'test/*' 'contracts/dev-contracts/*' 'lib/*' --output-file lcov.info --rc lcov_branch_coverage=1
lcov --remove lcov.info 'test/*' 'contracts/dev-contracts/*' '../lib/forge-std/*' '../lib/murky/*' 'lib/*' '../lib/*' 'lib/' --output-file lcov.info --rc lcov_branch_coverage=1
# This step posts a detailed coverage report as a comment and deletes previous comments on
# each push. The below step is used to fail coverage if the specified coverage threshold is
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/l1-contracts-foundry-ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ jobs:

- name: Copy configs from template
working-directory: ./l1-contracts
run: cp -r deploy-script-config-template script-config
run: cp -r deploy-script-config-template/. script-config

- name: Run anvil
run: |
Expand Down Expand Up @@ -119,11 +119,11 @@ jobs:
working-directory: ./l1-contracts
run: forge script ./deploy-scripts/DeployErc20.s.sol --ffi --rpc-url $ANVIL_RPC_URL --broadcast --private-key $ANVIL_PRIVATE_KEY
# TODO restore scripts verification
# - name: Run RegisterHyperchain script
# - name: Run RegisterZKChain script
# working-directory: ./l1-contracts
# run: |
# cat ./script-out/output-deploy-l1.toml >> ./script-config/register-hyperchain.toml
# forge script ./deploy-scripts/RegisterHyperchain.s.sol --ffi --rpc-url $ANVIL_RPC_URL --broadcast --private-key $ANVIL_PRIVATE_KEY
# cat ./script-out/output-deploy-l1.toml >> ./script-config/register-zk-chain.toml
# forge script ./deploy-scripts/RegisterZKChain.s.sol --ffi --rpc-url $ANVIL_RPC_URL --broadcast --private-key $ANVIL_PRIVATE_KEY
# - name: Run InitializeL2WethToken script
# working-directory: ./l1-contracts-foundry
# run: forge script ./deploy-scripts/InitializeL2WethToken.s.sol --ffi --rpc-url $ANVIL_RPC_URL --broadcast --private-key $ANVIL_PRIVATE_KEY
44 changes: 37 additions & 7 deletions .github/workflows/l2-contracts-ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ jobs:
- name: Build L2 artifacts
run: yarn l2 build

- name: Build system contract artifacts
run: yarn sc build

- name: Create cache
uses: actions/cache/save@v3
with:
Expand All @@ -37,6 +40,9 @@ jobs:
l2-contracts/artifacts-zk
l2-contracts/cache-zk
l2-contracts/typechain
system-contracts/artifacts-zk
system-contracts/cache-zk
system-contracts/typechain
lint:
runs-on: ubuntu-latest
Expand All @@ -57,6 +63,23 @@ jobs:
- name: Lint
run: yarn lint:check

check-verifier-generator-l2:
needs: [build]
runs-on: ubuntu-latest

steps:
- name: Checkout the repository
uses: actions/checkout@v4
with:
submodules: recursive

- name: Generate Verifier.sol
working-directory: tools
run: cargo run --bin zksync_verifier_contract_generator --release -- --input_path data/scheduler_key.json --l2_mode

- name: Compare
run: diff tools/data/Verifier.sol l2-contracts/contracts/verifier/Verifier.sol

test:
needs: [build, lint]
runs-on: ubuntu-latest
Expand Down Expand Up @@ -88,12 +111,19 @@ jobs:
l2-contracts/artifacts-zk
l2-contracts/cache-zk
l2-contracts/typechain
- name: Run Era test node
uses: dutterbutter/[email protected]

- name: Copy typechain from System Contracts
run: yarn sc build && yarn sc copy:typechain
system-contracts/artifacts-zk
system-contracts/cache-zk
system-contracts/typechain
- name: Install foundry zksync
run: |
wget https://github.com/matter-labs/foundry-zksync/releases/download/nightly-f908ce43834bc1ffb4de6576ea5600eaab49dddb/foundry_nightly_linux_amd64.tar.gz -O foundry-zksync.tar.gz
tar -xzf foundry-zksync.tar.gz
sudo mv forge /usr/local/bin/forge
sudo mv cast /usr/local/bin/cast
sudo chmod +x /usr/local/bin/forge
sudo chmod +x /usr/local/bin/cast
forge --version
- name: Run tests
run: yarn l2 test
run: yarn l2 test:foundry
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,13 @@ l1-contracts/lcov.info
l1-contracts/report/*
l1-contracts/coverage/*
l1-contracts/out/*
l1-contracts/zkout/*
l1-contracts/broadcast/*
l1-contracts/script-config/*
!l1-contracts/script-config/artifacts
l1-contracts/script-out/*
l1-contracts/test/foundry/integration/deploy-scripts/script-out/*.toml
l1-contracts/test/foundry/l1/integration/deploy-scripts/script-out/*.toml
!l1-contracts/script-out/.gitkeep
*.timestamp
l1-contracts/test/foundry/l1/integration/deploy-scripts/script-out/*
l1-contracts/zkout/*
21 changes: 12 additions & 9 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
[submodule "l1-contracts/lib/forge-std"]
path = l1-contracts/lib/forge-std
url = https://github.com/foundry-rs/forge-std
[submodule "l1-contracts/lib/murky"]
path = l1-contracts/lib/murky
[submodule "lib/murky"]
path = lib/murky
url = https://github.com/dmfxyz/murky
[submodule "l1-contracts/lib/openzeppelin-contracts-upgradeable"]
path = l1-contracts/lib/openzeppelin-contracts-upgradeable
[submodule "lib/openzeppelin-contracts-upgradeable-v4"]
path = lib/openzeppelin-contracts-upgradeable-v4
url = https://github.com/Openzeppelin/openzeppelin-contracts-upgradeable
branch = release-v4.9
[submodule "l1-contracts/lib/openzeppelin-contracts"]
path = l1-contracts/lib/openzeppelin-contracts
[submodule "lib/openzeppelin-contracts-v4"]
path = lib/openzeppelin-contracts-v4
url = https://github.com/Openzeppelin/openzeppelin-contracts
branch = release-v4.9
[submodule "lib/forge-std"]
path = lib/forge-std
url = https://github.com/foundry-rs/forge-std
[submodule "lib/@matterlabs/zksync-contracts"]
path = lib/@matterlabs/zksync-contracts
url = https://github.com/matter-labs/v2-testnet-contracts
6 changes: 5 additions & 1 deletion .markdownlintignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
node_modules

# l1-contracts
l1-contracts/lib
l1-contracts/node_modules

# l1-contracts-foundry
Expand All @@ -14,3 +13,8 @@ l2-contracts/node_modules
# system-contracts
system-contracts/node_modules
system-contracts/bootloader/test_infra/target

l1-contracts/lib
lib/
l2-contracts/lib
system-contracts/lib
4 changes: 4 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
tools/data
l1-contracts/lib
l1-contracts-foundry/lib
lib
system-contracts/contracts/openzeppelin
system-contracts/contracts/Constants.sol
system-contracts/artifacts-zk
Expand All @@ -10,3 +11,6 @@ l1-contracts/cache
l1-contracts/cache-forge
l1-contracts/artifacts
l1-contracts/artifacts-forge
l1-contracts/zkout
l2-contracts/zkout
system-contracts/zkout
8 changes: 7 additions & 1 deletion .solhintignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ l1-contracts/lib
l1-contracts/node_modules
l1-contracts/contracts/dev-contracts
l1-contracts/test
l1-contracts/deploy-scripts

# l1-contracts-foundry
l1-contracts-foundry/cache
Expand All @@ -16,6 +17,7 @@ l1-contracts-foundry/lib
# l2-contracts
l2-contracts/cache-zk
l2-contracts/node_modules
l2-contracts/test

# system-contracts
system-contracts/contracts/openzeppelin
Expand All @@ -24,4 +26,8 @@ system-contracts/contracts/test-contracts
system-contracts/contracts-preprocessed

# gas-bound-caller
gas-bound-caller/contracts/test-contracts
gas-bound-caller

lib/*
l2-contracts/lib
system-contracts/lib
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ We aim to make it as easy as possible to contribute to the mission. This is stil
and suggestions here too. Some resources to help:

1. [In-repo docs aimed at developers](docs)
2. [zkSync Era docs!](https://era.zksync.io/docs/)
2. [ZKsync Era docs!](https://era.zksync.io/docs/)
3. Company links can be found in the [repo's readme](README.md)

## Code of Conduct
Expand Down
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
# zkSync Era: Smart Contracts
# ZKsync Era: Smart Contracts

[![Logo](eraLogo.svg)](https://zksync.io/)

zkSync Era is a layer 2 rollup that uses zero-knowledge proofs to scale Ethereum without compromising on security or
ZKsync Era is a layer 2 rollup that uses zero-knowledge proofs to scale Ethereum without compromising on security or
decentralization. Since it's EVM compatible (Solidity/Vyper), 99% of Ethereum projects can redeploy without refactoring
or re-auditing a single line of code. zkSync Era also uses an LLVM-based compiler that will eventually let developers
or re-auditing a single line of code. ZKsync Era also uses an LLVM-based compiler that will eventually let developers
write smart contracts in C++, Rust and other popular languages.

This repository contains both L1 and L2 zkSync smart contracts. For their description see the
This repository contains both L1 and L2 ZKsync smart contracts. For their description see the
[system overview](docs/Overview.md).

## Disclaimer
Expand All @@ -17,7 +17,7 @@ others may not.

## License

zkSync Era contracts are distributed under the terms of the MIT license.
ZKsync Era contracts are distributed under the terms of the MIT license.

See [LICENSE-MIT](LICENSE-MIT) for details.

Expand All @@ -33,7 +33,7 @@ See [LICENSE-MIT](LICENSE-MIT) for details.

## Disclaimer

zkSync Era has been through lots of testing and audits. Although it is live, it is still in alpha state and will go
ZKsync Era has been through lots of testing and audits. Although it is live, it is still in alpha state and will go
through more audits and bug bounties programs. We would love to hear our community's thoughts and suggestions about it!
It is important to state that forking it now can potentially lead to missing important security updates, critical
features, and performance improvements.
1 change: 1 addition & 0 deletions _typos.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ extend-exclude = [
"/l1-contracts/out/",
"/l1-contracts/node_modules/",
"/l1-contracts/artifacts",
"/l1-contracts-foundry/lib/",
"/l2-contracts/artifacts-zk",
"/l2-contracts/cache-zk",
"/l2-contracts/typechain",
Expand Down
4 changes: 2 additions & 2 deletions da-contracts/contracts/CalldataDA.sol
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ abstract contract CalldataDA {

require(_operatorDAInput.length >= BLOB_DATA_OFFSET + 32 * blobsProvided, "invalid blobs hashes");

cloneCalldata(blobsLinearHashes, _operatorDAInput[BLOB_DATA_OFFSET:], blobsProvided);
_cloneCalldata(blobsLinearHashes, _operatorDAInput[BLOB_DATA_OFFSET:], blobsProvided);

uint256 ptr = BLOB_DATA_OFFSET + 32 * blobsProvided;

Expand Down Expand Up @@ -100,7 +100,7 @@ abstract contract CalldataDA {
/// @param _dst The destination array.
/// @param _input The input calldata.
/// @param _len The length of the slice in 32-byte words to clone.
function cloneCalldata(bytes32[] memory _dst, bytes calldata _input, uint256 _len) internal pure {
function _cloneCalldata(bytes32[] memory _dst, bytes calldata _input, uint256 _len) internal pure {
assembly {
// The pointer to the allocated memory above. We skip 32 bytes to avoid overwriting the length.
let dstPtr := add(_dst, 0x20)
Expand Down
19 changes: 19 additions & 0 deletions da-contracts/contracts/DAContractsErrors.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.21;

// 0x53dee67b
error PubdataCommitmentsEmpty();
// 0x7734c31a
error PubdataCommitmentsTooBig();
// 0x53e6d04d
error InvalidPubdataCommitmentsSize();
// 0xafd53e2f
error BlobHashCommitmentError(uint256 index, bool blobHashEmpty, bool blobCommitmentEmpty);
// 0xfc7ab1d3
error EmptyBlobVersionHash(uint256 index);
// 0x92290acc
error NonEmptyBlobVersionHash(uint256 index);
// 0x8d5851de
error PointEvalCallFailed(bytes);
// 0x4daa985d
error PointEvalFailed(bytes);
Loading

0 comments on commit 17a8300

Please sign in to comment.