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 16 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
5 changes: 5 additions & 0 deletions .github/workflows/l1-contracts-ci.yaml
Original file line number Diff line number Diff line change
@@ -3,6 +3,11 @@ name: L1 contracts CI
on:
pull_request:

# We need this permissions for this CI to work with external contributions
permissions:
contents: read
pull-requests: write

jobs:
build:
runs-on: ubuntu-latest
2 changes: 1 addition & 1 deletion gas-bound-caller/package.json
Original file line number Diff line number Diff line change
@@ -38,7 +38,7 @@
"ts-node": "^10.1.0",
"typechain": "^4.0.0",
"typescript": "^4.6.4",
"zksync-ethers": "5.8.0-beta.5"
"zksync-ethers": "^5.9.0"
},
"mocha": {
"timeout": 240000,
Original file line number Diff line number Diff line change
@@ -8,6 +8,8 @@ import {IMessageRoot} from "../../bridgehub/IMessageRoot.sol";

import {IGetters} from "../../state-transition/chain-interfaces/IGetters.sol";

/// @title DummyBridgehub
/// @notice A test smart contract that allows to set State Transition Manager for a given chain
contract DummyBridgehub {
IMessageRoot public messageRoot;

Original file line number Diff line number Diff line change
@@ -13,6 +13,10 @@ contract DummyHyperchain is MailboxFacet {
s.bridgehub = bridgeHubAddress;
}

function getEraChainId() public view returns (uint256) {
return ERA_CHAIN_ID;
}

function setBridgeHubAddress(address bridgeHubAddress) public {
s.bridgehub = bridgeHubAddress;
}
109 changes: 85 additions & 24 deletions l1-contracts/contracts/dev-contracts/test/DummySharedBridge.sol
Original file line number Diff line number Diff line change
@@ -5,25 +5,32 @@ pragma solidity 0.8.24;
import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol";

import {L2TransactionRequestTwoBridgesInner} from "../../bridgehub/IBridgehub.sol";
import {TWO_BRIDGES_MAGIC_VALUE} from "../../common/Config.sol";
import {PausableUpgradeable} from "@openzeppelin/contracts-upgradeable/security/PausableUpgradeable.sol";
import {TWO_BRIDGES_MAGIC_VALUE, ETH_TOKEN_ADDRESS} from "../../common/Config.sol";
import {IL1NativeTokenVault} from "../../bridge/L1NativeTokenVault.sol";
import {L2_NATIVE_TOKEN_VAULT_ADDRESS} from "../../common/L2ContractAddresses.sol";
import {SafeERC20} from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
import {IL2Bridge} from "../../bridge/interfaces/IL2Bridge.sol";
import {IL2BridgeLegacy} from "../../bridge/interfaces/IL2BridgeLegacy.sol";


contract DummySharedBridge is PausableUpgradeable {
using SafeERC20 for IERC20;

contract DummySharedBridge {
IL1NativeTokenVault public nativeTokenVault;

event BridgehubDepositBaseTokenInitiated(
uint256 indexed chainId,
address indexed from,
address l1Token,
bytes32 assetId,
uint256 amount
);

bytes32 dummyL2DepositTxHash;

/// @dev Maps token balances for each chain to prevent unauthorized spending across hyperchains.
/// This serves as a security measure until hyperbridging is implemented.
mapping(uint256 chainId => mapping(address l1Token => uint256 balance)) internal chainBalance;
mapping(uint256 chainId => mapping(address l1Token => uint256 balance)) public chainBalance;

/// @dev Indicates whether the hyperbridging is enabled for a given chain.
mapping(uint256 chainId => bool enabled) internal hyperbridgingEnabled;
@@ -47,6 +54,8 @@ contract DummySharedBridge {
amountReturnInFinalizeWithdrawal = _amount;
}

function receiveEth(uint256 _chainId) external payable {}

function depositLegacyErc20Bridge(
address, //_msgSender,
address, //_l2Receiver,
@@ -96,28 +105,61 @@ contract DummySharedBridge {

event Debugger(uint256);

function pause() external {
_pause();
}

function unpause() external {
_unpause();
}

// This function expects abi encoded data
function _parseL2WithdrawalMessage(
bytes memory _l2ToL1message
) internal view returns (address l1Receiver, address l1Token, uint256 amount) {
(l1Receiver, l1Token, amount) = abi.decode(_l2ToL1message, (address, address, uint256));
}

// simple function to just transfer the funds
function finalizeWithdrawal(
uint256 _chainId,
uint256 _l2BatchNumber,
uint256 _l2MessageIndex,
uint16 _l2TxNumberInBatch,
bytes calldata _message,
bytes32[] calldata _merkleProof
) external {
(address l1Receiver, address l1Token, uint256 amount) = _parseL2WithdrawalMessage(_message);

if (l1Token == address(1)) {
bool callSuccess;
// Low-level assembly call, to avoid any memory copying (save gas)
assembly {
callSuccess := call(gas(), l1Receiver, amount, 0, 0, 0, 0)
}
require(callSuccess, "ShB: withdraw failed");
} else {
// Withdraw funds
IERC20(l1Token).safeTransfer(l1Receiver, amount);
}
}

function bridgehubDepositBaseToken(
uint256 _chainId,
bytes32 _assetId,
address _prevMsgSender,
address _l1Token,
uint256 _amount
) external payable {
if (_l1Token == address(1)) {
require(msg.value == _amount, "L1AR: msg.value not equal to amount");
} else {
// The Bridgehub also checks this, but we want to be sure
require(msg.value == 0, "L1AR: m.v > 0 b d.it");
uint256 amount = _depositFunds(_prevMsgSender, IERC20(_l1Token), _amount); // note if _prevMsgSender is this contract, this will return 0. This does not happen.
require(amount == _amount, "5T"); // The token has non-standard transfer logic
}
) external payable whenNotPaused {
// Dummy bridge supports only working with ETH for simplicity.
require(msg.value == _amount, "L1AR: msg.value not equal to amount");


if (!hyperbridgingEnabled[_chainId]) {
chainBalance[_chainId][_l1Token] += _amount;
chainBalance[_chainId][address(1)] += _amount;
}

emit Debugger(5);
// Note that we don't save the deposited amount, as this is for the base token, which gets sent to the refundRecipient if the tx fails
emit BridgehubDepositBaseTokenInitiated(_chainId, _prevMsgSender, _l1Token, _amount);
emit BridgehubDepositBaseTokenInitiated(_chainId, _prevMsgSender, _assetId, _amount);
}

function _depositFunds(address _from, IERC20 _token, uint256 _amount) internal returns (uint256) {
@@ -129,14 +171,33 @@ contract DummySharedBridge {
}

function bridgehubDeposit(
uint256, //_chainId,
address, //_prevMsgSender,
uint256, // l2Value, needed for Weth deposits in the future
bytes calldata //_data
uint256,
address _prevMsgSender,
uint256,
bytes calldata _data
) external payable returns (L2TransactionRequestTwoBridgesInner memory request) {
// Request the finalization of the deposit on the L2 side
bytes memory l2TxCalldata = bytes("0xabcd123");
bytes32 txDataHash = bytes32("0x1212121212abf");
(address _l1Token, uint256 _depositAmount, address _l2Receiver) = abi.decode(
_data,
(address, uint256, address)
);
uint256 amount;

if (_l1Token == ETH_TOKEN_ADDRESS) {
amount = msg.value;
require(_depositAmount == 0, "ShB wrong withdraw amount");
} else {
require(msg.value == 0, "ShB m.v > 0 for BH d.it 2");
amount = _depositAmount;

uint256 withdrawAmount = _depositFunds(_prevMsgSender, IERC20(_l1Token), _depositAmount);
require(withdrawAmount == _depositAmount, "5T"); // The token has non-standard transfer logic
}

bytes memory l2TxCalldata = abi.encodeCall(
IL2BridgeLegacy.finalizeDeposit,
(_prevMsgSender, _l2Receiver, _l1Token, amount, new bytes(0))
);
bytes32 txDataHash = keccak256(abi.encode(_prevMsgSender, _l1Token, amount));

request = L2TransactionRequestTwoBridgesInner({
magicValue: TWO_BRIDGES_MAGIC_VALUE,
39 changes: 31 additions & 8 deletions l1-contracts/contracts/governance/ChainAdmin.sol
Original file line number Diff line number Diff line change
@@ -4,22 +4,38 @@

import {Ownable2Step} from "@openzeppelin/contracts/access/Ownable2Step.sol";
import {IChainAdmin} from "./IChainAdmin.sol";
import {IAdmin} from "../state-transition/chain-interfaces/IAdmin.sol";

/// @author Matter Labs
/// @custom:security-contact security@matterlabs.dev
/// @notice The contract is designed to hold the `admin` role in ZKSync Chain (State Transition) contracts.
/// The owner of the contract can perform any external calls and also save the information needed for
/// the blockchain node to accept the protocol upgrade.
/// the blockchain node to accept the protocol upgrade. Another role - `tokenMultiplierSetter` can be used in the contract
/// to change the base token gas price in the Chain contract.
contract ChainAdmin is IChainAdmin, Ownable2Step {
constructor(address _initialOwner) {
// solhint-disable-next-line gas-custom-errors, reason-string
/// @notice Mapping of protocol versions to their expected upgrade timestamps.
/// @dev Needed for the offchain node administration to know when to start building batches with the new protocol version.
mapping(uint256 protocolVersion => uint256 upgradeTimestamp) public protocolVersionToUpgradeTimestamp;

/// @notice The address which can call `setTokenMultiplier` function to change the base token gas price in the Chain contract.
/// @dev The token base price can be changed quite often, so the private key for this role is supposed to be stored in the node
/// and used by the automated service in a way similar to the sequencer workflow.
address public tokenMultiplierSetter;

constructor(address _initialOwner, address _initialTokenMultiplierSetter) {
require(_initialOwner != address(0), "Initial owner should be non zero address");

Check failure on line 26 in l1-contracts/contracts/governance/ChainAdmin.sol

GitHub Actions / lint

Error message for require is too long: 40 counted / 32 allowed

Check failure on line 26 in l1-contracts/contracts/governance/ChainAdmin.sol

GitHub Actions / lint

GC: Use Custom Errors instead of require statements

Check failure on line 26 in l1-contracts/contracts/governance/ChainAdmin.sol

GitHub Actions / lint

Error message for require is too long: 40 counted / 32 allowed

Check failure on line 26 in l1-contracts/contracts/governance/ChainAdmin.sol

GitHub Actions / lint

GC: Use Custom Errors instead of require statements

Check failure on line 26 in l1-contracts/contracts/governance/ChainAdmin.sol

GitHub Actions / lint

Error message for require is too long: 40 counted / 32 allowed

Check failure on line 26 in l1-contracts/contracts/governance/ChainAdmin.sol

GitHub Actions / lint

GC: Use Custom Errors instead of require statements
_transferOwnership(_initialOwner);
// Can be zero if no one has this permission.
tokenMultiplierSetter = _initialTokenMultiplierSetter;
emit NewTokenMultiplierSetter(address(0), _initialTokenMultiplierSetter);
}

/// @notice Mapping of protocol versions to their expected upgrade timestamps.
/// @dev Needed for the offchain node administration to know when to start building batches with the new protocol version.
mapping(uint256 protocolVersion => uint256 upgradeTimestamp) public protocolVersionToUpgradeTimestamp;
/// @notice Updates the address responsible for setting token multipliers on the Chain contract .
/// @param _tokenMultiplierSetter The new address to be set as the token multiplier setter.
function setTokenMultiplierSetter(address _tokenMultiplierSetter) external onlyOwner {
emit NewTokenMultiplierSetter(tokenMultiplierSetter, _tokenMultiplierSetter);
tokenMultiplierSetter = _tokenMultiplierSetter;
}

/// @notice Set the expected upgrade timestamp for a specific protocol version.
/// @param _protocolVersion The ZKsync chain protocol version.
@@ -34,10 +50,8 @@
/// @param _requireSuccess If true, reverts transaction on any call failure.
/// @dev Intended for batch processing of contract interactions, managing gas efficiency and atomicity of operations.
function multicall(Call[] calldata _calls, bool _requireSuccess) external payable onlyOwner {
// solhint-disable-next-line gas-custom-errors
require(_calls.length > 0, "No calls provided");

Check failure on line 53 in l1-contracts/contracts/governance/ChainAdmin.sol

GitHub Actions / lint

GC: Use Custom Errors instead of require statements

Check failure on line 53 in l1-contracts/contracts/governance/ChainAdmin.sol

GitHub Actions / lint

GC: Use Custom Errors instead of require statements

Check failure on line 53 in l1-contracts/contracts/governance/ChainAdmin.sol

GitHub Actions / lint

GC: Use Custom Errors instead of require statements
// solhint-disable-next-line gas-length-in-loops
for (uint256 i = 0; i < _calls.length; ++i) {

Check failure on line 54 in l1-contracts/contracts/governance/ChainAdmin.sol

GitHub Actions / lint

GC: Found [ .length ] property in Loop condition. Suggestion: assign it to a variable

Check failure on line 54 in l1-contracts/contracts/governance/ChainAdmin.sol

GitHub Actions / lint

GC: Found [ .length ] property in Loop condition. Suggestion: assign it to a variable

Check failure on line 54 in l1-contracts/contracts/governance/ChainAdmin.sol

GitHub Actions / lint

GC: Found [ .length ] property in Loop condition. Suggestion: assign it to a variable
// slither-disable-next-line arbitrary-send-eth
(bool success, bytes memory returnData) = _calls[i].target.call{value: _calls[i].value}(_calls[i].data);
if (_requireSuccess && !success) {
@@ -50,6 +64,15 @@
}
}

/// @notice Sets the token multiplier in the specified Chain contract.
/// @param _chainContract The chain contract address where the token multiplier will be set.
/// @param _nominator The numerator part of the token multiplier.
/// @param _denominator The denominator part of the token multiplier.
function setTokenMultiplier(IAdmin _chainContract, uint128 _nominator, uint128 _denominator) external {
require(msg.sender == tokenMultiplierSetter, "Only the token multiplier setter can call this function");

Check failure on line 72 in l1-contracts/contracts/governance/ChainAdmin.sol

GitHub Actions / lint

Error message for require is too long: 55 counted / 32 allowed

Check failure on line 72 in l1-contracts/contracts/governance/ChainAdmin.sol

GitHub Actions / lint

GC: Use Custom Errors instead of require statements

Check failure on line 72 in l1-contracts/contracts/governance/ChainAdmin.sol

GitHub Actions / lint

Error message for require is too long: 55 counted / 32 allowed

Check failure on line 72 in l1-contracts/contracts/governance/ChainAdmin.sol

GitHub Actions / lint

GC: Use Custom Errors instead of require statements

Check failure on line 72 in l1-contracts/contracts/governance/ChainAdmin.sol

GitHub Actions / lint

Error message for require is too long: 55 counted / 32 allowed

Check failure on line 72 in l1-contracts/contracts/governance/ChainAdmin.sol

GitHub Actions / lint

GC: Use Custom Errors instead of require statements
_chainContract.setTokenMultiplier(_nominator, _denominator);
}

/// @dev Contract might receive/hold ETH as part of the maintenance process.
receive() external payable {}
}
15 changes: 14 additions & 1 deletion l1-contracts/contracts/governance/IChainAdmin.sol
Original file line number Diff line number Diff line change
@@ -2,6 +2,8 @@

pragma solidity 0.8.24;

import {IAdmin} from "../state-transition/chain-interfaces/IAdmin.sol";

/// @title ChainAdmin contract interface
/// @author Matter Labs
/// @custom:security-contact security@matterlabs.dev
@@ -20,5 +22,16 @@ interface IChainAdmin {
event UpdateUpgradeTimestamp(uint256 indexed _protocolVersion, uint256 _upgradeTimestamp);

/// @notice Emitted when the call is executed from the contract.
event CallExecuted(Call _call, bool success, bytes returnData);
event CallExecuted(Call _call, bool _success, bytes _returnData);

/// @notice Emitted when the new token multiplier address is set.
event NewTokenMultiplierSetter(address _oldTokenMultiplierSetter, address _newTokenMultiplierSetter);

function setTokenMultiplierSetter(address _tokenMultiplierSetter) external;

function setUpgradeTimestamp(uint256 _protocolVersion, uint256 _upgradeTimestamp) external;

function multicall(Call[] calldata _calls, bool _requireSuccess) external payable;

function setTokenMultiplier(IAdmin _chainContract, uint128 _nominator, uint128 _denominator) external;
}
37 changes: 28 additions & 9 deletions l1-contracts/deploy-scripts/AcceptAdmin.s.sol
Original file line number Diff line number Diff line change
@@ -28,11 +28,9 @@ contract AcceptAdmin is Script {
config.governor = toml.readAddress("$.governor");
}

// This function should be called by the owner to accept the owner role
function acceptOwner() public {
initConfig();

Ownable2Step adminContract = Ownable2Step(config.admin);
// This function should be called by the owner to accept the admin role
function governanceAcceptOwner(address governor, address target) public {
Ownable2Step adminContract = Ownable2Step(target);
Utils.executeUpgrade({
_governor: governor,
_salt: bytes32(0),
@@ -44,15 +42,36 @@ contract AcceptAdmin is Script {
}

// This function should be called by the owner to accept the admin role
function acceptAdmin(address payable _admin, address _target) public {
IZkSyncHyperchain hyperchain = IZkSyncHyperchain(_target);
ChainAdmin chainAdmin = ChainAdmin(_admin);
function governanceAcceptAdmin(address governor, address target) public {
IZkSyncHyperchain adminContract = IZkSyncHyperchain(target);
Utils.executeUpgrade({
_governor: governor,
_salt: bytes32(0),
_target: target,
_data: abi.encodeCall(adminContract.acceptAdmin, ()),
_value: 0,
_delay: 0
});
}

// This function should be called by the owner to accept the admin role
function chainAdminAcceptAdmin(ChainAdmin chainAdmin, address target) public {
IZkSyncHyperchain adminContract = IZkSyncHyperchain(target);

IChainAdmin.Call[] memory calls = new IChainAdmin.Call[](1);
calls[0] = IChainAdmin.Call({target: _target, value: 0, data: abi.encodeCall(hyperchain.acceptAdmin, ())});
calls[0] = IChainAdmin.Call({target: target, value: 0, data: abi.encodeCall(adminContract.acceptAdmin, ())});

vm.startBroadcast();
chainAdmin.multicall(calls, true);
vm.stopBroadcast();
}

// This function should be called by the owner to update token multiplier setter role
function chainSetTokenMultiplierSetter(address chainAdmin, address target) public {
IChainAdmin admin = IChainAdmin(chainAdmin);

vm.startBroadcast();
admin.setTokenMultiplierSetter(target);
vm.stopBroadcast();
}
}
Loading
Loading