Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
208 commits
Select commit Hold shift + click to select a range
3803bf5
interop center comment clarification
0xValera Jun 25, 2025
c8cc107
InteropCenter onlyL1 correct error
0xValera Jun 25, 2025
2ae0ded
fix imports
0xValera Jun 25, 2025
1713601
split setAddresses into two functions, add events
0xValera Jun 25, 2025
6cbda51
onlyL2NotToL1 -> onlyL2ToL2
0xValera Jun 25, 2025
e0a3093
fixing function sections, public -> external
0xValera Jun 25, 2025
931ffe0
nextContract -> to for clarity. fix comments.
0xValera Jun 26, 2025
53c5ef2
pause InteropCenter functionality, lint errors
0xValera Jun 26, 2025
bf37d0d
callAttributes -> attributes for readability and consistency
0xValera Jun 26, 2025
2358b04
Revert "callAttributes -> attributes for readability and consistency"
0xValera Jun 26, 2025
ac45bfb
callAtributes -> attributes for consistency
0xValera Jun 26, 2025
3482e6d
comments fixes
0xValera Jun 26, 2025
57e5d09
if + revert -> require
0xValera Jun 26, 2025
8988efa
verify bundle message sender, lint
0xValera Jun 26, 2025
072de6c
change branching for readability
0xValera Jun 26, 2025
0b150b2
blacklist -> whitelist in status verification in unbundling
0xValera Jun 26, 2025
6ba3f93
shadow account comment
0xValera Jun 26, 2025
07f3150
revert callAttributes -> attributes changes
0xValera Jun 27, 2025
90c5d1d
destination chainId check
0xValera Jun 27, 2025
82208e1
unbundler address check
0xValera Jun 27, 2025
0c09915
Combine _sendBundle and _finalizeAndSendBundle
0xValera Jun 27, 2025
b18fdf9
fix _sendBundle bundleHash
0xValera Jun 27, 2025
a9a3611
basic token balance migration
kelemeno Jul 2, 2025
50110b1
token registration in asset tracker
kelemeno Jul 2, 2025
0219b32
Revert "split setAddresses into two functions, add events"
0xValera Jul 2, 2025
58f7ea6
linting
kelemeno Jul 3, 2025
9eea29d
add transient for recursive merkle proofs
kelemeno Jul 3, 2025
0cc8a98
linting
kelemeno Jul 3, 2025
41121f2
Merge branch 'kl/medium-interop' into vg/interop-center-and-handler-r…
0xValera Jul 4, 2025
dddb810
fix two tests and bug in decodeAddress
0xValera Jul 4, 2025
fe236e5
Merge branch 'kl/medium-interop' of ssh://github.com/matter-labs/era-…
kelemeno Jul 5, 2025
2490c22
linting and tests
kelemeno Jul 5, 2025
bf2d9e5
lint
0xValera Jul 8, 2025
26bd484
comment out broken tests (containing hardcoded proof), to be fixed
0xValera Jul 9, 2025
201c643
address -> InteroperableAddress in 7786 attributes
0xValera Jul 9, 2025
3335891
undo proveL2.. to public from view
kelemeno Jul 9, 2025
e60b775
correct transient lib name
kelemeno Jul 9, 2025
6cc17e4
sendCall -> sendMessage, executeMessage -> receiveMessage
0xValera Jul 9, 2025
eae4c41
IERC7786Receiver -> Recipient, fix bug
0xValera Jul 9, 2025
aa67dab
IERC7786 -> IERC7786GatewaySource
0xValera Jul 9, 2025
b4d9df6
7786 events
0xValera Jul 9, 2025
6f563b3
adding transient settlement layer to l1 nullifier
kelemeno Jul 9, 2025
8cfad47
add receiveMessage to InteropHandler for unbundle/execute bundle support
0xValera Jul 9, 2025
67063db
address raised issues
0xValera Jul 10, 2025
8bc534f
small fixes
kelemeno Jul 10, 2025
afe240a
some test fixes, linting, access control fix
0xValera Jul 10, 2025
ea9290a
remove unused error
0xValera Jul 10, 2025
19f5f59
more Asset tracker fixes
kelemeno Jul 11, 2025
a50581d
Merge branch 'kl/medium-interop' of ssh://github.com/matter-labs/era-…
kelemeno Jul 11, 2025
59d5bd7
fix tests
0xValera Jul 11, 2025
44eec16
Revert "fix tests"
0xValera Jul 11, 2025
dd737a0
fix tests
0xValera Jul 11, 2025
f31f6c5
Merge branch 'kl/medium-interop' into vg/medium-interop-review-fixes
0xValera Jul 11, 2025
7e044d1
linting
0xValera Jul 11, 2025
6692e96
issue fix
kelemeno Jul 11, 2025
6d56a0a
more token balance migration fixes
kelemeno Jul 13, 2025
e951b90
lint
kelemeno Jul 13, 2025
dc7d2f6
adding getTotalBatchesExecuted to provider
kelemeno Jul 14, 2025
bf93ccb
initial small cleanup
kelemeno Jul 14, 2025
ad603b7
small further cleanups
kelemeno Jul 15, 2025
2fe8f78
more fixes
kelemeno Jul 16, 2025
adb9f8c
further fixes
kelemeno Jul 16, 2025
1bfd1cf
more fixes
kelemeno Jul 16, 2025
7bac763
linting
kelemeno Jul 17, 2025
d0ad54a
add IL2CrossChainSender, polish ILxCrossChainSender's
0xValera Jul 18, 2025
4f56bd5
Merge branch 'kl/medium-interop' into vg/medium-interop-review-fixes
0xValera Jul 18, 2025
1940b80
sync Kalman's fix for onlyAssetRouterCounterpartOrSelf
0xValera Jul 18, 2025
5c4685d
basic exposing settlement layer in bootloader
kelemeno Jul 18, 2025
b09915f
migration number check in assetTracker
kelemeno Jul 20, 2025
e98c4af
cleanup
kelemeno Jul 20, 2025
4aea347
Update Messaging.sol
0xValera Jul 21, 2025
96360e3
Update InteropCenter.sol
0xValera Jul 21, 2025
1a46489
Update l1-contracts/contracts/bridge/asset-router/L2AssetRouter.sol
0xValera Jul 21, 2025
568e083
unify Unauthorized and InvalidCaller errors
0xValera Jul 21, 2025
25aaba2
Update l1-contracts/contracts/interop/InteropCenter.sol
0xValera Jul 21, 2025
4ba9dff
parseEvmV1Calldata where applicable
0xValera Jul 21, 2025
b228190
remove underscore to keep code consistent
0xValera Jul 21, 2025
bf0c8b9
Update l1-contracts/contracts/interop/InteropCenter.sol
0xValera Jul 21, 2025
7464198
use selector instead of index in AttributeAlreadySet
0xValera Jul 21, 2025
01357d0
Update InteropCenter.sol
0xValera Jul 21, 2025
a88db11
gas optimization
0xValera Jul 21, 2025
53fe4c3
add _ensureL2ToL2 to remove code duplication
0xValera Jul 21, 2025
c9ddc7e
Update InteropErrors.sol
0xValera Jul 21, 2025
c8b6aa2
small fix, and temporary not checking SL in executor
kelemeno Jul 21, 2025
16c8a75
restrict state mutability of `_ensureL2ToL2`
nikitastupin-matterlabs Jul 21, 2025
7ee8ca0
wording
nikitastupin-matterlabs Jul 21, 2025
3e01f73
update notice of `initialize`
nikitastupin-matterlabs Jul 21, 2025
ba7b99e
some more linting and cleanup
kelemeno Jul 21, 2025
1f04867
unused code
kelemeno Jul 21, 2025
988b8cb
build fix
kelemeno Jul 21, 2025
83f48ae
Merge branch 'kl/medium-interop' of ssh://github.com/matter-labs/era-…
kelemeno Jul 21, 2025
9c1d04e
typos
kelemeno Jul 21, 2025
9f0e2eb
linting
kelemeno Jul 21, 2025
c6ca994
add user-facing comments for receiveMessage in IH
0xValera Jul 21, 2025
8991b7a
fix the issue of parsing when the execution address is not specified
0xValera Jul 21, 2025
6a53169
migrate back fixes
kelemeno Jul 21, 2025
7005097
simplify require statements
nikitastupin-matterlabs Jul 21, 2025
3aa681f
wording
nikitastupin-matterlabs Jul 21, 2025
8a39b2e
wording
0xValera Jul 21, 2025
3ebb1fc
lint
0xValera Jul 21, 2025
7062284
rework parseAttributes
0xValera Jul 21, 2025
7226db5
sendMessage and sendBundle 7786 events rework
0xValera Jul 21, 2025
1e5c7c8
fix: bundle attributes are used with the `OnlyCallAttributes` restric…
nikitastupin-matterlabs Jul 22, 2025
b692e99
refacot: flatten require statements
nikitastupin-matterlabs Jul 22, 2025
ad21f3a
wording
nikitastupin-matterlabs Jul 22, 2025
4828a27
Revert "sendMessage and sendBundle 7786 events rework"
0xValera Jul 22, 2025
dbf7939
fix compilation, lint
0xValera Jul 22, 2025
3f25388
unify attributes errors into AttributeViolatesRestriction
0xValera Jul 22, 2025
a8e2e07
shuffle gitmodule
0xValera Jul 22, 2025
e56c68d
Merge branch 'kl/medium-interop' into vg/medium-interop-review-fixes
0xValera Jul 22, 2025
cd30a83
moving system upgrades to folder
kelemeno Jul 22, 2025
80e9dce
set migration number during upgrade
kelemeno Jul 22, 2025
cb3ad55
more asset tracker fixes
kelemeno Jul 22, 2025
66f7434
Update IERC7786Attributes.sol
0xValera Jul 22, 2025
bdfaf6c
events on setAddresses
0xValera Jul 22, 2025
a7cf9c6
asset tracker fixes
kelemeno Jul 23, 2025
9955daa
linting
kelemeno Jul 23, 2025
f9cb577
fmt
0xValera Jul 23, 2025
c62089d
add events and storage checks to execute/unbundle bundle tests
0xValera Jul 23, 2025
4ba3f66
linter
0xValera Jul 23, 2025
b7588f7
directCall -> indirectCall
0xValera Jul 23, 2025
f482ce2
add regression test for verify bundle access control fix
0xValera Jul 23, 2025
100ff8f
add regression test for verification of one bundle on multiple chains…
0xValera Jul 23, 2025
01f5b0b
use whitelist in executeBundle, use require
0xValera Jul 23, 2025
c625156
add pause/unpause and setAddresses tests for IC
0xValera Jul 23, 2025
39569c6
public -> internal fix in AssetRouterBase
0xValera Jul 23, 2025
c361bb6
public -> external for functions not used internally
0xValera Jul 23, 2025
b30b0a7
add missing onlyL2InteropCenter
0xValera Jul 23, 2025
6cab264
fix indirectCallMessageValue accounting issue
0xValera Jul 23, 2025
6a0b9fe
try skipping if file does not exist
kelemeno Jul 24, 2025
7d96d90
create testing suite to compare DIMT functionality with FullMerkle
0xValera Jul 24, 2025
8c66a9e
lint
0xValera Jul 24, 2025
d6b020e
DIMT functions state mutability
0xValera Jul 24, 2025
e9c313a
rework dimt testing
0xValera Jul 24, 2025
4092ec2
Update DynamicIncrementalMerkle.sol
0xValera Jul 24, 2025
c1d8546
linter
0xValera Jul 24, 2025
b0ea086
cleanup the L1Messenger, make sure the test passes
0xValera Jul 24, 2025
52d8891
remove storage logsTree
0xValera Jul 25, 2025
ab10705
L1Nullifier comments + event emission
0xValera Jul 25, 2025
2581cd5
more L1Nullifier nits
0xValera Jul 25, 2025
c366e40
small comment
kelemeno Jul 25, 2025
9dfee54
Merge branch 'kl/medium-interop' of https://github.com/matter-labs/er…
0xValera Jul 28, 2025
b911ed9
some unresolved conflicts, fix
0xValera Jul 28, 2025
8a2c29d
linter
0xValera Jul 28, 2025
a19d517
errors lint
0xValera Jul 28, 2025
91e5eea
small cleanup unused vars
kelemeno Jul 28, 2025
9489cde
small bootloader fixes
kelemeno Jul 28, 2025
d889e9b
get balance change from gw mailbox not chain's
kelemeno Jul 28, 2025
1254f92
migrate migration number with chain
kelemeno Jul 28, 2025
982eec4
Merge branch 'kl/medium-interop' of https://github.com/matter-labs/er…
0xValera Jul 28, 2025
3b88e65
rollback L1Messenger to v29 state
0xValera Jul 28, 2025
0b32e0a
add pushLazy
0xValera Jul 28, 2025
dc8a8ec
add pushLazy testing
0xValera Jul 28, 2025
f99df9d
linter
0xValera Jul 29, 2025
e2aaf36
Merge branch 'kl/asset-tracker-migration' into vg/dimt-testing-cleanup
0xValera Jul 29, 2025
657052b
add lazy pushes to DynamicIncrementalMerkleMemory (l1-contracts)
0xValera Jul 29, 2025
100e344
use lazy pushes in AssetTracker
0xValera Jul 29, 2025
6766a8c
splitting asset tracker
kelemeno Jul 29, 2025
c29450c
add message verification to message root
kelemeno Jul 29, 2025
eaf3ef2
asset tracker split other contract changes
kelemeno Jul 29, 2025
fe6a3f2
asset tracker fix test fixes
kelemeno Jul 29, 2025
2dd95ce
imports cleanup
kelemeno Jul 29, 2025
2b7789a
add token origin chain id to balanceChange sent to Gw
kelemeno Jul 29, 2025
d680f2b
simplify pushLazy
0xValera Jul 29, 2025
69db5cd
Update L1Messenger.spec.ts
0xValera Jul 29, 2025
190ed9c
Merge branch 'kl/asset-tracker-migration' of https://github.com/matte…
0xValera Jul 29, 2025
95755ce
use pushLazy in L2AssetTracker
0xValera Jul 29, 2025
91f0cc6
mark root as calculated on usual pushes
0xValera Jul 30, 2025
3d2ebd3
add messageVerification to MessageRoot
kelemeno Jul 30, 2025
679244a
make _recalculateRoot functions consistent
0xValera Jul 30, 2025
1a480a8
reduce code duplication via shared internal function for lazy and reg…
0xValera Jul 30, 2025
a6ce4ad
linter
0xValera Jul 30, 2025
7766b7b
rework test suite, fixes
0xValera Jul 31, 2025
eed11d7
reducing code duplication
kelemeno Aug 3, 2025
8028e25
small fixes and cleanup
kelemeno Aug 5, 2025
9dd9729
linting
kelemeno Aug 5, 2025
879304f
compilation fix
kelemeno Aug 5, 2025
f34cfaa
setAddresses in L2 AssetTracker
kelemeno Aug 11, 2025
da1949e
addChainBatchRoot L1
kelemeno Aug 11, 2025
9a51989
add service tx to know deposit boundary
kelemeno Aug 12, 2025
7962c1f
linting
kelemeno Aug 12, 2025
52c5ee8
imports
kelemeno Aug 12, 2025
5d15d88
broadcasTypes cleanup
kelemeno Aug 12, 2025
3eaf23a
small further cleanup
kelemeno Aug 12, 2025
24df7f6
Merge pull request #1590 from matter-labs/vg/asset-tracker-cleanup
kelemeno Aug 12, 2025
516720f
handle initiate base token bridging
kelemeno Aug 13, 2025
b1a5843
better error message for gateway token migration
kelemeno Aug 13, 2025
37df43d
linting
kelemeno Aug 13, 2025
75172bc
cleanup of system context, migrateTokenBalanceFromNTV to AT,
kelemeno Aug 13, 2025
e228001
better access control for addChainBatchRoot
kelemeno Aug 13, 2025
573ce3b
more issues fixed
kelemeno Aug 13, 2025
d1b6754
test fixes, small bug fix
kelemeno Aug 13, 2025
ddc6fa0
Merge branch 'kl/asset-tracker-migration' of ssh://github.com/matter-…
kelemeno Aug 13, 2025
db804ae
some small further fixes
kelemeno Aug 13, 2025
01f7d76
Merge pull request #1578 from matter-labs/vg/dimt-testing-cleanup
kelemeno Aug 13, 2025
470c04a
small fix needed for compilation
kelemeno Aug 13, 2025
0e623d5
Merge branch 'kl/medium-interop' of ssh://github.com/matter-labs/era-…
kelemeno Aug 13, 2025
e0172c7
clean up l2 set Addresses
kelemeno Aug 14, 2025
39b910d
small renaming for better understanding
kelemeno Aug 14, 2025
ff016df
chainassetHandler immutables
kelemeno Aug 14, 2025
5e314a7
Messageroot cleanup, chainAH fixes
kelemeno Aug 14, 2025
4c9c88b
adding encoding version
kelemeno Aug 14, 2025
bd5d113
getChainMigrationNumber name,
kelemeno Aug 14, 2025
e639db8
add proveL1DepositParamsInclusion to MessageVerification
kelemeno Aug 15, 2025
6cb2613
add settlementLayerBatchNumber check against GW V30 block number for …
kelemeno Aug 15, 2025
997b501
test fixes
kelemeno Aug 15, 2025
3e058b9
test fixes
kelemeno Aug 17, 2025
c0a3d7d
lint
kelemeno Aug 17, 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
4 changes: 4 additions & 0 deletions l1-contracts/contracts/bridge/L1BridgeContractErrors.sol
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,14 @@ pragma solidity ^0.8.21;
error ClaimFailedDepositFailed();
// 0x066f53b1
error EmptyToken();
// 0x82b0de47
error EthAlreadyMigratedToL1NTV();
// 0x6d963f88
error EthTransferFailed();
// 0x1c55230b
error NativeTokenVaultAlreadySet();
// 0x84204265
error TokenAlreadyInBridgedTokensList();
// 0xb4aeddbc
error WrongCounterpart();
// 0x636c90db
Expand Down
67 changes: 51 additions & 16 deletions l1-contracts/contracts/bridge/L1Nullifier.sol
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,11 @@ import {IL1NativeTokenVault} from "./ntv/IL1NativeTokenVault.sol";

