Skip to content

Commit

Permalink
Merge branch 'dev' into oz-audit-vm-1-5-0
Browse files Browse the repository at this point in the history
  • Loading branch information
vladbochok authored Apr 11, 2024
2 parents bfbe725 + 036dfe3 commit c00de27
Show file tree
Hide file tree
Showing 123 changed files with 2,769 additions and 1,151 deletions.
2 changes: 1 addition & 1 deletion .codespell/.codespellrc
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[codespell]
skip = .git,_typos.toml,artifacts,lib,node_modules,artifacts-zk,yarn.lock,contracts-preprocessed,Cargo.lock
skip = .git,_typos.toml,artifacts,lib,node_modules,artifacts-zk,yarn.lock,contracts-preprocessed,Cargo.lock,SECURITY.md
count = true
quiet-level = 3
ignore-words = ./.codespell/wordlist.txt
111 changes: 111 additions & 0 deletions .github/workflows/l1-contracts-foundry-ci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
name: L1 contracts foundry CI

env:
ANVIL_PRIVATE_KEY: "0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80"
ANVIL_RPC_URL: "http://127.0.0.1:8545"

on:
pull_request:
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout the repository
uses: actions/checkout@v4
with:
submodules: true

- name: Use Foundry
uses: foundry-rs/foundry-toolchain@v1

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

- name: Install dependencies
run: yarn

- name: Build artifacts
working-directory: ./l1-contracts-foundry
run: forge build

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

- name: Create cache
uses: actions/cache/save@v3
with:
key: artifacts-l1-contracts-foudry-${{ github.sha }}
path: |
l1-contracts-foundry/cache
l1-contracts-foundry/out
system-contracts/artifacts-zk
system-contracts/bootloader/build
system-contracts/cache-zk
system-contracts/contracts-preprocessed
system-contracts/typechain
scripts:
runs-on: ubuntu-latest
needs: build
steps:
- name: Checkout the repository
uses: actions/checkout@v4
with:
submodules: true

- name: Restore artifacts cache
uses: actions/cache/restore@v3
with:
fail-on-cache-miss: true
key: artifacts-l1-contracts-foudry-${{ github.sha }}
path: |
l1-contracts-foundry/cache
l1-contracts-foundry/out
system-contracts/artifacts-zk
system-contracts/bootloader/build
system-contracts/cache-zk
system-contracts/contracts-preprocessed
system-contracts/typechain
- name: Use Foundry
uses: foundry-rs/foundry-toolchain@v1

- name: Run anvil
run: |
anvil --silent &
ANVIL_READY=0
for i in {1..10}; do
if curl -s -o /dev/null $ANVIL_RPC_URL -X POST -H "Content-Type: application/json" -d '{"jsonrpc":"2.0","method":"eth_chainId","id":1}'; then
echo "Anvil is ready"
ANVIL_READY=1
break
else
echo "Waiting for Anvil to become ready..."
sleep 1
fi
done
if [ $ANVIL_READY -ne 1 ]; then
echo "Anvil failed to become ready after 10 attempts."
exit 1
fi
- name: Run DeployL1 script
working-directory: ./l1-contracts-foundry
run: forge script ./script/DeployL1.s.sol --ffi --rpc-url $ANVIL_RPC_URL --broadcast --private-key $ANVIL_PRIVATE_KEY

- name: Run RegisterHyperchain script
working-directory: ./l1-contracts-foundry
run: forge script ./script/RegisterHyperchain.s.sol --ffi --rpc-url $ANVIL_RPC_URL --broadcast --private-key $ANVIL_PRIVATE_KEY

- name: Run DeployErc20 script
working-directory: ./l1-contracts-foundry
run: forge script ./script/DeployErc20.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 ./script/InitializeL2WethToken.s.sol --ffi --rpc-url $ANVIL_RPC_URL --broadcast --private-key $ANVIL_PRIVATE_KEY
46 changes: 46 additions & 0 deletions .github/workflows/slither.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: Slither scanner

on: pull_request

jobs:
slither-l1:
name: Slither check for L1 contracts
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: Setup Python
uses: actions/setup-python@v5
with:
python-version: 3.8

