Skip to content
Open
Show file tree
Hide file tree
Changes from 80 commits
Commits
Show all changes
780 commits
Select commit Hold shift + click to select a range
ad7ebd8
Merge pull request #1679 from matter-labs/kl/imports-fix2
kelemeno Sep 29, 2025
40b9f6e
linting
kelemeno Sep 29, 2025
0ea4cbd
build issues
kelemeno Sep 29, 2025
716c66f
lint
kelemeno Sep 29, 2025
6e7b807
Merge branch 'draft-v30' of ssh://github.com/matter-labs/era-contract…
kelemeno Sep 29, 2025
f850c3f
Merge branch 'kl/medium-interop' into sb/additional-comments-for-kl-m…
StanislavBreadless Sep 29, 2025
a391100
small fixes from merge
kelemeno Sep 29, 2025
0ccf231
run clean imports
kelemeno Sep 29, 2025
22b7786
lint
kelemeno Sep 29, 2025
0c748a5
lint
kelemeno Sep 29, 2025
67f08eb
test fix
kelemeno Sep 29, 2025
0aaffd2
nikita fix registerToken
kelemeno Sep 29, 2025
dea67c3
Merge branch 'kl/medium-interop' of ssh://github.com/matter-labs/era-…
kelemeno Sep 29, 2025
976e2c7
Merge pull request #1681 from matter-labs/kl/better-imports3
kelemeno Sep 29, 2025
5676494
Merge branch 'kl/medium-interop' of ssh://github.com/matter-labs/era-…
kelemeno Sep 29, 2025
2fb2b8c
nikita ntv fixes
kelemeno Sep 29, 2025
5f3e0c3
stas chain migration number check
kelemeno Sep 29, 2025
daacae4
Merge pull request #1682 from matter-labs/kl/29-09-25
kelemeno Sep 29, 2025
243c99f
Merge branch 'draft-v30' of ssh://github.com/matter-labs/era-contract…
kelemeno Sep 29, 2025
d92513d
merge issues 1
kelemeno Sep 29, 2025
52c5021
post merge cleanup 1
kelemeno Sep 29, 2025
7b0aa3c
merge cleanup 2
kelemeno Sep 29, 2025
e543e9e
get tests to work
kelemeno Sep 30, 2025
66eb569
imports
kelemeno Sep 30, 2025
1ce6bb3
errors linting
kelemeno Sep 30, 2025
b3e2a5b
linting
kelemeno Sep 30, 2025
8e8fb36
build issues
kelemeno Sep 30, 2025
514a330
delete removed contract
kelemeno Sep 30, 2025
d3dcb79
errors lint fix
kelemeno Sep 30, 2025
1cceeb7
more test fixes
kelemeno Sep 30, 2025
7c0a2b7
lint
kelemeno Sep 30, 2025
ee1205d
redundunt check in L1AT
kelemeno Sep 30, 2025
c6d18cb
remove eraVMCTM
kelemeno Sep 30, 2025
f24e144
Update l1-contracts/contracts/bridge/asset-tracker/L1AssetTracker.sol
kelemeno Sep 30, 2025
b32524e
wrong access management for registerL2NativeToken
kelemeno Sep 30, 2025
ba60c62
set L2DaValidator to 0
kelemeno Sep 30, 2025
aea34c8
remove ThisAddress from BaseUupgrade
kelemeno Sep 30, 2025
7ac9441
remove bad onlyChainAdmin
kelemeno Sep 30, 2025
6e6d849
separate out registerNewToken logic
kelemeno Sep 30, 2025
85350f9
fix todos
kelemeno Sep 30, 2025
f1d128e
add back PriorityQueueNotFullyProcessed
kelemeno Sep 30, 2025
5c54719
redundunt asset tracker
kelemeno Oct 1, 2025
191b846
slither fixes
kelemeno Oct 1, 2025
d489db2
add missing error
kelemeno Oct 1, 2025
2cf3811
lint
kelemeno Oct 1, 2025
eeecb94
Merge pull request #1684 from matter-labs/kl/30-09-25
kelemeno Oct 1, 2025
831ebe4
linting
kelemeno Oct 1, 2025
0c89daa
typos
kelemeno Oct 1, 2025
b183a11
fix some zkfoundry tests
kelemeno Oct 1, 2025
24cdb4d
Merge branch 'kl/medium-interop' of ssh://github.com/matter-labs/era-…
kelemeno Oct 1, 2025
0d38d3d
Merge pull request #1686 from matter-labs/kl/01-10-25/1
kelemeno Oct 1, 2025
71673ac
errors
kelemeno Oct 1, 2025
8de412e
Merge pull request #1688 from matter-labs/kl/01-10-25/2
kelemeno Oct 1, 2025
616e068
don't save transient in L1AT for base token
kelemeno Oct 1, 2025
6b458da
check migrate data version
kelemeno Oct 1, 2025
b5e4633
add more comments
StanislavBreadless Oct 1, 2025
ebef355
sync with origin
StanislavBreadless Oct 1, 2025
8567b0d
remove redundunt L2GenesisForceDeployments
kelemeno Oct 1, 2025
d0033af
delete changes to L2BaseToken
kelemeno Oct 1, 2025
2222a14
Merge branch 'kl/01-10-25/4' of ssh://github.com/matter-labs/era-cont…
kelemeno Oct 1, 2025
63a587c
redundunt check
kelemeno Oct 1, 2025
8307029
remove old requestL2TransactionToGatewayMailbox
kelemeno Oct 1, 2025
92be3dd
fix _needToForceSetAssetMigrationOnL2 in l2AT
kelemeno Oct 1, 2025
c106c01
compilation fix
kelemeno Oct 1, 2025
ed9b54c
compilation
kelemeno Oct 1, 2025
3c712c6
fix test and comment
kelemeno Oct 1, 2025
6eec1de
fix double assignment max token bug
kelemeno Oct 1, 2025
c60e6b0
move L2V30upgrade
kelemeno Oct 1, 2025
b2512c3
Merge branch 'draft-v30' of ssh://github.com/matter-labs/era-contract…
kelemeno Oct 1, 2025
e2ac3e8
fixes
kelemeno Oct 1, 2025
9458351
build issues
kelemeno Oct 1, 2025
8097804
build issue
kelemeno Oct 1, 2025
4349eed
setAddressesV30
kelemeno Oct 1, 2025
72c182a
hardcode legacySharedBridgeAddresses
kelemeno Oct 1, 2025
6673bd4
add back pq fully processed check
kelemeno Oct 1, 2025
a5d3ce1
build issues
kelemeno Oct 1, 2025
d23ddce
comment out failing tests
kelemeno Oct 1, 2025
eca1b5b
remove registerNewToken
kelemeno Oct 1, 2025
5371636
incorrect delete bytes32
kelemeno Oct 1, 2025
9562f56
build fixes, lint
0xValera Oct 1, 2025
1111fa6
lint errors
0xValera Oct 1, 2025
c4943fe
build fixes
0xValera Oct 1, 2025
1e7b960
errors lint
0xValera Oct 1, 2025
be956f2
fix
0xValera Oct 1, 2025
a5b15f6
Merge pull request #1691 from matter-labs/kl/01-10-25/merge-draft-v30
kelemeno Oct 1, 2025
7879945
Merge branch 'kl/medium-interop' of ssh://github.com/matter-labs/era-…
kelemeno Oct 1, 2025
ffc603b
linting
kelemeno Oct 1, 2025
fa26fb0
more lint
kelemeno Oct 1, 2025
9abc1fc
fix tests
kelemeno Oct 1, 2025
19ad7f7
missing libraries
kelemeno Oct 1, 2025
8934b46
Merge pull request #1689 from matter-labs/kl/01-10-25/4
kelemeno Oct 1, 2025
c4be9c5
indirect migration for origin chain in L1AT
kelemeno Oct 1, 2025
ff33726
l1 token balance migration
kelemeno Oct 1, 2025
cecce69
parity in L1AT simplification
kelemeno Oct 1, 2025
edc6418
Merge branch 'kl/medium-interop' of ssh://github.com/matter-labs/era-…
kelemeno Oct 1, 2025
76cc6fe
general assetIdCheck in GWAssetTracker
kelemeno Oct 1, 2025
be73d2d
maxChainBalanceAssigned deduplication
kelemeno Oct 1, 2025
87acc97
build issues
kelemeno Oct 1, 2025
e4c1930
linting
kelemeno Oct 1, 2025
d5d1e6d
lint 2
kelemeno Oct 1, 2025
1e55b2f
one more lint
kelemeno Oct 1, 2025
ffb1b13
Merge pull request #1694 from matter-labs/kl/01-10-25/5
kelemeno Oct 2, 2025
2efe252
fix 2 small issues in AT tests
0xValera Oct 2, 2025
f9e9261
Merge pull request #1695 from matter-labs/vg/fix-2-small-foundry-tests
kelemeno Oct 2, 2025
ea05b90
add unpauseDeposits for chain admin (issue #19)
0xValera Oct 2, 2025
0a63088
make signature database update optional to speed up linter
0xValera Oct 2, 2025
6b35266
Delete GatewayUpgrade files (24)
0xValera Oct 2, 2025
39b98b9
linter
0xValera Oct 2, 2025
a44ed0e
chainBalance initialization in L2AT
0xValera Oct 2, 2025
487f501
wait for pause window in _checkV30UpgradeProcessed
0xValera Oct 2, 2025
a39ffdd
add some more comments
StanislavBreadless Oct 2, 2025
104321a
pausedDepositsTimestamp mapping to variable
0xValera Oct 2, 2025
10bbd13
Merge branch 'vg/02-10-2025' of https://github.com/matter-labs/era-co…
0xValera Oct 2, 2025
e802b36
fix + lint after pulling
0xValera Oct 2, 2025
f9498c5
minor updates
StanislavBreadless Oct 2, 2025
578ba46
sync with base
StanislavBreadless Oct 2, 2025
8748252
add permissionless chainBalance initialization to L2AT
0xValera Oct 3, 2025
7aec612
reuse _depositsPaused()
0xValera Oct 3, 2025
68a169c
move depositsPaused check out of _checkV30UpgradeProcessed
0xValera Oct 3, 2025
d79e087
remove redundunt assetMigrationNumber check
kelemeno Oct 3, 2025
e4ae8ca
fix some comments
StanislavBreadless Oct 3, 2025
43ac018
small comment removal, redundunt check, error importing
kelemeno Oct 3, 2025
4d49456
deduplicate maxChainBalanceAssignment
kelemeno Oct 3, 2025
ac13d7e
just return array
kelemeno Oct 3, 2025
133f674
request full list for legacySharedBridge
kelemeno Oct 3, 2025
f9d3fa6
remove onlyWithdrawals
kelemeno Oct 3, 2025
0b875d6
check all batches executed
kelemeno Oct 3, 2025
c18c1ad
rename gateway chain id
kelemeno Oct 3, 2025
d27e121
unneded var
kelemeno Oct 3, 2025
d1a2280
follow CEI
0xValera Oct 3, 2025
3dd0b04
migrateTokenBalance only for tokens native to the current chain
0xValera Oct 3, 2025
89ed957
redundant check
0xValera Oct 3, 2025
4403097
remove l2 native token registration
kelemeno Oct 3, 2025
95a9c9d
remove parity check from L1AT
kelemeno Oct 3, 2025
e15cc51
linting
kelemeno Oct 3, 2025
4e0ae48
lint 2
kelemeno Oct 3, 2025
707c703
errors check
kelemeno Oct 3, 2025
cbf22fb
chainBalance fix
0xValera Oct 3, 2025
31c986f
fix test
kelemeno Oct 3, 2025
3b0abde
Merge pull request #1698 from matter-labs/kl/03-10-25/1
kelemeno Oct 3, 2025
94d2723
address comments
0xValera Oct 3, 2025
55e457c
Merge branch 'kl/medium-interop' of https://github.com/matter-labs/er…
0xValera Oct 3, 2025
e1864ce
Merge pull request #1696 from matter-labs/vg/02-10-2025
kelemeno Oct 3, 2025
024e8eb
sync with base
StanislavBreadless Oct 3, 2025
6f1da2b
readd parity check
kelemeno Oct 5, 2025
72047aa
parity check comment
kelemeno Oct 5, 2025
e64b837
migration window check
kelemeno Oct 5, 2025
6ef6d39
linting
kelemeno Oct 5, 2025
2c56e35
lint 2
kelemeno Oct 5, 2025
db3bd15
Merge pull request #1701 from matter-labs/kl/05-10-25/add-chain-migra…
kelemeno Oct 5, 2025
308c997
change note of possible deprecation
0xValera Oct 6, 2025
e77e86e
Update l1-contracts/contracts/common/Config.sol
kelemeno Oct 6, 2025
4421880
allow immediate pause of deposits for new chains
0xValera Oct 6, 2025
c6a5244
errors fix
kelemeno Oct 6, 2025
24e13e2
enable migration from GW for when chain migrated back to GW
kelemeno Oct 6, 2025
554d096
save correct savedTotalSupply
kelemeno Oct 6, 2025
21d6f40
missing access control
kelemeno Oct 6, 2025
e84cf10
save chainBalance for correct migration number -2
kelemeno Oct 6, 2025
709cefd
incorrect location in function
kelemeno Oct 6, 2025
01a6ae9
make migrationNumber deprecatable public, delete gated getter
0xValera Oct 6, 2025
b870553
gw asset tracker fix
kelemeno Oct 6, 2025
46ae089
Merge branch 'kl/06-10-25/1' of ssh://github.com/matter-labs/era-cont…
kelemeno Oct 6, 2025
0d2a4e0
Various CI fixes (#1690)
zkzoomer Oct 6, 2025
312f02a
Merge branch 'kl/medium-interop' into vg/06-10-2025
0xValera Oct 6, 2025
35c94ec
Apply suggestions from code review
0xValera Oct 6, 2025
c0a2cc2
Merge pull request #1702 from matter-labs/vg/06-10-2025
kelemeno Oct 6, 2025
f68672f
remove unprocessed deposits in GW AT
kelemeno Oct 6, 2025
322fa1d
cherrypick Stas's PR
0xValera Oct 6, 2025
fb6a11d
Merge pull request #1705 from matter-labs/vg/sb-server-fixes-cherrypick
0xValera Oct 6, 2025
f64c0ef
pause deposits on GW
kelemeno Oct 6, 2025
25b20d9
Merge branch 'kl/medium-interop' of ssh://github.com/matter-labs/era-…
kelemeno Oct 6, 2025
4c36eb4
puased deposits check also on GW for chain migration
kelemeno Oct 6, 2025
a5cc118
rename GW savedTotalUpply
kelemeno Oct 6, 2025
ebb95f6
migrationNumber selector
kelemeno Oct 6, 2025
1065567
some comments
0xValera Oct 6, 2025
00ba368
server bump
zkzoomer Oct 6, 2025
ce365aa
L1BatchEnv fixes
zkzoomer Oct 6, 2025
ec71a1b
replay protection
kelemeno Oct 6, 2025
b08496e
some more comments
0xValera Oct 6, 2025
1a32cf2
lint
0xValera Oct 6, 2025
10cd713
Merge branch 'kl/medium-interop' of https://github.com/matter-labs/er…
0xValera Oct 6, 2025
005d439
slither silencers
0xValera Oct 6, 2025
508a518
fix dependencies
zkzoomer Oct 6, 2025
83369c6
fix test
zkzoomer Oct 6, 2025
1b26555
some more fixes
0xValera Oct 6, 2025
1ed4348
Merge pull request #1706 from matter-labs/sma/medium-interop-ci-fixes-ii
kelemeno Oct 6, 2025
f01dde5
fix link in readme
0xValera Oct 6, 2025
c022c57
address outdated comment
0xValera Oct 6, 2025
34f3a5d
typo
0xValera Oct 6, 2025
b7d1f05
add interop balance change
kelemeno Oct 6, 2025
44c3997
testing linting
kelemeno Oct 6, 2025
9a4e523
add AssetTracker to mocks
zkzoomer Oct 6, 2025
cea5177
Merge pull request #1707 from matter-labs/vg/fix-broken-link
kelemeno Oct 6, 2025
e954643
lint
zkzoomer Oct 6, 2025
10c283a
reentrancy, typo
kelemeno Oct 6, 2025
5b5b9a1
slither 2
kelemeno Oct 6, 2025
c6c17b1
fix constants
zkzoomer Oct 6, 2025
c5983ae
fixing contract size
kelemeno Oct 6, 2025
48f64de
linting
kelemeno Oct 6, 2025
4c1e38d
errors
kelemeno Oct 6, 2025
22afe1e
Merge branch 'kl/medium-interop' of ssh://github.com/matter-labs/era-…
kelemeno Oct 6, 2025
1129bc7
avoid avoidViaIrStruct
0xValera Oct 7, 2025
7831684
stylistic issues
0xValera Oct 7, 2025
f32677e
avoid stack too deep
0xValera Oct 7, 2025
5e1200e
lint
0xValera Oct 7, 2025
d8c9cc5
a bit more
0xValera Oct 7, 2025
bf00aad
Merge pull request #1699 from matter-labs/sb/additional-comments-for-…
kelemeno Oct 7, 2025
5ddc2b5
Merge pull request #1709 from matter-labs/vg/avoid-avoid-via-ir
kelemeno Oct 7, 2025
11fe14b
Merge branch 'kl/medium-interop' of ssh://github.com/matter-labs/era-…
kelemeno Oct 7, 2025
f1e259f
push for review, incomplete
kelemeno Oct 7, 2025
d0f1bec
linting
kelemeno Oct 7, 2025
d12dc60
fix issue with l1 asset tracker token balance migration
kelemeno Oct 7, 2025
e7947c8
source vs destination chain id
kelemeno Oct 7, 2025
166ec4e
source vs destination chain id 2
kelemeno Oct 7, 2025
ada702b
rename pauseDepositsBeforeInitiatingMigration
kelemeno Oct 7, 2025
a531675
save chainBalance correctly, don't reset chainBalance to 0
kelemeno Oct 7, 2025
907cfef
save chainBalance in confirmMigrationOnGateway
kelemeno Oct 7, 2025
7e82465
replace chainBalance increase with special function
kelemeno Oct 7, 2025
f894e11
only pause deposits on L1
kelemeno Oct 7, 2025
ca7ac52
add l1 chain id check in IH
kelemeno Oct 7, 2025
f7065f7
linting
kelemeno Oct 7, 2025
639f7e2
no iterated migrations
kelemeno Oct 7, 2025
f33b264
deduplicate some code
kelemeno Oct 7, 2025
6ad872d
linting
kelemeno Oct 7, 2025
92d56bf
one more comment
kelemeno Oct 7, 2025
7fcd5f2
fix test
kelemeno Oct 7, 2025
227955a
Merge pull request #1703 from matter-labs/kl/06-10-25/1
kelemeno Oct 7, 2025
313c35a
delete received interop messages
kelemeno Oct 7, 2025
1d3452c
linting
kelemeno Oct 7, 2025
923f5bd
Merge pull request #1710 from matter-labs/kl/07-10-25/1
kelemeno Oct 7, 2025
a290ce1
add back assetMigratin check
kelemeno Oct 7, 2025
4b0c50e
correct aMN check
kelemeno Oct 7, 2025
884d5bd
A bit more comments (#1712)
StanislavBreadless Oct 7, 2025
2f88afe
Merge pull request #1711 from matter-labs/kl/07-10-25/2
kelemeno Oct 7, 2025
be61bd9
Kl/08 10 25/oz fixes (#1714)
kelemeno Oct 8, 2025
ed31c01
Merge branch 'draft-v30' of ssh://github.com/matter-labs/era-contract…
kelemeno Oct 13, 2025
b56fcb4
build fixes
kelemeno Oct 13, 2025
d5a5e31
stack too deep
kelemeno Oct 13, 2025
20f2dbe
wrong contract name
kelemeno Oct 13, 2025
6915321
selectors
kelemeno Oct 13, 2025
524c0cd
fix test
kelemeno Oct 17, 2025
3d96c70
linting
kelemeno Oct 17, 2025
5190830
Merge pull request #1721 from matter-labs/kl/13-10-25/merge-draft
kelemeno Oct 17, 2025
1079469
Merge branch 'draft-v30' of ssh://github.com/matter-labs/era-contract…
kelemeno Oct 17, 2025
d86014c
imports
kelemeno Oct 17, 2025
43496f7
getting to build
kelemeno Oct 17, 2025
7cdf58b
lint
kelemeno Oct 17, 2025
899b659
Merge pull request #1733 from matter-labs/kl/17-10-25/merge-draft
kelemeno Oct 17, 2025
68f79ed
Merge remote-tracking branch 'origin/draft-v30' into kl/medium-interop
zkzoomer Oct 22, 2025
0741356
merge fixes
zkzoomer Oct 22, 2025
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
2 changes: 1 addition & 1 deletion .github/workflows/l1-contracts-ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,7 @@ jobs:
system-contracts/zkout

- name: Run coverage
run: yarn test:foundry && yarn coverage:foundry --report summary --report lcov
run: yarn test:foundry --no-match-path 'test/foundry/l1/unit/concrete/Executor/*' && yarn coverage:foundry --report summary --report lcov

# Installing the specific version of `lcov` because of
# the `genhtml: ERROR: line ... of ... has branchcov but no linecov data` error.
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ l1-contracts/out/*
l1-contracts/zkout/*
l1-contracts/broadcast/*
l1-contracts/script-config/*
l1-contracts/snapshots/*
!l1-contracts/script-config/artifacts
l1-contracts/script-out/*
l1-contracts/test/foundry/l1/integration/deploy-scripts/script-out/*.toml
Expand Down
1 change: 1 addition & 0 deletions .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/snapshots/*
l1-contracts/deploy-scripts
!l1-contracts/deploy-scripts/DeployL1.s.sol
!l1-contracts/deploy-scripts/DeployUtils.s.sol
Expand Down
570 changes: 353 additions & 217 deletions AllContractsHashes.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions l1-contracts/.env
Original file line number Diff line number Diff line change
Expand Up @@ -57,3 +57,4 @@ DEPLOY_GATEWAY_TX_FILTERER_INPUT=/script-config/deploy-gateway-tx-filterer.toml
DEPLOY_GATEWAY_TX_FILTERER_OUTPUT=/script-out/deploy-gateway-tx-filterer.toml
GATEWAY_VOTE_PREPARATION_INPUT=/script-config/gateway-vote-preparation.toml
GATEWAY_VOTE_PREPARATION_OUTPUT=/script-out/gateway-vote-preparation.toml
CONTRACTS_PATH=..
4 changes: 0 additions & 4 deletions l1-contracts/contracts/bridge/L1BridgeContractErrors.sol
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,9 @@ error EmptyToken();
error EthTransferFailed();
// 0x1c55230b
error NativeTokenVaultAlreadySet();
// 0xfeda3bf8
error WrongAmountTransferred(uint256 balance, uint256 nullifierChainBalance);
// 0xb4aeddbc
error WrongCounterpart();
// 0x636c90db
error WrongL2Sender(address providedL2Sender);
// 0x61cdb17e
error WrongMsgLength(uint256 expected, uint256 length);
// 0xe4742c42
error ZeroAmountToTransfer();
14 changes: 12 additions & 2 deletions l1-contracts/contracts/bridge/L1Nullifier.sol
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import {ETH_TOKEN_ADDRESS} from "../common/Config.sol";
import {DataEncoding} from "../common/libraries/DataEncoding.sol";

import {IBridgehub} from "../bridgehub/IBridgehub.sol";
import {IInteropCenter} from "../interop/IInteropCenter.sol";
import {L2_ASSET_ROUTER_ADDR, L2_BASE_TOKEN_SYSTEM_CONTRACT_ADDR} from "../common/l2-helpers/L2ContractAddresses.sol";
import {AddressAlreadySet, DepositDoesNotExist, DepositExists, InvalidProof, InvalidSelector, L2WithdrawalMessageWrongLength, LegacyBridgeNotSet, LegacyMethodForNonL1Token, SharedBridgeKey, SharedBridgeValueNotSet, TokenNotLegacy, Unauthorized, WithdrawalAlreadyFinalized, ZeroAddress} from "../common/L1ContractErrors.sol";
import {EthTransferFailed, NativeTokenVaultAlreadySet, WrongL2Sender, WrongMsgLength} from "./L1BridgeContractErrors.sol";
Expand All @@ -39,6 +40,9 @@ contract L1Nullifier is IL1Nullifier, ReentrancyGuard, Ownable2StepUpgradeable,
/// @dev Bridgehub smart contract that is used to operate with L2 via asynchronous L2 <-> L1 communication.
IBridgehub public immutable override BRIDGE_HUB;

/// @dev InteropCenter smart contract that is used to used to operate with L2 via asynchronous L2 <-> L1 communication.
IInteropCenter internal immutable INTEROP_CENTER;

/// @dev Era's chainID
uint256 internal immutable ERA_CHAIN_ID;

Expand Down Expand Up @@ -134,9 +138,15 @@ contract L1Nullifier is IL1Nullifier, ReentrancyGuard, Ownable2StepUpgradeable,

/// @dev Contract is expected to be used as proxy implementation.
/// @dev Initialize the implementation to prevent Parity hack.
constructor(IBridgehub _bridgehub, uint256 _eraChainId, address _eraDiamondProxy) reentrancyGuardInitializer {
constructor(
IBridgehub _bridgehub,
IInteropCenter _interopCenter,
uint256 _eraChainId,
address _eraDiamondProxy
) reentrancyGuardInitializer {
_disableInitializers();
BRIDGE_HUB = _bridgehub;
INTEROP_CENTER = _interopCenter;
ERA_CHAIN_ID = _eraChainId;
ERA_DIAMOND_PROXY = _eraDiamondProxy;
}
Expand Down Expand Up @@ -382,7 +392,7 @@ contract L1Nullifier is IL1Nullifier, ReentrancyGuard, Ownable2StepUpgradeable,
_transferData: _assetData
});
if (dataHash != txDataHash) {
revert DepositDoesNotExist();
revert DepositDoesNotExist(dataHash, txDataHash);
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions l1-contracts/contracts/bridge/L2SharedBridgeLegacy.sol
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import {IL2AssetRouter} from "./asset-router/IL2AssetRouter.sol";
import {IL2NativeTokenVault} from "./ntv/IL2NativeTokenVault.sol";

import {IL2SharedBridgeLegacy} from "./interfaces/IL2SharedBridgeLegacy.sol";
import {AmountMustBeGreaterThanZero, DeployFailed, EmptyBytes32, InvalidCaller, Unauthorized, ZeroAddress} from "../common/L1ContractErrors.sol";
import {AmountMustBeGreaterThanZero, DeployFailed, EmptyBytes32, Unauthorized, ZeroAddress} from "../common/L1ContractErrors.sol";

/// @author Matter Labs
/// @custom:security-contact [email protected]
Expand Down Expand Up @@ -125,7 +125,7 @@ contract L2SharedBridgeLegacy is IL2SharedBridgeLegacy, Initializable {
AddressAliasHelper.undoL1ToL2Alias(msg.sender) != l1Bridge &&
AddressAliasHelper.undoL1ToL2Alias(msg.sender) != l1SharedBridge
) {
revert InvalidCaller(msg.sender);
// revert InvalidCaller(msg.sender);
}

IL2AssetRouter(L2_ASSET_ROUTER_ADDR).finalizeDepositLegacyBridge({
Expand Down
163 changes: 158 additions & 5 deletions l1-contracts/contracts/bridge/asset-router/AssetRouterBase.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,22 @@

pragma solidity 0.8.28;

import {Ownable2StepUpgradeable} from "@openzeppelin/contracts-upgradeable-v4/access/Ownable2StepUpgradeable.sol";

Check warning on line 5 in l1-contracts/contracts/bridge/asset-router/AssetRouterBase.sol

View workflow job for this annotation

GitHub Actions / lint

Import in l1-contracts/contracts/bridge/asset-router/AssetRouterBase.sol doesn't exist in: @openzeppelin/contracts-upgradeable-v4/access/Ownable2StepUpgradeable.sol

Check warning on line 5 in l1-contracts/contracts/bridge/asset-router/AssetRouterBase.sol

View workflow job for this annotation

GitHub Actions / lint

Import in l1-contracts/contracts/bridge/asset-router/AssetRouterBase.sol doesn't exist in: @openzeppelin/contracts-upgradeable-v4/access/Ownable2StepUpgradeable.sol

Check warning on line 5 in l1-contracts/contracts/bridge/asset-router/AssetRouterBase.sol

View workflow job for this annotation

GitHub Actions / lint

Import in l1-contracts/contracts/bridge/asset-router/AssetRouterBase.sol doesn't exist in: @openzeppelin/contracts-upgradeable-v4/access/Ownable2StepUpgradeable.sol
import {PausableUpgradeable} from "@openzeppelin/contracts-upgradeable-v4/security/PausableUpgradeable.sol";

Check warning on line 6 in l1-contracts/contracts/bridge/asset-router/AssetRouterBase.sol

View workflow job for this annotation

GitHub Actions / lint

Import in l1-contracts/contracts/bridge/asset-router/AssetRouterBase.sol doesn't exist in: @openzeppelin/contracts-upgradeable-v4/security/PausableUpgradeable.sol

Check warning on line 6 in l1-contracts/contracts/bridge/asset-router/AssetRouterBase.sol

View workflow job for this annotation

GitHub Actions / lint

Import in l1-contracts/contracts/bridge/asset-router/AssetRouterBase.sol doesn't exist in: @openzeppelin/contracts-upgradeable-v4/security/PausableUpgradeable.sol

Check warning on line 6 in l1-contracts/contracts/bridge/asset-router/AssetRouterBase.sol

View workflow job for this annotation

GitHub Actions / lint

Import in l1-contracts/contracts/bridge/asset-router/AssetRouterBase.sol doesn't exist in: @openzeppelin/contracts-upgradeable-v4/security/PausableUpgradeable.sol

import {IERC20} from "@openzeppelin/contracts-v4/token/ERC20/IERC20.sol";

Check warning on line 8 in l1-contracts/contracts/bridge/asset-router/AssetRouterBase.sol

View workflow job for this annotation

GitHub Actions / lint

Import in l1-contracts/contracts/bridge/asset-router/AssetRouterBase.sol doesn't exist in: @openzeppelin/contracts-v4/token/ERC20/IERC20.sol

Check warning on line 8 in l1-contracts/contracts/bridge/asset-router/AssetRouterBase.sol

View workflow job for this annotation

GitHub Actions / lint

Import in l1-contracts/contracts/bridge/asset-router/AssetRouterBase.sol doesn't exist in: @openzeppelin/contracts-v4/token/ERC20/IERC20.sol

Check warning on line 8 in l1-contracts/contracts/bridge/asset-router/AssetRouterBase.sol

View workflow job for this annotation

GitHub Actions / lint

Import in l1-contracts/contracts/bridge/asset-router/AssetRouterBase.sol doesn't exist in: @openzeppelin/contracts-v4/token/ERC20/IERC20.sol
import {SafeERC20} from "@openzeppelin/contracts-v4/token/ERC20/utils/SafeERC20.sol";

Check warning on line 9 in l1-contracts/contracts/bridge/asset-router/AssetRouterBase.sol

View workflow job for this annotation

GitHub Actions / lint

Import in l1-contracts/contracts/bridge/asset-router/AssetRouterBase.sol doesn't exist in: @openzeppelin/contracts-v4/token/ERC20/utils/SafeERC20.sol

Check warning on line 9 in l1-contracts/contracts/bridge/asset-router/AssetRouterBase.sol

View workflow job for this annotation

GitHub Actions / lint

Import in l1-contracts/contracts/bridge/asset-router/AssetRouterBase.sol doesn't exist in: @openzeppelin/contracts-v4/token/ERC20/utils/SafeERC20.sol

Check warning on line 9 in l1-contracts/contracts/bridge/asset-router/AssetRouterBase.sol

View workflow job for this annotation

GitHub Actions / lint

Import in l1-contracts/contracts/bridge/asset-router/AssetRouterBase.sol doesn't exist in: @openzeppelin/contracts-v4/token/ERC20/utils/SafeERC20.sol

import {IAssetRouterBase} from "./IAssetRouterBase.sol";
import {IAssetRouterBase, NEW_ENCODING_VERSION} from "./IAssetRouterBase.sol";
import {IAssetHandler} from "../interfaces/IAssetHandler.sol";
import {DataEncoding} from "../../common/libraries/DataEncoding.sol";

import {L2_NATIVE_TOKEN_VAULT_ADDR} from "../../common/l2-helpers/L2ContractAddresses.sol";
import {TWO_BRIDGES_MAGIC_VALUE} from "../../common/Config.sol";
import {L2_ASSET_ROUTER_ADDR, L2_NATIVE_TOKEN_VAULT_ADDR} from "../../common/l2-helpers/L2ContractAddresses.sol";

import {IBridgehub} from "../../bridgehub/IBridgehub.sol";
import {Unauthorized} from "../../common/L1ContractErrors.sol";
import {IBridgehub, L2TransactionRequestTwoBridgesInner} from "../../bridgehub/IBridgehub.sol";
import {IInteropCenter} from "../../interop/IInteropCenter.sol";
import {AssetIdNotSupported, Unauthorized, UnsupportedEncodingVersion, AssetHandlerDoesNotExist} from "../../common/L1ContractErrors.sol";
import {INativeTokenVault} from "../ntv/INativeTokenVault.sol";

/// @author Matter Labs
Expand All @@ -28,6 +30,9 @@
/// @dev Bridgehub smart contract that is used to operate with L2 via asynchronous L2 <-> L1 communication.
IBridgehub public immutable override BRIDGE_HUB;

/// @dev InteropCenter smart contract that is used to operate with L2 via asynchronous L2 <-> L1 communication.
IInteropCenter public immutable override INTEROP_CENTER;

/// @dev Chain ID of L1 for bridging reasons
uint256 public immutable L1_CHAIN_ID;

Expand Down Expand Up @@ -63,10 +68,11 @@

/// @dev Contract is expected to be used as proxy implementation.
/// @dev Initialize the implementation to prevent Parity hack.
constructor(uint256 _l1ChainId, uint256 _eraChainId, IBridgehub _bridgehub) {
constructor(uint256 _l1ChainId, uint256 _eraChainId, IBridgehub _bridgehub, IInteropCenter _interopCenter) {
L1_CHAIN_ID = _l1ChainId;
ERA_CHAIN_ID = _eraChainId;
BRIDGE_HUB = _bridgehub;
INTEROP_CENTER = _interopCenter;
}

/// @inheritdoc IAssetRouterBase
Expand All @@ -91,6 +97,121 @@
emit AssetDeploymentTrackerRegistered(assetId, _assetRegistrationData, msg.sender);
}

/*//////////////////////////////////////////////////////////////
INITIATTE DEPOSIT Functions
//////////////////////////////////////////////////////////////*/

function bridgehubDepositBaseToken(
uint256 _chainId,
bytes32 _assetId,
address _originalCaller,
uint256 _amount
) public payable virtual;

function _bridgehubDepositBaseToken(
uint256 _chainId,
bytes32 _assetId,
address _originalCaller,
uint256 _amount
) public payable virtual {
address assetHandler = assetHandlerAddress[_assetId];
if (assetHandler == address(0)) {
revert AssetHandlerDoesNotExist(_assetId);
}

// slither-disable-next-line unused-return
IAssetHandler(assetHandler).bridgeBurn{value: msg.value}({
_chainId: _chainId,
_msgValue: 0,
_assetId: _assetId,
_originalCaller: _originalCaller,
_data: DataEncoding.encodeBridgeBurnData(_amount, address(0), address(0))
});

// 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, _originalCaller, _assetId, _amount);
}

function _bridgehubDeposit(
uint256 _chainId,
address _originalCaller,
uint256 _value,
bytes calldata _data,
address _nativeTokenVault
) internal virtual whenNotPaused returns (L2TransactionRequestTwoBridgesInner memory request) {
bytes1 encodingVersion = _data[0];
if (encodingVersion == NEW_ENCODING_VERSION) {
return
_bridgehubDepositRealAsset({
_chainId: _chainId,
_originalCaller: _originalCaller,
_value: _value,
_data: _data,
_nativeTokenVault: _nativeTokenVault
});
} else {
revert UnsupportedEncodingVersion();
}
}

function _bridgehubDepositRealAsset(
uint256 _chainId,
address _originalCaller,
uint256 _value,
bytes calldata _data,
address _nativeTokenVault
) internal returns (L2TransactionRequestTwoBridgesInner memory request) {
bytes1 encodingVersion = _data[0];

(bytes32 assetId, bytes memory transferData) = _getTransferData(encodingVersion, _originalCaller, _data);
if (BRIDGE_HUB.baseTokenAssetId(_chainId) == assetId) {
revert AssetIdNotSupported(assetId);
}

bytes memory bridgeMintCalldata = _burn({
_chainId: _chainId,
_nextMsgValue: _value,
_assetId: assetId,
_originalCaller: _originalCaller,
_transferData: transferData,
_passValue: true,
_nativeTokenVault: _nativeTokenVault
});

bytes32 txDataHash = DataEncoding.encodeTxDataHash({
_nativeTokenVault: _nativeTokenVault,
_encodingVersion: encodingVersion,
_originalCaller: _originalCaller,
_assetId: assetId,
_transferData: transferData
});

request = _requestToBridge({
_originalCaller: _originalCaller,
_assetId: assetId,
_bridgeMintCalldata: bridgeMintCalldata,
_txDataHash: txDataHash
});

emit BridgehubDepositInitiated({
chainId: _chainId,
txDataHash: txDataHash,
from: _originalCaller,
assetId: assetId,
bridgeMintCalldata: bridgeMintCalldata
});
}

function _getTransferData(
bytes1 _encodingVersion,
address,
bytes calldata _data
) internal virtual returns (bytes32 assetId, bytes memory transferData) {
if (_encodingVersion == NEW_ENCODING_VERSION) {
(assetId, transferData) = abi.decode(_data[1:], (bytes32, bytes));
}
}

/*//////////////////////////////////////////////////////////////
Receive transaction Functions
//////////////////////////////////////////////////////////////*/
Expand Down Expand Up @@ -171,6 +292,38 @@
});
}

/// @dev The request data that is passed to the bridgehub.
/// @param _originalCaller The `msg.sender` address from the external call that initiated current one.
/// @param _assetId The deposited asset ID.
/// @param _bridgeMintCalldata The calldata used by remote asset handler to mint tokens for recipient.
/// @param _txDataHash The keccak256 hash of 0x01 || abi.encode(bytes32, bytes) to identify deposits.
/// @return request The data used by the bridgehub to create L2 transaction request to specific ZK chain.
function _requestToBridge(
address _originalCaller,
bytes32 _assetId,
bytes memory _bridgeMintCalldata,
bytes32 _txDataHash
) internal view virtual returns (L2TransactionRequestTwoBridgesInner memory request) {
bytes memory l2TxCalldata = getDepositCalldata(_originalCaller, _assetId, _bridgeMintCalldata);

request = L2TransactionRequestTwoBridgesInner({
magicValue: TWO_BRIDGES_MAGIC_VALUE,
l2Contract: L2_ASSET_ROUTER_ADDR,
l2Calldata: l2TxCalldata,
factoryDeps: new bytes[](0),
txDataHash: _txDataHash
});
}

/// @inheritdoc IAssetRouterBase
function getDepositCalldata(
address,
bytes32 _assetId,
bytes memory _assetData
) public view virtual override returns (bytes memory) {
return abi.encodeCall(IAssetRouterBase.finalizeDeposit, (block.chainid, _assetId, _assetData));
}

/// @notice Ensures that token is registered with native token vault.
/// @dev Only used when deposit is made with legacy data encoding format.
/// @param _token The native token address which should be registered with native token vault.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
pragma solidity 0.8.28;

import {IBridgehub} from "../../bridgehub/IBridgehub.sol";

import {IInteropCenter} from "../../interop/IInteropCenter.sol";
/// @dev The encoding version used for legacy txs.
bytes1 constant LEGACY_ENCODING_VERSION = 0x00;

Expand Down Expand Up @@ -53,6 +53,8 @@ interface IAssetRouterBase {

function L1_CHAIN_ID() external view returns (uint256);

function INTEROP_CENTER() external view returns (IInteropCenter);

/// @notice Sets the asset handler address for a specified asset ID on the chain of the asset deployment tracker.
/// @dev The caller of this function is encoded within the `assetId`, therefore, it should be invoked by the asset deployment tracker contract.
/// @dev No access control on the caller, as msg.sender is encoded in the assetId.
Expand All @@ -71,4 +73,29 @@ interface IAssetRouterBase {
/// @dev We have both the legacy finalizeWithdrawal and the new finalizeDeposit functions,
/// finalizeDeposit uses the new format. On the L2 we have finalizeDeposit with new and old formats both.
function finalizeDeposit(uint256 _chainId, bytes32 _assetId, bytes memory _transferData) external payable;

/// @notice Generates a calldata for calling the deposit finalization on the L2 native token contract.
// / @param _chainId The chain ID of the ZK chain to which deposit.
/// @param _sender The address of the deposit initiator.
/// @param _assetId The deposited asset ID.
/// @param _assetData The encoded data, which is used by the asset handler to determine L2 recipient and amount. Might include extra information.
/// @return Returns calldata used on ZK chain.
function getDepositCalldata(
address _sender,
bytes32 _assetId,
bytes memory _assetData
) external view returns (bytes memory);

/// @notice Allows bridgehub to acquire mintValue for L1->L2 and L2->L2 transactions.
/// @dev If the corresponding L2 transaction fails, refunds are issued to a refund recipient on L2.
/// @param _chainId The chain ID of the ZK chain to which deposit.
/// @param _assetId The deposited asset ID.
/// @param _originalCaller The `msg.sender` address from the external call that initiated current one.
/// @param _amount The total amount of tokens to be bridged.
function bridgehubDepositBaseToken(
uint256 _chainId,
bytes32 _assetId,
address _originalCaller,
uint256 _amount
) external payable;
}
26 changes: 1 addition & 25 deletions l1-contracts/contracts/bridge/asset-router/IL1AssetRouter.sol
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import {IL1ERC20Bridge} from "../interfaces/IL1ERC20Bridge.sol";

/// @title L1 Bridge contract interface
/// @author Matter Labs
/// @notice This contract implement IL1CrossChainSender interface. We do not import it here to decrease inheritance.
/// @custom:security-contact [email protected]
interface IL1AssetRouter is IAssetRouterBase, IL1SharedBridgeLegacy {
event BridgehubMintData(bytes bridgeMintData);
Expand Down Expand Up @@ -165,31 +166,6 @@ interface IL1AssetRouter is IAssetRouterBase, IL1SharedBridgeLegacy {
bytes calldata _data
) external payable returns (L2TransactionRequestTwoBridgesInner memory request);

/// @notice Generates a calldata for calling the deposit finalization on the L2 native token contract.
// / @param _chainId The chain ID of the ZK chain to which deposit.
/// @param _sender The address of the deposit initiator.
/// @param _assetId The deposited asset ID.
/// @param _assetData The encoded data, which is used by the asset handler to determine L2 recipient and amount. Might include extra information.
/// @return Returns calldata used on ZK chain.
function getDepositCalldata(
address _sender,
bytes32 _assetId,
bytes memory _assetData
) external view returns (bytes memory);

/// @notice Allows bridgehub to acquire mintValue for L1->L2 transactions.
/// @dev If the corresponding L2 transaction fails, refunds are issued to a refund recipient on L2.
/// @param _chainId The chain ID of the ZK chain to which deposit.
/// @param _assetId The deposited asset ID.
/// @param _originalCaller The `msg.sender` address from the external call that initiated current one.
/// @param _amount The total amount of tokens to be bridged.
function bridgehubDepositBaseToken(
uint256 _chainId,
bytes32 _assetId,
address _originalCaller,
uint256 _amount
) external payable;

/// @notice Routes the confirmation to nullifier for backward compatibility.
/// @notice Confirms the acceptance of a transaction by the Mailbox, as part of the L2 transaction process within Bridgehub.
/// This function is utilized by `requestL2TransactionTwoBridges` to validate the execution of a transaction.
Expand Down
Loading
Loading