import {IL1ERC20Bridge} from "./interfaces/IL1ERC20Bridge.sol";
import {IL1AssetRouter} from "./asset-router/IL1AssetRouter.sol";

import {FinalizeL1DepositParams, IL1Nullifier} from "./interfaces/IL1Nullifier.sol";
import {FinalizeL1DepositParams, IL1Nullifier, TRANSIENT_SETTLEMENT_LAYER_SLOT} from "./interfaces/IL1Nullifier.sol";

import {IGetters} from "../state-transition/chain-interfaces/IGetters.sol";
import {IMailboxImpl} from "../state-transition/chain-interfaces/IMailboxImpl.sol";
import {L2Message, TxStatus} from "../common/Messaging.sol";
import {L2Log, L2Message, TxStatus} from "../common/Messaging.sol";
import {UnsafeBytes} from "../common/libraries/UnsafeBytes.sol";
import {ReentrancyGuard} from "../common/ReentrancyGuard.sol";
import {ETH_TOKEN_ADDRESS} from "../common/Config.sol";
Expand All @@ -28,7 +27,10 @@ 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";
import {EthAlreadyMigratedToL1NTV, NativeTokenVaultAlreadySet, WrongL2Sender, WrongMsgLength} from "./L1BridgeContractErrors.sol";
import {MessageHashing, ProofData} from "../common/libraries/MessageHashing.sol";
import {TransientPrimitivesLib} from "../common/libraries/TransientPrimitives/TransientPrimitives.sol";
import {IMessageRoot} from "../bridgehub/MessageRoot.sol";

