Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: L-02 Unnecessary Legacy Check For Chain Migration #1000

Draft
wants to merge 267 commits into
base: oz-audit-sep-base
Choose a base branch
from
Draft
Changes from 23 commits
Commits
Show all changes
267 commits
Select commit Hold shift + click to select a range
4c4411c
Merge pull request #692 from matter-labs/sb-set-of-fixes-1
StanislavBreadless Aug 13, 2024
2a2e6cf
amend some functions
StanislavBreadless Aug 14, 2024
9f6d439
make scripts work
StanislavBreadless Aug 14, 2024
576a59c
fmt
StanislavBreadless Aug 14, 2024
779c707
fix lint
StanislavBreadless Aug 14, 2024
8534b30
Merge pull request #697 from matter-labs/sb-synced-sync-layer-reorg
StanislavBreadless Aug 14, 2024
50c633c
Kl/l2 bridge fixes (#687)
kelemeno Aug 14, 2024
4fec3c1
Merge branch 'kl/sync-layer-reorg' of ssh://github.com/matter-labs/er…
kelemeno Aug 14, 2024
fd4aebc
fix: zksync-ethers v5 dependency (#702)
benceharomi Aug 15, 2024
f1a8c2d
Kl/stmdt counterpart fix EVM-701 (#693)
kelemeno Aug 15, 2024
df1c5c8
fix: move hyperchain mapping EVM-709 (#704)
kelemeno Aug 16, 2024
acd603a
bridgehub small fixes, some cleanup
kelemeno Aug 16, 2024
ad92d47
Merge branch 'kl/sync-layer-reorg' of ssh://github.com/matter-labs/er…
kelemeno Aug 16, 2024
7d4b79c
fix: EVM-708 bridge fixes (#703)
kelemeno Aug 16, 2024
4c82e7d
Limitations for the l2 migrated chain (#707)
StanislavBreadless Aug 16, 2024
6d0ceb9
small fixes
kelemeno Aug 16, 2024
a738dc8
Merge branch 'kl/sync-layer-reorg' of ssh://github.com/matter-labs/er…
kelemeno Aug 16, 2024
c168183
more fixes
kelemeno Aug 16, 2024
a9a4646
typo
kelemeno Aug 16, 2024
ff10238
Stas issues
kelemeno Aug 16, 2024
d4bb8c5
removed unsued function + some changes
StanislavBreadless Aug 16, 2024
2a22e23
fixes
kelemeno Aug 16, 2024
590d207
fix some legacy methods
StanislavBreadless Aug 17, 2024
83cd458
fmt
StanislavBreadless Aug 17, 2024
42e7e0a
additional changes
StanislavBreadless Aug 18, 2024
aff1f4e
fmt
StanislavBreadless Aug 18, 2024
8099c0e
commented out code
StanislavBreadless Aug 19, 2024
ce27e0b
lint fix
StanislavBreadless Aug 19, 2024
ec64d85
should work
StanislavBreadless Aug 19, 2024
ea24b02
move some methods around
StanislavBreadless Aug 19, 2024
e58a3ee
fmt
StanislavBreadless Aug 19, 2024
d0a4401
remove useless change
StanislavBreadless Aug 19, 2024
ade586e
codespell
StanislavBreadless Aug 19, 2024
9e52539
router
StanislavBreadless Aug 19, 2024
8e59135
upd some files
StanislavBreadless Aug 19, 2024
859eed8
fix tests
StanislavBreadless Aug 19, 2024
568d65c
Merge remote-tracking branch 'origin/sb-sync-layer-reorg-stable-sync-…
StanislavBreadless Aug 19, 2024
a94a1b1
fmt
StanislavBreadless Aug 19, 2024
e7865bc
Merge pull request #712 from matter-labs/sb-sync-layer-reorg-stable-s…
StanislavBreadless Aug 19, 2024
9ebe7aa
fix lint
StanislavBreadless Aug 19, 2024
f105566
fix sys contracts tests
StanislavBreadless Aug 19, 2024
0640579
lint
StanislavBreadless Aug 19, 2024
ad726f7
fix
StanislavBreadless Aug 19, 2024
fa16bcb
fix
StanislavBreadless Aug 19, 2024
d50bf31
Merge pull request #714 from matter-labs/sb-fix-sl-stable
StanislavBreadless Aug 19, 2024
6a5dada
Merge branch 'sync-layer-stable' into sb-reduce-owner-footprint-on-ge…
StanislavBreadless Aug 19, 2024
1b8393b
fix check hashes
StanislavBreadless Aug 20, 2024
3de3430
Remove Base Token Address from Chain Registration (#700)
Raid5594 Aug 20, 2024
a91bc7a
Merge pull request #711 from matter-labs/sb-reduce-owner-footprint-on…
StanislavBreadless Aug 20, 2024
5853c3a
feat(consensus): add L2 registry contract (BFT-434) (#555) (#718)
pompon0 Aug 20, 2024
8f4aad4
Merge pull request #719 from matter-labs/sync-layer-stable
StanislavBreadless Aug 20, 2024
9b24cce
merge dev into the kl sync layer reorg
StanislavBreadless Aug 20, 2024
66e8494
fix sc build
StanislavBreadless Aug 20, 2024
47495d1
fix some lints
StanislavBreadless Aug 20, 2024
def5d47
fix lint
StanislavBreadless Aug 20, 2024
336e40c
Merge pull request #721 from matter-labs/sb-merge-dev-kl-reorg
StanislavBreadless Aug 20, 2024
fb536f2
fix chainRegistered
kelemeno Aug 20, 2024
21a10e0
gw fixes
StanislavBreadless Aug 20, 2024
86d2cc0
script fixes
kelemeno Aug 20, 2024
092d198
local zk fmt breaks...
kelemeno Aug 20, 2024
ed036a2
fmt
StanislavBreadless Aug 21, 2024
792d059
fix comment
StanislavBreadless Aug 21, 2024
7ef7a6d
fmt
StanislavBreadless Aug 21, 2024
739fabb
some contract fixes
kelemeno Aug 21, 2024
d7928ba
commented out code
kelemeno Aug 21, 2024
8b45eff
some more fixes
kelemeno Aug 21, 2024
95f5085
forgot await
kelemeno Aug 21, 2024
4d5cdc9
undo getL1ChainId, its async
kelemeno Aug 21, 2024
c1675c3
fix tests
StanislavBreadless Aug 21, 2024
96fa8e4
wip
StanislavBreadless Aug 21, 2024
c7b7123
foundry test fixes
kelemeno Aug 21, 2024
1e13d50
add a getAssetId function
kelemeno Aug 21, 2024
e7442e6
Merge pull request #725 from matter-labs/sb-some-gw-messaing-fixes
StanislavBreadless Aug 21, 2024
d29195b
first round of conflict resolution
StanislavBreadless Aug 21, 2024
9e19b5a
system contracts compile
StanislavBreadless Aug 21, 2024
a7a10ae
l2 contracts compile
StanislavBreadless Aug 21, 2024
ad7c0ad
Stas issue fixes
kelemeno Aug 21, 2024
d31866a
Merge branch 'kl/sync-layer-reorg' of ssh://github.com/matter-labs/er…
kelemeno Aug 21, 2024
3274507
fix remappings
Deniallugo Aug 21, 2024
37245fa
foundry test and small fixes
kelemeno Aug 21, 2024
a7e3d0a
linting
kelemeno Aug 21, 2024
daf396e
make l1 contracts compile
StanislavBreadless Aug 21, 2024
a59077c
script fix
kelemeno Aug 21, 2024
1d62e8e
foundry test are running
StanislavBreadless Aug 21, 2024
8a2d7c8
Merge branch 'kl/script-fixes' of ssh://github.com/matter-labs/era-co…
kelemeno Aug 21, 2024
391fa4d
fix: script fixes (#726)
kelemeno Aug 21, 2024
70a0660
Merge branch 'sync-layer-stable' of ssh://github.com/matter-labs/era-…
kelemeno Aug 21, 2024
2b2af24
foundry tests pass (though some were commented out)
StanislavBreadless Aug 21, 2024
d1b5149
Merge branch 'sync-layer-stable' of ssh://github.com/matter-labs/era-…
kelemeno Aug 21, 2024
00f7d8e
partial l1 test fix
StanislavBreadless Aug 21, 2024
446d391
Add admin role to shared bridge (#727)
StanislavBreadless Aug 21, 2024
94b2646
chore: Kl/merge-stable (#730)
kelemeno Aug 21, 2024
5ec24e2
Kl/merge-stable2 (#731)
kelemeno Aug 21, 2024
8421abc
forceDeploymetns data
kelemeno Aug 21, 2024
095a55a
bad merge
StanislavBreadless Aug 22, 2024
4e084b7
merge kl reorg branch
StanislavBreadless Aug 22, 2024
ab605b2
foundry tests pass
StanislavBreadless Aug 22, 2024
9e0c329
make more tests pass
StanislavBreadless Aug 22, 2024
377d0aa
fmt
StanislavBreadless Aug 22, 2024
9a168a6
Merge branch 'kl/sync-layer-reorg-dev' into kl/sync-layer-reorg-foundry
StanislavBreadless Aug 22, 2024
a80a667
message root fix
kelemeno Aug 22, 2024
4255c63
renaming and some fixes
kelemeno Aug 22, 2024
51d5dc4
lint
kelemeno Aug 22, 2024
f741346
wip
StanislavBreadless Aug 22, 2024
f617301
erc20 tests in foundry work
StanislavBreadless Aug 22, 2024
0d7ee23
aggregated root return value
kelemeno Aug 22, 2024
d2f83db
cover most of weth tsts
StanislavBreadless Aug 22, 2024
ebfb6d2
port the rest of the tests
StanislavBreadless Aug 22, 2024
c90c9f6
remove old tests
StanislavBreadless Aug 23, 2024
3c1b796
old proof support
StanislavBreadless Aug 23, 2024
6225350
unit tests
StanislavBreadless Aug 23, 2024
5e1ada2
fix lint
StanislavBreadless Aug 23, 2024
774ef90
fix comment
StanislavBreadless Aug 23, 2024
7931924
Merge pull request #736 from matter-labs/sb-support-old-proving-format
StanislavBreadless Aug 26, 2024
a4a2b06
add a few events for migration
StanislavBreadless Aug 26, 2024
e05866e
ensure that the STM has to be whitelisted before it is used
StanislavBreadless Aug 26, 2024
18f66ba
some fixes
StanislavBreadless Aug 26, 2024
7c8ef21
fix lint
StanislavBreadless Aug 26, 2024
9a3b546
rename event
StanislavBreadless Aug 26, 2024
b6d6c47
lint
StanislavBreadless Aug 26, 2024
e5b44c6
remove unused methods from validator timelock and executor
StanislavBreadless Aug 26, 2024
a478e2e
some more fixes
StanislavBreadless Aug 26, 2024
823ef65
Merge remote-tracking branch 'origin/sb-set-of-fixes-2' into sb-set-o…
StanislavBreadless Aug 26, 2024
3f17ff8
fix compile
StanislavBreadless Aug 26, 2024
caf4192
fix some more stuff
StanislavBreadless Aug 26, 2024
ae9add5
lint
StanislavBreadless Aug 26, 2024
dc1da58
migrate tests
StanislavBreadless Aug 26, 2024
60b7fc4
lint fix
StanislavBreadless Aug 26, 2024
2071f78
test
StanislavBreadless Aug 26, 2024
d5ecc4a
fmt
StanislavBreadless Aug 26, 2024
075eed8
Merge pull request #737 from matter-labs/sb-set-of-fixes-2
StanislavBreadless Aug 27, 2024
3a4fc67
make scripts work with the server
StanislavBreadless Aug 27, 2024
5cb5a03
sync with sync-layer-stable
StanislavBreadless Aug 27, 2024
d273ebf
fmt
StanislavBreadless Aug 27, 2024
95c501b
Merge pull request #744 from matter-labs/sb-port-kl/sync-layer-reorg
StanislavBreadless Aug 27, 2024
709bd86
Merge pull request #746 from matter-labs/sync-layer-stable
StanislavBreadless Aug 27, 2024
c82a950
sync with dev
StanislavBreadless Aug 28, 2024
7bcf8ac
sync with kl/sync-layer-reorg
StanislavBreadless Aug 28, 2024
a102e75
fix l1 tests
StanislavBreadless Aug 28, 2024
1dfc1ef
fmt
StanislavBreadless Aug 28, 2024
ad046e0
most of lints
StanislavBreadless Aug 28, 2024
4ac4e01
tmp: submodules work
StanislavBreadless Aug 28, 2024
d77b6a8
remove forge std
StanislavBreadless Aug 28, 2024
60935d3
remove l1-contracts/lib/murky
StanislavBreadless Aug 28, 2024
2c03a8d
remove mode subdmoules
StanislavBreadless Aug 28, 2024
f3e83dd
fix unit tests
StanislavBreadless Aug 28, 2024
8b025a4
fmt
StanislavBreadless Aug 28, 2024
60a1f7b
fix ci
StanislavBreadless Aug 28, 2024
f3a9481
fix spelling
StanislavBreadless Aug 28, 2024
fa4baf0
check hashes
StanislavBreadless Aug 28, 2024
6fa9393
better compare
StanislavBreadless Aug 28, 2024
8632559
correct address
StanislavBreadless Aug 28, 2024
2d92a68
comments
StanislavBreadless Aug 28, 2024
277d61d
fix addr
StanislavBreadless Aug 28, 2024
955979c
lint
StanislavBreadless Aug 28, 2024
10ec8ba
Merge pull request #749 from matter-labs/kl/sync-layer-reorg-dev
StanislavBreadless Aug 28, 2024
ac415e2
Merge pull request #753 from matter-labs/kl/sync-layer-reorg
StanislavBreadless Aug 28, 2024
03644e6
Merge branch 'kl/sync-layer-reorg' into kl/sync-layer-reorg-foundry
StanislavBreadless Aug 29, 2024
a557c01
upd workflow
StanislavBreadless Aug 29, 2024
487dd71
forge install: v2-testnet-contracts
StanislavBreadless Aug 29, 2024
4bac7cb
wip
StanislavBreadless Aug 29, 2024
1a2390c
forge install: @matterlabs/zksync-contracts
StanislavBreadless Aug 29, 2024
2d9ad08
using foundry deps
StanislavBreadless Aug 29, 2024
bc54d47
remove unneeded changes
StanislavBreadless Aug 29, 2024
e4689f0
wip
StanislavBreadless Aug 29, 2024
0a5e318
fix typo
StanislavBreadless Aug 29, 2024
6775587
install foundry zksync in ci
StanislavBreadless Aug 29, 2024
12cb8d0
fix lint
StanislavBreadless Aug 29, 2024
db7eafb
more efficient forge install
StanislavBreadless Aug 29, 2024
e70b722
fmt
StanislavBreadless Aug 29, 2024
e572c91
compile sc contracts also
StanislavBreadless Aug 29, 2024
dfd969c
Merge pull request #755 from matter-labs/kl/sync-layer-reorg-foundry
StanislavBreadless Aug 29, 2024
c905dd3
sync with stable
StanislavBreadless Aug 29, 2024
f17d7e1
Merge branch 'kl/sync-layer-reorg' into kl/migrate-back-from-gw
StanislavBreadless Aug 29, 2024
8affc3c
fix compile
StanislavBreadless Aug 29, 2024
adc2e76
Merge pull request #706 from matter-labs/kl/migrate-back-from-gw
StanislavBreadless Aug 29, 2024
3301a13
add ability to recover from failed migration (#715)
koloz193 Aug 29, 2024
de2cca7
sync with stable
StanislavBreadless Aug 29, 2024
464382e
fix compile
StanislavBreadless Aug 29, 2024
c05daf6
Fixed yarn clean - to remove zksync artifacts too
mm-zk Aug 30, 2024
262ee7e
Merge pull request #759 from matter-labs/mmzk_0830_fix_cleanup
StanislavBreadless Aug 30, 2024
989f2c1
L2 verifier support (#756)
StanislavBreadless Aug 30, 2024
d669a5f
Merge pull request #758 from matter-labs/sb-sync-sync-layer-stable
StanislavBreadless Aug 30, 2024
b212535
sync with kl sync layer reorg
StanislavBreadless Aug 30, 2024
840df35
fix comile
StanislavBreadless Aug 30, 2024
9fa2d66
fix lint
StanislavBreadless Aug 30, 2024
f469e7c
fix script
StanislavBreadless Aug 30, 2024
9d319e7
Merge branch 'sync-layer-stable' into kl/message-root-update
StanislavBreadless Aug 30, 2024
73ddd6d
Merge pull request #724 from matter-labs/kl/message-root-update
StanislavBreadless Aug 30, 2024
d368769
feat: Deploy ConsensusRegistry through L1 to L2 transaction (BFT-504)…
aakoshh Sep 2, 2024
3a1aecc
Fix token info upon migration (#760)
StanislavBreadless Sep 2, 2024
7f2c27a
Small PR to Fix "Ethers" and "ETH" encoding (#762)
Raid5594 Sep 3, 2024
78b0ce8
STM -> CTM
StanislavBreadless Sep 4, 2024
213f990
chore: Kl/merge-dev-sync-layer-stable (#763)
kelemeno Sep 4, 2024
249e012
Merge branch 'kl/sync-layer-reorg' into sb-rename-stm
StanislavBreadless Sep 4, 2024
28aadaa
migrate in script files as well
StanislavBreadless Sep 4, 2024
e8d47b4
l1 foundry test work
StanislavBreadless Sep 4, 2024
ae911bb
fix ts tests
StanislavBreadless Sep 4, 2024
b23bf7c
lint
StanislavBreadless Sep 4, 2024
566a54b
Resolve some of the leftover todos (#765)
StanislavBreadless Sep 5, 2024
9d1ce13
fix lib to remove it from coverage report
StanislavBreadless Sep 5, 2024
6fff2b1
sync with base
StanislavBreadless Sep 5, 2024
af14533
recalc hashes
StanislavBreadless Sep 5, 2024
aab2f77
toml file
StanislavBreadless Sep 5, 2024
3d6e02f
Set foundry optimizer_runs (#770)
perekopskiy Sep 5, 2024
42933cd
Merge pull request #766 from matter-labs/sb-rename-stm
StanislavBreadless Sep 5, 2024
4a062d0
Rename hyperchain -> ZK chain (#771)
StanislavBreadless Sep 5, 2024
8b5b296
Implement restriction to allow limiting chain admin in power (#699)
StanislavBreadless Sep 5, 2024
c95f623
sync with dev
StanislavBreadless Sep 6, 2024
93ed4dc
fix l1 compile
StanislavBreadless Sep 6, 2024
265166b
fix l1 foundry tests
StanislavBreadless Sep 6, 2024
1a23102
fix l2 compile
StanislavBreadless Sep 6, 2024
bd438c5
fix lint
StanislavBreadless Sep 6, 2024
99e9a0a
hopefully fix ci
StanislavBreadless Sep 6, 2024
2929483
hopefully fix ci 2
StanislavBreadless Sep 6, 2024
a1705ab
delete duplicated contract
StanislavBreadless Sep 6, 2024
6892ccc
Add admin permission to add custom base tokens (#776)
vladbochok Sep 6, 2024
b6c7130
merge main into dev
StanislavBreadless Sep 6, 2024
0fa0fa2
foundry tests pass
StanislavBreadless Sep 6, 2024
00ddc06
fix compile for registry
StanislavBreadless Sep 6, 2024
b6766b0
Merge pull request #777 from matter-labs/sb-merge-dev-kl-sync-layer-r…
StanislavBreadless Sep 6, 2024
ef33539
lint
StanislavBreadless Sep 6, 2024
dccc114
Remove most info from relayed L1->GW priority ops (#775)
StanislavBreadless Sep 6, 2024
b653ac8
Merge pull request #778 from matter-labs/sb-merge-main-to-dev
StanislavBreadless Sep 6, 2024
cb3c177
sync with reorg
StanislavBreadless Sep 6, 2024
23f5e3c
fmt
StanislavBreadless Sep 6, 2024
cb42ae4
Merge pull request #779 from matter-labs/sb-sync-reorg-with-stable
StanislavBreadless Sep 6, 2024
49868af
Change Executor.sol interface (#780)
vladbochok Sep 9, 2024
bebdefc
(feat): add tx filterer contract (#772)
Raid5594 Sep 10, 2024
f95beef
Ra/split asset router (#595)
Raid5594 Sep 10, 2024
8479868
chore: merge stable (#785)
kelemeno Sep 10, 2024
d1b7e16
Update l1-contracts/contracts/bridge/L1Nullifier.sol
kelemeno Sep 10, 2024
e741471
Update l1-contracts/contracts/bridge/asset-router/IL1AssetRouter.sol
kelemeno Sep 10, 2024
a42b991
fix: vlad issues (#788)
kelemeno Sep 10, 2024
2508f36
Recover some tests (#789)
StanislavBreadless Sep 10, 2024
b3564ef
Kl/chain balance fix (#786)
kelemeno Sep 10, 2024
1404dc0
Merge branch 'dev' of ssh://github.com/matter-labs/era-contracts into…
kelemeno Sep 10, 2024
cc3b2ac
chore: merge main (#790)
kelemeno Sep 10, 2024
8155711
Merge branch 'dev' of ssh://github.com/matter-labs/era-contracts into…
kelemeno Sep 10, 2024
c0d45fa
test fixes
kelemeno Sep 10, 2024
6de2963
Merge pull request #791 from matter-labs/kl/merge-dev
StanislavBreadless Sep 10, 2024
07d0462
Fixes (#792)
vladbochok Sep 11, 2024
1673186
sync head with base
StanislavBreadless Sep 11, 2024
eb3583a
delete unneeded files
StanislavBreadless Sep 11, 2024
e5727a0
Sync audit head with base (#797)
StanislavBreadless Sep 11, 2024
ef318e2
Merge pull request #798 from matter-labs/sb-sync-head-base
StanislavBreadless Sep 11, 2024
8208402
Better governance protection (audit) (#822)
StanislavBreadless Sep 26, 2024
9ccd217
fix: L-02 Unnecessary Legacy Check For Chain Migration
kelemeno Oct 25, 2024
0067c0a
remove IL2Bridge
kelemeno Oct 25, 2024
bc7013b
extra brackets
kelemeno Oct 28, 2024
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
27 changes: 20 additions & 7 deletions .github/workflows/l2-contracts-ci.yaml
Original file line number Diff line number Diff line change
@@ -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:
@@ -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
@@ -88,12 +94,19 @@ jobs:
l2-contracts/artifacts-zk
l2-contracts/cache-zk
l2-contracts/typechain
- name: Run Era test node
uses: dutterbutter/era-test-node-action@v0.1.3

- 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
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -12,3 +12,6 @@
[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
36 changes: 36 additions & 0 deletions l2-contracts/contracts/L2ContractHelper.sol
Original file line number Diff line number Diff line change
@@ -56,6 +56,13 @@ interface IContractDeployer {
/// @param _bytecodeHash the bytecodehash of the new contract to be deployed
/// @param _input the calldata to be sent to the constructor of the new contract
function create2(bytes32 _salt, bytes32 _bytecodeHash, bytes calldata _input) external returns (address);

function getNewAddressCreate2(
address _sender,
bytes32 _bytecodeHash,
bytes32 _salt,
bytes calldata _input
) external view returns (address newAddress);
}

/**
@@ -193,6 +200,35 @@ library L2ContractHelper {
// Setting the length
hashedBytecode = hashedBytecode | bytes32(bytecodeLenInWords << 224);
}

/// @notice Validate the bytecode format and calculate its hash.
/// @param _bytecode The bytecode to hash.
/// @return hashedBytecode The 32-byte hash of the bytecode.
/// Note: The function reverts the execution if the bytecode has non expected format:
/// - Bytecode bytes length is not a multiple of 32
/// - Bytecode bytes length is not less than 2^21 bytes (2^16 words)
/// - Bytecode words length is not odd
function hashL2BytecodeMemory(bytes memory _bytecode) internal view returns (bytes32 hashedBytecode) {
// Note that the length of the bytecode must be provided in 32-byte words.
if (_bytecode.length % 32 != 0) {
revert MalformedBytecode(BytecodeError.Length);
}

uint256 bytecodeLenInWords = _bytecode.length / 32;
// bytecode length must be less than 2^16 words
if (bytecodeLenInWords >= 2 ** 16) {
revert MalformedBytecode(BytecodeError.NumberOfWords);
}
// bytecode length in words must be odd
if (bytecodeLenInWords % 2 == 0) {
revert MalformedBytecode(BytecodeError.WordsMustBeOdd);
}
hashedBytecode = sha256(_bytecode) & 0x00000000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF;
// Setting the version of the hash
hashedBytecode = (hashedBytecode | bytes32(uint256(1 << 248)));
// Setting the length
hashedBytecode = hashedBytecode | bytes32(bytecodeLenInWords << 224);
}
}

/// @notice Structure used to represent a ZKsync transaction.
22 changes: 18 additions & 4 deletions l2-contracts/foundry.toml
Original file line number Diff line number Diff line change
@@ -2,12 +2,26 @@
src = "contracts"
out = "out"
libs = ["lib"]
test = "test/foundry"
solc_version = "0.8.20"
cache_path = "cache-forge"
via_ir = true
evm_version = "paris"
ignored_error_codes = ["missing-receive-ether", "code-size"]
ignored_warnings_from = ["test", "contracts/dev-contracts"]
remappings = [
"@openzeppelin/contracts/=lib/openzeppelin-contracts/contracts/",
"@openzeppelin/contracts-upgradeable/=lib/openzeppelin-contracts-upgradeable/contracts/",
"forge-std/=lib/forge-std/src/",
"foundry-test/=test/foundry/",
"@openzeppelin/contracts-v4/=./lib/openzeppelin-contracts-v4/contracts/",
"@openzeppelin/contracts-upgradeable-v4/=./lib/openzeppelin-contracts-upgradeable-v4/contracts/",
"@matterlabs/zksync-contracts/=./lib/@matterlabs/zksync-contracts/",
]
fs_permissions = [
{ access = "read", path = "zkout" },
{ access = "read", path = "../system-contracts/bootloader/build/artifacts" },
{ access = "read", path = "../system-contracts/artifacts-zk/contracts-preprocessed" }
]

[profile.default.zksync]
zksolc = "1.5.0"
[profile.default.zksync]
enable_eravm_extensions = true
zksolc = "1.5.1"
1 change: 1 addition & 0 deletions l2-contracts/lib/@matterlabs
1 change: 0 additions & 1 deletion l2-contracts/lib/openzeppelin-contracts

This file was deleted.

1 change: 0 additions & 1 deletion l2-contracts/lib/openzeppelin-contracts-upgradeable

This file was deleted.

1 change: 1 addition & 0 deletions l2-contracts/lib/openzeppelin-contracts-upgradeable-v4
1 change: 1 addition & 0 deletions l2-contracts/lib/openzeppelin-contracts-v4
1 change: 1 addition & 0 deletions l2-contracts/package.json
Original file line number Diff line number Diff line change
@@ -33,6 +33,7 @@
},
"scripts": {
"build": "hardhat compile",
"test:foundry": "forge test --zksync",
"clean": "hardhat clean",
"test": "hardhat test",
"verify": "hardhat run src/verify.ts",
179 changes: 0 additions & 179 deletions l2-contracts/test/erc20.test.ts

This file was deleted.

135 changes: 135 additions & 0 deletions l2-contracts/test/foundry/unit/erc20/L2Erc20BridgeTest.t.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
// SPDX-License-Identifier: MIT

pragma solidity 0.8.20;

// solhint-disable gas-custom-errors

import {Test} from "forge-std/Test.sol";

import {L2StandardERC20} from "contracts/bridge/L2StandardERC20.sol";
import {L2AssetRouter} from "contracts/bridge/L2AssetRouter.sol";

import {UpgradeableBeacon} from "@openzeppelin/contracts-v4/proxy/beacon/UpgradeableBeacon.sol";
import {BeaconProxy} from "@openzeppelin/contracts-v4/proxy/beacon/BeaconProxy.sol";

import {L2_ASSET_ROUTER, L2_NATIVE_TOKEN_VAULT} from "contracts/L2ContractHelper.sol";

import {AddressAliasHelper} from "contracts/vendor/AddressAliasHelper.sol";

import {Utils} from "../utils/Utils.sol";

contract L2Erc20BridgeTest is Test {
// We need to emulate a L1->L2 transaction from the L1 bridge to L2 counterpart.
// It is a bit easier to use EOA and it is sufficient for the tests.
address internal l1BridgeWallet = address(1);
address internal aliasedL1BridgeWallet;

// The owner of the beacon and the native token vault
address internal ownerWallet = address(2);

L2StandardERC20 internal standardErc20Impl;

UpgradeableBeacon internal beacon;

uint256 internal constant L1_CHAIN_ID = 9;
uint256 internal ERA_CHAIN_ID = 270;

// We won't actually deploy an L1 token in these tests, but we need some address for it.
address internal L1_TOKEN_ADDRESS = 0x1111100000000000000000000000000000011111;

string internal constant TOKEN_DEFAULT_NAME = "TestnetERC20Token";
string internal constant TOKEN_DEFAULT_SYMBOL = "TET";
uint8 internal constant TOKEN_DEFAULT_DECIMALS = 18;

function setUp() public {
aliasedL1BridgeWallet = AddressAliasHelper.applyL1ToL2Alias(l1BridgeWallet);

standardErc20Impl = new L2StandardERC20();

beacon = new UpgradeableBeacon(address(standardErc20Impl));
beacon.transferOwnership(ownerWallet);

// One of the purposes of deploying it here is to publish its bytecode
BeaconProxy proxy = new BeaconProxy(address(beacon), new bytes(0));

bytes32 beaconProxyBytecodeHash;
assembly {
beaconProxyBytecodeHash := extcodehash(proxy)
}

Utils.initSystemContracts();
Utils.forceDeployAssetRouter(L1_CHAIN_ID, ERA_CHAIN_ID, l1BridgeWallet, address(0));
Utils.forceDeployNativeTokenVault({
_l1ChainId: L1_CHAIN_ID,
_aliasedOwner: ownerWallet,
_l2TokenProxyBytecodeHash: beaconProxyBytecodeHash,
_legacySharedBridge: address(0),
_l2TokenBeacon: address(beacon),
_contractsDeployedAlready: true
});
}

function performDeposit(address depositor, address receiver, uint256 amount) internal {
vm.prank(aliasedL1BridgeWallet);
L2AssetRouter(address(L2_ASSET_ROUTER)).finalizeDeposit({
_l1Sender: depositor,
_l2Receiver: receiver,
_l1Token: L1_TOKEN_ADDRESS,
_amount: amount,
_data: Utils.encodeTokenData(TOKEN_DEFAULT_NAME, TOKEN_DEFAULT_SYMBOL, TOKEN_DEFAULT_DECIMALS)
});
}

function initializeTokenByDeposit() internal returns (address l2TokenAddress) {
performDeposit(makeAddr("someDepositor"), makeAddr("someReeiver"), 1);

l2TokenAddress = L2_NATIVE_TOKEN_VAULT.l2TokenAddress(L1_TOKEN_ADDRESS);
require(l2TokenAddress != address(0), "Token not initialized");
}

function test_shouldFinalizeERC20Deposit() public {
address depositor = makeAddr("depositor");
address receiver = makeAddr("receiver");

performDeposit(depositor, receiver, 100);

address l2TokenAddress = L2_NATIVE_TOKEN_VAULT.l2TokenAddress(L1_TOKEN_ADDRESS);

assertEq(L2StandardERC20(l2TokenAddress).balanceOf(receiver), 100);
assertEq(L2StandardERC20(l2TokenAddress).totalSupply(), 100);
assertEq(L2StandardERC20(l2TokenAddress).name(), TOKEN_DEFAULT_NAME);
assertEq(L2StandardERC20(l2TokenAddress).symbol(), TOKEN_DEFAULT_SYMBOL);
assertEq(L2StandardERC20(l2TokenAddress).decimals(), TOKEN_DEFAULT_DECIMALS);
}

function test_governanceShouldBeAbleToReinitializeToken() public {
address l2TokenAddress = initializeTokenByDeposit();

L2StandardERC20.ERC20Getters memory getters = L2StandardERC20.ERC20Getters({
ignoreName: false,
ignoreSymbol: false,
ignoreDecimals: false
});

vm.prank(ownerWallet);
L2StandardERC20(l2TokenAddress).reinitializeToken(getters, "TestTokenNewName", "TTN", 2);
assertEq(L2StandardERC20(l2TokenAddress).name(), "TestTokenNewName");
assertEq(L2StandardERC20(l2TokenAddress).symbol(), "TTN");
// The decimals should stay the same
assertEq(L2StandardERC20(l2TokenAddress).decimals(), 18);
}

function test_governanceShouldNotBeAbleToSkipInitializerVersions() public {
address l2TokenAddress = initializeTokenByDeposit();

L2StandardERC20.ERC20Getters memory getters = L2StandardERC20.ERC20Getters({
ignoreName: false,
ignoreSymbol: false,
ignoreDecimals: false
});

vm.expectRevert();
vm.prank(ownerWallet);
L2StandardERC20(l2TokenAddress).reinitializeToken(getters, "TestTokenNewName", "TTN", 20);
}
}
156 changes: 156 additions & 0 deletions l2-contracts/test/foundry/unit/utils/Utils.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,156 @@
// SPDX-License-Identifier: MIT

pragma solidity 0.8.20;

import {Vm} from "forge-std/Vm.sol";

import {IContractDeployer, DEPLOYER_SYSTEM_CONTRACT, L2ContractHelper, L2_ASSET_ROUTER, L2_NATIVE_TOKEN_VAULT} from "contracts/L2ContractHelper.sol";

import {L2AssetRouter} from "contracts/bridge/L2AssetRouter.sol";
import {L2NativeTokenVault} from "contracts/bridge/L2NativeTokenVault.sol";

library Utils {
address internal constant VM_ADDRESS = address(uint160(uint256(keccak256("hevm cheat code"))));
Vm internal constant vm = Vm(VM_ADDRESS);

address internal constant L2_FORCE_DEPLOYER_ADDR = address(0x8007);

string internal constant L2_ASSET_ROUTER_PATH = "./zkout/L2AssetRouter.sol/L2AssetRouter.json";
string internal constant L2_NATIVE_TOKEN_VAULT_PATH = "./zkout/L2NativeTokenVault.sol/L2NativeTokenVault.json";

/// @notice Returns the bytecode of a given era contract from a `zkout` folder.
function readEraBytecode(string memory _filename) internal returns (bytes memory bytecode) {
string memory artifact = vm.readFile(
// solhint-disable-next-line func-named-parameters
string.concat("./zkout/", _filename, ".sol/", _filename, ".json")
);

bytecode = vm.parseJsonBytes(artifact, ".bytecode.object");
}

/// @notice Returns the bytecode of a given system contract.
function readSystemContractsBytecode(string memory _filename) internal view returns (bytes memory) {
string memory file = vm.readFile(
// solhint-disable-next-line func-named-parameters
string.concat(
"../system-contracts/artifacts-zk/contracts-preprocessed/",
_filename,
".sol/",
_filename,
".json"
)
);
bytes memory bytecode = vm.parseJson(file, "$.bytecode");
return bytecode;
}

/**
* @dev Initializes the system contracts.
* @dev It is a hack needed to make the tests be able to call system contracts directly.
*/
function initSystemContracts() internal {
bytes memory contractDeployerBytecode = readSystemContractsBytecode("ContractDeployer");
vm.etch(DEPLOYER_SYSTEM_CONTRACT, contractDeployerBytecode);
}

/// @notice Deploys the L2AssetRouter contract.
/// @param _l1ChainId The chain ID of the L1 chain.
/// @param _eraChainId The chain ID of the era chain.
/// @param _l1AssetRouter The address of the L1 asset router.
/// @param _legacySharedBridge The address of the legacy shared bridge.
function forceDeployAssetRouter(
uint256 _l1ChainId,
uint256 _eraChainId,
address _l1AssetRouter,
address _legacySharedBridge
) internal {
// to ensure that the bytecode is known
{
new L2AssetRouter(_l1ChainId, _eraChainId, _l1AssetRouter, _legacySharedBridge);
}

bytes memory bytecode = readEraBytecode("L2AssetRouter");

bytes32 bytecodehash = L2ContractHelper.hashL2BytecodeMemory(bytecode);

IContractDeployer.ForceDeployment[] memory deployments = new IContractDeployer.ForceDeployment[](1);
deployments[0] = IContractDeployer.ForceDeployment({
bytecodeHash: bytecodehash,
newAddress: address(L2_ASSET_ROUTER),
callConstructor: true,
value: 0,
input: abi.encode(_l1ChainId, _eraChainId, _l1AssetRouter, _legacySharedBridge)
});

vm.prank(L2_FORCE_DEPLOYER_ADDR);
IContractDeployer(DEPLOYER_SYSTEM_CONTRACT).forceDeployOnAddresses(deployments);
}

/// @notice Deploys the L2NativeTokenVault contract.
/// @param _l1ChainId The chain ID of the L1 chain.
/// @param _aliasedOwner The address of the aliased owner.
/// @param _l2TokenProxyBytecodeHash The hash of the L2 token proxy bytecode.
/// @param _legacySharedBridge The address of the legacy shared bridge.
/// @param _l2TokenBeacon The address of the L2 token beacon.
/// @param _contractsDeployedAlready Whether the contracts are deployed already.
function forceDeployNativeTokenVault(
uint256 _l1ChainId,
address _aliasedOwner,
bytes32 _l2TokenProxyBytecodeHash,
address _legacySharedBridge,
address _l2TokenBeacon,
bool _contractsDeployedAlready
) internal {
// to ensure that the bytecode is known
{
new L2NativeTokenVault({
_l1ChainId: _l1ChainId,
_aliasedOwner: _aliasedOwner,
_l2TokenProxyBytecodeHash: _l2TokenProxyBytecodeHash,
_legacySharedBridge: _legacySharedBridge,
_l2TokenBeacon: _l2TokenBeacon,
_contractsDeployedAlready: _contractsDeployedAlready
});
}

bytes memory bytecode = readEraBytecode("L2NativeTokenVault");

bytes32 bytecodehash = L2ContractHelper.hashL2BytecodeMemory(bytecode);

IContractDeployer.ForceDeployment[] memory deployments = new IContractDeployer.ForceDeployment[](1);
deployments[0] = IContractDeployer.ForceDeployment({
bytecodeHash: bytecodehash,
newAddress: address(L2_NATIVE_TOKEN_VAULT),
callConstructor: true,
value: 0,
// solhint-disable-next-line func-named-parameters
input: abi.encode(
_l1ChainId,
_aliasedOwner,
_l2TokenProxyBytecodeHash,
_legacySharedBridge,
_l2TokenBeacon,
_contractsDeployedAlready
)
});

vm.prank(L2_FORCE_DEPLOYER_ADDR);
IContractDeployer(DEPLOYER_SYSTEM_CONTRACT).forceDeployOnAddresses(deployments);
}

/// @notice Encodes the token data.
/// @param name The name of the token.
/// @param symbol The symbol of the token.
/// @param decimals The decimals of the token.
function encodeTokenData(
string memory name,
string memory symbol,
uint8 decimals
) internal pure returns (bytes memory) {
bytes memory encodedName = abi.encode(name);
bytes memory encodedSymbol = abi.encode(symbol);
bytes memory encodedDecimals = abi.encode(decimals);

return abi.encode(encodedName, encodedSymbol, encodedDecimals);
}
}
118 changes: 118 additions & 0 deletions l2-contracts/test/foundry/unit/weth/WETH.t.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
// SPDX-License-Identifier: MIT

pragma solidity 0.8.20;

import {Test} from "forge-std/Test.sol";

import {L2WrappedBaseToken} from "contracts/bridge/L2WrappedBaseToken.sol";
import {TransparentUpgradeableProxy} from "@openzeppelin/contracts-v4/proxy/transparent/TransparentUpgradeableProxy.sol";

import {Unauthorized, UnimplementedMessage, BRIDGE_MINT_NOT_IMPLEMENTED} from "contracts/errors/L2ContractErrors.sol";

contract WethTest is Test {
L2WrappedBaseToken internal weth;

// The owner of the proxy
address internal ownerWallet = address(2);

address internal l2BridgeAddress = address(3);
address internal l1Address = address(4);

function setUp() public {
ownerWallet = makeAddr("owner");
L2WrappedBaseToken impl = new L2WrappedBaseToken();

TransparentUpgradeableProxy proxy = new TransparentUpgradeableProxy(address(impl), ownerWallet, "");

weth = L2WrappedBaseToken(payable(proxy));

weth.initializeV2("Wrapped Ether", "WETH", l2BridgeAddress, l1Address);
}

function test_shouldDepositWethByCallingDeposit() public {
uint256 amount = 100;
weth.deposit{value: amount}();
assertEq(weth.balanceOf(address(this)), amount);
}

function test_shouldDepositWethBySendingEth() public {
uint256 amount = 100;
address(weth).call{value: amount}("");
assertEq(weth.balanceOf(address(this)), amount);
}

function test_revertWhenDepositingWithRandomCalldata() public {
(bool success, ) = address(weth).call{value: 100}(hex"00000000");
assertEq(success, false);
}

function test_shouldWithdrawWethToL2Eth() public {
address sender = makeAddr("sender");
uint256 amount = 100;

vm.deal(sender, amount);

vm.prank(sender);
weth.deposit{value: amount}();

vm.prank(sender);
weth.withdraw(amount);

assertEq(weth.balanceOf(sender), 0);
assertEq(address(sender).balance, amount);
}

function test_shouldDepositWethToAnotherAccount() public {
address sender = makeAddr("sender");
address receiver = makeAddr("receiver");

uint256 amount = 100;

vm.deal(sender, amount);

vm.prank(sender);
weth.depositTo{value: amount}(receiver);

assertEq(weth.balanceOf(receiver), amount);
assertEq(weth.balanceOf(sender), 0);
}

function test_shouldWithdrawWethToAnotherAccount() public {
address sender = makeAddr("sender");
address receiver = makeAddr("receiver");

uint256 amount = 100;

vm.deal(sender, amount);

vm.prank(sender);
weth.deposit{value: amount}();

vm.prank(sender);
weth.withdrawTo(receiver, amount);

assertEq(receiver.balance, amount);
assertEq(sender.balance, 0);
}

function test_revertWhenWithdrawingMoreThanBalance() public {
vm.expectRevert();
weth.withdraw(1);
}

function test_revertWhenCallingBridgeMint() public {
vm.expectRevert(abi.encodeWithSelector(UnimplementedMessage.selector, BRIDGE_MINT_NOT_IMPLEMENTED));
vm.prank(l2BridgeAddress);
weth.bridgeMint(address(1), 1);
}

function test_revertWhenCallingBridgeMintDirectly() public {
vm.expectRevert(abi.encodeWithSelector(Unauthorized.selector, address(this)));
weth.bridgeMint(address(1), 1);
}

function test_revertWhenCallingBridgeBurnDirectly() public {
vm.expectRevert(abi.encodeWithSelector(Unauthorized.selector, address(this)));
weth.bridgeBurn(address(1), 1);
}
}
57 changes: 0 additions & 57 deletions l2-contracts/test/test-utils.ts

This file was deleted.

132 changes: 0 additions & 132 deletions l2-contracts/test/weth.test.ts

This file was deleted.

1 change: 1 addition & 0 deletions lib/@matterlabs/zksync-contracts
Submodule zksync-contracts added at b8449b

Unchanged files with check annotations Beta

// Change the sender address if it is a smart contract to prevent address collision between L1 and L2.
// Please note, currently ZKsync address derivation is different from Ethereum one, but it may be changed in the future.
// slither-disable-next-line tx-origin
if (request.sender != tx.origin) {

Check warning on line 482 in l1-contracts/contracts/state-transition/chain-deps/facets/Mailbox.sol

GitHub Actions / lint

Avoid to use tx.origin

Check warning on line 482 in l1-contracts/contracts/state-transition/chain-deps/facets/Mailbox.sol

GitHub Actions / lint

Avoid to use tx.origin

Check warning on line 482 in l1-contracts/contracts/state-transition/chain-deps/facets/Mailbox.sol

GitHub Actions / lint

Avoid to use tx.origin
request.sender = AddressAliasHelper.applyL1ToL2Alias(request.sender);
}