Skip to content

Commit

Permalink
Merge branch 'release-v25-protocol-defense' into deniallugo-zk-toolbo…
Browse files Browse the repository at this point in the history
…x-dev
  • Loading branch information
koloz193 committed Sep 27, 2024
2 parents fc7c206 + 1fba03d commit c5fda60
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 24 deletions.
3 changes: 2 additions & 1 deletion gas-bound-caller/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@
"ethers": "^5.7.0",
"fast-glob": "^3.3.2",
"hardhat": "=2.22.2",
"preprocess": "^3.2.0"
"preprocess": "^3.2.0",
"zksync-ethers": "^5.9.0"
},
"devDependencies": {
"@matterlabs/hardhat-zksync-chai-matchers": "^0.2.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -339,16 +339,13 @@ contract ExperimentalBridgeTest is Test {
bridgeHub.addToken(randomAddress);
}

function test_addToken_cannotBeCalledByRandomAddress(
address randomAddress,
address randomCaller,
uint256 randomValue
) public useRandomToken(randomValue) {
if (randomCaller != bridgeOwner) {
vm.prank(randomCaller);
vm.expectRevert(bytes("Ownable: caller is not the owner"));
bridgeHub.addToken(randomAddress);
}
function test_addToken_cannotBeCalledByRandomAddress(address randomAddress, address randomCaller) public {
vm.assume(randomCaller != bridgeOwner);
vm.assume(randomCaller != bridgeHub.admin());

vm.prank(randomCaller);
vm.expectRevert(abi.encodeWithSelector(Unauthorized.selector, randomCaller));
bridgeHub.addToken(randomAddress);

assertTrue(!bridgeHub.tokenIsRegistered(randomAddress), "This random address is not registered as a token");

Expand Down
2 changes: 1 addition & 1 deletion l2-contracts/contracts/ConsensusRegistry.sol
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.20;
pragma solidity 0.8.24;

import {Ownable2StepUpgradeable} from "@openzeppelin/contracts-upgradeable-v4/access/Ownable2StepUpgradeable.sol";
import {Initializable} from "@openzeppelin/contracts-upgradeable-v4/proxy/utils/Initializable.sol";
Expand Down
2 changes: 1 addition & 1 deletion l2-contracts/contracts/interfaces/IConsensusRegistry.sol
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.20;
pragma solidity 0.8.24;

/// @author Matter Labs
/// @custom:security-contact [email protected]
Expand Down
3 changes: 2 additions & 1 deletion system-contracts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@
"ethers": "^5.7.0",
"fast-glob": "^3.3.2",
"hardhat": "=2.22.2",
"preprocess": "^3.2.0"
"preprocess": "^3.2.0",
"zksync-ethers": "^5.9.0"
},
"devDependencies": {
"@matterlabs/hardhat-zksync-chai-matchers": "^0.2.0",
Expand Down
33 changes: 23 additions & 10 deletions system-contracts/scripts/preprocess-bootloader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ const preprocess = require("preprocess");
const SYSTEM_PARAMS = require("../../SystemConfig.json");
/* eslint-enable@typescript-eslint/no-var-requires */

const OUTPUT_DIR = "contracts-preprocessed/bootloader";
const OUTPUT_DIR_1 = "contracts-preprocessed/bootloader";
const OUTPUT_DIR_2 = "bootloader/build";

const PREPROCCESING_MODES = ["proved_batch", "playground_batch"];

Expand Down Expand Up @@ -224,20 +225,32 @@ async function main() {
});
const provedBootloaderWithTests = preprocess.preprocess(bootloaderWithTests, { BOOTLOADER_TYPE: "proved_batch" });

if (!existsSync(OUTPUT_DIR)) {
mkdirSync(OUTPUT_DIR);
if (!existsSync(OUTPUT_DIR_1)) {
mkdirSync(OUTPUT_DIR_1);
}

if (!existsSync(OUTPUT_DIR_2)) {
mkdirSync(OUTPUT_DIR_2);
}

const transferTest = readFileSync("bootloader/tests/transfer_test.yul").toString();
const dummy = readFileSync("bootloader/tests/dummy.yul").toString();

writeFileSync(`${OUTPUT_DIR}/bootloader_test.yul`, provedBootloaderWithTests);
writeFileSync(`${OUTPUT_DIR}/proved_batch.yul`, provedBatchBootloader);
writeFileSync(`${OUTPUT_DIR}/playground_batch.yul`, playgroundBatchBootloader);
writeFileSync(`${OUTPUT_DIR}/gas_test.yul`, gasTestBootloader);
writeFileSync(`${OUTPUT_DIR}/fee_estimate.yul`, feeEstimationBootloader);
writeFileSync(`${OUTPUT_DIR}/dummy.yul`, dummy);
writeFileSync(`${OUTPUT_DIR}/transfer_test.yul`, transferTest);
writeFileSync(`${OUTPUT_DIR_1}/bootloader_test.yul`, provedBootloaderWithTests);
writeFileSync(`${OUTPUT_DIR_1}/proved_batch.yul`, provedBatchBootloader);
writeFileSync(`${OUTPUT_DIR_1}/playground_batch.yul`, playgroundBatchBootloader);
writeFileSync(`${OUTPUT_DIR_1}/gas_test.yul`, gasTestBootloader);
writeFileSync(`${OUTPUT_DIR_1}/fee_estimate.yul`, feeEstimationBootloader);
writeFileSync(`${OUTPUT_DIR_1}/dummy.yul`, dummy);
writeFileSync(`${OUTPUT_DIR_1}/transfer_test.yul`, transferTest);

writeFileSync(`${OUTPUT_DIR_2}/bootloader_test.yul`, provedBootloaderWithTests);
writeFileSync(`${OUTPUT_DIR_2}/proved_batch.yul`, provedBatchBootloader);
writeFileSync(`${OUTPUT_DIR_2}/playground_batch.yul`, playgroundBatchBootloader);
writeFileSync(`${OUTPUT_DIR_2}/gas_test.yul`, gasTestBootloader);
writeFileSync(`${OUTPUT_DIR_2}/fee_estimate.yul`, feeEstimationBootloader);
writeFileSync(`${OUTPUT_DIR_2}/dummy.yul`, dummy);
writeFileSync(`${OUTPUT_DIR_2}/transfer_test.yul`, transferTest);

console.log("Bootloader preprocessing done!");
}
Expand Down

0 comments on commit c5fda60

Please sign in to comment.