/// @author Matter Labs
/// @custom:security-contact [email protected]
Expand All @@ -50,6 +52,9 @@ contract L1Nullifier is IL1Nullifier, ReentrancyGuard, Ownable2StepUpgradeable,
/// @dev The address of ZKsync Era diamond proxy contract.
address internal immutable ERA_DIAMOND_PROXY;

/// @dev MessageRoot smart contract that is used to prove message inclusion.
IMessageRoot public immutable MESSAGE_ROOT;

/// @dev Stores the first batch number on the ZKsync Era Diamond Proxy that was settled after Diamond proxy upgrade.
/// This variable is used to differentiate between pre-upgrade and post-upgrade Eth withdrawals. Withdrawals from batches older
/// than this value are considered to have been finalized prior to the upgrade and handled separately.
Expand Down Expand Up @@ -135,12 +140,14 @@ contract L1Nullifier is IL1Nullifier, ReentrancyGuard, Ownable2StepUpgradeable,
/// @dev Initialize the implementation to prevent Parity hack.
constructor(
IBridgehub _bridgehub,
IMessageRoot _messageRoot,
IInteropCenter _interopCenter,
uint256 _eraChainId,
address _eraDiamondProxy
) reentrancyGuardInitializer {
_disableInitializers();
BRIDGE_HUB = _bridgehub;
MESSAGE_ROOT = _messageRoot;
INTEROP_CENTER = _interopCenter;
ERA_CHAIN_ID = _eraChainId;
ERA_DIAMOND_PROXY = _eraDiamondProxy;
Expand Down Expand Up @@ -177,13 +184,7 @@ contract L1Nullifier is IL1Nullifier, ReentrancyGuard, Ownable2StepUpgradeable,
function transferTokenToNTV(address _token) external onlyL1NTV {
address ntvAddress = address(l1NativeTokenVault);
if (ETH_TOKEN_ADDRESS == _token) {
uint256 amount = address(this).balance;
bool callSuccess;
// Low-level assembly call, to avoid any memory copying (save gas)
assembly {
callSuccess := call(gas(), ntvAddress, amount, 0, 0, 0, 0)
}
require(callSuccess, EthTransferFailed());
revert EthAlreadyMigratedToL1NTV();
} else {
IERC20(_token).safeTransfer(ntvAddress, IERC20(_token).balanceOf(address(this)));
}
Expand All @@ -206,8 +207,10 @@ contract L1Nullifier is IL1Nullifier, ReentrancyGuard, Ownable2StepUpgradeable,
}

/// @notice Legacy function used for migration, do not use!
/// @dev Returns the deprecated chain balance for backwards compatibility.
/// @param _chainId The chain id we want to get the balance for.
/// @param _token The address of the token.
/// @return The balance of the token on the specified chain (deprecated).
// slither-disable-next-line uninitialized-state-variables
function chainBalance(uint256 _chainId, address _token) external view returns (uint256) {
// slither-disable-next-line uninitialized-state-variables
Expand Down Expand Up @@ -256,7 +259,7 @@ contract L1Nullifier is IL1Nullifier, ReentrancyGuard, Ownable2StepUpgradeable,
emit BridgehubDepositFinalized(_chainId, _txDataHash, _txHash);
}

/// @dev Calls the library `encodeTxDataHash`. Used as a wrapped for try / catch case.
/// @dev Calls the library `encodeTxDataHash`. Used as a wrapper for try / catch case.
/// @dev Encodes the transaction data hash using either the latest encoding standard or the legacy standard.
/// @param _encodingVersion EncodingVersion.
/// @param _originalCaller The address of the entity that initiated the deposit.
Expand Down Expand Up @@ -307,6 +310,7 @@ contract L1Nullifier is IL1Nullifier, ReentrancyGuard, Ownable2StepUpgradeable,
}