- name: Install Slither
run: |
pip install slither-analyzer
- name: Use Foundry
uses: foundry-rs/foundry-toolchain@v1

- name: Remove non-compiled files
run: |
rm -rf ./l1-contracts/contracts/state-transition/utils/
rm -rf ./l1-contracts/contracts/state-transition/Verifier.sol
rm -rf ./l1-contracts/contracts/state-transition/TestnetVerifier.sol
rm -rf ./l1-contracts/contracts/dev-contracts/test/VerifierTest.sol
rm -rf ./l1-contracts/contracts/dev-contracts/test/VerifierRecursiveTest.sol
- name: Run Slither
run: slither --config ./l1-contracts/slither.config.json ./l1-contracts
7 changes: 6 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ cache/
contracts-preprocessed/
era_test_node.log*
node_modules/
out/
target/
tools/data/Verifier.sol
typechain/
Expand All @@ -19,4 +20,8 @@ yarn-error.log*
l1-contracts/yarn-error.log*
l1-contracts/lcov.info
l1-contracts/report/*
l1-contracts/coverage/*
l1-contracts/coverage/*
l1-contracts/out/*
l1-contracts-foundry/broadcast/*
l1-contracts-foundry/script-out/*
!l1-contracts-foundry/script-out/.gitkeep
9 changes: 9 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,12 @@
[submodule "l1-contracts/lib/murky"]
path = l1-contracts/lib/murky
url = https://github.com/dmfxyz/murky
[submodule "l1-contracts-foundry/lib/forge-std"]
path = l1-contracts-foundry/lib/forge-std
url = https://github.com/foundry-rs/forge-std
[submodule "l1-contracts-foundry/lib/openzeppelin-contracts"]
path = l1-contracts-foundry/lib/openzeppelin-contracts
url = https://github.com/Openzeppelin/openzeppelin-contracts
[submodule "l1-contracts-foundry/lib/openzeppelin-contracts-upgradeable"]
path = l1-contracts-foundry/lib/openzeppelin-contracts-upgradeable
url = https://github.com/Openzeppelin/openzeppelin-contracts-upgradeable
3 changes: 3 additions & 0 deletions .markdownlintignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ node_modules
l1-contracts/lib
l1-contracts/node_modules

# l1-contracts-foundry
l1-contracts-foundry/lib

# l2-contracts
l2-contracts/node_modules

Expand Down
1 change: 1 addition & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
tools/data
l1-contracts/lib
l1-contracts-foundry/lib
system-contracts/contracts/openzeppelin
system-contracts/contracts/Constants.sol
system-contracts/artifacts-zk
Expand Down
4 changes: 4 additions & 0 deletions .solhintignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ l1-contracts/cache-forge
l1-contracts/lib
l1-contracts/node_modules

# l1-contracts-foundry
l1-contracts-foundry/cache
l1-contracts-foundry/lib

# l2-contracts
l2-contracts/cache-zk
l2-contracts/node_modules
Expand Down
3 changes: 2 additions & 1 deletion _typos.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ extend-exclude = [
"/system-contracts/typechain",
"*.json",
"*.lock",
".git/"
".git/",
"SECURITY.md"
]

[default.extend-words]
Expand Down
2 changes: 1 addition & 1 deletion docs/Overview.md
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ this trick:
#### L1 -> L2 Transaction filtering

There is a mechanism for applying custom filters to the L1 -> L2 communication. It is achieved by having an address of
the `TransactionFilterer` contract in the `ZkSyncStateTransitionStorage`. If the filterer exists, it is being called in
the `TransactionFilterer` contract in the `ZkSyncHyperchainStorage`. If the filterer exists, it is being called in
the `Mailbox` facet with the tx details and has to return whether the transaction can be executed or not. The filterer
has to implement the `ITransactionFilterer` interface. The ones intended to use this feature, have to deploy the
contract that implements `ITransactionFilterer` and use `setTransactionFilterer` function of `AdminFacet` to set the
Expand Down
19 changes: 19 additions & 0 deletions l1-contracts-foundry/foundry.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
[profile.default]
src = "../l1-contracts/contracts"
out = "out"
libs = ["lib"]
remappings = [
"@openzeppelin/contracts/=lib/openzeppelin-contracts/contracts/",
"@openzeppelin/contracts-upgradeable/=lib/openzeppelin-contracts-upgradeable/contracts/",
"contracts/=../l1-contracts/contracts/",
"l2-contracts/=../l2-contracts/contracts/"
]
allow_paths = ["../l1-contracts/contracts", "../l2-contracts/contracts"]
fs_permissions = [
{ access = "read", path = "../system-contracts/bootloader/build/artifacts"},
{ access = "read", path = "../system-contracts/artifacts-zk/contracts-preprocessed"},
{ access = "read", path = "./script-config" },
{ access = "read-write", path = "./script-out" },
{ access = "read", path = "./out" }
]
evm_version="cancun"
1 change: 1 addition & 0 deletions l1-contracts-foundry/lib/forge-std
Submodule forge-std added at b6a506
1 change: 1 addition & 0 deletions l1-contracts-foundry/lib/openzeppelin-contracts
Submodule openzeppelin-contracts added at dc44c9
16 changes: 16 additions & 0 deletions l1-contracts-foundry/script-config/config-deploy-erc20.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
create2_factory_addr = "0x4e59b44847b379578588920cA78FbF26c0B4956C"
create2_factory_salt = "0x00000000000000000000000000000000000000000000000000000000000000ff"

[tokens.dai]
name = "DAI"
symbol = "DAI"
decimals = 18
implementation = "TestnetERC20Token.sol"
mint = "10000000000"

[tokens.weth]
name = "Wrapped Ether"
symbol = "WETH"
decimals = 18
implementation = "WETH9.sol"
mint = "0"
37 changes: 37 additions & 0 deletions l1-contracts-foundry/script-config/config-deploy-l1.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
era_chain_id = 9
owner_address = "0x70997970C51812dc3A010C7d01b50e0d17dc79C8"

[contracts]
governance_security_council_address = "0x0000000000000000000000000000000000000000"
governance_min_delay = 0
create2_factory_salt = "0x00000000000000000000000000000000000000000000000000000000000000ff"
create2_factory_addr = "0x0000000000000000000000000000000000000000"
validator_timelock_execution_delay = 0
genesis_root = "0x0000000000000000000000000000000000000000000000000000000000000000"
genesis_rollup_leaf_index = 0
genesis_batch_commitment = "0x0000000000000000000000000000000000000000000000000000000000000000"
latest_protocol_version = 0
recursion_node_level_vk_hash = "0x0000000000000000000000000000000000000000000000000000000000000000"
recursion_leaf_level_vk_hash = "0x0000000000000000000000000000000000000000000000000000000000000000"
recursion_circuits_set_vks_hash = "0x0000000000000000000000000000000000000000000000000000000000000000"
priority_tx_max_gas_limit = 80000000
shared_bridge_upgrade_storage_switch = 0
diamond_init_pubdata_pricing_mode = 0
diamond_init_batch_overhead_l1_gas = 1000000
diamond_init_max_pubdata_per_batch = 120000
diamond_init_max_l2_gas_per_batch = 80000000
diamond_init_priority_tx_max_pubdata = 99000
diamond_init_minimal_l2_gas_price = 250000000

[tokens]
token_weth_address = "0x0000000000000000000000000000000000000000"

[hyperchain]
hyperchain_chain_id = 9
base_token_addr = "0x0000000000000000000000000000000000000001"
bridgehub_create_new_chain_salt = 0
validium_mode = false
validator_sender_operator_commit_eth = "0x0000000000000000000000000000000000000000"
validator_sender_operator_blobs_eth = "0x0000000000000000000000000000000000000001"
base_token_gas_price_multiplier_nominator = 1
base_token_gas_price_multiplier_denominator = 1
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
l2_shared_bridge_addr = "0x0000000000000000000000000000000000000000"
l2_weth_token_proxy_addr = "0x0000000000000000000000000000000000000000"
l2_weth_token_impl_addr = "0x0000000000000000000000000000000000000000"
deploy_l2_bridge_counterpart_gas_limit = "10000000"
required_l2_gas_price_per_pubdata = "800"
gas_multiplier = "3"
Empty file.
Loading

0 comments on commit c00de27

Please sign in to comment.