From f7364fb39cf75ae7f6eed09b049ee47debba9b38 Mon Sep 17 00:00:00 2001 From: Stanislav Bezkorovainyi Date: Fri, 29 Nov 2024 12:40:28 +0100 Subject: [PATCH] Fix audittens I08 (#42) --- .../contracts/state-transition/chain-deps/facets/Admin.sol | 4 ++-- .../l2-tests-in-l1-context/_SharedL2ContractDeployer.sol | 7 +++++++ 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/l1-contracts/contracts/state-transition/chain-deps/facets/Admin.sol b/l1-contracts/contracts/state-transition/chain-deps/facets/Admin.sol index 451120979..a782a73d0 100644 --- a/l1-contracts/contracts/state-transition/chain-deps/facets/Admin.sol +++ b/l1-contracts/contracts/state-transition/chain-deps/facets/Admin.sol @@ -80,7 +80,7 @@ contract AdminFacet is ZKChainBase, IAdmin { } /// @inheritdoc IAdmin - function setPriorityTxMaxGasLimit(uint256 _newPriorityTxMaxGasLimit) external onlyChainTypeManager { + function setPriorityTxMaxGasLimit(uint256 _newPriorityTxMaxGasLimit) external onlyChainTypeManager onlyL1 { if (_newPriorityTxMaxGasLimit > MAX_GAS_PER_TRANSACTION) { revert TooMuchGas(); } @@ -111,7 +111,7 @@ contract AdminFacet is ZKChainBase, IAdmin { } /// @inheritdoc IAdmin - function setTokenMultiplier(uint128 _nominator, uint128 _denominator) external onlyAdminOrChainTypeManager { + function setTokenMultiplier(uint128 _nominator, uint128 _denominator) external onlyAdminOrChainTypeManager onlyL1 { if (_denominator == 0) { revert DenominatorIsZero(); } diff --git a/l1-contracts/test/foundry/l1/integration/l2-tests-in-l1-context/_SharedL2ContractDeployer.sol b/l1-contracts/test/foundry/l1/integration/l2-tests-in-l1-context/_SharedL2ContractDeployer.sol index 448794e27..0425df454 100644 --- a/l1-contracts/test/foundry/l1/integration/l2-tests-in-l1-context/_SharedL2ContractDeployer.sol +++ b/l1-contracts/test/foundry/l1/integration/l2-tests-in-l1-context/_SharedL2ContractDeployer.sol @@ -150,9 +150,16 @@ abstract contract SharedL2ContractDeployer is Test, DeployUtils { new bytes[](0) ); + uint256 currentChainId = block.chainid; + + // This function is available only on L1 (and it is correct), + // but inside testing we need to call this function to recreate commitment + vm.chainId(L1_CHAIN_ID); vm.prank(chainAdmin); AdminFacet(chainAddress).setTokenMultiplier(1, 1); + vm.chainId(currentChainId); + // Now, let's also append a priority transaction for a more representative example bytes[] memory deps = new bytes[](0);