/// @dev Withdraw funds from the initiated deposit, that failed when finalizing on L2.
/// @param _checkedInLegacyBridge Whether the deposit was already checked in the legacy bridge system.
/// @param _chainId The ZK chain id to which deposit was initiated.
/// @param _depositSender The address of the entity that initiated the deposit.
/// @param _assetId The unique identifier of the deposited L1 token.
Expand All @@ -330,7 +334,7 @@ contract L1Nullifier is IL1Nullifier, ReentrancyGuard, Ownable2StepUpgradeable,
bytes32[] calldata _merkleProof
) internal whenNotPaused {
{
bool proofValid = BRIDGE_HUB.proveL1ToL2TransactionStatus({
bool proofValid = MESSAGE_ROOT.proveL1ToL2TransactionStatusShared({
_chainId: _chainId,
_l2TxHash: _l2TxHash,
_l2BatchNumber: _l2BatchNumber,
Expand All @@ -339,6 +343,22 @@ contract L1Nullifier is IL1Nullifier, ReentrancyGuard, Ownable2StepUpgradeable,
_merkleProof: _merkleProof,
_status: TxStatus.Failure
});
L2Log memory l2Log = MessageHashing.getL2LogFromL1ToL2Transaction(
_l2TxNumberInBatch,
_l2TxHash,
TxStatus.Failure
);

bytes32 leaf = MessageHashing.getLeafHashFromLog(l2Log);
ProofData memory proofData = MESSAGE_ROOT.getProofData({
_chainId: _chainId,
_batchNumber: _l2BatchNumber,
_leafProofMask: _l2MessageIndex,
_leaf: leaf,
_proof: _merkleProof
});
TransientPrimitivesLib.set(TRANSIENT_SETTLEMENT_LAYER_SLOT, proofData.settlementLayerChainId);
emit TransientSettlementLayerSet(proofData.settlementLayerChainId);
require(proofValid, InvalidProof());
}

Expand Down Expand Up @@ -502,24 +522,39 @@ contract L1Nullifier is IL1Nullifier, ReentrancyGuard, Ownable2StepUpgradeable,
});
}

