From 0ce3595be17c2cb8bfffb7ea301fcd0a6a8d4506 Mon Sep 17 00:00:00 2001 From: Denis Kolegov Date: Thu, 21 Mar 2024 14:21:42 +0100 Subject: [PATCH] Enforce solhint func-named-parameters (#274) --- .solhint.json | 1 + .../contracts/bridge/L1ERC20Bridge.sol | 47 +-- .../contracts/bridge/L1SharedBridge.sol | 112 ++++--- .../contracts/bridgehub/Bridgehub.sol | 19 +- .../common/libraries/L2ContractHelper.sol | 1 + .../test/ReenterL1ERC20Bridge.sol | 19 +- .../StateTransitionManager.sol | 22 +- .../chain-deps/facets/Executor.sol | 22 +- .../chain-deps/facets/Mailbox.sol | 17 +- .../Bridgehub/_Bridgehub_Shared.t.sol | 1 - .../Bridgehub/experimental_bridge.t.sol | 169 +++++----- .../L1Erc20Bridge/ClaimFailedDeposit.t.sol | 21 +- .../Bridges/L1Erc20Bridge/Deposit.t.sol | 18 +- .../Bridges/L1Erc20Bridge/Reentrancy.t.sol | 19 +- .../L1SharedBridge/L1SharedBridge.t.sol | 176 ++++++----- .../L1SharedBridge/L1SharedBridgeFails.t.sol | 294 ++++++++++-------- .../L1SharedBridgeHyperEnabled.t.sol | 170 ++++++---- .../L1SharedBridge/L1SharedBridgeLegacy.t.sol | 53 ++-- .../unit/concrete/Executor/Committing.t.sol | 2 + .../unit/concrete/Executor/Executing.t.sol | 19 +- .../foundry/unit/concrete/Utils/Utils.sol | 3 + .../libraries/UnsafeBytes/UnsafeBytes.t.sol | 2 +- l2-contracts/contracts/L2ContractHelper.sol | 1 + .../contracts/SystemContractsCaller.sol | 36 +-- system-contracts/SystemContractsHashes.json | 36 +-- .../contracts/BootloaderUtilities.sol | 5 + .../contracts/ContractDeployer.sol | 51 +-- system-contracts/contracts/L1Messenger.sol | 1 + .../contracts/MsgValueSimulator.sol | 10 +- .../contracts/libraries/EfficientCall.sol | 10 +- .../libraries/SystemContractsCaller.sol | 22 +- .../contracts/libraries/TransactionHelper.sol | 6 + .../contracts/test-contracts/KeccakTest.sol | 80 ++--- .../contracts/test-contracts/SystemCaller.sol | 22 +- 34 files changed, 874 insertions(+), 613 deletions(-) diff --git a/.solhint.json b/.solhint.json index ac9f33d23..fd754d6af 100644 --- a/.solhint.json +++ b/.solhint.json @@ -24,6 +24,7 @@ "use-forbidden-name": "error", "visibility-modifier-order": "error", "reentrancy": "error", + "func-named-parameters": ["error", 5], "compiler-version": ["error", "^0.8.0"] } } diff --git a/l1-contracts/contracts/bridge/L1ERC20Bridge.sol b/l1-contracts/contracts/bridge/L1ERC20Bridge.sol index 90d52ca01..b9af07d6b 100644 --- a/l1-contracts/contracts/bridge/L1ERC20Bridge.sol +++ b/l1-contracts/contracts/bridge/L1ERC20Bridge.sol @@ -102,7 +102,14 @@ contract L1ERC20Bridge is IL1ERC20Bridge, ReentrancyGuard { uint256 _l2TxGasLimit, uint256 _l2TxGasPerPubdataByte ) external payable returns (bytes32 l2TxHash) { - l2TxHash = deposit(_l2Receiver, _l1Token, _amount, _l2TxGasLimit, _l2TxGasPerPubdataByte, address(0)); + l2TxHash = deposit({ + _l2Receiver: _l2Receiver, + _l1Token: _l1Token, + _amount: _amount, + _l2TxGasLimit: _l2TxGasLimit, + _l2TxGasPerPubdataByte: _l2TxGasPerPubdataByte, + _refundRecipient: address(0) + }); } /// @notice Initiates a deposit by locking funds on the contract and sending the request @@ -142,15 +149,15 @@ contract L1ERC20Bridge is IL1ERC20Bridge, ReentrancyGuard { uint256 amount = _depositFundsToSharedBridge(msg.sender, IERC20(_l1Token), _amount); require(amount == _amount, "3T"); // The token has non-standard transfer logic - l2TxHash = sharedBridge.depositLegacyErc20Bridge{value: msg.value}( - msg.sender, - _l2Receiver, - _l1Token, - _amount, - _l2TxGasLimit, - _l2TxGasPerPubdataByte, - _refundRecipient - ); + l2TxHash = sharedBridge.depositLegacyErc20Bridge{value: msg.value}({ + _msgSender: msg.sender, + _l2Receiver: _l2Receiver, + _l1Token: _l1Token, + _amount: _amount, + _l2TxGasLimit: _l2TxGasLimit, + _l2TxGasPerPubdataByte: _l2TxGasPerPubdataByte, + _refundRecipient: _refundRecipient + }); depositAmount[msg.sender][_l1Token][l2TxHash] = _amount; emit DepositInitiated(l2TxHash, msg.sender, _l2Receiver, _l1Token, _amount); } @@ -186,16 +193,16 @@ contract L1ERC20Bridge is IL1ERC20Bridge, ReentrancyGuard { require(amount != 0, "2T"); // empty deposit delete depositAmount[_depositSender][_l1Token][_l2TxHash]; - sharedBridge.claimFailedDepositLegacyErc20Bridge( - _depositSender, - _l1Token, - amount, - _l2TxHash, - _l2BatchNumber, - _l2MessageIndex, - _l2TxNumberInBatch, - _merkleProof - ); + sharedBridge.claimFailedDepositLegacyErc20Bridge({ + _depositSender: _depositSender, + _l1Token: _l1Token, + _amount: amount, + _l2TxHash: _l2TxHash, + _l2BatchNumber: _l2BatchNumber, + _l2MessageIndex: _l2MessageIndex, + _l2TxNumberInBatch: _l2TxNumberInBatch, + _merkleProof: _merkleProof + }); emit ClaimedFailedDeposit(_depositSender, _l1Token, amount); } diff --git a/l1-contracts/contracts/bridge/L1SharedBridge.sol b/l1-contracts/contracts/bridge/L1SharedBridge.sol index a05653bea..7fee105d4 100644 --- a/l1-contracts/contracts/bridge/L1SharedBridge.sol +++ b/l1-contracts/contracts/bridge/L1SharedBridge.sol @@ -182,7 +182,8 @@ contract L1SharedBridge is IL1SharedBridge, ReentrancyGuard, Initializable, Owna function bridgehubDeposit( uint256 _chainId, address _prevMsgSender, - uint256, // l2Value, needed for Weth deposits in the future + // solhint-disable-next-line no-unused-vars + uint256 _l2Value, // l2Value, needed for Weth deposits in the future bytes calldata _data ) external payable override onlyBridgehub returns (L2TransactionRequestTwoBridgesInner memory request) { require(l2BridgeAddress[_chainId] != address(0), "ShB l2 bridge not deployed"); @@ -224,7 +225,14 @@ contract L1SharedBridge is IL1SharedBridge, ReentrancyGuard, Initializable, Owna txDataHash: txDataHash }); } - emit BridgehubDepositInitiated(_chainId, txDataHash, _prevMsgSender, _l2Receiver, _l1Token, amount); + emit BridgehubDepositInitiated({ + chainId: _chainId, + txDataHash: txDataHash, + from: _prevMsgSender, + to: _l2Receiver, + l1Token: _l1Token, + amount: amount + }); } /// @notice Confirms the acceptance of a transaction by the Mailbox, as part of the L2 transaction process within Bridgehub. @@ -285,18 +293,18 @@ contract L1SharedBridge is IL1SharedBridge, ReentrancyGuard, Initializable, Owna uint16 _l2TxNumberInBatch, bytes32[] calldata _merkleProof ) external override { - _claimFailedDeposit( - false, - _chainId, - _depositSender, - _l1Token, - _amount, - _l2TxHash, - _l2BatchNumber, - _l2MessageIndex, - _l2TxNumberInBatch, - _merkleProof - ); + _claimFailedDeposit({ + _checkedInLegacyBridge: false, + _chainId: _chainId, + _depositSender: _depositSender, + _l1Token: _l1Token, + _amount: _amount, + _l2TxHash: _l2TxHash, + _l2BatchNumber: _l2BatchNumber, + _l2MessageIndex: _l2MessageIndex, + _l2TxNumberInBatch: _l2TxNumberInBatch, + _merkleProof: _merkleProof + }); } /// @dev Processes claims of failed deposit, whether they originated from the legacy bridge or the current system. @@ -313,15 +321,15 @@ contract L1SharedBridge is IL1SharedBridge, ReentrancyGuard, Initializable, Owna bytes32[] calldata _merkleProof ) internal nonReentrant { { - bool proofValid = bridgehub.proveL1ToL2TransactionStatus( - _chainId, - _l2TxHash, - _l2BatchNumber, - _l2MessageIndex, - _l2TxNumberInBatch, - _merkleProof, - TxStatus.Failure - ); + bool proofValid = bridgehub.proveL1ToL2TransactionStatus({ + _chainId: _chainId, + _l2TxHash: _l2TxHash, + _l2BatchNumber: _l2BatchNumber, + _l2MessageIndex: _l2MessageIndex, + _l2TxNumberInBatch: _l2TxNumberInBatch, + _merkleProof: _merkleProof, + _status: TxStatus.Failure + }); require(proofValid, "yn"); } require(_amount > 0, "y1"); @@ -395,7 +403,14 @@ contract L1SharedBridge is IL1SharedBridge, ReentrancyGuard, Initializable, Owna if (_isEraLegacyWithdrawal(_chainId, _l2BatchNumber)) { require(!legacyBridge.isWithdrawalFinalized(_l2BatchNumber, _l2MessageIndex), "ShB: legacy withdrawal"); } - _finalizeWithdrawal(_chainId, _l2BatchNumber, _l2MessageIndex, _l2TxNumberInBatch, _message, _merkleProof); + _finalizeWithdrawal({ + _chainId: _chainId, + _l2BatchNumber: _l2BatchNumber, + _l2MessageIndex: _l2MessageIndex, + _l2TxNumberInBatch: _l2TxNumberInBatch, + _message: _message, + _merkleProof: _merkleProof + }); } struct MessageParams { @@ -599,7 +614,14 @@ contract L1SharedBridge is IL1SharedBridge, ReentrancyGuard, Initializable, Owna // Save the deposited amount to claim funds on L1 if the deposit failed on L2 depositHappened[ERA_CHAIN_ID][l2TxHash] = txDataHash; - emit LegacyDepositInitiated(ERA_CHAIN_ID, l2TxHash, _prevMsgSender, _l2Receiver, _l1Token, _amount); + emit LegacyDepositInitiated({ + chainId: ERA_CHAIN_ID, + l2DepositTxHash: l2TxHash, + from: _prevMsgSender, + to: _l2Receiver, + l1Token: _l1Token, + amount: _amount + }); } /// @notice Finalizes the withdrawal for transactions initiated via the legacy ERC20 bridge. @@ -619,14 +641,14 @@ contract L1SharedBridge is IL1SharedBridge, ReentrancyGuard, Initializable, Owna bytes calldata _message, bytes32[] calldata _merkleProof ) external override onlyLegacyBridge returns (address l1Receiver, address l1Token, uint256 amount) { - (l1Receiver, l1Token, amount) = _finalizeWithdrawal( - ERA_CHAIN_ID, - _l2BatchNumber, - _l2MessageIndex, - _l2TxNumberInBatch, - _message, - _merkleProof - ); + (l1Receiver, l1Token, amount) = _finalizeWithdrawal({ + _chainId: ERA_CHAIN_ID, + _l2BatchNumber: _l2BatchNumber, + _l2MessageIndex: _l2MessageIndex, + _l2TxNumberInBatch: _l2TxNumberInBatch, + _message: _message, + _merkleProof: _merkleProof + }); } /// @notice Withdraw funds from the initiated deposit, that failed when finalizing on zkSync Era chain. @@ -651,17 +673,17 @@ contract L1SharedBridge is IL1SharedBridge, ReentrancyGuard, Initializable, Owna uint16 _l2TxNumberInBatch, bytes32[] calldata _merkleProof ) external override onlyLegacyBridge { - _claimFailedDeposit( - true, - ERA_CHAIN_ID, - _depositSender, - _l1Token, - _amount, - _l2TxHash, - _l2BatchNumber, - _l2MessageIndex, - _l2TxNumberInBatch, - _merkleProof - ); + _claimFailedDeposit({ + _checkedInLegacyBridge: true, + _chainId: ERA_CHAIN_ID, + _depositSender: _depositSender, + _l1Token: _l1Token, + _amount: _amount, + _l2TxHash: _l2TxHash, + _l2BatchNumber: _l2BatchNumber, + _l2MessageIndex: _l2MessageIndex, + _l2TxNumberInBatch: _l2TxNumberInBatch, + _merkleProof: _merkleProof + }); } } diff --git a/l1-contracts/contracts/bridgehub/Bridgehub.sol b/l1-contracts/contracts/bridgehub/Bridgehub.sol index ba338daad..0e19a34f1 100644 --- a/l1-contracts/contracts/bridgehub/Bridgehub.sol +++ b/l1-contracts/contracts/bridgehub/Bridgehub.sol @@ -115,7 +115,8 @@ contract Bridgehub is IBridgehub, ReentrancyGuard, Ownable2Step { uint256 _chainId, address _stateTransitionManager, address _baseToken, - uint256, //_salt + // solhint-disable-next-line no-unused-vars + uint256 _salt, address _admin, bytes calldata _initData ) external onlyOwnerOrAdmin nonReentrant returns (uint256 chainId) { @@ -184,14 +185,14 @@ contract Bridgehub is IBridgehub, ReentrancyGuard, Ownable2Step { ) external view override returns (bool) { address stateTransition = getStateTransition(_chainId); return - IZkSyncStateTransition(stateTransition).proveL1ToL2TransactionStatus( - _l2TxHash, - _l2BatchNumber, - _l2MessageIndex, - _l2TxNumberInBatch, - _merkleProof, - _status - ); + IZkSyncStateTransition(stateTransition).proveL1ToL2TransactionStatus({ + _l2TxHash: _l2TxHash, + _l2BatchNumber: _l2BatchNumber, + _l2MessageIndex: _l2MessageIndex, + _l2TxNumberInBatch: _l2TxNumberInBatch, + _merkleProof: _merkleProof, + _status: _status + }); } /// @notice forwards function call to Mailbox based on ChainId diff --git a/l1-contracts/contracts/common/libraries/L2ContractHelper.sol b/l1-contracts/contracts/common/libraries/L2ContractHelper.sol index 5f6354383..2ebfb3562 100644 --- a/l1-contracts/contracts/common/libraries/L2ContractHelper.sol +++ b/l1-contracts/contracts/common/libraries/L2ContractHelper.sol @@ -65,6 +65,7 @@ library L2ContractHelper { ) internal pure returns (address) { bytes32 senderBytes = bytes32(uint256(uint160(_sender))); bytes32 data = keccak256( + // solhint-disable-next-line func-named-parameters bytes.concat(CREATE2_PREFIX, senderBytes, _salt, _bytecodeHash, _constructorInputHash) ); diff --git a/l1-contracts/contracts/dev-contracts/test/ReenterL1ERC20Bridge.sol b/l1-contracts/contracts/dev-contracts/test/ReenterL1ERC20Bridge.sol index 819002b7b..f7afdfacc 100644 --- a/l1-contracts/contracts/dev-contracts/test/ReenterL1ERC20Bridge.sol +++ b/l1-contracts/contracts/dev-contracts/test/ReenterL1ERC20Bridge.sol @@ -32,10 +32,25 @@ contract ReenterL1ERC20Bridge { if (functionToCall == FunctionToCall.LegacyDeposit) { l1Erc20Bridge.deposit(address(0), address(0), 0, 0, 0); } else if (functionToCall == FunctionToCall.Deposit) { - l1Erc20Bridge.deposit(address(0), address(0), 0, 0, 0, address(0)); + l1Erc20Bridge.deposit({ + _l2Receiver: address(0), + _l1Token: address(0), + _amount: 0, + _l2TxGasLimit: 0, + _l2TxGasPerPubdataByte: 0, + _refundRecipient: address(0) + }); } else if (functionToCall == FunctionToCall.ClaimFailedDeposit) { bytes32[] memory merkleProof; - l1Erc20Bridge.claimFailedDeposit(address(0), address(0), bytes32(0), 0, 0, 0, merkleProof); + l1Erc20Bridge.claimFailedDeposit({ + _depositSender: address(0), + _l1Token: address(0), + _l2TxHash: bytes32(0), + _l2BatchNumber: 0, + _l2MessageIndex: 0, + _l2TxNumberInBatch: 0, + _merkleProof: merkleProof + }); } else if (functionToCall == FunctionToCall.FinalizeWithdrawal) { bytes32[] memory merkleProof; l1Erc20Bridge.finalizeWithdrawal(0, 0, 0, bytes(""), merkleProof); diff --git a/l1-contracts/contracts/state-transition/StateTransitionManager.sol b/l1-contracts/contracts/state-transition/StateTransitionManager.sol index 95987eee6..f84785c55 100644 --- a/l1-contracts/contracts/state-transition/StateTransitionManager.sol +++ b/l1-contracts/contracts/state-transition/StateTransitionManager.sol @@ -87,16 +87,17 @@ contract StateTransitionManager is IStateTransitionManager, ReentrancyGuard, Own validatorTimelock = _initializeData.validatorTimelock; // We need to initialize the state hash because it is used in the commitment of the next batch - IExecutor.StoredBatchInfo memory batchZero = IExecutor.StoredBatchInfo( - 0, - _initializeData.genesisBatchHash, - _initializeData.genesisIndexRepeatedStorageChanges, - 0, - EMPTY_STRING_KECCAK, - DEFAULT_L2_LOGS_TREE_ROOT_HASH, - 0, - _initializeData.genesisBatchCommitment - ); + IExecutor.StoredBatchInfo memory batchZero = IExecutor.StoredBatchInfo({ + batchNumber: 0, + batchHash: _initializeData.genesisBatchHash, + indexRepeatedStorageChanges: _initializeData.genesisIndexRepeatedStorageChanges, + numberOfLayer1Txs: 0, + priorityOperationsHash: EMPTY_STRING_KECCAK, + l2LogsTreeRoot: DEFAULT_L2_LOGS_TREE_ROOT_HASH, + timestamp: 0, + commitment: _initializeData.genesisBatchCommitment + }); + storedBatchZero = keccak256(abi.encode(batchZero)); initialCutHash = keccak256(abi.encode(_initializeData.diamondCut)); @@ -258,6 +259,7 @@ contract StateTransitionManager is IStateTransitionManager, ReentrancyGuard, Own // construct init data bytes memory initData; /// all together 4+9*32=292 bytes + // solhint-disable-next-line func-named-parameters initData = bytes.concat( IDiamondInit.initialize.selector, bytes32(_chainId), diff --git a/l1-contracts/contracts/state-transition/chain-deps/facets/Executor.sol b/l1-contracts/contracts/state-transition/chain-deps/facets/Executor.sol index cc7390d14..6de04f34f 100644 --- a/l1-contracts/contracts/state-transition/chain-deps/facets/Executor.sol +++ b/l1-contracts/contracts/state-transition/chain-deps/facets/Executor.sol @@ -84,16 +84,16 @@ contract ExecutorFacet is ZkSyncStateTransitionBase, IExecutor { bytes32 commitment = _createBatchCommitment(_newBatch, logOutput.stateDiffHash, blobCommitments, blobHashes); return - StoredBatchInfo( - _newBatch.batchNumber, - _newBatch.newStateRoot, - _newBatch.indexRepeatedStorageChanges, - _newBatch.numberOfLayer1Txs, - _newBatch.priorityOperationsHash, - logOutput.l2LogsTreeRoot, - _newBatch.timestamp, - commitment - ); + StoredBatchInfo({ + batchNumber: _newBatch.batchNumber, + batchHash: _newBatch.newStateRoot, + indexRepeatedStorageChanges: _newBatch.indexRepeatedStorageChanges, + numberOfLayer1Txs: _newBatch.numberOfLayer1Txs, + priorityOperationsHash: _newBatch.priorityOperationsHash, + l2LogsTreeRoot: logOutput.l2LogsTreeRoot, + timestamp: _newBatch.timestamp, + commitment: commitment + }); } /// @notice checks that the timestamps of both the new batch and the new L2 block are correct. @@ -514,6 +514,7 @@ contract ExecutorFacet is ZkSyncStateTransitionBase, IExecutor { function _batchPassThroughData(CommitBatchInfo calldata _batch) internal pure returns (bytes memory) { return + // solhint-disable-next-line func-named-parameters abi.encodePacked( _batch.indexRepeatedStorageChanges, _batch.newStateRoot, @@ -537,6 +538,7 @@ contract ExecutorFacet is ZkSyncStateTransitionBase, IExecutor { bytes32 l2ToL1LogsHash = keccak256(_batch.systemLogs); return + // solhint-disable-next-line func-named-parameters abi.encode( l2ToL1LogsHash, _stateDiffHash, diff --git a/l1-contracts/contracts/state-transition/chain-deps/facets/Mailbox.sol b/l1-contracts/contracts/state-transition/chain-deps/facets/Mailbox.sol index 749e9b8b7..813c580ef 100644 --- a/l1-contracts/contracts/state-transition/chain-deps/facets/Mailbox.sol +++ b/l1-contracts/contracts/state-transition/chain-deps/facets/Mailbox.sol @@ -108,6 +108,7 @@ contract MailboxFacet is ZkSyncStateTransitionBase, IMailbox { require(_batchNumber <= s.totalBatchesExecuted, "xx"); bytes32 hashedLog = keccak256( + // solhint-disable-next-line func-named-parameters abi.encodePacked(_log.l2ShardId, _log.isService, _log.txNumberInBatch, _log.sender, _log.key, _log.value) ); // Check that hashed log is not the default one, @@ -181,14 +182,14 @@ contract MailboxFacet is ZkSyncStateTransitionBase, IMailbox { bytes32[] calldata _merkleProof ) external nonReentrant { require(s.chainId == ERA_CHAIN_ID, "finalizeEthWithdrawal only available for Era on mailbox"); - IL1SharedBridge(s.baseTokenBridge).finalizeWithdrawal( - ERA_CHAIN_ID, - _l2BatchNumber, - _l2MessageIndex, - _l2TxNumberInBatch, - _message, - _merkleProof - ); + IL1SharedBridge(s.baseTokenBridge).finalizeWithdrawal({ + _chainId: ERA_CHAIN_ID, + _l2BatchNumber: _l2BatchNumber, + _l2MessageIndex: _l2MessageIndex, + _l2TxNumberInBatch: _l2TxNumberInBatch, + _message: _message, + _merkleProof: _merkleProof + }); } /// @inheritdoc IMailbox diff --git a/l1-contracts/test/foundry/unit/concrete/Bridgehub/_Bridgehub_Shared.t.sol b/l1-contracts/test/foundry/unit/concrete/Bridgehub/_Bridgehub_Shared.t.sol index 4fcc8d872..e35a6630b 100644 --- a/l1-contracts/test/foundry/unit/concrete/Bridgehub/_Bridgehub_Shared.t.sol +++ b/l1-contracts/test/foundry/unit/concrete/Bridgehub/_Bridgehub_Shared.t.sol @@ -24,7 +24,6 @@ contract BridgehubTest is Test { function getDiamondCutData(address diamondInit) internal pure returns (Diamond.DiamondCutData memory) { address governor = GOVERNOR; - bytes memory initCalldata = abi.encodeWithSelector(IDiamondInit.initialize.selector, governor); return diff --git a/l1-contracts/test/foundry/unit/concrete/Bridgehub/experimental_bridge.t.sol b/l1-contracts/test/foundry/unit/concrete/Bridgehub/experimental_bridge.t.sol index 91c8e95a1..22cdc4ab1 100644 --- a/l1-contracts/test/foundry/unit/concrete/Bridgehub/experimental_bridge.t.sol +++ b/l1-contracts/test/foundry/unit/concrete/Bridgehub/experimental_bridge.t.sol @@ -343,7 +343,14 @@ contract ExperimentalBridgeTest is Test { if (randomCaller != deployerAddress && randomCaller != bridgeOwner) { vm.prank(randomCaller); vm.expectRevert(bytes("Bridgehub: not owner or admin")); - bridgeHub.createNewChain(chainId, address(mockSTM), address(testToken), uint256(123), admin, bytes("")); + bridgeHub.createNewChain({ + _chainId: chainId, + _stateTransitionManager: address(mockSTM), + _baseToken: address(testToken), + _salt: uint256(123), + _admin: admin, + _initData: bytes("") + }); } chainId = bound(chainId, 1, type(uint48).max); @@ -362,6 +369,7 @@ contract ExperimentalBridgeTest is Test { vm.startPrank(deployerAddress); vm.mockCall( address(mockSTM), + // solhint-disable-next-line func-named-parameters abi.encodeWithSelector( mockSTM.createNewChain.selector, chainId, @@ -373,14 +381,15 @@ contract ExperimentalBridgeTest is Test { bytes("") ); - newChainId = bridgeHub.createNewChain( - chainId, - address(mockSTM), - address(testToken), - uint256(chainId * 2), - admin, - _newChainInitData - ); + newChainId = bridgeHub.createNewChain({ + _chainId: chainId, + _stateTransitionManager: address(mockSTM), + _baseToken: address(testToken), + _salt: uint256(chainId * 2), + _admin: admin, + _initData: _newChainInitData + }); + vm.stopPrank(); vm.clearMockedCalls(); @@ -420,6 +429,7 @@ contract ExperimentalBridgeTest is Test { // to the same function in the mailbox, we will mock the call to the mailbox to return true and see if it works. vm.mockCall( address(mockChainContract), + // solhint-disable-next-line func-named-parameters abi.encodeWithSelector( mockChainContract.proveL2MessageInclusion.selector, mockBatchNumber, @@ -453,19 +463,20 @@ contract ExperimentalBridgeTest is Test { assertTrue(bridgeHub.getStateTransition(mockChainId) == address(mockChainContract)); // Creating a random L2Log::l2Log so that we pass the correct parameters to `proveL2LogInclusion` - L2Log memory l2Log = _createMockL2Log( - randomL2ShardId, - randomIsService, - randomTxNumInBatch, - randomSender, - randomKey, - randomValue - ); + L2Log memory l2Log = _createMockL2Log({ + randomL2ShardId: randomL2ShardId, + randomIsService: randomIsService, + randomTxNumInBatch: randomTxNumInBatch, + randomSender: randomSender, + randomKey: randomKey, + randomValue: randomValue + }); // Since we have used random data for the `bridgeHub.proveL2LogInclusion` function which basically forwards the call // to the same function in the mailbox, we will mock the call to the mailbox to return true and see if it works. vm.mockCall( address(mockChainContract), + // solhint-disable-next-line func-named-parameters abi.encodeWithSelector( mockChainContract.proveL2LogInclusion.selector, mockBatchNumber, @@ -502,6 +513,7 @@ contract ExperimentalBridgeTest is Test { vm.mockCall( address(mockChainContract), + // solhint-disable-next-line func-named-parameters abi.encodeWithSelector( mockChainContract.proveL1ToL2TransactionStatus.selector, randomL2TxHash, @@ -515,15 +527,15 @@ contract ExperimentalBridgeTest is Test { ); assertTrue( - bridgeHub.proveL1ToL2TransactionStatus( - randomChainId, - randomL2TxHash, - randomL2BatchNumber, - randomL2MessageIndex, - randomL2TxNumberInBatch, - randomMerkleProof, - txStatus - ) == randomResultantBool + bridgeHub.proveL1ToL2TransactionStatus({ + _chainId: randomChainId, + _l2TxHash: randomL2TxHash, + _l2BatchNumber: randomL2BatchNumber, + _l2MessageIndex: randomL2MessageIndex, + _l2TxNumberInBatch: randomL2TxNumberInBatch, + _merkleProof: randomMerkleProof, + _status: txStatus + }) == randomResultantBool ); } @@ -538,6 +550,7 @@ contract ExperimentalBridgeTest is Test { vm.mockCall( address(mockChainContract), + // solhint-disable-next-line func-named-parameters abi.encodeWithSelector( mockChainContract.l2TransactionBaseCost.selector, mockGasPrice, @@ -570,17 +583,17 @@ contract ExperimentalBridgeTest is Test { mockFactoryDeps = _restrictArraySize(mockFactoryDeps, MAX_NEW_FACTORY_DEPS); } - L2TransactionRequestDirect memory l2TxnReqDirect = _createMockL2TransactionRequestDirect( - mockChainId, - mockMintValue, - mockL2Contract, - mockL2Value, - mockL2Calldata, - mockL2GasLimit, - mockL2GasPerPubdataByteLimit, - mockFactoryDeps, - mockRefundRecipient - ); + L2TransactionRequestDirect memory l2TxnReqDirect = _createMockL2TransactionRequestDirect({ + mockChainId: mockChainId, + mockMintValue: mockMintValue, + mockL2Contract: mockL2Contract, + mockL2Value: mockL2Value, + mockL2Calldata: mockL2Calldata, + mockL2GasLimit: mockL2GasLimit, + mockL2GasPerPubdataByteLimit: mockL2GasPerPubdataByteLimit, + mockFactoryDeps: mockFactoryDeps, + mockRefundRecipient: mockRefundRecipient + }); l2TxnReqDirect.chainId = _setUpStateTransitionForChainId(l2TxnReqDirect.chainId); @@ -632,17 +645,17 @@ contract ExperimentalBridgeTest is Test { mockFactoryDeps = _restrictArraySize(mockFactoryDeps, MAX_NEW_FACTORY_DEPS); } - L2TransactionRequestDirect memory l2TxnReqDirect = _createMockL2TransactionRequestDirect( - mockChainId, - mockMintValue, - mockL2Contract, - mockL2Value, - mockL2Calldata, - mockL2GasLimit, - mockL2GasPerPubdataByteLimit, - mockFactoryDeps, - mockRefundRecipient - ); + L2TransactionRequestDirect memory l2TxnReqDirect = _createMockL2TransactionRequestDirect({ + mockChainId: mockChainId, + mockMintValue: mockMintValue, + mockL2Contract: mockL2Contract, + mockL2Value: mockL2Value, + mockL2Calldata: mockL2Calldata, + mockL2GasLimit: mockL2GasLimit, + mockL2GasPerPubdataByteLimit: mockL2GasPerPubdataByteLimit, + mockFactoryDeps: mockFactoryDeps, + mockRefundRecipient: mockRefundRecipient + }); l2TxnReqDirect.chainId = _setUpStateTransitionForChainId(l2TxnReqDirect.chainId); @@ -696,16 +709,16 @@ contract ExperimentalBridgeTest is Test { uint256 secondBridgeValue, bytes memory secondBridgeCalldata ) public { - L2TransactionRequestTwoBridgesOuter memory l2TxnReq2BridgeOut = _createMockL2TransactionRequestTwoBridgesOuter( - chainId, - mintValue, - l2Value, - l2GasLimit, - l2GasPerPubdataByteLimit, - refundRecipient, - secondBridgeValue, - secondBridgeCalldata - ); + L2TransactionRequestTwoBridgesOuter memory l2TxnReq2BridgeOut = _createMockL2TransactionRequestTwoBridgesOuter({ + chainId: chainId, + mintValue: mintValue, + l2Value: l2Value, + l2GasLimit: l2GasLimit, + l2GasPerPubdataByteLimit: l2GasPerPubdataByteLimit, + refundRecipient: refundRecipient, + secondBridgeValue: secondBridgeValue, + secondBridgeCalldata: secondBridgeCalldata + }); l2TxnReq2BridgeOut.chainId = _setUpStateTransitionForChainId(l2TxnReq2BridgeOut.chainId); @@ -872,7 +885,8 @@ contract ExperimentalBridgeTest is Test { uint256 mockL2Value, bytes memory mockL2Calldata, uint256 mockL2GasLimit, - uint256, //mockL2GasPerPubdataByteLimit, + // solhint-disable-next-line no-unused-vars + uint256 mockL2GasPerPubdataByteLimit, bytes[] memory mockFactoryDeps, address mockRefundRecipient ) internal pure returns (L2TransactionRequestDirect memory) { @@ -940,6 +954,7 @@ contract ExperimentalBridgeTest is Test { vm.mockCall( address(bridgeHub), + // solhint-disable-next-line func-named-parameters abi.encodeWithSelector( bridgeHub.proveL2MessageInclusion.selector, mockChainId, @@ -970,17 +985,18 @@ contract ExperimentalBridgeTest is Test { bridgeHub.addStateTransitionManager(address(mockSTM)); vm.stopPrank(); - L2Log memory l2Log = _createMockL2Log( - randomL2ShardId, - randomIsService, - randomTxNumInBatch, - randomSender, - randomKey, - randomValue - ); + L2Log memory l2Log = _createMockL2Log({ + randomL2ShardId: randomL2ShardId, + randomIsService: randomIsService, + randomTxNumInBatch: randomTxNumInBatch, + randomSender: randomSender, + randomKey: randomKey, + randomValue: randomValue + }); vm.mockCall( address(bridgeHub), + // solhint-disable-next-line func-named-parameters abi.encodeWithSelector( bridgeHub.proveL2LogInclusion.selector, mockChainId, @@ -1018,6 +1034,7 @@ contract ExperimentalBridgeTest is Test { vm.mockCall( address(bridgeHub), + // solhint-disable-next-line func-named-parameters abi.encodeWithSelector( bridgeHub.proveL1ToL2TransactionStatus.selector, randomChainId, @@ -1032,15 +1049,15 @@ contract ExperimentalBridgeTest is Test { ); assertTrue( - bridgeHub.proveL1ToL2TransactionStatus( - randomChainId, - randomL2TxHash, - randomL2BatchNumber, - randomL2MessageIndex, - randomL2TxNumberInBatch, - randomMerkleProof, - txStatus - ) == randomResultantBool + bridgeHub.proveL1ToL2TransactionStatus({ + _chainId: randomChainId, + _l2TxHash: randomL2TxHash, + _l2BatchNumber: randomL2BatchNumber, + _l2MessageIndex: randomL2MessageIndex, + _l2TxNumberInBatch: randomL2TxNumberInBatch, + _merkleProof: randomMerkleProof, + _status: txStatus + }) == randomResultantBool ); } } diff --git a/l1-contracts/test/foundry/unit/concrete/Bridges/L1Erc20Bridge/ClaimFailedDeposit.t.sol b/l1-contracts/test/foundry/unit/concrete/Bridges/L1Erc20Bridge/ClaimFailedDeposit.t.sol index 3dff333c5..18dcbed65 100644 --- a/l1-contracts/test/foundry/unit/concrete/Bridges/L1Erc20Bridge/ClaimFailedDeposit.t.sol +++ b/l1-contracts/test/foundry/unit/concrete/Bridges/L1Erc20Bridge/ClaimFailedDeposit.t.sol @@ -13,7 +13,16 @@ contract ClaimFailedDepositTest is L1Erc20BridgeTest { function test_RevertWhen_ClaimAmountIsZero() public { vm.expectRevert(bytes("2T")); bytes32[] memory merkleProof; - bridge.claimFailedDeposit(randomSigner, address(token), dummyL2DepositTxHash, 0, 0, 0, merkleProof); + + bridge.claimFailedDeposit({ + _depositSender: randomSigner, + _l1Token: address(token), + _l2TxHash: dummyL2DepositTxHash, + _l2BatchNumber: 0, + _l2MessageIndex: 0, + _l2TxNumberInBatch: 0, + _merkleProof: merkleProof + }); } function test_claimFailedDepositSuccessfully() public { @@ -36,7 +45,15 @@ contract ClaimFailedDepositTest is L1Erc20BridgeTest { vm.expectEmit(true, true, true, true, address(bridge)); emit ClaimedFailedDeposit(alice, address(token), amount); bytes32[] memory merkleProof; - bridge.claimFailedDeposit(alice, address(token), dummyL2DepositTxHash, 0, 0, 0, merkleProof); + bridge.claimFailedDeposit({ + _depositSender: alice, + _l1Token: address(token), + _l2TxHash: dummyL2DepositTxHash, + _l2BatchNumber: 0, + _l2MessageIndex: 0, + _l2TxNumberInBatch: 0, + _merkleProof: merkleProof + }); uint256 depositedAmountAfterWithdrawal = bridge.depositAmount(alice, address(token), dummyL2DepositTxHash); assertEq(depositedAmountAfterWithdrawal, 0); diff --git a/l1-contracts/test/foundry/unit/concrete/Bridges/L1Erc20Bridge/Deposit.t.sol b/l1-contracts/test/foundry/unit/concrete/Bridges/L1Erc20Bridge/Deposit.t.sol index 941e224bb..fb4860904 100644 --- a/l1-contracts/test/foundry/unit/concrete/Bridges/L1Erc20Bridge/Deposit.t.sol +++ b/l1-contracts/test/foundry/unit/concrete/Bridges/L1Erc20Bridge/Deposit.t.sol @@ -15,7 +15,14 @@ contract DepositTest is L1Erc20BridgeTest { function test_RevertWhen_depositAmountIsZero() public { vm.expectRevert(bytes("0T")); - bridge.deposit(randomSigner, address(token), 0, 0, 0, address(0)); + bridge.deposit({ + _l2Receiver: randomSigner, + _l1Token: address(token), + _l2TxGasLimit: 0, + _l2TxGasPerPubdataByte: 0, + _amount: 0, + _refundRecipient: address(0) + }); } function test_RevertWhen_legacyDepositAmountIsZero() public { @@ -68,7 +75,14 @@ contract DepositTest is L1Erc20BridgeTest { vm.prank(alice); vm.expectEmit(true, true, true, true, address(bridge)); emit DepositInitiated(dummyL2DepositTxHash, alice, randomSigner, address(token), amount); - bytes32 txHash = bridge.deposit(randomSigner, address(token), amount, 0, 0, address(0)); + bytes32 txHash = bridge.deposit({ + _l2Receiver: randomSigner, + _l1Token: address(token), + _amount: amount, + _l2TxGasLimit: 0, + _l2TxGasPerPubdataByte: 0, + _refundRecipient: address(0) + }); assertEq(txHash, dummyL2DepositTxHash); uint256 depositedAmount = bridge.depositAmount(alice, address(token), dummyL2DepositTxHash); diff --git a/l1-contracts/test/foundry/unit/concrete/Bridges/L1Erc20Bridge/Reentrancy.t.sol b/l1-contracts/test/foundry/unit/concrete/Bridges/L1Erc20Bridge/Reentrancy.t.sol index 2fcb7e428..b9d8fd9d8 100644 --- a/l1-contracts/test/foundry/unit/concrete/Bridges/L1Erc20Bridge/Reentrancy.t.sol +++ b/l1-contracts/test/foundry/unit/concrete/Bridges/L1Erc20Bridge/Reentrancy.t.sol @@ -16,7 +16,14 @@ contract ReentrancyTest is L1Erc20BridgeTest { vm.prank(alice); vm.expectRevert(bytes("r1")); - bridgeReenterItself.deposit(randomSigner, address(token), amount, 0, 0, address(0)); + bridgeReenterItself.deposit({ + _l2Receiver: randomSigner, + _l1Token: address(token), + _amount: amount, + _l2TxGasLimit: 0, + _l2TxGasPerPubdataByte: 0, + _refundRecipient: address(0) + }); } function _legacyDepositExpectRevertOnReentrancy() internal { @@ -42,7 +49,15 @@ contract ReentrancyTest is L1Erc20BridgeTest { vm.prank(alice); bytes32[] memory merkleProof; vm.expectRevert(bytes("r1")); - bridgeReenterItself.claimFailedDeposit(alice, address(token), dummyL2DepositTxHash, 0, 0, 0, merkleProof); + bridgeReenterItself.claimFailedDeposit({ + _depositSender: alice, + _l1Token: address(token), + _l2TxHash: dummyL2DepositTxHash, + _l2BatchNumber: 0, + _l2MessageIndex: 0, + _l2TxNumberInBatch: 0, + _merkleProof: merkleProof + }); } function _finalizeWithdrawalExpectRevertOnReentrancy() internal { diff --git a/l1-contracts/test/foundry/unit/concrete/Bridges/L1SharedBridge/L1SharedBridge.t.sol b/l1-contracts/test/foundry/unit/concrete/Bridges/L1SharedBridge/L1SharedBridge.t.sol index 030432dac..b282b449b 100644 --- a/l1-contracts/test/foundry/unit/concrete/Bridges/L1SharedBridge/L1SharedBridge.t.sol +++ b/l1-contracts/test/foundry/unit/concrete/Bridges/L1SharedBridge/L1SharedBridge.t.sol @@ -156,7 +156,14 @@ contract L1SharedBridgeTest is Test { ); bytes32 txDataHash = keccak256(abi.encode(alice, ETH_TOKEN_ADDRESS, amount)); vm.expectEmit(true, true, true, true, address(sharedBridge)); - emit BridgehubDepositInitiated(chainId, txDataHash, alice, zkSync, ETH_TOKEN_ADDRESS, amount); + emit BridgehubDepositInitiated({ + chainId: chainId, + txDataHash: txDataHash, + from: alice, + to: zkSync, + l1Token: ETH_TOKEN_ADDRESS, + amount: amount + }); sharedBridge.bridgehubDeposit{value: amount}(chainId, alice, 0, abi.encode(ETH_TOKEN_ADDRESS, 0, bob)); } @@ -172,7 +179,14 @@ contract L1SharedBridgeTest is Test { abi.encode(ETH_TOKEN_ADDRESS) ); bytes32 txDataHash = keccak256(abi.encode(alice, address(token), amount)); - emit BridgehubDepositInitiated(chainId, txDataHash, alice, zkSync, address(token), amount); + emit BridgehubDepositInitiated({ + chainId: chainId, + txDataHash: txDataHash, + from: alice, + to: zkSync, + l1Token: address(token), + amount: amount + }); sharedBridge.bridgehubDeposit(chainId, alice, 0, abi.encode(address(token), amount, bob)); } @@ -186,7 +200,6 @@ contract L1SharedBridgeTest is Test { function test_claimFailedDeposit_Erc() public { token.mint(address(sharedBridge), amount); - bytes32 txDataHash = keccak256(abi.encode(alice, address(token), amount)); vm.store( address(sharedBridge), @@ -208,6 +221,7 @@ contract L1SharedBridgeTest is Test { vm.mockCall( bridgehubAddress, + // solhint-disable-next-line func-named-parameters abi.encodeWithSelector( IBridgehub.proveL1ToL2TransactionStatus.selector, chainId, @@ -222,18 +236,18 @@ contract L1SharedBridgeTest is Test { ); vm.expectEmit(true, true, true, true, address(sharedBridge)); - emit ClaimedFailedDepositSharedBridge(chainId, alice, address(token), amount); - sharedBridge.claimFailedDeposit( - chainId, - alice, - address(token), - amount, - txHash, - l2BatchNumber, - l2MessageIndex, - l2TxNumberInBatch, - merkleProof - ); + emit ClaimedFailedDepositSharedBridge({chainId: chainId, to: alice, l1Token: address(token), amount: amount}); + sharedBridge.claimFailedDeposit({ + _chainId: chainId, + _depositSender: alice, + _l1Token: address(token), + _amount: amount, + _l2TxHash: txHash, + _l2BatchNumber: l2BatchNumber, + _l2MessageIndex: l2MessageIndex, + _l2TxNumberInBatch: l2TxNumberInBatch, + _merkleProof: merkleProof + }); } function test_claimFailedDeposit_Eth() public { @@ -260,6 +274,7 @@ contract L1SharedBridgeTest is Test { vm.mockCall( bridgehubAddress, + // solhint-disable-next-line func-named-parameters abi.encodeWithSelector( IBridgehub.proveL1ToL2TransactionStatus.selector, chainId, @@ -274,18 +289,23 @@ contract L1SharedBridgeTest is Test { ); vm.expectEmit(true, true, true, true, address(sharedBridge)); - emit ClaimedFailedDepositSharedBridge(chainId, alice, ETH_TOKEN_ADDRESS, amount); - sharedBridge.claimFailedDeposit( - chainId, - alice, - ETH_TOKEN_ADDRESS, - amount, - txHash, - l2BatchNumber, - l2MessageIndex, - l2TxNumberInBatch, - merkleProof - ); + emit ClaimedFailedDepositSharedBridge({ + chainId: chainId, + to: alice, + l1Token: ETH_TOKEN_ADDRESS, + amount: amount + }); + sharedBridge.claimFailedDeposit({ + _chainId: chainId, + _depositSender: alice, + _l1Token: ETH_TOKEN_ADDRESS, + _amount: amount, + _l2TxHash: txHash, + _l2BatchNumber: l2BatchNumber, + _l2MessageIndex: l2MessageIndex, + _l2TxNumberInBatch: l2TxNumberInBatch, + _merkleProof: merkleProof + }); } function test_finalizeWithdrawal_EthOnEth() public { @@ -316,6 +336,7 @@ contract L1SharedBridgeTest is Test { vm.mockCall( bridgehubAddress, + // solhint-disable-next-line func-named-parameters abi.encodeWithSelector( IBridgehub.proveL2MessageInclusion.selector, chainId, @@ -329,14 +350,14 @@ contract L1SharedBridgeTest is Test { vm.expectEmit(true, true, true, true, address(sharedBridge)); emit WithdrawalFinalizedSharedBridge(chainId, alice, ETH_TOKEN_ADDRESS, amount); - sharedBridge.finalizeWithdrawal( - chainId, - l2BatchNumber, - l2MessageIndex, - l2TxNumberInBatch, - message, - merkleProof - ); + sharedBridge.finalizeWithdrawal({ + _chainId: chainId, + _l2BatchNumber: l2BatchNumber, + _l2MessageIndex: l2MessageIndex, + _l2TxNumberInBatch: l2TxNumberInBatch, + _message: message, + _merkleProof: merkleProof + }); } function test_finalizeWithdrawal_ErcOnEth() public { @@ -372,6 +393,7 @@ contract L1SharedBridgeTest is Test { vm.mockCall( bridgehubAddress, + // solhint-disable-next-line func-named-parameters abi.encodeWithSelector( IBridgehub.proveL2MessageInclusion.selector, chainId, @@ -385,14 +407,14 @@ contract L1SharedBridgeTest is Test { vm.expectEmit(true, true, true, true, address(sharedBridge)); emit WithdrawalFinalizedSharedBridge(chainId, alice, address(token), amount); - sharedBridge.finalizeWithdrawal( - chainId, - l2BatchNumber, - l2MessageIndex, - l2TxNumberInBatch, - message, - merkleProof - ); + sharedBridge.finalizeWithdrawal({ + _chainId: chainId, + _l2BatchNumber: l2BatchNumber, + _l2MessageIndex: l2MessageIndex, + _l2TxNumberInBatch: l2TxNumberInBatch, + _message: message, + _merkleProof: merkleProof + }); } function test_finalizeWithdrawal_EthOnErc() public { @@ -428,6 +450,7 @@ contract L1SharedBridgeTest is Test { vm.mockCall( bridgehubAddress, + // solhint-disable-next-line func-named-parameters abi.encodeWithSelector( IBridgehub.proveL2MessageInclusion.selector, chainId, @@ -441,14 +464,14 @@ contract L1SharedBridgeTest is Test { vm.expectEmit(true, true, true, true, address(sharedBridge)); emit WithdrawalFinalizedSharedBridge(chainId, alice, ETH_TOKEN_ADDRESS, amount); - sharedBridge.finalizeWithdrawal( - chainId, - l2BatchNumber, - l2MessageIndex, - l2TxNumberInBatch, - message, - merkleProof - ); + sharedBridge.finalizeWithdrawal({ + _chainId: chainId, + _l2BatchNumber: l2BatchNumber, + _l2MessageIndex: l2MessageIndex, + _l2TxNumberInBatch: l2TxNumberInBatch, + _message: message, + _merkleProof: merkleProof + }); } function test_finalizeWithdrawal_BaseErcOnErc() public { @@ -484,6 +507,7 @@ contract L1SharedBridgeTest is Test { vm.mockCall( bridgehubAddress, + // solhint-disable-next-line func-named-parameters abi.encodeWithSelector( IBridgehub.proveL2MessageInclusion.selector, chainId, @@ -497,14 +521,14 @@ contract L1SharedBridgeTest is Test { vm.expectEmit(true, true, true, true, address(sharedBridge)); emit WithdrawalFinalizedSharedBridge(chainId, alice, address(token), amount); - sharedBridge.finalizeWithdrawal( - chainId, - l2BatchNumber, - l2MessageIndex, - l2TxNumberInBatch, - message, - merkleProof - ); + sharedBridge.finalizeWithdrawal({ + _chainId: chainId, + _l2BatchNumber: l2BatchNumber, + _l2MessageIndex: l2MessageIndex, + _l2TxNumberInBatch: l2TxNumberInBatch, + _message: message, + _merkleProof: merkleProof + }); } function test_finalizeWithdrawal_NonBaseErcOnErc() public { @@ -536,6 +560,7 @@ contract L1SharedBridgeTest is Test { vm.mockCall( bridgehubAddress, + // solhint-disable-next-line func-named-parameters abi.encodeWithSelector( IBridgehub.proveL2MessageInclusion.selector, chainId, @@ -549,14 +574,14 @@ contract L1SharedBridgeTest is Test { vm.expectEmit(true, true, true, true, address(sharedBridge)); emit WithdrawalFinalizedSharedBridge(chainId, alice, address(token), amount); - sharedBridge.finalizeWithdrawal( - chainId, - l2BatchNumber, - l2MessageIndex, - l2TxNumberInBatch, - message, - merkleProof - ); + sharedBridge.finalizeWithdrawal({ + _chainId: chainId, + _l2BatchNumber: l2BatchNumber, + _l2MessageIndex: l2MessageIndex, + _l2TxNumberInBatch: l2TxNumberInBatch, + _message: message, + _merkleProof: merkleProof + }); } function test_finalizeWithdrawal_EthOnEth_LegacyTx() public { @@ -600,6 +625,7 @@ contract L1SharedBridgeTest is Test { vm.mockCall( bridgehubAddress, + // solhint-disable-next-line func-named-parameters abi.encodeWithSelector( IBridgehub.proveL2MessageInclusion.selector, ERA_CHAIN_ID, @@ -613,13 +639,13 @@ contract L1SharedBridgeTest is Test { vm.expectEmit(true, true, true, true, address(sharedBridge)); emit WithdrawalFinalizedSharedBridge(ERA_CHAIN_ID, alice, ETH_TOKEN_ADDRESS, amount); - sharedBridge.finalizeWithdrawal( - ERA_CHAIN_ID, - legacyBatchNumber, - l2MessageIndex, - l2TxNumberInBatch, - message, - merkleProof - ); + sharedBridge.finalizeWithdrawal({ + _chainId: ERA_CHAIN_ID, + _l2BatchNumber: legacyBatchNumber, + _l2MessageIndex: l2MessageIndex, + _l2TxNumberInBatch: l2TxNumberInBatch, + _message: message, + _merkleProof: merkleProof + }); } } diff --git a/l1-contracts/test/foundry/unit/concrete/Bridges/L1SharedBridge/L1SharedBridgeFails.t.sol b/l1-contracts/test/foundry/unit/concrete/Bridges/L1SharedBridge/L1SharedBridgeFails.t.sol index 4e0edc474..299dc2a51 100644 --- a/l1-contracts/test/foundry/unit/concrete/Bridges/L1SharedBridge/L1SharedBridgeFails.t.sol +++ b/l1-contracts/test/foundry/unit/concrete/Bridges/L1SharedBridge/L1SharedBridgeFails.t.sol @@ -137,6 +137,7 @@ contract L1SharedBridgeFailTest is Test { new TransparentUpgradeableProxy( address(sharedBridgeImpl), admin, + // solhint-disable-next-line func-named-parameters abi.encodeWithSelector(L1SharedBridge.initialize.selector, address(0), eraFirstPostUpgradeBatch) ); } @@ -182,12 +183,14 @@ contract L1SharedBridgeFailTest is Test { abi.encode(address(token)) ); vm.expectRevert("ShB l2 bridge not deployed"); + // solhint-disable-next-line func-named-parameters sharedBridge.bridgehubDeposit{value: amount}(chainId, alice, 0, abi.encode(ETH_TOKEN_ADDRESS, 0, bob)); } function test_bridgehubDeposit_Erc_weth() public { vm.prank(bridgehubAddress); vm.expectRevert("ShB: WETH deposit not supported"); + // solhint-disable-next-line func-named-parameters sharedBridge.bridgehubDeposit(chainId, alice, 0, abi.encode(l1WethAddress, amount, bob)); } @@ -199,6 +202,7 @@ contract L1SharedBridgeFailTest is Test { abi.encode(ETH_TOKEN_ADDRESS) ); vm.expectRevert("ShB: baseToken deposit not supported"); + // solhint-disable-next-line func-named-parameters sharedBridge.bridgehubDeposit(chainId, alice, 0, abi.encode(ETH_TOKEN_ADDRESS, 0, bob)); } @@ -213,6 +217,7 @@ contract L1SharedBridgeFailTest is Test { abi.encode(address(token)) ); vm.expectRevert("ShB wrong withdraw amount"); + // solhint-disable-next-line func-named-parameters sharedBridge.bridgehubDeposit(chainId, alice, 0, abi.encode(ETH_TOKEN_ADDRESS, amount, bob)); } @@ -228,6 +233,7 @@ contract L1SharedBridgeFailTest is Test { abi.encode(ETH_TOKEN_ADDRESS) ); vm.expectRevert("ShB m.v > 0 for BH d.it 2"); + // solhint-disable-next-line func-named-parameters sharedBridge.bridgehubDeposit{value: amount}(chainId, alice, 0, abi.encode(address(token), amount, bob)); } @@ -244,6 +250,7 @@ contract L1SharedBridgeFailTest is Test { vm.mockCall(address(token), abi.encodeWithSelector(IERC20.balanceOf.selector), abi.encode(10)); bytes memory message = bytes("5T"); vm.expectRevert(message); + // solhint-disable-next-line func-named-parameters sharedBridge.bridgehubDeposit(chainId, alice, 0, abi.encode(address(token), amount, bob)); } @@ -256,6 +263,7 @@ contract L1SharedBridgeFailTest is Test { ); bytes memory message = bytes("6T"); vm.expectRevert(message); + // solhint-disable-next-line func-named-parameters sharedBridge.bridgehubDeposit(chainId, alice, 0, abi.encode(ETH_TOKEN_ADDRESS, 0, bob)); } @@ -280,17 +288,17 @@ contract L1SharedBridgeFailTest is Test { vm.prank(bridgehubAddress); bytes memory message = bytes("yn"); vm.expectRevert(message); - sharedBridge.claimFailedDeposit( - chainId, - alice, - ETH_TOKEN_ADDRESS, - amount, - txHash, - l2BatchNumber, - l2MessageIndex, - l2TxNumberInBatch, - merkleProof - ); + sharedBridge.claimFailedDeposit({ + _chainId: chainId, + _depositSender: alice, + _l1Token: ETH_TOKEN_ADDRESS, + _amount: amount, + _l2TxHash: txHash, + _l2BatchNumber: l2BatchNumber, + _l2MessageIndex: l2MessageIndex, + _l2TxNumberInBatch: l2TxNumberInBatch, + _merkleProof: merkleProof + }); } function test_claimFailedDeposit_amountZero() public { @@ -298,6 +306,7 @@ contract L1SharedBridgeFailTest is Test { vm.mockCall( bridgehubAddress, + // solhint-disable-next-line func-named-parameters abi.encodeWithSelector( IBridgehub.proveL1ToL2TransactionStatus.selector, chainId, @@ -313,17 +322,17 @@ contract L1SharedBridgeFailTest is Test { bytes memory message = bytes("y1"); vm.expectRevert(message); - sharedBridge.claimFailedDeposit( - chainId, - alice, - ETH_TOKEN_ADDRESS, - 0, - txHash, - l2BatchNumber, - l2MessageIndex, - l2TxNumberInBatch, - merkleProof - ); + sharedBridge.claimFailedDeposit({ + _chainId: chainId, + _depositSender: alice, + _l1Token: ETH_TOKEN_ADDRESS, + _amount: 0, + _l2TxHash: txHash, + _l2BatchNumber: l2BatchNumber, + _l2MessageIndex: l2MessageIndex, + _l2TxNumberInBatch: l2TxNumberInBatch, + _merkleProof: merkleProof + }); } function test_claimFailedDeposit_depositDidNotHappen() public { @@ -331,6 +340,7 @@ contract L1SharedBridgeFailTest is Test { vm.mockCall( bridgehubAddress, + // solhint-disable-next-line func-named-parameters abi.encodeWithSelector( IBridgehub.proveL1ToL2TransactionStatus.selector, chainId, @@ -345,17 +355,17 @@ contract L1SharedBridgeFailTest is Test { ); vm.expectRevert("ShB: d.it not hap"); - sharedBridge.claimFailedDeposit( - chainId, - alice, - ETH_TOKEN_ADDRESS, - amount, - txHash, - l2BatchNumber, - l2MessageIndex, - l2TxNumberInBatch, - merkleProof - ); + sharedBridge.claimFailedDeposit({ + _chainId: chainId, + _depositSender: alice, + _l1Token: ETH_TOKEN_ADDRESS, + _amount: amount, + _l2TxHash: txHash, + _l2BatchNumber: l2BatchNumber, + _l2MessageIndex: l2MessageIndex, + _l2TxNumberInBatch: l2TxNumberInBatch, + _merkleProof: merkleProof + }); } function test_claimFailedDeposit_chainBalanceLow() public { @@ -371,6 +381,7 @@ contract L1SharedBridgeFailTest is Test { vm.mockCall( bridgehubAddress, + // solhint-disable-next-line func-named-parameters abi.encodeWithSelector( IBridgehub.proveL1ToL2TransactionStatus.selector, chainId, @@ -385,17 +396,17 @@ contract L1SharedBridgeFailTest is Test { ); vm.expectRevert("ShB n funds"); - sharedBridge.claimFailedDeposit( - chainId, - alice, - ETH_TOKEN_ADDRESS, - amount, - txHash, - l2BatchNumber, - l2MessageIndex, - l2TxNumberInBatch, - merkleProof - ); + sharedBridge.claimFailedDeposit({ + _chainId: chainId, + _depositSender: alice, + _l1Token: ETH_TOKEN_ADDRESS, + _amount: amount, + _l2TxHash: txHash, + _l2BatchNumber: l2BatchNumber, + _l2MessageIndex: l2MessageIndex, + _l2TxNumberInBatch: l2TxNumberInBatch, + _merkleProof: merkleProof + }); } // forge messes up low level calls @@ -471,14 +482,14 @@ contract L1SharedBridgeFailTest is Test { ); vm.expectRevert("ShB: legacy withdrawal"); - sharedBridge.finalizeWithdrawal( - ERA_CHAIN_ID, - legacyBatchNumber, - l2MessageIndex, - l2TxNumberInBatch, - message, - merkleProof - ); + sharedBridge.finalizeWithdrawal({ + _chainId: ERA_CHAIN_ID, + _l2BatchNumber: legacyBatchNumber, + _l2MessageIndex: l2MessageIndex, + _l2TxNumberInBatch: l2TxNumberInBatch, + _message: message, + _merkleProof: merkleProof + }); } function test_finalizeWithdrawal_EthOnEth_LegacyTxFinalizedInSharedBridge() public { @@ -515,14 +526,14 @@ contract L1SharedBridgeFailTest is Test { ); vm.expectRevert("Withdrawal is already finalized"); - sharedBridge.finalizeWithdrawal( - ERA_CHAIN_ID, - legacyBatchNumber, - l2MessageIndex, - l2TxNumberInBatch, - message, - merkleProof - ); + sharedBridge.finalizeWithdrawal({ + _chainId: ERA_CHAIN_ID, + _l2BatchNumber: legacyBatchNumber, + _l2MessageIndex: l2MessageIndex, + _l2TxNumberInBatch: l2TxNumberInBatch, + _message: message, + _merkleProof: merkleProof + }); } function test_finalizeWithdrawal_EthOnEth_LegacyTxFinalizedInDiamondProxy() public { @@ -549,14 +560,14 @@ contract L1SharedBridgeFailTest is Test { ); vm.expectRevert("Withdrawal is already finalized 2"); - sharedBridge.finalizeWithdrawal( - ERA_CHAIN_ID, - legacyBatchNumber, - l2MessageIndex, - l2TxNumberInBatch, - message, - merkleProof - ); + sharedBridge.finalizeWithdrawal({ + _chainId: ERA_CHAIN_ID, + _l2BatchNumber: legacyBatchNumber, + _l2MessageIndex: l2MessageIndex, + _l2TxNumberInBatch: l2TxNumberInBatch, + _message: message, + _merkleProof: merkleProof + }); } function test_finalizeWithdrawal_chainBalance() public { @@ -577,6 +588,7 @@ contract L1SharedBridgeFailTest is Test { vm.mockCall( bridgehubAddress, + // solhint-disable-next-line func-named-parameters abi.encodeWithSelector( IBridgehub.proveL2MessageInclusion.selector, chainId, @@ -590,14 +602,14 @@ contract L1SharedBridgeFailTest is Test { vm.expectRevert("ShB not enough funds 2"); - sharedBridge.finalizeWithdrawal( - chainId, - l2BatchNumber, - l2MessageIndex, - l2TxNumberInBatch, - message, - merkleProof - ); + sharedBridge.finalizeWithdrawal({ + _chainId: chainId, + _l2BatchNumber: l2BatchNumber, + _l2MessageIndex: l2MessageIndex, + _l2TxNumberInBatch: l2TxNumberInBatch, + _message: message, + _merkleProof: merkleProof + }); } function test_checkWithdrawal_wrongProof() public { @@ -618,6 +630,7 @@ contract L1SharedBridgeFailTest is Test { vm.mockCall( bridgehubAddress, + // solhint-disable-next-line func-named-parameters abi.encodeWithSelector( IBridgehub.proveL2MessageInclusion.selector, chainId, @@ -631,14 +644,14 @@ contract L1SharedBridgeFailTest is Test { vm.expectRevert("ShB withd w proof"); - sharedBridge.finalizeWithdrawal( - chainId, - l2BatchNumber, - l2MessageIndex, - l2TxNumberInBatch, - message, - merkleProof - ); + sharedBridge.finalizeWithdrawal({ + _chainId: chainId, + _l2BatchNumber: l2BatchNumber, + _l2MessageIndex: l2MessageIndex, + _l2TxNumberInBatch: l2TxNumberInBatch, + _message: message, + _merkleProof: merkleProof + }); } function test_parseL2WithdrawalMessage_WrongMsgLength() public { @@ -653,14 +666,14 @@ contract L1SharedBridgeFailTest is Test { bytes memory message = abi.encodePacked(IMailbox.finalizeEthWithdrawal.selector); vm.expectRevert("ShB wrong msg len"); - sharedBridge.finalizeWithdrawal( - chainId, - l2BatchNumber, - l2MessageIndex, - l2TxNumberInBatch, - message, - merkleProof - ); + sharedBridge.finalizeWithdrawal({ + _chainId: chainId, + _l2BatchNumber: l2BatchNumber, + _l2MessageIndex: l2MessageIndex, + _l2TxNumberInBatch: l2TxNumberInBatch, + _message: message, + _merkleProof: merkleProof + }); } function test_parseL2WithdrawalMessage_WrongMsgLength2() public { @@ -675,14 +688,15 @@ contract L1SharedBridgeFailTest is Test { bytes memory message = abi.encodePacked(IL1ERC20Bridge.finalizeWithdrawal.selector, alice, amount); /// should have more data here vm.expectRevert("ShB wrong msg len 2"); - sharedBridge.finalizeWithdrawal( - chainId, - l2BatchNumber, - l2MessageIndex, - l2TxNumberInBatch, - message, - merkleProof - ); + + sharedBridge.finalizeWithdrawal({ + _chainId: ERA_CHAIN_ID, + _l2BatchNumber: l2BatchNumber, + _l2MessageIndex: l2MessageIndex, + _l2TxNumberInBatch: l2TxNumberInBatch, + _message: message, + _merkleProof: merkleProof + }); } function test_parseL2WithdrawalMessage_WrongSelector() public { @@ -698,14 +712,14 @@ contract L1SharedBridgeFailTest is Test { bytes memory message = abi.encodePacked(IMailbox.proveL2LogInclusion.selector, alice, amount); vm.expectRevert("ShB Incorrect message function selector"); - sharedBridge.finalizeWithdrawal( - chainId, - l2BatchNumber, - l2MessageIndex, - l2TxNumberInBatch, - message, - merkleProof - ); + sharedBridge.finalizeWithdrawal({ + _chainId: ERA_CHAIN_ID, + _l2BatchNumber: l2BatchNumber, + _l2MessageIndex: l2MessageIndex, + _l2TxNumberInBatch: l2TxNumberInBatch, + _message: message, + _merkleProof: merkleProof + }); } function test_depositLegacyERC20Bridge_l2BridgeNotDeployed() public { @@ -718,15 +732,15 @@ contract L1SharedBridgeFailTest is Test { vm.expectRevert("ShB b. n dep"); vm.prank(l1ERC20BridgeAddress); - sharedBridge.depositLegacyErc20Bridge( - alice, - bob, - address(token), - amount, - l2TxGasLimit, - l2TxGasPerPubdataByte, - refundRecipient - ); + sharedBridge.depositLegacyErc20Bridge({ + _prevMsgSender: alice, + _l2Receiver: bob, + _l1Token: address(token), + _amount: amount, + _l2TxGasLimit: l2TxGasLimit, + _l2TxGasPerPubdataByte: l2TxGasPerPubdataByte, + _refundRecipient: refundRecipient + }); } function test_depositLegacyERC20Bridge_weth() public { @@ -736,15 +750,15 @@ contract L1SharedBridgeFailTest is Test { vm.expectRevert("ShB: WETH deposit not supported 2"); vm.prank(l1ERC20BridgeAddress); - sharedBridge.depositLegacyErc20Bridge( - alice, - bob, - l1WethAddress, - amount, - l2TxGasLimit, - l2TxGasPerPubdataByte, - refundRecipient - ); + sharedBridge.depositLegacyErc20Bridge({ + _prevMsgSender: alice, + _l2Receiver: bob, + _l1Token: l1WethAddress, + _amount: amount, + _l2TxGasLimit: l2TxGasLimit, + _l2TxGasPerPubdataByte: l2TxGasPerPubdataByte, + _refundRecipient: refundRecipient + }); } function test_depositLegacyERC20Bridge_refundRecipient() public { @@ -752,7 +766,15 @@ contract L1SharedBridgeFailTest is Test { uint256 l2TxGasPerPubdataByte = 100; vm.expectEmit(true, true, true, true, address(sharedBridge)); - emit LegacyDepositInitiated(ERA_CHAIN_ID, txHash, alice, bob, address(token), amount); + + emit LegacyDepositInitiated({ + chainId: ERA_CHAIN_ID, + l2DepositTxHash: txHash, + from: alice, + to: bob, + l1Token: address(token), + amount: amount + }); vm.mockCall( bridgehubAddress, @@ -761,14 +783,14 @@ contract L1SharedBridgeFailTest is Test { ); vm.prank(l1ERC20BridgeAddress); - sharedBridge.depositLegacyErc20Bridge( - alice, - bob, - address(token), - amount, - l2TxGasLimit, - l2TxGasPerPubdataByte, - address(1) - ); + sharedBridge.depositLegacyErc20Bridge({ + _prevMsgSender: alice, + _l2Receiver: bob, + _l1Token: address(token), + _amount: amount, + _l2TxGasLimit: l2TxGasLimit, + _l2TxGasPerPubdataByte: l2TxGasPerPubdataByte, + _refundRecipient: address(1) + }); } } diff --git a/l1-contracts/test/foundry/unit/concrete/Bridges/L1SharedBridge/L1SharedBridgeHyperEnabled.t.sol b/l1-contracts/test/foundry/unit/concrete/Bridges/L1SharedBridge/L1SharedBridgeHyperEnabled.t.sol index f574a066b..c7a0f3daf 100644 --- a/l1-contracts/test/foundry/unit/concrete/Bridges/L1SharedBridge/L1SharedBridgeHyperEnabled.t.sol +++ b/l1-contracts/test/foundry/unit/concrete/Bridges/L1SharedBridge/L1SharedBridgeHyperEnabled.t.sol @@ -139,7 +139,12 @@ contract L1SharedBridgeHyperEnabledTest is Test { vm.prank(bridgehubAddress); vm.expectEmit(true, true, true, true, address(sharedBridge)); emit BridgehubDepositBaseTokenInitiated(chainId, alice, ETH_TOKEN_ADDRESS, amount); - sharedBridge.bridgehubDepositBaseToken{value: amount}(chainId, alice, ETH_TOKEN_ADDRESS, amount); + sharedBridge.bridgehubDepositBaseToken{value: amount}({ + _chainId: chainId, + _prevMsgSender: alice, + _l1Token: ETH_TOKEN_ADDRESS, + _amount: amount + }); } function test_bridgehubDepositBaseToken_Erc() public { @@ -149,7 +154,12 @@ contract L1SharedBridgeHyperEnabledTest is Test { vm.prank(bridgehubAddress); vm.expectEmit(true, true, true, true, address(sharedBridge)); emit BridgehubDepositBaseTokenInitiated(chainId, alice, address(token), amount); - sharedBridge.bridgehubDepositBaseToken(chainId, alice, address(token), amount); + sharedBridge.bridgehubDepositBaseToken({ + _chainId: chainId, + _prevMsgSender: alice, + _l1Token: address(token), + _amount: amount + }); } function test_bridgehubDeposit_Eth() public { @@ -162,8 +172,20 @@ contract L1SharedBridgeHyperEnabledTest is Test { abi.encode(address(token)) ); bytes32 txDataHash = keccak256(abi.encode(alice, ETH_TOKEN_ADDRESS, amount)); - emit BridgehubDepositInitiated(chainId, txDataHash, alice, zkSync, ETH_TOKEN_ADDRESS, amount); - sharedBridge.bridgehubDeposit{value: amount}(chainId, alice, 0, abi.encode(ETH_TOKEN_ADDRESS, 0, bob)); + emit BridgehubDepositInitiated({ + chainId: chainId, + txDataHash: txDataHash, + from: alice, + to: zkSync, + l1Token: ETH_TOKEN_ADDRESS, + amount: amount + }); + sharedBridge.bridgehubDeposit{value: amount}({ + _chainId: chainId, + _prevMsgSender: alice, + _l2Value: 0, + _data: abi.encode(ETH_TOKEN_ADDRESS, 0, bob) + }); } function test_bridgehubDeposit_Erc() public { @@ -178,7 +200,14 @@ contract L1SharedBridgeHyperEnabledTest is Test { abi.encode(ETH_TOKEN_ADDRESS) ); bytes32 txDataHash = keccak256(abi.encode(alice, address(token), amount)); - emit BridgehubDepositInitiated(chainId, txDataHash, alice, zkSync, address(token), amount); + emit BridgehubDepositInitiated({ + chainId: chainId, + txDataHash: txDataHash, + from: alice, + to: zkSync, + l1Token: address(token), + amount: amount + }); sharedBridge.bridgehubDeposit(chainId, alice, 0, abi.encode(address(token), amount, bob)); } @@ -221,6 +250,7 @@ contract L1SharedBridgeHyperEnabledTest is Test { vm.mockCall( bridgehubAddress, + // solhint-disable-next-line func-named-parameters abi.encodeWithSelector( IBridgehub.proveL1ToL2TransactionStatus.selector, chainId, @@ -237,17 +267,17 @@ contract L1SharedBridgeHyperEnabledTest is Test { vm.expectEmit(true, true, true, true, address(sharedBridge)); emit ClaimedFailedDepositSharedBridge(chainId, alice, address(token), amount); vm.prank(bridgehubAddress); - sharedBridge.claimFailedDeposit( - chainId, - alice, - address(token), - amount, - txHash, - l2BatchNumber, - l2MessageIndex, - l2TxNumberInBatch, - merkleProof - ); + sharedBridge.claimFailedDeposit({ + _chainId: chainId, + _depositSender: alice, + _l1Token: address(token), + _amount: amount, + _l2TxHash: txHash, + _l2BatchNumber: l2BatchNumber, + _l2MessageIndex: l2MessageIndex, + _l2TxNumberInBatch: l2TxNumberInBatch, + _merkleProof: merkleProof + }); } function test_claimFailedDeposit_Eth() public { @@ -282,6 +312,7 @@ contract L1SharedBridgeHyperEnabledTest is Test { vm.mockCall( bridgehubAddress, + // solhint-disable-next-line func-named-parameters abi.encodeWithSelector( IBridgehub.proveL1ToL2TransactionStatus.selector, chainId, @@ -298,17 +329,17 @@ contract L1SharedBridgeHyperEnabledTest is Test { vm.expectEmit(true, true, true, true, address(sharedBridge)); emit ClaimedFailedDepositSharedBridge(chainId, alice, ETH_TOKEN_ADDRESS, amount); vm.prank(bridgehubAddress); - sharedBridge.claimFailedDeposit( - chainId, - alice, - ETH_TOKEN_ADDRESS, - amount, - txHash, - l2BatchNumber, - l2MessageIndex, - l2TxNumberInBatch, - merkleProof - ); + sharedBridge.claimFailedDeposit({ + _chainId: chainId, + _depositSender: alice, + _l1Token: ETH_TOKEN_ADDRESS, + _amount: amount, + _l2TxHash: txHash, + _l2BatchNumber: l2BatchNumber, + _l2MessageIndex: l2MessageIndex, + _l2TxNumberInBatch: l2TxNumberInBatch, + _merkleProof: merkleProof + }); } function test_finalizeWithdrawal_EthOnEth() public { @@ -341,6 +372,7 @@ contract L1SharedBridgeHyperEnabledTest is Test { vm.mockCall( bridgehubAddress, + // solhint-disable-next-line func-named-parameters abi.encodeWithSelector( IBridgehub.proveL2MessageInclusion.selector, chainId, @@ -354,14 +386,14 @@ contract L1SharedBridgeHyperEnabledTest is Test { vm.expectEmit(true, true, true, true, address(sharedBridge)); emit WithdrawalFinalizedSharedBridge(chainId, alice, ETH_TOKEN_ADDRESS, amount); - sharedBridge.finalizeWithdrawal( - chainId, - l2BatchNumber, - l2MessageIndex, - l2TxNumberInBatch, - message, - merkleProof - ); + sharedBridge.finalizeWithdrawal({ + _chainId: chainId, + _l2BatchNumber: l2BatchNumber, + _l2MessageIndex: l2MessageIndex, + _l2TxNumberInBatch: l2TxNumberInBatch, + _message: message, + _merkleProof: merkleProof + }); } function test_finalizeWithdrawal_ErcOnEth() public { @@ -399,6 +431,7 @@ contract L1SharedBridgeHyperEnabledTest is Test { vm.mockCall( bridgehubAddress, + // solhint-disable-next-line func-named-parameters abi.encodeWithSelector( IBridgehub.proveL2MessageInclusion.selector, chainId, @@ -412,14 +445,14 @@ contract L1SharedBridgeHyperEnabledTest is Test { vm.expectEmit(true, true, true, true, address(sharedBridge)); emit WithdrawalFinalizedSharedBridge(chainId, alice, address(token), amount); - sharedBridge.finalizeWithdrawal( - chainId, - l2BatchNumber, - l2MessageIndex, - l2TxNumberInBatch, - message, - merkleProof - ); + sharedBridge.finalizeWithdrawal({ + _chainId: chainId, + _l2BatchNumber: l2BatchNumber, + _l2MessageIndex: l2MessageIndex, + _l2TxNumberInBatch: l2TxNumberInBatch, + _message: message, + _merkleProof: merkleProof + }); } function test_finalizeWithdrawal_EthOnErc() public { @@ -457,6 +490,7 @@ contract L1SharedBridgeHyperEnabledTest is Test { vm.mockCall( bridgehubAddress, + // solhint-disable-next-line func-named-parameters abi.encodeWithSelector( IBridgehub.proveL2MessageInclusion.selector, chainId, @@ -470,14 +504,14 @@ contract L1SharedBridgeHyperEnabledTest is Test { vm.expectEmit(true, true, true, true, address(sharedBridge)); emit WithdrawalFinalizedSharedBridge(chainId, alice, ETH_TOKEN_ADDRESS, amount); - sharedBridge.finalizeWithdrawal( - chainId, - l2BatchNumber, - l2MessageIndex, - l2TxNumberInBatch, - message, - merkleProof - ); + sharedBridge.finalizeWithdrawal({ + _chainId: chainId, + _l2BatchNumber: l2BatchNumber, + _l2MessageIndex: l2MessageIndex, + _l2TxNumberInBatch: l2TxNumberInBatch, + _message: message, + _merkleProof: merkleProof + }); } function test_finalizeWithdrawal_BaseErcOnErc() public { @@ -515,6 +549,7 @@ contract L1SharedBridgeHyperEnabledTest is Test { vm.mockCall( bridgehubAddress, + // solhint-disable-next-line func-named-parameters abi.encodeWithSelector( IBridgehub.proveL2MessageInclusion.selector, chainId, @@ -528,14 +563,14 @@ contract L1SharedBridgeHyperEnabledTest is Test { vm.expectEmit(true, true, true, true, address(sharedBridge)); emit WithdrawalFinalizedSharedBridge(chainId, alice, address(token), amount); - sharedBridge.finalizeWithdrawal( - chainId, - l2BatchNumber, - l2MessageIndex, - l2TxNumberInBatch, - message, - merkleProof - ); + sharedBridge.finalizeWithdrawal({ + _chainId: chainId, + _l2BatchNumber: l2BatchNumber, + _l2MessageIndex: l2MessageIndex, + _l2TxNumberInBatch: l2TxNumberInBatch, + _message: message, + _merkleProof: merkleProof + }); } function test_finalizeWithdrawal_NonBaseErcOnErc() public { @@ -569,6 +604,7 @@ contract L1SharedBridgeHyperEnabledTest is Test { vm.mockCall( bridgehubAddress, + // solhint-disable-next-line func-named-parameters abi.encodeWithSelector( IBridgehub.proveL2MessageInclusion.selector, chainId, @@ -582,13 +618,13 @@ contract L1SharedBridgeHyperEnabledTest is Test { vm.expectEmit(true, true, true, true, address(sharedBridge)); emit WithdrawalFinalizedSharedBridge(chainId, alice, address(token), amount); - sharedBridge.finalizeWithdrawal( - chainId, - l2BatchNumber, - l2MessageIndex, - l2TxNumberInBatch, - message, - merkleProof - ); + sharedBridge.finalizeWithdrawal({ + _chainId: chainId, + _l2BatchNumber: l2BatchNumber, + _l2MessageIndex: l2MessageIndex, + _l2TxNumberInBatch: l2TxNumberInBatch, + _message: message, + _merkleProof: merkleProof + }); } } diff --git a/l1-contracts/test/foundry/unit/concrete/Bridges/L1SharedBridge/L1SharedBridgeLegacy.t.sol b/l1-contracts/test/foundry/unit/concrete/Bridges/L1SharedBridge/L1SharedBridgeLegacy.t.sol index 51d4af718..b689e695f 100644 --- a/l1-contracts/test/foundry/unit/concrete/Bridges/L1SharedBridge/L1SharedBridgeLegacy.t.sol +++ b/l1-contracts/test/foundry/unit/concrete/Bridges/L1SharedBridge/L1SharedBridgeLegacy.t.sol @@ -125,7 +125,14 @@ contract L1SharedBridgeLegacyTest is Test { address refundRecipient = address(0); vm.expectEmit(true, true, true, true, address(sharedBridge)); - emit LegacyDepositInitiated(ERA_CHAIN_ID, txHash, alice, bob, address(token), amount); + emit LegacyDepositInitiated({ + chainId: ERA_CHAIN_ID, + l2DepositTxHash: txHash, + from: alice, + to: bob, + l1Token: address(token), + amount: amount + }); vm.mockCall( bridgehubAddress, @@ -134,15 +141,16 @@ contract L1SharedBridgeLegacyTest is Test { ); vm.prank(l1ERC20BridgeAddress); - sharedBridge.depositLegacyErc20Bridge( - alice, - bob, - address(token), - amount, - l2TxGasLimit, - l2TxGasPerPubdataByte, - refundRecipient - ); + + sharedBridge.depositLegacyErc20Bridge({ + _prevMsgSender: alice, + _l2Receiver: bob, + _l1Token: address(token), + _amount: amount, + _l2TxGasLimit: l2TxGasLimit, + _l2TxGasPerPubdataByte: l2TxGasPerPubdataByte, + _refundRecipient: refundRecipient + }); } function test_finalizeWithdrawalLegacyErc20Bridge_EthOnEth() public { @@ -175,6 +183,7 @@ contract L1SharedBridgeLegacyTest is Test { vm.mockCall( bridgehubAddress, + // solhint-disable-next-line func-named-parameters abi.encodeWithSelector( IBridgehub.proveL2MessageInclusion.selector, ERA_CHAIN_ID, @@ -219,6 +228,7 @@ contract L1SharedBridgeLegacyTest is Test { abi.encode(ETH_TOKEN_ADDRESS) ); + // solhint-disable-next-line func-named-parameters bytes memory message = abi.encodePacked( IL1ERC20Bridge.finalizeWithdrawal.selector, alice, @@ -233,6 +243,7 @@ contract L1SharedBridgeLegacyTest is Test { vm.mockCall( bridgehubAddress, + // solhint-disable-next-line func-named-parameters abi.encodeWithSelector( IBridgehub.proveL2MessageInclusion.selector, ERA_CHAIN_ID, @@ -287,6 +298,7 @@ contract L1SharedBridgeLegacyTest is Test { vm.mockCall( bridgehubAddress, + // solhint-disable-next-line func-named-parameters abi.encodeWithSelector( IBridgehub.proveL1ToL2TransactionStatus.selector, ERA_CHAIN_ID, @@ -303,15 +315,16 @@ contract L1SharedBridgeLegacyTest is Test { vm.expectEmit(true, true, true, true, address(sharedBridge)); emit ClaimedFailedDepositSharedBridge(ERA_CHAIN_ID, alice, address(token), amount); vm.prank(l1ERC20BridgeAddress); - sharedBridge.claimFailedDepositLegacyErc20Bridge( - alice, - address(token), - amount, - txHash, - l2BatchNumber, - l2MessageIndex, - l2TxNumberInBatch, - merkleProof - ); + + sharedBridge.claimFailedDepositLegacyErc20Bridge({ + _depositSender: alice, + _l1Token: address(token), + _amount: amount, + _l2TxHash: txHash, + _l2BatchNumber: l2BatchNumber, + _l2MessageIndex: l2MessageIndex, + _l2TxNumberInBatch: l2TxNumberInBatch, + _merkleProof: merkleProof + }); } } diff --git a/l1-contracts/test/foundry/unit/concrete/Executor/Committing.t.sol b/l1-contracts/test/foundry/unit/concrete/Executor/Committing.t.sol index 5dfe9a662..9a273c052 100644 --- a/l1-contracts/test/foundry/unit/concrete/Executor/Committing.t.sol +++ b/l1-contracts/test/foundry/unit/concrete/Executor/Committing.t.sol @@ -149,6 +149,7 @@ contract CommittingTest is ExecutorTest { bytes memory wrongL2Logs = abi.encodePacked( Utils.encodePacked(l2Logs), + // solhint-disable-next-line func-named-parameters Utils.constructL2Log( true, L2_SYSTEM_CONTEXT_ADDRESS, @@ -239,6 +240,7 @@ contract CommittingTest is ExecutorTest { bytes[] memory l2Logs = Utils.createSystemLogs(); bytes memory wrongL2Logs = abi.encodePacked( Utils.encodePacked(l2Logs), + // solhint-disable-next-line func-named-parameters abi.encodePacked(bytes2(0x0001), bytes2(0x0000), L2_SYSTEM_CONTEXT_ADDRESS, uint256(119), bytes32("")) ); diff --git a/l1-contracts/test/foundry/unit/concrete/Executor/Executing.t.sol b/l1-contracts/test/foundry/unit/concrete/Executor/Executing.t.sol index e96e236a7..5356af91a 100644 --- a/l1-contracts/test/foundry/unit/concrete/Executor/Executing.t.sol +++ b/l1-contracts/test/foundry/unit/concrete/Executor/Executing.t.sol @@ -212,15 +212,15 @@ contract ExecutingTest is ExecutorTest { uint256 l2Value = 10 ether; uint256 totalCost = baseCost + l2Value; - mailbox.requestL2Transaction{value: totalCost}( - address(0), - l2Value, - bytes(""), - l2GasLimit, - REQUIRED_L2_GAS_PRICE_PER_PUBDATA, - factoryDeps, - address(0) - ); + mailbox.requestL2Transaction{value: totalCost}({ + _contractL2: address(0), + _l2Value: l2Value, + _calldata: bytes(""), + _l2GasLimit: l2GasLimit, + _l2GasPerPubdataByteLimit: REQUIRED_L2_GAS_PRICE_PER_PUBDATA, + _factoryDeps: factoryDeps, + _refundRecipient: address(0) + }); vm.prank(validator); vm.expectRevert(bytes.concat("x")); @@ -228,6 +228,7 @@ contract ExecutingTest is ExecutorTest { } function test_RevertWhen_CommittingBlockWithWrongPreviousBatchHash() public { + // solhint-disable-next-line func-named-parameters bytes memory correctL2Logs = abi.encodePacked( bytes4(0x00000001), bytes4(0x00000000), diff --git a/l1-contracts/test/foundry/unit/concrete/Utils/Utils.sol b/l1-contracts/test/foundry/unit/concrete/Utils/Utils.sol index a3d93cb13..d90cc3249 100644 --- a/l1-contracts/test/foundry/unit/concrete/Utils/Utils.sol +++ b/l1-contracts/test/foundry/unit/concrete/Utils/Utils.sol @@ -47,6 +47,7 @@ library Utils { servicePrefix = 0x0000; } + // solhint-disable-next-line func-named-parameters return abi.encodePacked(servicePrefix, bytes2(0x0000), sender, key, value); } @@ -411,6 +412,7 @@ library Utils { function _batchPassThroughData(IExecutor.CommitBatchInfo calldata _batch) internal pure returns (bytes memory) { return + // solhint-disable-next-line func-named-parameters abi.encodePacked( _batch.indexRepeatedStorageChanges, _batch.newStateRoot, @@ -434,6 +436,7 @@ library Utils { bytes32 l2ToL1LogsHash = keccak256(_batch.systemLogs); return + // solhint-disable-next-line func-named-parameters abi.encode( l2ToL1LogsHash, _stateDiffHash, diff --git a/l1-contracts/test/foundry/unit/concrete/common/libraries/UnsafeBytes/UnsafeBytes.t.sol b/l1-contracts/test/foundry/unit/concrete/common/libraries/UnsafeBytes/UnsafeBytes.t.sol index 084c93728..9b51b202b 100644 --- a/l1-contracts/test/foundry/unit/concrete/common/libraries/UnsafeBytes/UnsafeBytes.t.sol +++ b/l1-contracts/test/foundry/unit/concrete/common/libraries/UnsafeBytes/UnsafeBytes.t.sol @@ -20,7 +20,7 @@ contract UnsafeBytesTestTest is Test { function setUp() public { unsafeBytesTest = new UnsafeBytesTest(); - + // solhint-disable-next-line func-named-parameters bytesData = abi.encodePacked(addr0, addr1, u256, u321, u322, addr2, b32, addr3); } diff --git a/l2-contracts/contracts/L2ContractHelper.sol b/l2-contracts/contracts/L2ContractHelper.sol index 8699cf761..79090a3a9 100644 --- a/l2-contracts/contracts/L2ContractHelper.sol +++ b/l2-contracts/contracts/L2ContractHelper.sol @@ -106,6 +106,7 @@ library L2ContractHelper { ) internal pure returns (address) { bytes32 senderBytes = bytes32(uint256(uint160(_sender))); bytes32 data = keccak256( + // solhint-disable-next-line func-named-parameters bytes.concat(CREATE2_PREFIX, senderBytes, _salt, _bytecodeHash, _constructorInputHash) ); diff --git a/l2-contracts/contracts/SystemContractsCaller.sol b/l2-contracts/contracts/SystemContractsCaller.sol index 26033e0ef..36153eb6d 100644 --- a/l2-contracts/contracts/SystemContractsCaller.sol +++ b/l2-contracts/contracts/SystemContractsCaller.sol @@ -43,18 +43,18 @@ library SystemContractsCaller { } uint32 dataLength = uint32(Utils.safeCastToU32(data.length)); - uint256 farCallAbi = getFarCallABI( - 0, - 0, - dataStart, - dataLength, - gasLimit, + uint256 farCallAbi = getFarCallABI({ + dataOffset: 0, + memoryPage: 0, + dataStart: dataStart, + dataLength: dataLength, + gasPassed: gasLimit, // Only rollup is supported for now - 0, - CalldataForwardingMode.UseHeap, - false, - true - ); + shardId: 0, + forwardingMode: CalldataForwardingMode.UseHeap, + isConstructorCall: false, + isSystemCall: true + }); if (value == 0) { // Doing the system call directly @@ -104,13 +104,13 @@ library SystemContractsCaller { bool isSystemCall ) internal pure returns (uint256 farCallAbi) { // Fill in the call parameter fields - farCallAbi = getFarCallABIWithEmptyFatPointer( - gasPassed, - shardId, - forwardingMode, - isConstructorCall, - isSystemCall - ); + farCallAbi = getFarCallABIWithEmptyFatPointer({ + gasPassed: gasPassed, + shardId: shardId, + forwardingMode: forwardingMode, + isConstructorCall: isConstructorCall, + isSystemCall: isSystemCall + }); // Fill in the fat pointer fields farCallAbi |= dataOffset; farCallAbi |= (uint256(memoryPage) << 32); diff --git a/system-contracts/SystemContractsHashes.json b/system-contracts/SystemContractsHashes.json index 3b6ad1b0d..09a607d02 100644 --- a/system-contracts/SystemContractsHashes.json +++ b/system-contracts/SystemContractsHashes.json @@ -3,42 +3,42 @@ "contractName": "AccountCodeStorage", "bytecodePath": "artifacts-zk/contracts-preprocessed/AccountCodeStorage.sol/AccountCodeStorage.json", "sourceCodePath": "contracts-preprocessed/AccountCodeStorage.sol", - "bytecodeHash": "0x010000758728c2ff9650fa47ecbe140c6b92aed9c50f94d79e541cd1014ed5d5", + "bytecodeHash": "0x01000075ba09414f06fd01fc9fa80294d3b506e7ab1305413f36aa8ad2592cc1", "sourceCodeHash": "0xfbf66e830201c4b7fda14f0ddf28a53beb7fbb48a8406392bcfd0ef7ea9265c8" }, { "contractName": "BootloaderUtilities", "bytecodePath": "artifacts-zk/contracts-preprocessed/BootloaderUtilities.sol/BootloaderUtilities.json", "sourceCodePath": "contracts-preprocessed/BootloaderUtilities.sol", - "bytecodeHash": "0x010007c9205b21491264a60e04bd188d581d7e6e53a76ae91d6f25ccf971d8f2", - "sourceCodeHash": "0xf48319ea1cfc95e6e2203b8186b21e3f3168136b92125e935b9bca81da42ad2a" + "bytecodeHash": "0x010007c90e5f6032dbdb48b527403e648cc8d82eb76b2ad3a9a338065e435bc1", + "sourceCodeHash": "0x9ff5a2da00acfa145ee4575381ad386587d96b6a0309d05015974f4726881132" }, { "contractName": "ComplexUpgrader", "bytecodePath": "artifacts-zk/contracts-preprocessed/ComplexUpgrader.sol/ComplexUpgrader.json", "sourceCodePath": "contracts-preprocessed/ComplexUpgrader.sol", - "bytecodeHash": "0x010000555742e30ecf1475e314c26b4dad7ad814fda10432d1fff8b75a3349e0", + "bytecodeHash": "0x01000055a940562961f198e4ebb4f84805fb04ecb2db5b67e5bd054b50af2d2a", "sourceCodeHash": "0x0aa5d7ed159e783acde47856b13801b7f2268ba39b2fa50807fe3d705c506e96" }, { "contractName": "Compressor", "bytecodePath": "artifacts-zk/contracts-preprocessed/Compressor.sol/Compressor.json", "sourceCodePath": "contracts-preprocessed/Compressor.sol", - "bytecodeHash": "0x0100016d2df3432bcaad1fb67f5161785bc188604e395f8b887eaf799852ee09", + "bytecodeHash": "0x0100016db59521a1e96e120f169db106f2045ee683be8c1ab01be5968b332b4b", "sourceCodeHash": "0xe289c3a39b5c9837d71ab2d79afce20c28a8474c4f008719c5b1d0c2f3725e33" }, { "contractName": "ContractDeployer", "bytecodePath": "artifacts-zk/contracts-preprocessed/ContractDeployer.sol/ContractDeployer.json", "sourceCodePath": "contracts-preprocessed/ContractDeployer.sol", - "bytecodeHash": "0x01000555ca33b389c6fc3ca149bfb43943b59571de2b4bdfc8558d264aa8627e", - "sourceCodeHash": "0x37deef4ef277cf0d1e0c56194650beceaeaa2fa3f0e5d0165ef60b7f2fb6a859" + "bytecodeHash": "0x010005557fc07d84d572c18b0cc805fe5ee1b3a92f9befe93f57e2b463b20033", + "sourceCodeHash": "0x73a09191c62f897122f22aa950b6f86b55710e5ff70fd3b66267c197cf535a97" }, { "contractName": "DefaultAccount", "bytecodePath": "artifacts-zk/contracts-preprocessed/DefaultAccount.sol/DefaultAccount.json", "sourceCodePath": "contracts-preprocessed/DefaultAccount.sol", - "bytecodeHash": "0x0100055b4f231e4b5cb98428c318d3213d7226b8f7e03d9e91834a54498d0ed2", + "bytecodeHash": "0x0100055b07fa5594ecca1a2cfec163b64ac5963373d0f3c76828c809c7634bfc", "sourceCodeHash": "0xa6931c6e2f7545d24c361cea1a498393e6352f138d476a837114415c6f557630" }, { @@ -52,56 +52,56 @@ "contractName": "ImmutableSimulator", "bytecodePath": "artifacts-zk/contracts-preprocessed/ImmutableSimulator.sol/ImmutableSimulator.json", "sourceCodePath": "contracts-preprocessed/ImmutableSimulator.sol", - "bytecodeHash": "0x0100003d30a5ed5e1e7760532ae6dee5d8cbe0adf84ae713a9a8c3204be341e1", + "bytecodeHash": "0x0100003d63260aa04b33493f7a086630565e3df14c13dcf8cc6bcc7447ac33f3", "sourceCodeHash": "0x30df621c72cb35b8820b902b91057f72d0214a0e4a6b7ad4c0847e674e8b9df8" }, { "contractName": "KnownCodesStorage", "bytecodePath": "artifacts-zk/contracts-preprocessed/KnownCodesStorage.sol/KnownCodesStorage.json", "sourceCodePath": "contracts-preprocessed/KnownCodesStorage.sol", - "bytecodeHash": "0x0100007d4e603cc6d8c26b8ebd773f0c707744a9b806f7388279c6b60325ba6d", + "bytecodeHash": "0x0100007df99d1abe1b4650bc9a77678ee7edd0099da9323e520ac93042bf4728", "sourceCodeHash": "0x51d388adc58f67ef975a94a7978caa60ed8a0df9d3bd9ac723dfcfc540286c70" }, { "contractName": "L1Messenger", "bytecodePath": "artifacts-zk/contracts-preprocessed/L1Messenger.sol/L1Messenger.json", "sourceCodePath": "contracts-preprocessed/L1Messenger.sol", - "bytecodeHash": "0x010002afff3719590c21c3b42b7c396b6bee062603a6bc14d384c9597a91584d", - "sourceCodeHash": "0x85a2d5884c92a28c298e626f8c9b0cdba868f2e6fddfe199dacb7900b889131a" + "bytecodeHash": "0x010002af2032fed66936f523a49f899db74e8d83ca81efb349c1e0ba31db2702", + "sourceCodeHash": "0x96113425ee0e2c6c7c5c90c3e78a6eceba14178003590f2e017f7c7803820cc3" }, { "contractName": "L2BaseToken", "bytecodePath": "artifacts-zk/contracts-preprocessed/L2BaseToken.sol/L2BaseToken.json", "sourceCodePath": "contracts-preprocessed/L2BaseToken.sol", - "bytecodeHash": "0x0100010178e9f69ae0758db6fc66502071b920b732232a2cd713e8468d8f6126", + "bytecodeHash": "0x0100010147b63491807d091cc60e135809645ff4789b653ffcb04e0404b9c296", "sourceCodeHash": "0x5cfb3a7f69db57a455682f339879a5d5ae679c8deff2ea6669b0a6d0fe538d6c" }, { "contractName": "MsgValueSimulator", "bytecodePath": "artifacts-zk/contracts-preprocessed/MsgValueSimulator.sol/MsgValueSimulator.json", "sourceCodePath": "contracts-preprocessed/MsgValueSimulator.sol", - "bytecodeHash": "0x01000063aed0ecee0bb38eb5189f992173aa18b5353fba856577950b216917d1", - "sourceCodeHash": "0xd052abaab1b0091c37d0763bba924ff5ed2be59f68cc29a850cb9b41de72bc06" + "bytecodeHash": "0x010000632a04547ce90e834bbd61e9948d8ccdded64f6d1f14c6da25a365f464", + "sourceCodeHash": "0x66703611a2d2c5390249c6f5c03b723c333ee1327cd976b70639c949e73491a8" }, { "contractName": "NonceHolder", "bytecodePath": "artifacts-zk/contracts-preprocessed/NonceHolder.sol/NonceHolder.json", "sourceCodePath": "contracts-preprocessed/NonceHolder.sol", - "bytecodeHash": "0x010000e5f0ccd42048caafac6cef23fe92f2dcd2892754a31e5c71847ac3f177", + "bytecodeHash": "0x010000e54eb0ea2801bd4ee6af1da87cb2e2092506b7b549f80a8641020a7613", "sourceCodeHash": "0x91847512344ac5026e9fd396189c23ad9e253f22cb6e2fe65805c20c915797d4" }, { "contractName": "PubdataChunkPublisher", "bytecodePath": "artifacts-zk/contracts-preprocessed/PubdataChunkPublisher.sol/PubdataChunkPublisher.json", "sourceCodePath": "contracts-preprocessed/PubdataChunkPublisher.sol", - "bytecodeHash": "0x01000047a19c8eca41287a2d3558ca3bfe53475349f146fc915e55e18f34e91d", + "bytecodeHash": "0x010000477a6d9e5e2da817293b8661879644ce2e24018b60b5a30a6ec10e2b70", "sourceCodeHash": "0x590a1db7278ba5a40153555b4fe47f3b15e04d55aa06c0f996483730cd1a5998" }, { "contractName": "SystemContext", "bytecodePath": "artifacts-zk/contracts-preprocessed/SystemContext.sol/SystemContext.json", "sourceCodePath": "contracts-preprocessed/SystemContext.sol", - "bytecodeHash": "0x01000187ecdffbbc16d7f05656d56e77ae751ca00db689c5403db20096cdd985", + "bytecodeHash": "0x0100018752e4c588d542c6114819b7211d5fe8dcef6ae20835ab5ec0f430e3c2", "sourceCodeHash": "0x95af356a9c20e9faafae8f404049c5312e4666b85110600d8a6e00b21d5e3bd5" }, { diff --git a/system-contracts/contracts/BootloaderUtilities.sol b/system-contracts/contracts/BootloaderUtilities.sol index 71f6b0e65..5551764dd 100644 --- a/system-contracts/contracts/BootloaderUtilities.sol +++ b/system-contracts/contracts/BootloaderUtilities.sol @@ -118,6 +118,7 @@ contract BootloaderUtilities is IBootloaderUtilities { return keccak256( + // solhint-disable-next-line func-named-parameters bytes.concat( encodedListLength, encodedNonce, @@ -146,6 +147,7 @@ contract BootloaderUtilities is IBootloaderUtilities { bytes memory encodedGasLimit = RLPEncoder.encodeUint256(_transaction.gasLimit); bytes memory encodedTo = RLPEncoder.encodeAddress(address(uint160(_transaction.to))); bytes memory encodedValue = RLPEncoder.encodeUint256(_transaction.value); + // solhint-disable-next-line func-named-parameters encodedFixedLengthParams = bytes.concat( encodedChainId, encodedNonce, @@ -209,6 +211,7 @@ contract BootloaderUtilities is IBootloaderUtilities { return keccak256( + // solhint-disable-next-line func-named-parameters bytes.concat( "\x01", encodedListLength, @@ -240,6 +243,7 @@ contract BootloaderUtilities is IBootloaderUtilities { bytes memory encodedGasLimit = RLPEncoder.encodeUint256(_transaction.gasLimit); bytes memory encodedTo = RLPEncoder.encodeAddress(address(uint160(_transaction.to))); bytes memory encodedValue = RLPEncoder.encodeUint256(_transaction.value); + // solhint-disable-next-line func-named-parameters encodedFixedLengthParams = bytes.concat( encodedChainId, encodedNonce, @@ -304,6 +308,7 @@ contract BootloaderUtilities is IBootloaderUtilities { return keccak256( + // solhint-disable-next-line func-named-parameters bytes.concat( "\x02", encodedListLength, diff --git a/system-contracts/contracts/ContractDeployer.sol b/system-contracts/contracts/ContractDeployer.sol index f61b45aed..f35728be1 100644 --- a/system-contracts/contracts/ContractDeployer.sol +++ b/system-contracts/contracts/ContractDeployer.sol @@ -103,6 +103,7 @@ contract ContractDeployer is IContractDeployer, ISystemContract { bytes32 constructorInputHash = EfficientCall.keccak(_input); bytes32 hash = keccak256( + // solhint-disable-next-line func-named-parameters bytes.concat(CREATE2_PREFIX, bytes32(uint256(uint160(_sender))), _salt, _bytecodeHash, constructorInputHash) ); @@ -222,14 +223,14 @@ contract ContractDeployer is IContractDeployer, ISystemContract { newAccountInfo.nonceOrdering = AccountNonceOrdering.Sequential; _storeAccountInfo(_deployment.newAddress, newAccountInfo); - _constructContract( - _sender, - _deployment.newAddress, - _deployment.bytecodeHash, - _deployment.input, - false, - _deployment.callConstructor - ); + _constructContract({ + _sender: _sender, + _newAddress: _deployment.newAddress, + _bytecodeHash: _deployment.bytecodeHash, + _input: _deployment.input, + _isSystem: false, + _callConstructor: _deployment.callConstructor + }); } /// @notice The method that is temporarily needed to upgrade the Keccak256 precompile. This function and `Bootloader:upgradeKeccakIfNeeded` @@ -240,14 +241,14 @@ contract ContractDeployer is IContractDeployer, ISystemContract { function forceDeployKeccak256(bytes32 _keccak256BytecodeHash) external payable onlyCallFrom(FORCE_DEPLOYER) { _ensureBytecodeIsKnown(_keccak256BytecodeHash); - _constructContract( - msg.sender, - address(KECCAK256_SYSTEM_CONTRACT), - _keccak256BytecodeHash, - msg.data[0:0], - false, - false - ); + _constructContract({ + _sender: msg.sender, + _newAddress: address(KECCAK256_SYSTEM_CONTRACT), + _bytecodeHash: _keccak256BytecodeHash, + _input: msg.data[0:0], + _isSystem: false, + _callConstructor: false + }); } /// @notice This method is to be used only during an upgrade to set bytecodes on specific addresses. @@ -312,7 +313,14 @@ contract ContractDeployer is IContractDeployer, ISystemContract { newAccountInfo.nonceOrdering = AccountNonceOrdering.Sequential; _storeAccountInfo(_newAddress, newAccountInfo); - _constructContract(msg.sender, _newAddress, _bytecodeHash, _input, false, true); + _constructContract({ + _sender: msg.sender, + _newAddress: _newAddress, + _bytecodeHash: _bytecodeHash, + _input: _input, + _isSystem: false, + _callConstructor: true + }); } /// @notice Check that bytecode hash is marked as known on the `KnownCodeStorage` system contracts @@ -358,7 +366,14 @@ contract ContractDeployer is IContractDeployer, ISystemContract { // Safe to cast value, because `msg.value` <= `uint128.max` due to `MessageValueSimulator` invariant SystemContractHelper.setValueForNextFarCall(uint128(value)); } - bytes memory returnData = EfficientCall.mimicCall(gasleft(), _newAddress, _input, _sender, true, _isSystem); + bytes memory returnData = EfficientCall.mimicCall({ + _gas: gasleft(), + _address: _newAddress, + _data: _input, + _whoToMimic: _sender, + _isConstructor: true, + _isSystem: _isSystem + }); // 4. Mark bytecode hash as constructed ACCOUNT_CODE_STORAGE_SYSTEM_CONTRACT.markAccountCodeHashAsConstructed(_newAddress); // 5. Set the contract immutables diff --git a/system-contracts/contracts/L1Messenger.sol b/system-contracts/contracts/L1Messenger.sol index 0f4e4b82e..2735dde9f 100644 --- a/system-contracts/contracts/L1Messenger.sol +++ b/system-contracts/contracts/L1Messenger.sol @@ -93,6 +93,7 @@ contract L1Messenger is IL1Messenger, ISystemContract { /// @notice Internal function to send L2ToL1Log. function _processL2ToL1Log(L2ToL1Log memory _l2ToL1Log) internal returns (uint256 logIdInMerkleTree) { bytes32 hashedLog = keccak256( + // solhint-disable-next-line func-named-parameters abi.encodePacked( _l2ToL1Log.l2ShardId, _l2ToL1Log.isService, diff --git a/system-contracts/contracts/MsgValueSimulator.sol b/system-contracts/contracts/MsgValueSimulator.sol index 09b6d0152..470306295 100644 --- a/system-contracts/contracts/MsgValueSimulator.sol +++ b/system-contracts/contracts/MsgValueSimulator.sol @@ -58,6 +58,14 @@ contract MsgValueSimulator is ISystemContract { // For the next call this `msg.value` will be used. SystemContractHelper.setValueForNextFarCall(Utils.safeCastToU128(value)); - return EfficientCall.mimicCall(gasleft(), to, _data, msg.sender, false, isSystemCall); + return + EfficientCall.mimicCall({ + _gas: gasleft(), + _address: to, + _data: _data, + _whoToMimic: msg.sender, + _isConstructor: false, + _isSystem: isSystemCall + }); } } diff --git a/system-contracts/contracts/libraries/EfficientCall.sol b/system-contracts/contracts/libraries/EfficientCall.sol index f44ac5185..a5a48d400 100644 --- a/system-contracts/contracts/libraries/EfficientCall.sol +++ b/system-contracts/contracts/libraries/EfficientCall.sol @@ -111,7 +111,15 @@ library EfficientCall { bool _isConstructor, bool _isSystem ) internal returns (bytes memory returnData) { - bool success = rawMimicCall(_gas, _address, _data, _whoToMimic, _isConstructor, _isSystem); + bool success = rawMimicCall({ + _gas: _gas, + _address: _address, + _data: _data, + _whoToMimic: _whoToMimic, + _isConstructor: _isConstructor, + _isSystem: _isSystem + }); + returnData = _verifyCallResult(success); } diff --git a/system-contracts/contracts/libraries/SystemContractsCaller.sol b/system-contracts/contracts/libraries/SystemContractsCaller.sol index 3ef62063d..1ccf0dea5 100644 --- a/system-contracts/contracts/libraries/SystemContractsCaller.sol +++ b/system-contracts/contracts/libraries/SystemContractsCaller.sol @@ -82,18 +82,18 @@ library SystemContractsCaller { } uint32 dataLength = uint32(Utils.safeCastToU32(data.length)); - uint256 farCallAbi = SystemContractsCaller.getFarCallABI( - 0, - 0, - dataStart, - dataLength, - gasLimit, + uint256 farCallAbi = SystemContractsCaller.getFarCallABI({ + dataOffset: 0, + memoryPage: 0, + dataStart: dataStart, + dataLength: dataLength, + gasPassed: gasLimit, // Only rollup is supported for now - 0, - CalldataForwardingMode.UseHeap, - false, - true - ); + shardId: 0, + forwardingMode: CalldataForwardingMode.UseHeap, + isConstructorCall: false, + isSystemCall: true + }); if (value == 0) { // Doing the system call directly diff --git a/system-contracts/contracts/libraries/TransactionHelper.sol b/system-contracts/contracts/libraries/TransactionHelper.sol index 31e665baa..9a2921010 100644 --- a/system-contracts/contracts/libraries/TransactionHelper.sol +++ b/system-contracts/contracts/libraries/TransactionHelper.sol @@ -116,6 +116,7 @@ library TransactionHelper { /// @return keccak256 hash of the EIP-712 encoded representation of transaction function _encodeHashEIP712Transaction(Transaction calldata _transaction) private view returns (bytes32) { bytes32 structHash = keccak256( + // solhint-disable-next-line func-named-parameters abi.encode( EIP712_TRANSACTION_TYPE_HASH, _transaction.txType, @@ -200,6 +201,7 @@ library TransactionHelper { return keccak256( + // solhint-disable-next-line func-named-parameters bytes.concat( encodedListLength, encodedNonce, @@ -230,6 +232,7 @@ library TransactionHelper { bytes memory encodedGasLimit = RLPEncoder.encodeUint256(_transaction.gasLimit); bytes memory encodedTo = RLPEncoder.encodeAddress(address(uint160(_transaction.to))); bytes memory encodedValue = RLPEncoder.encodeUint256(_transaction.value); + // solhint-disable-next-line func-named-parameters encodedFixedLengthParams = bytes.concat( encodedChainId, encodedNonce, @@ -272,6 +275,7 @@ library TransactionHelper { return keccak256( + // solhint-disable-next-line func-named-parameters bytes.concat( "\x01", encodedListLength, @@ -301,6 +305,7 @@ library TransactionHelper { bytes memory encodedGasLimit = RLPEncoder.encodeUint256(_transaction.gasLimit); bytes memory encodedTo = RLPEncoder.encodeAddress(address(uint160(_transaction.to))); bytes memory encodedValue = RLPEncoder.encodeUint256(_transaction.value); + // solhint-disable-next-line func-named-parameters encodedFixedLengthParams = bytes.concat( encodedChainId, encodedNonce, @@ -344,6 +349,7 @@ library TransactionHelper { return keccak256( + // solhint-disable-next-line func-named-parameters bytes.concat( "\x02", encodedListLength, diff --git a/system-contracts/contracts/test-contracts/KeccakTest.sol b/system-contracts/contracts/test-contracts/KeccakTest.sol index bc4d9e9ba..f87eb2ed7 100644 --- a/system-contracts/contracts/test-contracts/KeccakTest.sol +++ b/system-contracts/contracts/test-contracts/KeccakTest.sol @@ -84,14 +84,14 @@ contract KeccakTest { bytes calldata upgradeCalldata ) external returns (bytes32 hash) { // Firstly, we reset keccak256 bytecode to be some random bytecode - EfficientCall.mimicCall( - gasleft(), - address(REAL_DEPLOYER_SYSTEM_CONTRACT), - eraseCallData, - REAL_FORCE_DEPLOYER_ADDRESS, - false, - false - ); + EfficientCall.mimicCall({ + _gas: gasleft(), + _address: address(REAL_DEPLOYER_SYSTEM_CONTRACT), + _data: eraseCallData, + _whoToMimic: REAL_FORCE_DEPLOYER_ADDRESS, + _isConstructor: false, + _isSystem: false + }); // Since the keccak contract has been erased, it should not work anymore try this.callKeccak(msg.data[0:0]) returns (bytes32) { @@ -99,14 +99,14 @@ contract KeccakTest { } catch {} // Upgrading it back to the correct version: - EfficientCall.mimicCall( - gasleft(), - address(REAL_DEPLOYER_SYSTEM_CONTRACT), - upgradeCalldata, - REAL_FORCE_DEPLOYER_ADDRESS, - false, - false - ); + EfficientCall.mimicCall({ + _gas: gasleft(), + _address: address(REAL_DEPLOYER_SYSTEM_CONTRACT), + _data: upgradeCalldata, + _whoToMimic: REAL_FORCE_DEPLOYER_ADDRESS, + _isConstructor: false, + _isSystem: false + }); // Now it should work again hash = this.callKeccak(msg.data[0:0]); @@ -114,14 +114,14 @@ contract KeccakTest { } function keccakPerformUpgrade(bytes calldata upgradeCalldata) external { - EfficientCall.mimicCall( - gasleft(), - address(REAL_DEPLOYER_SYSTEM_CONTRACT), - upgradeCalldata, - REAL_FORCE_DEPLOYER_ADDRESS, - false, - false - ); + EfficientCall.mimicCall({ + _gas: gasleft(), + _address: address(REAL_DEPLOYER_SYSTEM_CONTRACT), + _data: upgradeCalldata, + _whoToMimic: REAL_FORCE_DEPLOYER_ADDRESS, + _isConstructor: false, + _isSystem: false + }); } function callKeccak(bytes calldata _data) external pure returns (bytes32 hash) { @@ -137,14 +137,14 @@ contract KeccakTest { require(testInputs.length == expectedOutputs.length, "mismatch between number of inputs and outputs"); // Firstly, we upgrade keccak256 bytecode to the correct version. - EfficientCall.mimicCall( - gasleft(), - address(REAL_DEPLOYER_SYSTEM_CONTRACT), - upgradeCalldata, - REAL_FORCE_DEPLOYER_ADDRESS, - false, - false - ); + EfficientCall.mimicCall({ + _gas: gasleft(), + _address: address(REAL_DEPLOYER_SYSTEM_CONTRACT), + _data: upgradeCalldata, + _whoToMimic: REAL_FORCE_DEPLOYER_ADDRESS, + _isConstructor: false, + _isSystem: false + }); bytes32[] memory result = new bytes32[](testInputs.length); @@ -158,13 +158,13 @@ contract KeccakTest { } // Upgrading it back to the original version: - EfficientCall.mimicCall( - gasleft(), - address(REAL_DEPLOYER_SYSTEM_CONTRACT), - resetCalldata, - REAL_FORCE_DEPLOYER_ADDRESS, - false, - false - ); + EfficientCall.mimicCall({ + _gas: gasleft(), + _address: address(REAL_DEPLOYER_SYSTEM_CONTRACT), + _data: resetCalldata, + _whoToMimic: REAL_FORCE_DEPLOYER_ADDRESS, + _isConstructor: false, + _isSystem: false + }); } } diff --git a/system-contracts/contracts/test-contracts/SystemCaller.sol b/system-contracts/contracts/test-contracts/SystemCaller.sol index 96c512d9f..a377174ae 100644 --- a/system-contracts/contracts/test-contracts/SystemCaller.sol +++ b/system-contracts/contracts/test-contracts/SystemCaller.sol @@ -28,18 +28,18 @@ contract SystemCaller { } uint32 dataLength = uint32(Utils.safeCastToU32(data.length)); - uint256 farCallAbi = SystemContractsCaller.getFarCallABI( - 0, - 0, - dataStart, - dataLength, - Utils.safeCastToU32(gasleft()), + uint256 farCallAbi = SystemContractsCaller.getFarCallABI({ + dataOffset: 0, + memoryPage: 0, + dataStart: dataStart, + dataLength: dataLength, + gasPassed: Utils.safeCastToU32(gasleft()), // Only rollup is supported for now - 0, - CalldataForwardingMode.UseHeap, - false, - true - ); + shardId: 0, + forwardingMode: CalldataForwardingMode.UseHeap, + isConstructorCall: false, + isSystemCall: true + }); bool success; if (msg.value == 0) {