bool success = BRIDGE_HUB.proveL2MessageInclusion({
bool success = MESSAGE_ROOT.proveL2MessageInclusionShared({
_chainId: _finalizeWithdrawalParams.chainId,
_batchNumber: _finalizeWithdrawalParams.l2BatchNumber,
_blockOrBatchNumber: _finalizeWithdrawalParams.l2BatchNumber,
_index: _finalizeWithdrawalParams.l2MessageIndex,
_message: l2ToL1Message,
_proof: _finalizeWithdrawalParams.merkleProof
});
bytes32 leaf = MessageHashing.getLeafHashFromMessage(l2ToL1Message);
ProofData memory proofData = MESSAGE_ROOT.getProofData({
_chainId: _finalizeWithdrawalParams.chainId,
_batchNumber: _finalizeWithdrawalParams.l2BatchNumber,
_leafProofMask: _finalizeWithdrawalParams.l2MessageIndex,
_leaf: leaf,
_proof: _finalizeWithdrawalParams.merkleProof
});
TransientPrimitivesLib.set(TRANSIENT_SETTLEMENT_LAYER_SLOT, proofData.settlementLayerChainId);
emit TransientSettlementLayerSet(proofData.settlementLayerChainId);
// withdrawal wrong proof
require(success, InvalidProof());
}

/// @inheritdoc IL1Nullifier
function getTransientSettlementLayer() external view returns (uint256) {
return TransientPrimitivesLib.getUint256(TRANSIENT_SETTLEMENT_LAYER_SLOT);
}

/// @notice Parses the withdrawal message and returns withdrawal details.
/// @dev Currently, 3 different encoding versions are supported: legacy mailbox withdrawal, ERC20 bridge withdrawal,
/// @dev and the latest version supported by shared bridge. Selectors are used for versioning.
/// @param _chainId The ZK chain ID.
/// @param _l2ToL1message The encoded L2 -> L1 message.
/// @return assetId The ID of the bridged asset.
/// @return transferData The transfer data used to finalize withdawal.
/// @return transferData The transfer data used to finalize withdrawal.
function _parseL2WithdrawalMessage(
uint256 _chainId,
bytes memory _l2ToL1message
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ import {IAssetHandler} from "../interfaces/IAssetHandler.sol";
import {DataEncoding} from "../../common/libraries/DataEncoding.sol";

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

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

/// @author Matter Labs
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ interface IL2AssetRouter is IAssetRouterBase, IL2CrossChainSender {

function L1_ASSET_ROUTER() external view returns (address);

function BASE_TOKEN_ASSET_ID() external view returns (bytes32);

function withdrawLegacyBridge(address _l1Receiver, address _l2Token, uint256 _amount, address _sender) external;

function finalizeDepositLegacyBridge(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import {InteropCallStarter} from "../../common/Messaging.sol";
import {L2_BRIDGEHUB_ADDR, L2_INTEROP_CENTER_ADDR, L2_NATIVE_TOKEN_VAULT_ADDR} from "../../common/l2-helpers/L2ContractAddresses.sol";
import {L2ContractHelper} from "../../common/l2-helpers/L2ContractHelper.sol";
import {DataEncoding} from "../../common/libraries/DataEncoding.sol";
import {AmountMustBeGreaterThanZero, AssetIdNotSupported, EmptyAddress, Unauthorized, TokenNotLegacy, InvalidSelector, PayloadTooShort, ExecuteMessageFailed} from "../../common/L1ContractErrors.sol";
import {AmountMustBeGreaterThanZero, AssetIdNotSupported, EmptyAddress, ExecuteMessageFailed, InvalidSelector, PayloadTooShort, TokenNotLegacy, Unauthorized} from "../../common/L1ContractErrors.sol";
import {IERC7786Recipient} from "../../interop/IERC7786Recipient.sol";
import {IERC7786Attributes} from "../../interop/IERC7786Attributes.sol";
import {InteroperableAddress} from "@openzeppelin/contracts-master/utils/draft-InteroperableAddress.sol";
Expand Down
Loading
Loading