From 1cefe2842d38c5d8bfb741c595d8b3891ac8d495 Mon Sep 17 00:00:00 2001 From: kelemeno <34402761+kelemeno@users.noreply.github.com> Date: Thu, 27 Jun 2024 14:49:23 +0100 Subject: [PATCH 01/10] feat: move da-contracts to their own folder (#556) --- da-contracts/.env | 2 + da-contracts/contracts/CalldataDA.sol | 92 +++++++ da-contracts/contracts/DAUtils.sol | 37 +++ da-contracts/contracts/IL1DAValidator.sol | 34 +++ da-contracts/contracts/IL1Messenger.sol | 11 + .../contracts}/RollupL1DAValidator.sol | 15 +- .../contracts}/ValidiumL1DAValidator.sol | 2 +- da-contracts/foundry.toml | 32 +++ da-contracts/hardhat.config.ts | 57 ++++ da-contracts/package.json | 66 +++++ da-contracts/slither.config.json | 11 + da-contracts/tsconfig.json | 7 + l1-contracts/package.json | 2 +- l1-contracts/src.ts/deploy-utils.ts | 15 +- l1-contracts/src.ts/deploy.ts | 40 ++- package.json | 2 + yarn.lock | 254 +++--------------- 17 files changed, 439 insertions(+), 240 deletions(-) create mode 100644 da-contracts/.env create mode 100644 da-contracts/contracts/CalldataDA.sol create mode 100644 da-contracts/contracts/DAUtils.sol create mode 100644 da-contracts/contracts/IL1DAValidator.sol create mode 100644 da-contracts/contracts/IL1Messenger.sol rename {l1-contracts/contracts/state-transition/data-availability => da-contracts/contracts}/RollupL1DAValidator.sol (94%) rename {l1-contracts/contracts/state-transition/data-availability => da-contracts/contracts}/ValidiumL1DAValidator.sol (89%) create mode 100644 da-contracts/foundry.toml create mode 100644 da-contracts/hardhat.config.ts create mode 100644 da-contracts/package.json create mode 100644 da-contracts/slither.config.json create mode 100644 da-contracts/tsconfig.json diff --git a/da-contracts/.env b/da-contracts/.env new file mode 100644 index 000000000..59a2db08b --- /dev/null +++ b/da-contracts/.env @@ -0,0 +1,2 @@ +CHAIN_ETH_NETWORK=hardhat +ETH_CLIENT_WEB3_URL=http://127.0.0.1:8545 diff --git a/da-contracts/contracts/CalldataDA.sol b/da-contracts/contracts/CalldataDA.sol new file mode 100644 index 000000000..26206f0d8 --- /dev/null +++ b/da-contracts/contracts/CalldataDA.sol @@ -0,0 +1,92 @@ +// SPDX-License-Identifier: MIT + +pragma solidity 0.8.24; + +// solhint-disable gas-custom-errors, reason-string + +// TODO: maybe move it here +import {BLOB_SIZE_BYTES} from "./DAUtils.sol"; + +uint256 constant BLOBS_SUPPORTED = 6; + +/// @notice Contract that contains the functionality for process the calldata DA. +/// @dev The expected l2DAValidator that should be used with it `RollupL2DAValidator`. +abstract contract CalldataDA { + /// @notice Parses the input that the l2 Da validator has provided to the contract. + /// @param _l2DAValidatorOutputHash The hash of the output of the L2 DA validator. + /// @param _maxBlobsSupported The maximal number of blobs supported by the chain. + /// @param _operatorDAInput The DA input by the operator provided on L1. + function _processL2RollupDAValidatorOutputHash( + bytes32 _l2DAValidatorOutputHash, + uint256 _maxBlobsSupported, + bytes calldata _operatorDAInput + ) + internal + pure + returns ( + bytes32 stateDiffHash, + bytes32 fullPubdataHash, + bytes32[] memory blobsLinearHashes, + uint256 blobsProvided, + bytes calldata l1DaInput + ) + { + // The preimage under the hash `l2DAValidatorOutputHash` is expected to be in the following format: + // - First 32 bytes are the hash of the uncompressed state diff. + // - Then, there is a 32-byte hash of the full pubdata. + // - Then, there is the 1-byte number of blobs published. + // - Then, there are linear hashes of the published blobs, 32 bytes each. + + // Check that it accommodates enough pubdata for the state diff hash, hash of pubdata + the number of blobs. + require(_operatorDAInput.length >= 32 + 32 + 1, "too small"); + + stateDiffHash = bytes32(_operatorDAInput[:32]); + fullPubdataHash = bytes32(_operatorDAInput[32:64]); + blobsProvided = uint256(uint8(_operatorDAInput[64])); + + require(blobsProvided <= _maxBlobsSupported, "invalid number of blobs"); + + // Note that the API of the contract requires that the returned blobs linear hashes have length of + // the `_maxBlobsSupported` + blobsLinearHashes = new bytes32[](_maxBlobsSupported); + + require(_operatorDAInput.length >= 65 + 32 * blobsProvided, "invalid blobs hashes"); + + uint256 ptr = 65; + + for (uint256 i = 0; i < blobsProvided; ++i) { + // Take the 32 bytes of the blob linear hash + blobsLinearHashes[i] = bytes32(_operatorDAInput[ptr:ptr + 32]); + ptr += 32; + } + + // Now, we need to double check that the provided input was indeed retutned by the L2 DA validator. + require(keccak256(_operatorDAInput[:ptr]) == _l2DAValidatorOutputHash, "invalid l2 DA output hash"); + + // The rest of the output were provided specifically by the operator + l1DaInput = _operatorDAInput[ptr:]; + } + + /// @notice Verify that the calldata DA was correctly provided. + /// todo: better doc comments + function _processCalldataDA( + uint256 _blobsProvided, + bytes32 _fullPubdataHash, + uint256 _maxBlobsSupported, + bytes calldata _pubdataInput + ) internal pure returns (bytes32[] memory blobCommitments, bytes calldata _pubdata) { + // We typically do not know whether we'll use calldata or blobs at the time when + // we start proving the batch. That's why the blob commitment for a single blob is still present in the case of calldata. + + blobCommitments = new bytes32[](_maxBlobsSupported); + + require(_blobsProvided == 1, "one one blob with calldata"); + + _pubdata = _pubdataInput[:_pubdataInput.length - 32]; + + // FIXME: allow larger lengths for SyncLayer-based chains. + require(_pubdata.length <= BLOB_SIZE_BYTES, "cz"); + require(_fullPubdataHash == keccak256(_pubdata), "wp"); + blobCommitments[0] = bytes32(_pubdataInput[_pubdataInput.length - 32:_pubdataInput.length]); + } +} diff --git a/da-contracts/contracts/DAUtils.sol b/da-contracts/contracts/DAUtils.sol new file mode 100644 index 000000000..f79e609e9 --- /dev/null +++ b/da-contracts/contracts/DAUtils.sol @@ -0,0 +1,37 @@ +// SPDX-License-Identifier: MIT + +pragma solidity 0.8.24; + +/// @dev Total number of bytes in a blob. Blob = 4096 field elements * 31 bytes per field element +/// @dev EIP-4844 defines it as 131_072 but we use 4096 * 31 within our circuits to always fit within a field element +/// @dev Our circuits will prove that a EIP-4844 blob and our internal blob are the same. +uint256 constant BLOB_SIZE_BYTES = 126_976; + +/// @dev Enum used to determine the source of pubdata. At first we will support calldata and blobs but this can be extended. +enum PubdataSource { + Calldata, + Blob +} + +/// @dev BLS Modulus value defined in EIP-4844 and the magic value returned from a successful call to the +/// point evaluation precompile +uint256 constant BLS_MODULUS = 52435875175126190479447740508185965837690552500527637822603658699938581184513; + +/// @dev Packed pubdata commitments. +/// @dev Format: list of: opening point (16 bytes) || claimed value (32 bytes) || commitment (48 bytes) || proof (48 bytes)) = 144 bytes +uint256 constant PUBDATA_COMMITMENT_SIZE = 144; + +/// @dev Offset in pubdata commitment of blobs for claimed value +uint256 constant PUBDATA_COMMITMENT_CLAIMED_VALUE_OFFSET = 16; + +/// @dev Offset in pubdata commitment of blobs for kzg commitment +uint256 constant PUBDATA_COMMITMENT_COMMITMENT_OFFSET = 48; + +/// @dev For each blob we expect that the commitment is provided as well as the marker whether a blob with such commitment has been published before. +uint256 constant BLOB_DA_INPUT_SIZE = PUBDATA_COMMITMENT_SIZE + 32; + +/// @dev Address of the point evaluation precompile used for EIP-4844 blob verification. +address constant POINT_EVALUATION_PRECOMPILE_ADDR = address(0x0A); + +/// @dev The address of the special smart contract that can send arbitrary length message as an L2 log +address constant L2_TO_L1_MESSENGER_SYSTEM_CONTRACT_ADDR = address(0x8008); diff --git a/da-contracts/contracts/IL1DAValidator.sol b/da-contracts/contracts/IL1DAValidator.sol new file mode 100644 index 000000000..3b4c339b8 --- /dev/null +++ b/da-contracts/contracts/IL1DAValidator.sol @@ -0,0 +1,34 @@ +// SPDX-License-Identifier: MIT + +pragma solidity 0.8.24; + +struct L1DAValidatorOutput { + /// @dev The hash of the uncompressed state diff. + bytes32 stateDiffHash; + /// @dev The hashes of the blobs on L1. The array is dynamic to account for forward compatibility. + /// The length of it must be equal to `maxBlobsSupported`. + bytes32[] blobsLinearHashes; + /// @dev The commitments to the blobs on L1. The array is dynamic to account for forward compatibility. + /// Its length must be equal to the length of blobsLinearHashes. + /// @dev If the system supports more blobs than returned, the rest of the array should be filled with zeros. + bytes32[] blobsOpeningCommitments; +} + +// TODO: require EIP165 support as this will allow changes for future compatibility. +interface IL1DAValidator { + /// @notice The function that checks the data availability for the given batch input. + /// @param chainId The chain id of the chain that is being committed. + /// @param l2DAValidatorOutputHash The hash of that was returned by the l2DAValidator. + /// @param operatorDAInput The DA input by the operator provided on L1. + /// @param maxBlobsSupported The maximal number of blobs supported by the chain. + /// We provide this value for future compatibility. + /// This is needed because the corresponding `blobsLinearHashes`/`blobsOpeningCommitments` + /// in the `L1DAValidatorOutput` struct will have to have this length as it is required + /// to be static by the circuits. + function checkDA( + uint256 chainId, + bytes32 l2DAValidatorOutputHash, + bytes calldata operatorDAInput, + uint256 maxBlobsSupported + ) external returns (L1DAValidatorOutput memory output); +} diff --git a/da-contracts/contracts/IL1Messenger.sol b/da-contracts/contracts/IL1Messenger.sol new file mode 100644 index 000000000..f0557487b --- /dev/null +++ b/da-contracts/contracts/IL1Messenger.sol @@ -0,0 +1,11 @@ +// SPDX-License-Identifier: MIT + +pragma solidity 0.8.24; +/** + * @author Matter Labs + * @custom:security-contact security@matterlabs.dev + * @notice The interface of the L1 Messenger contract, responsible for sending messages to L1. + */ +interface IL1Messenger { + function sendToL1(bytes memory _message) external returns (bytes32); +} diff --git a/l1-contracts/contracts/state-transition/data-availability/RollupL1DAValidator.sol b/da-contracts/contracts/RollupL1DAValidator.sol similarity index 94% rename from l1-contracts/contracts/state-transition/data-availability/RollupL1DAValidator.sol rename to da-contracts/contracts/RollupL1DAValidator.sol index 59514705d..c5878c4ab 100644 --- a/l1-contracts/contracts/state-transition/data-availability/RollupL1DAValidator.sol +++ b/da-contracts/contracts/RollupL1DAValidator.sol @@ -4,13 +4,12 @@ pragma solidity 0.8.24; // solhint-disable gas-custom-errors, reason-string -import {IL1DAValidator, L1DAValidatorOutput} from "../chain-interfaces/IL1DAValidator.sol"; -import {POINT_EVALUATION_PRECOMPILE_ADDR} from "../../common/Config.sol"; +import {IL1DAValidator, L1DAValidatorOutput} from "./IL1DAValidator.sol"; import {CalldataDA} from "./CalldataDA.sol"; // TODO: maybe move it here -import {PubdataSource, BLS_MODULUS, PUBDATA_COMMITMENT_SIZE, PUBDATA_COMMITMENT_CLAIMED_VALUE_OFFSET, PUBDATA_COMMITMENT_COMMITMENT_OFFSET, BLOB_DA_INPUT_SIZE} from "../chain-interfaces/IExecutor.sol"; +import {PubdataSource, BLS_MODULUS, PUBDATA_COMMITMENT_SIZE, PUBDATA_COMMITMENT_CLAIMED_VALUE_OFFSET, PUBDATA_COMMITMENT_COMMITMENT_OFFSET, BLOB_DA_INPUT_SIZE, POINT_EVALUATION_PRECOMPILE_ADDR} from "./DAUtils.sol"; uint256 constant BLOBS_SUPPORTED = 6; @@ -170,11 +169,9 @@ contract RollupL1DAValidator is IL1DAValidator, CalldataDA { require(result == BLS_MODULUS, "precompile unexpected output"); } - function _getBlobVersionedHash(uint256) internal view virtual returns (bytes32 versionedHash) { - // FIXME: enable blobs - revert("Blobs not supported on this codebase yet"); - // assembly { - // versionedHash := blobhash(_index) - // } + function _getBlobVersionedHash(uint256 _index) internal view virtual returns (bytes32 versionedHash) { + assembly { + versionedHash := blobhash(_index) + } } } diff --git a/l1-contracts/contracts/state-transition/data-availability/ValidiumL1DAValidator.sol b/da-contracts/contracts/ValidiumL1DAValidator.sol similarity index 89% rename from l1-contracts/contracts/state-transition/data-availability/ValidiumL1DAValidator.sol rename to da-contracts/contracts/ValidiumL1DAValidator.sol index 01e82c831..3235049d8 100644 --- a/l1-contracts/contracts/state-transition/data-availability/ValidiumL1DAValidator.sol +++ b/da-contracts/contracts/ValidiumL1DAValidator.sol @@ -4,7 +4,7 @@ pragma solidity 0.8.24; // solhint-disable gas-custom-errors, reason-string -import {IL1DAValidator, L1DAValidatorOutput} from "../chain-interfaces/IL1DAValidator.sol"; +import {IL1DAValidator, L1DAValidatorOutput} from "./IL1DAValidator.sol"; contract ValidiumL1DAValidator is IL1DAValidator { function checkDA( diff --git a/da-contracts/foundry.toml b/da-contracts/foundry.toml new file mode 100644 index 000000000..6f29a31cc --- /dev/null +++ b/da-contracts/foundry.toml @@ -0,0 +1,32 @@ +[profile.default] +src = 'contracts' +out = 'out' +libs = ['node_modules', 'lib'] +remappings = [ + "@openzeppelin/contracts/=lib/openzeppelin-contracts/contracts/", + "@openzeppelin/contracts-upgradeable/=lib/openzeppelin-contracts-upgradeable/contracts/", + "l2-contracts/=../l2-contracts/contracts/" +] +allow_paths = ["../l2-contracts/contracts"] +fs_permissions = [ + { access = "read", path = "../system-contracts/bootloader/build/artifacts" }, + { access = "read", path = "../system-contracts/artifacts-zk/contracts-preprocessed" }, + { access = "read", path = "../l2-contracts/artifacts-zk/" }, + { access = "read", path = "./script-config" }, + { access = "read-write", path = "./script-out" }, + { access = "read", path = "./out" } +] +cache_path = 'cache-forge' +test = 'test/foundry' +solc_version = "0.8.24" +evm_version = "cancun" +ignored_error_codes = [ + "missing-receive-ether", + "code-size", +] +ignored_warnings_from = [ + "test", + "contracts/dev-contracts" +] + +# See more config options https://github.com/foundry-rs/foundry/tree/master/crates/config diff --git a/da-contracts/hardhat.config.ts b/da-contracts/hardhat.config.ts new file mode 100644 index 000000000..884dc43d3 --- /dev/null +++ b/da-contracts/hardhat.config.ts @@ -0,0 +1,57 @@ +import "@nomiclabs/hardhat-ethers"; +import "@nomiclabs/hardhat-etherscan"; +import "@nomiclabs/hardhat-waffle"; +import "hardhat-contract-sizer"; +import "hardhat-gas-reporter"; +import "hardhat-typechain"; +import "solidity-coverage"; + +// If no network is specified, use the default config +if (!process.env.CHAIN_ETH_NETWORK) { + // eslint-disable-next-line @typescript-eslint/no-var-requires + require("dotenv").config(); +} + +export default { + defaultNetwork: "env", + solidity: { + version: "0.8.24", + settings: { + optimizer: { + enabled: true, + runs: 9999999, + }, + outputSelection: { + "*": { + "*": ["storageLayout"], + }, + }, + evmVersion: "cancun", + }, + }, + contractSizer: { + runOnCompile: false, + except: ["dev-contracts", "zksync/libraries", "common/libraries"], + }, + paths: { + sources: "./contracts", + }, + networks: { + env: { + url: process.env.ETH_CLIENT_WEB3_URL?.split(",")[0], + }, + hardhat: { + allowUnlimitedContractSize: false, + forking: { + url: "https://eth-goerli.g.alchemy.com/v2/" + process.env.ALCHEMY_KEY, + enabled: process.env.TEST_CONTRACTS_FORK === "1", + }, + }, + }, + etherscan: { + apiKey: process.env.MISC_ETHERSCAN_API_KEY, + }, + gasReporter: { + enabled: true, + }, +}; diff --git a/da-contracts/package.json b/da-contracts/package.json new file mode 100644 index 000000000..1f68dcdab --- /dev/null +++ b/da-contracts/package.json @@ -0,0 +1,66 @@ +{ + "name": "da-contracts", + "version": "0.1.0", + "license": "MIT", + "engines": { + "node": ">=16" + }, + "devDependencies": { + "@nomiclabs/hardhat-ethers": "^2.0.0", + "@nomiclabs/hardhat-etherscan": "^3.1.0", + "@nomiclabs/hardhat-waffle": "^2.0.0", + "@openzeppelin/contracts": "4.9.5", + "@openzeppelin/contracts-upgradeable": "4.9.5", + "@typechain/ethers-v5": "^2.0.0", + "@types/argparse": "^1.0.36", + "@types/chai": "^4.2.21", + "@types/chai-as-promised": "^7.1.4", + "@types/mocha": "^8.2.3", + "argparse": "^1.0.10", + "axios": "^0.21.1", + "chai": "^4.3.10", + "chai-as-promised": "^7.1.1", + "chalk": "^4.1.0", + "collections": "^5.1.12", + "commander": "^8.3.0", + "eslint": "^8.51.0", + "eslint-import-resolver-typescript": "^3.6.1", + "eslint-plugin-import": "^2.29.0", + "eslint-plugin-prettier": "^5.0.1", + "ethereum-waffle": "^4.0.10", + "ethereumjs-abi": "^0.6.8", + "ethers": "^5.7.0", + "ethjs": "^0.4.0", + "fs": "^0.0.1-security", + "handlebars": "^4.7.6", + "hardhat": "=2.22.2", + "hardhat-contract-sizer": "^2.0.2", + "hardhat-gas-reporter": "^1.0.9", + "hardhat-typechain": "^0.3.3", + "jsonwebtoken": "^8.5.1", + "markdownlint-cli": "^0.33.0", + "merkletreejs": "^0.3.11", + "mocha": "^9.0.2", + "path": "^0.12.7", + "querystring": "^0.2.0", + "solc": "0.8.17", + "solhint": "^3.6.2", + "solidity-coverage": "^0.8.5", + "ts-generator": "^0.1.1", + "ts-node": "^10.1.0", + "typechain": "^4.0.0", + "typescript": "^4.6.4", + "zksync-ethers": "5.8.0-beta.5" + }, + "scripts": { + "build": "hardhat compile ", + "build-l1": "harhdat compile", + "clean": "hardhat clean", + "clean:foundry": "forge clean", + "verify": "hardhat run --network env scripts/verify.ts" + }, + "dependencies": { + "dotenv": "^16.0.3", + "solhint-plugin-prettier": "^0.0.5" + } +} diff --git a/da-contracts/slither.config.json b/da-contracts/slither.config.json new file mode 100644 index 000000000..0db8465a6 --- /dev/null +++ b/da-contracts/slither.config.json @@ -0,0 +1,11 @@ +{ + "filter_paths": "(contracts/dev-contracts|lib|node_modules)", + "detectors_to_exclude": "assembly,solc-version,low-level-calls,conformance-to-solidity-naming-conventions,incorrect-equality,uninitialized-local", + "exclude_dependencies": true, + "compile_force_framework": "foundry", + "exclude_medium": false, + "exclude_high": false, + "exclude_low": true, + "exclude_informational": true, + "exclude_optimization": true +} diff --git a/da-contracts/tsconfig.json b/da-contracts/tsconfig.json new file mode 100644 index 000000000..41d8e3fa8 --- /dev/null +++ b/da-contracts/tsconfig.json @@ -0,0 +1,7 @@ +{ + "compilerOptions": { + "types": ["node", "mocha"], + "downlevelIteration": true, + "resolveJsonModule": true + } +} diff --git a/l1-contracts/package.json b/l1-contracts/package.json index ff21925f5..3f0415a70 100644 --- a/l1-contracts/package.json +++ b/l1-contracts/package.json @@ -57,7 +57,7 @@ "build-l1": "harhdat compile", "clean": "hardhat clean", "clean:foundry": "forge clean", - "test": "hardhat test test/unit_tests/*.spec.ts --network hardhat", + "test": "yarn workspace da-contracts build && hardhat test test/unit_tests/*.spec.ts --network hardhat", "test:foundry": "forge test", "test:fork": "TEST_CONTRACTS_FORK=1 yarn run hardhat test test/unit_tests/*.fork.ts --network hardhat", "coverage:foundry": "forge coverage", diff --git a/l1-contracts/src.ts/deploy-utils.ts b/l1-contracts/src.ts/deploy-utils.ts index 65794a1f2..fbb7346c3 100644 --- a/l1-contracts/src.ts/deploy-utils.ts +++ b/l1-contracts/src.ts/deploy-utils.ts @@ -15,15 +15,18 @@ export async function deployViaCreate2( create2FactoryAddress: string, verbose: boolean = true, // eslint-disable-next-line @typescript-eslint/no-explicit-any - libraries?: any + libraries?: any, + bytecode?: ethers.utils.BytesLike ): Promise<[string, string]> { // [address, txHash] - const contractFactory = await hardhat.ethers.getContractFactory(contractName, { - signer: deployWallet, - libraries, - }); - const bytecode = contractFactory.getDeployTransaction(...args, ethTxOptions).data; + if (!bytecode) { + const contractFactory = await hardhat.ethers.getContractFactory(contractName, { + signer: deployWallet, + libraries, + }); + bytecode = contractFactory.getDeployTransaction(...args, ethTxOptions).data; + } return await deployBytecodeViaCreate2( deployWallet, diff --git a/l1-contracts/src.ts/deploy.ts b/l1-contracts/src.ts/deploy.ts index df7aa6f95..f8d3eed47 100644 --- a/l1-contracts/src.ts/deploy.ts +++ b/l1-contracts/src.ts/deploy.ts @@ -70,6 +70,9 @@ import { ISTMDeploymentTrackerFactory } from "../typechain/ISTMDeploymentTracker import { TestnetERC20TokenFactory } from "../typechain/TestnetERC20TokenFactory"; +import { RollupL1DAValidatorFactory } from "../../da-contracts/typechain/RollupL1DAValidatorFactory"; +import { ValidiumL1DAValidatorFactory } from "../../da-contracts/typechain/ValidiumL1DAValidatorFactory"; + // const provider = web3Provider(); let L2_BOOTLOADER_BYTECODE_HASH: string; @@ -273,9 +276,14 @@ export class Deployer { create2Salt: string, ethTxOptions: ethers.providers.TransactionRequest, // eslint-disable-next-line @typescript-eslint/no-explicit-any - libraries?: any + libraries?: any, + bytecode?: ethers.utils.BytesLike ) { if (this.isZkMode()) { + if (bytecode != null) { + return ADDRESS_ONE; + // note providing bytecode is only for da-contracts on L1, we can skip it here + } const result = await deployViaCreate2Zk( this.deployWallet as ZkWallet, contractName, @@ -297,11 +305,22 @@ export class Deployer { ethTxOptions, this.addresses.Create2Factory, this.verbose, - libraries + libraries, + bytecode ); return result[0]; } + public async loadFromDAFolder(contractName: string) { + let factory; + if (contractName == "RollupL1DAValidator") { + factory = new RollupL1DAValidatorFactory(this.deployWallet); + } else if (contractName == "ValidiumL1DAValidator") { + factory = new ValidiumL1DAValidatorFactory(this.deployWallet); + } + return factory.getDeployTransaction().data; + } + private async deployBytecodeViaCreate2( contractName: string, bytecode: ethers.BytesLike, @@ -1347,17 +1366,28 @@ export class Deployer { ethTxOptions.gasLimit ??= 10_000_000; // This address only makes sense on the L1, but we deploy it anyway to keep the script simple - const rollupDAValidatorAddress = await this.deployViaCreate2("RollupL1DAValidator", [], create2Salt, ethTxOptions); + const rollupValidatorBytecode = await this.loadFromDAFolder("RollupL1DAValidator"); + const rollupDAValidatorAddress = await this.deployViaCreate2( + "RollupL1DAValidator", + [], + create2Salt, + ethTxOptions, + undefined, + rollupValidatorBytecode + ); if (this.verbose) { console.log(`CONTRACTS_L1_ROLLUP_DA_VALIDATOR=${rollupDAValidatorAddress}`); } - + const validiumValidatorBytecode = await this.loadFromDAFolder("ValidiumL1DAValidator"); const validiumDAValidatorAddress = await this.deployViaCreate2( "ValidiumL1DAValidator", [], create2Salt, - ethTxOptions + ethTxOptions, + undefined, + validiumValidatorBytecode ); + if (this.verbose) { console.log(`CONTRACTS_L1_VALIDIUM_DA_VALIDATOR=${validiumDAValidatorAddress}`); } diff --git a/package.json b/package.json index 5aeef0ff2..b17e3cb21 100644 --- a/package.json +++ b/package.json @@ -6,6 +6,7 @@ "packages": [ "l1-contracts", "l2-contracts", + "da-contracts", "system-contracts", "gas-bound-caller" ], @@ -38,6 +39,7 @@ "l1": "yarn workspace l1-contracts", "l2": "yarn workspace l2-contracts", "sc": "yarn workspace system-contracts", + "da": "yarn workspace da-contracts", "gas-bound-caller": "yarn workspace gas-bound-caller" } } diff --git a/yarn.lock b/yarn.lock index 3bee5312f..0b7dac94b 100644 --- a/yarn.lock +++ b/yarn.lock @@ -656,18 +656,6 @@ resolved "https://registry.yarnpkg.com/@humanwhocodes/object-schema/-/object-schema-2.0.3.tgz#4a2868d75d6d6963e423bcf90b7fd1be343409d3" integrity sha512-93zYdMES/c1D69yZiKDBj0V24vqNzB/koF26KPaagAfd3P/4gUlh3Dys5ogAK+Exi9QyzlD8x/08Zt7wIKcDcA== -"@isaacs/cliui@^8.0.2": - version "8.0.2" - resolved "https://registry.yarnpkg.com/@isaacs/cliui/-/cliui-8.0.2.tgz#b37667b7bc181c168782259bab42474fbf52b550" - integrity sha512-O8jcjabXaleOG9DQ0+ARXWZBTfnP4WNAqzuiJK7ll44AmxGKv/J2M4TPjxjY3znBCfvBXFzucm1twdyFybFqEA== - dependencies: - string-width "^5.1.2" - string-width-cjs "npm:string-width@^4.2.0" - strip-ansi "^7.0.1" - strip-ansi-cjs "npm:strip-ansi@^6.0.1" - wrap-ansi "^8.1.0" - wrap-ansi-cjs "npm:wrap-ansi@^7.0.0" - "@jridgewell/resolve-uri@^3.0.3": version "3.1.2" resolved "https://registry.yarnpkg.com/@jridgewell/resolve-uri/-/resolve-uri-3.1.2.tgz#7a0ee601f60f99a20c7c7c5ff0c80388c1189bd6" @@ -706,15 +694,6 @@ ordinal "1.0.3" zksync-ethers "^5.0.0" -"@matterlabs/hardhat-zksync-deploy@0.6.5": - version "0.6.5" - resolved "https://registry.yarnpkg.com/@matterlabs/hardhat-zksync-deploy/-/hardhat-zksync-deploy-0.6.5.tgz#fe56bf30850e71c8d328ac1a06a100c1a0af6e3e" - integrity sha512-EZpvn8pDslfO3UA2obT8FOi5jsHhxYS5ndIR7tjL2zXKbvkbpoJR5rgKoGTJJm0riaCud674sQcxMOybVQ+2gg== - dependencies: - "@matterlabs/hardhat-zksync-solc" "0.4.2" - chalk "4.1.2" - ts-morph "^19.0.0" - "@matterlabs/hardhat-zksync-deploy@^0.6.5": version "0.6.6" resolved "https://registry.yarnpkg.com/@matterlabs/hardhat-zksync-deploy/-/hardhat-zksync-deploy-0.6.6.tgz#5c86cf7da859844167d62300528c3e6013ee0286" @@ -733,32 +712,6 @@ chalk "4.1.2" ts-morph "^19.0.0" -"@matterlabs/hardhat-zksync-deploy@^1.1.2": - version "1.4.0" - resolved "https://registry.yarnpkg.com/@matterlabs/hardhat-zksync-deploy/-/hardhat-zksync-deploy-1.4.0.tgz#6958d6769d6464b501a034be958a520dd8030399" - integrity sha512-M/dHuVmx8AdWtJj5IHgPfFn8twde8VJU8bqD881uT32iMfODnP9/QmsRucS2oS6rqC9HmEpFFsIBQlqYBFGOyw== - dependencies: - "@matterlabs/hardhat-zksync-solc" "^1.0.4" - chai "^4.3.6" - chalk "4.1.2" - fs-extra "^11.2.0" - glob "^10.3.10" - lodash "^4.17.21" - sinon "^17.0.1" - sinon-chai "^3.7.0" - ts-morph "^21.0.1" - -"@matterlabs/hardhat-zksync-ethers@^1.0.0": - version "1.0.0" - resolved "https://registry.yarnpkg.com/@matterlabs/hardhat-zksync-ethers/-/hardhat-zksync-ethers-1.0.0.tgz#0b455b1434d8395b7ee8f475dbd5cd7e5877e358" - integrity sha512-+po8lqpFVKEwfjanhkUO+PLDmwf/GEBK21vd4X7Pn/g9RLLal1c5m+xhHIVWV99xWPnlHjHIPHZfBf8fN4UasA== - dependencies: - "@matterlabs/hardhat-zksync-deploy" "^1.1.2" - "@matterlabs/hardhat-zksync-solc" "^1.1.2" - chai "^4.2.0" - chalk "5.3.0" - hardhat "^2.19.4" - "@matterlabs/hardhat-zksync-node@^0.0.1-beta.7": version "0.0.1" resolved "https://registry.yarnpkg.com/@matterlabs/hardhat-zksync-node/-/hardhat-zksync-node-0.0.1.tgz#d44bda3c0069b149e2a67c9697eb81166b169ea6" @@ -802,7 +755,7 @@ chalk "4.1.2" dockerode "^3.3.4" -"@matterlabs/hardhat-zksync-solc@^1.0.4", "@matterlabs/hardhat-zksync-solc@^1.0.5", "@matterlabs/hardhat-zksync-solc@^1.1.2", "@matterlabs/hardhat-zksync-solc@^1.1.4": +"@matterlabs/hardhat-zksync-solc@^1.0.5", "@matterlabs/hardhat-zksync-solc@^1.1.4": version "1.1.4" resolved "https://registry.yarnpkg.com/@matterlabs/hardhat-zksync-solc/-/hardhat-zksync-solc-1.1.4.tgz#04a2fad6fb6b6944c64ad969080ee65b9af3f617" integrity sha512-4/usbogh9neewR2/v8Dn2OzqVblZMUuT/iH2MyPZgPRZYQlL4SlZtMvokU9UQjZT6iSoaKCbbdWESHDHSzfUjA== @@ -819,22 +772,10 @@ sinon-chai "^3.7.0" undici "^5.14.0" -"@matterlabs/hardhat-zksync-verify@^0.4.0": - version "0.4.0" - resolved "https://registry.yarnpkg.com/@matterlabs/hardhat-zksync-verify/-/hardhat-zksync-verify-0.4.0.tgz#f812c19950022fc36728f3796f6bdae5633e2fcd" - integrity sha512-GPZmAumFl3ZMPKbECX7Qw8CriwZKWd1DlCRhoG/6YYc6mFy4+MXkF1XsHLMs5r34N+GDOfbVZVMeftIlJC96Kg== - dependencies: - "@matterlabs/hardhat-zksync-solc" "^1.0.5" - "@nomicfoundation/hardhat-verify" "^1.0.2" - axios "^1.4.0" - chalk "4.1.2" - dockerode "^3.3.4" - zksync-ethers "^5.0.0" - -"@matterlabs/hardhat-zksync-verify@^1.4.2": - version "1.4.2" - resolved "https://registry.yarnpkg.com/@matterlabs/hardhat-zksync-verify/-/hardhat-zksync-verify-1.4.2.tgz#095af84021ad775ae45df3a94c95efd2528714ab" - integrity sha512-GKdb4/5Xx5O9AbwtUnKQELxzVrWzv8HzZtvTJulekNe7+zy43O4AYb0uOjD6jbGRBoTGjWektlh0JYdAHJEdZQ== +"@matterlabs/hardhat-zksync-verify@0.6.1": + version "0.6.1" + resolved "https://registry.yarnpkg.com/@matterlabs/hardhat-zksync-verify/-/hardhat-zksync-verify-0.6.1.tgz#3fd83f4177ac0b138656ed93d4756ec27f1d329d" + integrity sha512-W9gI4k1UnuQ2MaBnK1f7E8Z2C4uHxpeDkzmB/ZCKClai2A3vK2jAbfqiQbX0HvuLq2OOq4dbx83KehAXjXoHlw== dependencies: "@ethersproject/abi" "^5.1.2" "@ethersproject/address" "5.7.0" @@ -846,9 +787,22 @@ chai "^4.3.6" chalk "4.1.2" debug "^4.1.1" - hardhat "^2.19.4" + hardhat "^2.14.0" sinon "^17.0.1" sinon-chai "^3.7.0" + zksync-ethers "^5.0.0" + +"@matterlabs/hardhat-zksync-verify@^0.4.0": + version "0.4.0" + resolved "https://registry.yarnpkg.com/@matterlabs/hardhat-zksync-verify/-/hardhat-zksync-verify-0.4.0.tgz#f812c19950022fc36728f3796f6bdae5633e2fcd" + integrity sha512-GPZmAumFl3ZMPKbECX7Qw8CriwZKWd1DlCRhoG/6YYc6mFy4+MXkF1XsHLMs5r34N+GDOfbVZVMeftIlJC96Kg== + dependencies: + "@matterlabs/hardhat-zksync-solc" "^1.0.5" + "@nomicfoundation/hardhat-verify" "^1.0.2" + axios "^1.4.0" + chalk "4.1.2" + dockerode "^3.3.4" + zksync-ethers "^5.0.0" "@matterlabs/hardhat-zksync-verify@^1.4.3": version "1.4.3" @@ -1229,11 +1183,6 @@ resolved "https://registry.yarnpkg.com/@openzeppelin/contracts/-/contracts-4.9.6.tgz#2a880a24eb19b4f8b25adc2a5095f2aa27f39677" integrity sha512-xSmezSupL+y9VkHZJGDoCBpmnB2ogM13ccaYDWqJTfS3dbuHkgjuwDFUmaFauBCboQMGB/S5UqUl2y54X99BmA== -"@pkgjs/parseargs@^0.11.0": - version "0.11.0" - resolved "https://registry.yarnpkg.com/@pkgjs/parseargs/-/parseargs-0.11.0.tgz#a77ea742fab25775145434eb1d2328cf5013ac33" - integrity sha512-+1VkjdD0QBLPodGrJUeqarH8VAIvQODIbwh9XpP5Syisf7YoQgsJKPNFoqqLQlu+VQ/tVSshMR6loPMn8U+dPg== - "@pkgr/core@^0.1.0": version "0.1.1" resolved "https://registry.yarnpkg.com/@pkgr/core/-/core-0.1.1.tgz#1ec17e2edbec25c8306d424ecfbf13c7de1aaa31" @@ -1499,16 +1448,6 @@ mkdirp "^2.1.6" path-browserify "^1.0.1" -"@ts-morph/common@~0.22.0": - version "0.22.0" - resolved "https://registry.yarnpkg.com/@ts-morph/common/-/common-0.22.0.tgz#8951d451622a26472fbc3a227d6c3a90e687a683" - integrity sha512-HqNBuV/oIlMKdkLshXd1zKBqNQCsuPEsgQOkfFQ/eUKjRlwndXW1AjN9LVkBEIukm00gGXSRmfkl0Wv5VXLnlw== - dependencies: - fast-glob "^3.3.2" - minimatch "^9.0.3" - mkdirp "^3.0.1" - path-browserify "^1.0.1" - "@tsconfig/node10@^1.0.7": version "1.0.11" resolved "https://registry.yarnpkg.com/@tsconfig/node10/-/node10-1.0.11.tgz#6ee46400685f130e278128c7b38b7e031ff5b2f2" @@ -1988,11 +1927,6 @@ ansi-regex@^5.0.1: resolved "https://registry.yarnpkg.com/ansi-regex/-/ansi-regex-5.0.1.tgz#082cb2c89c9fe8659a311a53bd6a4dc5301db304" integrity sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ== -ansi-regex@^6.0.1: - version "6.0.1" - resolved "https://registry.yarnpkg.com/ansi-regex/-/ansi-regex-6.0.1.tgz#3183e38fae9a65d7cb5e53945cd5897d0260a06a" - integrity sha512-n5M855fKb2SsfMIiFFoVrABHJC8QtHwVx+mHWP3QcEqBHYienj5dHSgjbxtC0WEZXYt4wcD6zrQElDPhFuZgfA== - ansi-styles@^3.2.1: version "3.2.1" resolved "https://registry.yarnpkg.com/ansi-styles/-/ansi-styles-3.2.1.tgz#41fbb20243e50b12be0f04b8dedbf07520ce841d" @@ -2007,11 +1941,6 @@ ansi-styles@^4.0.0, ansi-styles@^4.1.0: dependencies: color-convert "^2.0.1" -ansi-styles@^6.1.0: - version "6.2.1" - resolved "https://registry.yarnpkg.com/ansi-styles/-/ansi-styles-6.2.1.tgz#0e62320cf99c21afff3b3012192546aacbfb05c5" - integrity sha512-bN798gFfQX+viw3R7yrGWRqnrN2oRkEkUjjl4JNn4E8GxxbjtG3FbrEIIY3l8/hrwUwIeCZvi4QuOTP4MErVug== - antlr4@^4.11.0: version "4.13.1" resolved "https://registry.yarnpkg.com/antlr4/-/antlr4-4.13.1.tgz#1e0a1830a08faeb86217cb2e6c34716004e4253d" @@ -2232,7 +2161,7 @@ axios@^0.21.1: dependencies: follow-redirects "^1.14.0" -axios@^1.4.0, axios@^1.5.1, axios@^1.6.2: +axios@^1.4.0, axios@^1.5.1: version "1.6.8" resolved "https://registry.yarnpkg.com/axios/-/axios-1.6.8.tgz#66d294951f5d988a00e87a0ffb955316a619ea66" integrity sha512-v/ZHtJDU39mDpyBoFVkETcd/uNdxrWRrg3bKpOKzXFA6Bvqopts6ALSMU3y6ijYxbw2B+wPrIv46egTzJXCLGQ== @@ -2559,7 +2488,7 @@ chai-as-promised@^7.1.1: dependencies: check-error "^1.0.2" -chai@^4.2.0, chai@^4.3.10, chai@^4.3.6, chai@^4.3.7: +chai@^4.3.10, chai@^4.3.6, chai@^4.3.7: version "4.4.1" resolved "https://registry.yarnpkg.com/chai/-/chai-4.4.1.tgz#3603fa6eba35425b0f2ac91a009fe924106e50d1" integrity sha512-13sOfMv2+DWduEU+/xbun3LScLoqN17nBeTLUsmDfKdoiC1fr0n9PU4guu4AhRcOVFk/sW8LyZWHuhWtQZiF+g== @@ -2580,11 +2509,6 @@ chalk@4.1.2, chalk@^4.0.0, chalk@^4.1.0, chalk@^4.1.2: ansi-styles "^4.1.0" supports-color "^7.1.0" -chalk@5.3.0: - version "5.3.0" - resolved "https://registry.yarnpkg.com/chalk/-/chalk-5.3.0.tgz#67c20a7ebef70e7f3970a01f90fa210cb6860385" - integrity sha512-dLitG79d+GV1Nb/VYcCDFivJeK1hiukt9QjRNVOsUtTy1rR1YJsmpGGTZ3qJos+uw7WmWF4wUwBd9jxjocFC2w== - chalk@^2.4.1, chalk@^2.4.2: version "2.4.2" resolved "https://registry.yarnpkg.com/chalk/-/chalk-2.4.2.tgz#cd42541677a54333cf541a49108c1432b44c9424" @@ -2903,7 +2827,7 @@ create-require@^1.1.0: resolved "https://registry.yarnpkg.com/create-require/-/create-require-1.1.1.tgz#c1d7e8f1e5f6cfc9ff65f9cd352d37348756c333" integrity sha512-dcKFX3jn0MpIaXjisoRvexIJVEKzaq7z2rZKxf+MSr9TkdmHmsU4m2lcLojrj/FHl8mk5VxMmYA+ftRkP/3oKQ== -cross-spawn@^7.0.0, cross-spawn@^7.0.2: +cross-spawn@^7.0.2: version "7.0.3" resolved "https://registry.yarnpkg.com/cross-spawn/-/cross-spawn-7.0.3.tgz#f73a85b9d5d41d045551c177e2882d4ac85728a6" integrity sha512-iRDPJKUPVEND7dHPO8rkbOnPpyDygcDFtWjpeWNCgy8WP2rXcxXL8TskReQl6OrB2G7+UJrags1q15Fudc7G6w== @@ -3164,11 +3088,6 @@ dotenv@^16.0.3: resolved "https://registry.yarnpkg.com/dotenv/-/dotenv-16.4.5.tgz#cdd3b3b604cb327e286b4762e13502f717cb099f" integrity sha512-ZmdL2rui+eB2YwhsWzjInR8LldtZHGDoQ1ugH85ppHKwpUHL7j7rN0Ti9NCnGiQbhaZ11FpR+7ao1dNsmduNUg== -eastasianwidth@^0.2.0: - version "0.2.0" - resolved "https://registry.yarnpkg.com/eastasianwidth/-/eastasianwidth-0.2.0.tgz#696ce2ec0aa0e6ea93a397ffcf24aa7840c827cb" - integrity sha512-I88TYZWc9XiYHRQ4/3c5rjjfgkjhLyW2luGIheGERbNQ6OY7yTybanSpDXZa8y7VUP9YmDcYa+eyq4ca7iLqWA== - ecc-jsbn@~0.1.1: version "0.1.2" resolved "https://registry.yarnpkg.com/ecc-jsbn/-/ecc-jsbn-0.1.2.tgz#3a83a904e54353287874c564b7549386849a98c9" @@ -3220,11 +3139,6 @@ emoji-regex@^8.0.0: resolved "https://registry.yarnpkg.com/emoji-regex/-/emoji-regex-8.0.0.tgz#e818fd69ce5ccfcb404594f842963bf53164cc37" integrity sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A== -emoji-regex@^9.2.2: - version "9.2.2" - resolved "https://registry.yarnpkg.com/emoji-regex/-/emoji-regex-9.2.2.tgz#840c8803b0d8047f4ff0cf963176b32d4ef3ed72" - integrity sha512-L18DaJsXSUk2+42pv8mLs5jJT2hqFkFE4j21wOmgbUqsZ2hL72NsUU785g9RXgo3s0ZNgVl42TiHp3ZtOv/Vyg== - encoding-down@^6.3.0: version "6.3.0" resolved "https://registry.yarnpkg.com/encoding-down/-/encoding-down-6.3.0.tgz#b1c4eb0e1728c146ecaef8e32963c549e76d082b" @@ -3979,14 +3893,6 @@ for-each@^0.3.3: dependencies: is-callable "^1.1.3" -foreground-child@^3.1.0: - version "3.1.1" - resolved "https://registry.yarnpkg.com/foreground-child/-/foreground-child-3.1.1.tgz#1d173e776d75d2772fed08efe4a0de1ea1b12d0d" - integrity sha512-TMKDUnIte6bfb5nWv7V/caI169OHgvwjb7V4WkeUvbQQdjr5rWKqHFiKWb/fcOwB+CzBT+qbWjvj+DVwRskpIg== - dependencies: - cross-spawn "^7.0.0" - signal-exit "^4.0.1" - forever-agent@~0.6.1: version "0.6.1" resolved "https://registry.yarnpkg.com/forever-agent/-/forever-agent-0.6.1.tgz#fbc71f0c41adeb37f96c577ad1ed42d8fdacca91" @@ -4050,7 +3956,7 @@ fs-extra@^0.30.0: path-is-absolute "^1.0.0" rimraf "^2.2.8" -fs-extra@^11.1.1, fs-extra@^11.2.0: +fs-extra@^11.1.1: version "11.2.0" resolved "https://registry.yarnpkg.com/fs-extra/-/fs-extra-11.2.0.tgz#e70e17dfad64232287d01929399e0ea7c86b0e5b" integrity sha512-PmDi3uwK5nFuXh7XDTlVnS17xJS7vW36is2+w3xcv8SVxiB4NyATf4ctkVY5bkSjX0Y4nbvZCq1/EjtEyr9ktw== @@ -4255,17 +4161,6 @@ glob@8.1.0, glob@^8.0.3: minimatch "^5.0.1" once "^1.3.0" -glob@^10.3.10: - version "10.3.12" - resolved "https://registry.yarnpkg.com/glob/-/glob-10.3.12.tgz#3a65c363c2e9998d220338e88a5f6ac97302960b" - integrity sha512-TCNv8vJ+xz4QiqTpfOJA7HvYv+tNIRHKfUWw/q+v2jdgN4ebz+KY9tGx5J4rHP0o84mNP+ApH66HRX8us3Khqg== - dependencies: - foreground-child "^3.1.0" - jackspeak "^2.3.6" - minimatch "^9.0.1" - minipass "^7.0.4" - path-scurry "^1.10.2" - glob@^5.0.15: version "5.0.15" resolved "https://registry.yarnpkg.com/glob/-/glob-5.0.15.tgz#1bc936b9e02f4a603fcc222ecf7633d30b8b93b1" @@ -5009,15 +4904,6 @@ isstream@~0.1.2: resolved "https://registry.yarnpkg.com/isstream/-/isstream-0.1.2.tgz#47e63f7af55afa6f92e1500e690eb8b8529c099a" integrity sha512-Yljz7ffyPbrLpLngrMtZ7NduUgVvi6wG9RJ9IUcyCd59YQ911PBJphODUcbOVbqYfxe1wuYf/LJ8PauMRwsM/g== -jackspeak@^2.3.6: - version "2.3.6" - resolved "https://registry.yarnpkg.com/jackspeak/-/jackspeak-2.3.6.tgz#647ecc472238aee4b06ac0e461acc21a8c505ca8" - integrity sha512-N3yCS/NegsOBokc8GAdM8UcmfsKiSS8cipheD/nivzr700H+nsMOxJjQnvwOcRYVuFkdH0wGUvW2WbXGmrZGbQ== - dependencies: - "@isaacs/cliui" "^8.0.2" - optionalDependencies: - "@pkgjs/parseargs" "^0.11.0" - js-sha3@0.5.5: version "0.5.5" resolved "https://registry.yarnpkg.com/js-sha3/-/js-sha3-0.5.5.tgz#baf0c0e8c54ad5903447df96ade7a4a1bca79a4a" @@ -5465,11 +5351,6 @@ lowercase-keys@^3.0.0: resolved "https://registry.yarnpkg.com/lowercase-keys/-/lowercase-keys-3.0.0.tgz#c5e7d442e37ead247ae9db117a9d0a467c89d4f2" integrity sha512-ozCC6gdQ+glXOQsveKD0YsDy8DSQFjDTz4zyzEHNV5+JP5D62LmfDZ6o1cycFx9ouG940M5dE8C8CTewdj2YWQ== -lru-cache@^10.2.0: - version "10.2.2" - resolved "https://registry.yarnpkg.com/lru-cache/-/lru-cache-10.2.2.tgz#48206bc114c1252940c41b25b41af5b545aca878" - integrity sha512-9hp3Vp2/hFQUiIwKo8XCeFVnrg8Pk3TYNPIR7tJADKi5YfcF7vEaK7avFHTlSy3kOKYaJQaalfEo6YuXdceBOQ== - lru-cache@^5.1.1: version "5.1.1" resolved "https://registry.yarnpkg.com/lru-cache/-/lru-cache-5.1.1.tgz#1da27e6710271947695daf6848e847f01d84b920" @@ -5696,23 +5577,11 @@ minimatch@^7.4.3: dependencies: brace-expansion "^2.0.1" -minimatch@^9.0.1, minimatch@^9.0.3: - version "9.0.4" - resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-9.0.4.tgz#8e49c731d1749cbec05050ee5145147b32496a51" - integrity sha512-KqWh+VchfxcMNRAJjj2tnsSJdNbHsVgnkBhTNrW7AjVo6OvLtxw8zfT9oLw1JSohlFzJ8jCoTgaoXvJ+kHt6fw== - dependencies: - brace-expansion "^2.0.1" - minimist@^1.2.0, minimist@^1.2.5, minimist@^1.2.6, minimist@^1.2.8: version "1.2.8" resolved "https://registry.yarnpkg.com/minimist/-/minimist-1.2.8.tgz#c1a464e7693302e082a075cee0c057741ac4772c" integrity sha512-2yyAR8qBkN3YuheJanUpWC5U3bb5osDywNB8RzDVlDwDHbocAJveqqj1u8+SVD7jkWT4yvsHCpWqqWqAxb0zCA== -"minipass@^5.0.0 || ^6.0.2 || ^7.0.0", minipass@^7.0.4: - version "7.0.4" - resolved "https://registry.yarnpkg.com/minipass/-/minipass-7.0.4.tgz#dbce03740f50a4786ba994c1fb908844d27b038c" - integrity sha512-jYofLM5Dam9279rdkWzqHozUo4ybjdZmCsDHePy5V/PbBcVMiSZR97gmAy45aqi8CK1lG2ECd356FU86avfwUQ== - mkdirp-classic@^0.5.2: version "0.5.3" resolved "https://registry.yarnpkg.com/mkdirp-classic/-/mkdirp-classic-0.5.3.tgz#fa10c9115cc6d8865be221ba47ee9bed78601113" @@ -5735,11 +5604,6 @@ mkdirp@^2.1.6: resolved "https://registry.yarnpkg.com/mkdirp/-/mkdirp-2.1.6.tgz#964fbcb12b2d8c5d6fbc62a963ac95a273e2cc19" integrity sha512-+hEnITedc8LAtIP9u3HJDFIdcLV2vXP33sqLLIzkv1Db1zO/1OxbvYf0Y1OC/S/Qo5dxHXepofhmxL02PsKe+A== -mkdirp@^3.0.1: - version "3.0.1" - resolved "https://registry.yarnpkg.com/mkdirp/-/mkdirp-3.0.1.tgz#e44e4c5607fb279c168241713cc6e0fea9adcb50" - integrity sha512-+NsyUUAZDmo6YVHzL/stxSu3t9YS1iljliy3BSDrXJ/dkn1KYdmtZODGGjLcc9XLgVVpH4KshHB8XmZgMhaBXg== - mnemonist@^0.38.0: version "0.38.5" resolved "https://registry.yarnpkg.com/mnemonist/-/mnemonist-0.38.5.tgz#4adc7f4200491237fe0fa689ac0b86539685cade" @@ -6136,14 +6000,6 @@ path-parse@^1.0.6, path-parse@^1.0.7: resolved "https://registry.yarnpkg.com/path-parse/-/path-parse-1.0.7.tgz#fbc114b60ca42b30d9daf5858e4bd68bbedb6735" integrity sha512-LDJzPVEEEPR+y48z93A0Ed0yXb8pAByGWo/k5YYdYgpY2/2EsOsksJrq7lOHxryrVOn1ejG6oAp8ahvOIQD8sw== -path-scurry@^1.10.2: - version "1.10.2" - resolved "https://registry.yarnpkg.com/path-scurry/-/path-scurry-1.10.2.tgz#8f6357eb1239d5fa1da8b9f70e9c080675458ba7" - integrity sha512-7xTavNy5RQXnsjANvVvMkEjvloOinkAjv/Z6Ildz9v2RinZ4SBKTWFOVRbaF8p0vpHnyjV/UwNDdKuUv6M5qcA== - dependencies: - lru-cache "^10.2.0" - minipass "^5.0.0 || ^6.0.2 || ^7.0.0" - path-to-regexp@^6.2.1: version "6.2.2" resolved "https://registry.yarnpkg.com/path-to-regexp/-/path-to-regexp-6.2.2.tgz#324377a83e5049cbecadc5554d6a63a9a4866b36" @@ -6839,11 +6695,6 @@ signal-exit@^3.0.2: resolved "https://registry.yarnpkg.com/signal-exit/-/signal-exit-3.0.7.tgz#a9a1767f8af84155114eaabd73f99273c8f59ad9" integrity sha512-wnD2ZE+l+SPC/uoS0vXeE9L1+0wuaMqKlfz9AMUo38JsyLSBWSFcHR1Rri62LZc12vLr1gb3jl7iwQhgwpAbGQ== -signal-exit@^4.0.1: - version "4.1.0" - resolved "https://registry.yarnpkg.com/signal-exit/-/signal-exit-4.1.0.tgz#952188c1cbd546070e2dd20d0f41c0ae0530cb04" - integrity sha512-bzyZ1e88w9O1iNJbKnOlvYTrWPDl46O1bG0D3XInv+9tkPrxrN8jUUTiFlDkkmKWgn1M6CfIA13SuGqOa9Korw== - sinon-chai@^3.7.0: version "3.7.0" resolved "https://registry.yarnpkg.com/sinon-chai/-/sinon-chai-3.7.0.tgz#cfb7dec1c50990ed18c153f1840721cf13139783" @@ -7077,15 +6928,6 @@ string-format@^2.0.0: resolved "https://registry.yarnpkg.com/string-format/-/string-format-2.0.0.tgz#f2df2e7097440d3b65de31b6d40d54c96eaffb9b" integrity sha512-bbEs3scLeYNXLecRRuk6uJxdXUSj6le/8rNPHChIJTn2V79aXVTR1EH2OH5zLKKoz0V02fOUKZZcw01pLUShZA== -"string-width-cjs@npm:string-width@^4.2.0", string-width@^4.0.0, string-width@^4.1.0, string-width@^4.2.0, string-width@^4.2.2, string-width@^4.2.3: - version "4.2.3" - resolved "https://registry.yarnpkg.com/string-width/-/string-width-4.2.3.tgz#269c7117d27b05ad2e536830a8ec895ef9c6d010" - integrity sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g== - dependencies: - emoji-regex "^8.0.0" - is-fullwidth-code-point "^3.0.0" - strip-ansi "^6.0.1" - string-width@^2.1.1: version "2.1.1" resolved "https://registry.yarnpkg.com/string-width/-/string-width-2.1.1.tgz#ab93f27a8dc13d28cac815c462143a6d9012ae9e" @@ -7094,14 +6936,14 @@ string-width@^2.1.1: is-fullwidth-code-point "^2.0.0" strip-ansi "^4.0.0" -string-width@^5.0.1, string-width@^5.1.2: - version "5.1.2" - resolved "https://registry.yarnpkg.com/string-width/-/string-width-5.1.2.tgz#14f8daec6d81e7221d2a357e668cab73bdbca794" - integrity sha512-HnLOCR3vjcY8beoNLtcjZ5/nxn2afmME6lhrDrebokqMap+XbeW8n9TXpPDOqdGK5qcI3oT0GKTW6wC7EMiVqA== +string-width@^4.0.0, string-width@^4.1.0, string-width@^4.2.0, string-width@^4.2.2, string-width@^4.2.3: + version "4.2.3" + resolved "https://registry.yarnpkg.com/string-width/-/string-width-4.2.3.tgz#269c7117d27b05ad2e536830a8ec895ef9c6d010" + integrity sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g== dependencies: - eastasianwidth "^0.2.0" - emoji-regex "^9.2.2" - strip-ansi "^7.0.1" + emoji-regex "^8.0.0" + is-fullwidth-code-point "^3.0.0" + strip-ansi "^6.0.1" string.prototype.trim@^1.2.9: version "1.2.9" @@ -7150,13 +6992,6 @@ string_decoder@~1.1.1: dependencies: safe-buffer "~5.1.0" -"strip-ansi-cjs@npm:strip-ansi@^6.0.1", strip-ansi@^6.0.0, strip-ansi@^6.0.1: - version "6.0.1" - resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-6.0.1.tgz#9e26c63d30f53443e9489495b2105d37b67a85d9" - integrity sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A== - dependencies: - ansi-regex "^5.0.1" - strip-ansi@^4.0.0: version "4.0.0" resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-4.0.0.tgz#a8479022eb1ac368a871389b635262c505ee368f" @@ -7164,12 +6999,12 @@ strip-ansi@^4.0.0: dependencies: ansi-regex "^3.0.0" -strip-ansi@^7.0.1: - version "7.1.0" - resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-7.1.0.tgz#d5b6568ca689d8561370b0707685d22434faff45" - integrity sha512-iq6eVVI64nQQTRYq2KtEg2d2uU7LElhTJwsH4YzIHZshxlgZms/wIc4VoDQTlG/IvVIrBKG06CrZnp0qv7hkcQ== +strip-ansi@^6.0.0, strip-ansi@^6.0.1: + version "6.0.1" + resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-6.0.1.tgz#9e26c63d30f53443e9489495b2105d37b67a85d9" + integrity sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A== dependencies: - ansi-regex "^6.0.1" + ansi-regex "^5.0.1" strip-bom@^3.0.0: version "3.0.0" @@ -7455,14 +7290,6 @@ ts-morph@^19.0.0: "@ts-morph/common" "~0.20.0" code-block-writer "^12.0.0" -ts-morph@^21.0.1: - version "21.0.1" - resolved "https://registry.yarnpkg.com/ts-morph/-/ts-morph-21.0.1.tgz#712302a0f6e9dbf1aa8d9cf33a4386c4b18c2006" - integrity sha512-dbDtVdEAncKctzrVZ+Nr7kHpHkv+0JDJb2MjjpBaj8bFeCkePU9rHfMklmhuLFnpeq/EJZk2IhStY6NzqgjOkg== - dependencies: - "@ts-morph/common" "~0.22.0" - code-block-writer "^12.0.0" - ts-node@^10.1.0: version "10.9.2" resolved "https://registry.yarnpkg.com/ts-node/-/ts-node-10.9.2.tgz#70f021c9e185bccdca820e26dc413805c101c71f" @@ -7879,7 +7706,7 @@ workerpool@6.2.1: resolved "https://registry.yarnpkg.com/workerpool/-/workerpool-6.2.1.tgz#46fc150c17d826b86a008e5a4508656777e9c343" integrity sha512-ILEIE97kDZvF9Wb9f6h5aXK4swSlKGUcOEGiIYb2OOu/IrDU9iwj0fD//SsA6E5ibwJxpEvhullJY4Sl4GcpAw== -"wrap-ansi-cjs@npm:wrap-ansi@^7.0.0", wrap-ansi@^7.0.0: +wrap-ansi@^7.0.0: version "7.0.0" resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-7.0.0.tgz#67e145cff510a6a6984bdf1152911d69d2eb9e43" integrity sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q== @@ -7888,15 +7715,6 @@ workerpool@6.2.1: string-width "^4.1.0" strip-ansi "^6.0.0" -wrap-ansi@^8.1.0: - version "8.1.0" - resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-8.1.0.tgz#56dc22368ee570face1b49819975d9b9a5ead214" - integrity sha512-si7QWI6zUMq56bESFvagtmzMdGOtoxfR+Sez11Mobfc7tm+VkUckk9bW2UeffTGVUbOksxmSw0AA2gs8g71NCQ== - dependencies: - ansi-styles "^6.1.0" - string-width "^5.0.1" - strip-ansi "^7.0.1" - wrappy@1: version "1.0.2" resolved "https://registry.yarnpkg.com/wrappy/-/wrappy-1.0.2.tgz#b5243d8f3ec1aa35f1364605bc0d1036e30ab69f" From 4a52da200bf6b8b964c3a258b649f3bf4e0881ca Mon Sep 17 00:00:00 2001 From: kelemeno Date: Thu, 27 Jun 2024 15:58:12 +0200 Subject: [PATCH 02/10] fixing small tests start --- .../RelayedSLDAValidator.sol | 1 + l2-contracts/test/erc20.test.ts | 26 +++++++++---------- 2 files changed, 14 insertions(+), 13 deletions(-) diff --git a/l1-contracts/contracts/state-transition/data-availability/RelayedSLDAValidator.sol b/l1-contracts/contracts/state-transition/data-availability/RelayedSLDAValidator.sol index 145b9a69b..205d4df69 100644 --- a/l1-contracts/contracts/state-transition/data-availability/RelayedSLDAValidator.sol +++ b/l1-contracts/contracts/state-transition/data-availability/RelayedSLDAValidator.sol @@ -62,6 +62,7 @@ contract RelayedSLDAValidator is IL1DAValidator, CalldataDA { ); // Re-sending all the pubdata in pure form to L1. + // slither-disable-next-line unused-return IL1Messenger(L2_TO_L1_MESSENGER_SYSTEM_CONTRACT_ADDR).sendToL1(abi.encode(_chainId, pubdata)); output.blobsOpeningCommitments = blobCommitments; diff --git a/l2-contracts/test/erc20.test.ts b/l2-contracts/test/erc20.test.ts index 15aa9e8f0..41038c2ca 100644 --- a/l2-contracts/test/erc20.test.ts +++ b/l2-contracts/test/erc20.test.ts @@ -5,8 +5,8 @@ import * as hre from "hardhat"; import { Provider, Wallet } from "zksync-ethers"; import { hashBytecode } from "zksync-ethers/build/utils"; import { unapplyL1ToL2Alias } from "./test-utils"; -import type { L2SharedBridge, L2NativeTokenVault, L2StandardERC20 } from "../typechain"; -import { L2SharedBridgeFactory, L2NativeTokenVaultFactory, L2StandardERC20Factory } from "../typechain"; +import type { L2AssetRouter, L2NativeTokenVault, L2StandardERC20 } from "../typechain"; +import { L2AssetRouterFactory, L2NativeTokenVaultFactory, L2StandardERC20Factory } from "../typechain"; const richAccount = [ { @@ -42,7 +42,7 @@ describe("ERC20Bridge", function () { const testChainId = 9; - let erc20Bridge: L2SharedBridge; + let erc20Bridge: L2AssetRouter; let erc20NativeTokenVault: L2NativeTokenVault; let erc20Token: L2StandardERC20; const contractsDeployedAlready: boolean = false; @@ -57,32 +57,32 @@ describe("ERC20Bridge", function () { ]); await deployer.deploy(await deployer.loadArtifact("BeaconProxy"), [l2Erc20TokenBeacon.address, "0x"]); const beaconProxyBytecodeHash = hashBytecode((await deployer.loadArtifact("BeaconProxy")).bytecode); - const erc20BridgeContract = await deployer.deploy(await deployer.loadArtifact("L2SharedBridge"), [ + const erc20BridgeContract = await deployer.deploy(await deployer.loadArtifact("L2AssetRouter"), [ testChainId, 1, unapplyL1ToL2Alias(l1BridgeWallet.address), unapplyL1ToL2Alias(l1BridgeWallet.address), ]); - erc20Bridge = L2SharedBridgeFactory.connect(erc20BridgeContract.address, deployerWallet); - const erc20NativeTokenVaultImpl = await deployer.deploy(await deployer.loadArtifact("L2NativeTokenVault")); - const assetHandlerInitializeData = erc20NativeTokenVaultImpl.interface.encodeFunctionData("initialize", [ + erc20Bridge = L2AssetRouterFactory.connect(erc20BridgeContract.address, deployerWallet); + const erc20NativeTokenVaultContract = await deployer.deploy(await deployer.loadArtifact("L2NativeTokenVault"), [ beaconProxyBytecodeHash, governorWallet.address, // Note on real deployment this will be the deployerWallet contractsDeployedAlready, ]); + // const assetHandlerInitializeData = erc20NativeTokenVaultImpl.interface.encodeFunctionData("initialize", ); - const erc20NativeTokenVaultProxy = await deployer.deploy( - await deployer.loadArtifact("TransparentUpgradeableProxy"), - [erc20NativeTokenVaultImpl.address, proxyAdminWallet.address, assetHandlerInitializeData] - ); + // const erc20NativeTokenVaultProxy = await deployer.deploy( + // await deployer.loadArtifact("TransparentUpgradeableProxy"), + // [erc20NativeTokenVaultImpl.address, proxyAdminWallet.address, assetHandlerInitializeData] + // ); - erc20NativeTokenVault = L2NativeTokenVaultFactory.connect(erc20NativeTokenVaultProxy.address, governorWallet); + erc20NativeTokenVault = L2NativeTokenVaultFactory.connect(erc20NativeTokenVaultContract.address, l1BridgeWallet); /// note in real deployment we have to transfer ownership of standard deployer here }); it("Should finalize deposit ERC20 deposit", async function () { - const erc20BridgeWithL1BridgeWallet = L2SharedBridgeFactory.connect(erc20Bridge.address, l1BridgeWallet); + const erc20BridgeWithL1BridgeWallet = L2AssetRouterFactory.connect(erc20Bridge.address, proxyAdminWallet); const l1Depositor = ethers.Wallet.createRandom(); const l2Receiver = ethers.Wallet.createRandom(); From 3eb60a92255c1b5b5a588ac9968c445f920b6966 Mon Sep 17 00:00:00 2001 From: kelemeno Date: Thu, 27 Jun 2024 17:10:23 +0200 Subject: [PATCH 03/10] system contract hashes --- l1-contracts/foundry.toml | 7 +- .../Bridgehub/experimental_bridge.t.sol | 2 +- .../concrete/Executor/Authorization.t.sol | 2 +- .../unit/concrete/Executor/Committing.t.sol | 22 +++---- .../concrete/Executor/ExecutorProof.t.sol | 2 +- .../concrete/Executor/_Executor_Shared.t.sol | 10 ++- .../foundry/unit/concrete/Utils/Utils.sol | 2 +- system-contracts/SystemContractsHashes.json | 66 ++++++++----------- 8 files changed, 54 insertions(+), 59 deletions(-) diff --git a/l1-contracts/foundry.toml b/l1-contracts/foundry.toml index 6f29a31cc..d723bf88f 100644 --- a/l1-contracts/foundry.toml +++ b/l1-contracts/foundry.toml @@ -1,20 +1,23 @@ [profile.default] src = 'contracts' out = 'out' -libs = ['node_modules', 'lib'] +libs = ['node_modules', 'lib', '../da-contracts/'] remappings = [ "@openzeppelin/contracts/=lib/openzeppelin-contracts/contracts/", "@openzeppelin/contracts-upgradeable/=lib/openzeppelin-contracts-upgradeable/contracts/", - "l2-contracts/=../l2-contracts/contracts/" + "l2-contracts/=../l2-contracts/contracts/", + "da-contracts/=../da-contracts/contracts/" ] allow_paths = ["../l2-contracts/contracts"] fs_permissions = [ { access = "read", path = "../system-contracts/bootloader/build/artifacts" }, { access = "read", path = "../system-contracts/artifacts-zk/contracts-preprocessed" }, { access = "read", path = "../l2-contracts/artifacts-zk/" }, + { access = "read", path = "../da-contracts/" }, { access = "read", path = "./script-config" }, { access = "read-write", path = "./script-out" }, { access = "read", path = "./out" } + ] cache_path = 'cache-forge' test = 'test/foundry' 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 aa27d7797..a3f01cf83 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 @@ -43,8 +43,8 @@ contract ExperimentalBridgeTest is Test { function setUp() public { eraChainId = 9; uint256 l1ChainId = 1; - bridgeHub = new Bridgehub(l1ChainId); bridgeOwner = makeAddr("BRIDGE_OWNER"); + bridgeHub = new Bridgehub(l1ChainId, bridgeOwner); address weth = makeAddr("WETH"); mockSTM = new DummyStateTransitionManagerWBH(address(bridgeHub)); mockChainContract = new DummyHyperchain(address(bridgeHub), eraChainId); diff --git a/l1-contracts/test/foundry/unit/concrete/Executor/Authorization.t.sol b/l1-contracts/test/foundry/unit/concrete/Executor/Authorization.t.sol index 498fb21a2..c711a9527 100644 --- a/l1-contracts/test/foundry/unit/concrete/Executor/Authorization.t.sol +++ b/l1-contracts/test/foundry/unit/concrete/Executor/Authorization.t.sol @@ -33,7 +33,7 @@ contract AuthorizationTest is ExecutorTest { bootloaderHeapInitialContentsHash: Utils.randomBytes32("bootloaderHeapInitialContentsHash"), eventsQueueStateHash: Utils.randomBytes32("eventsQueueStateHash"), systemLogs: bytes(""), - pubdataCommitments: bytes("") + operatorDAInput: bytes("") }); } 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 ce3e5947c..b9895f15f 100644 --- a/l1-contracts/test/foundry/unit/concrete/Executor/Committing.t.sol +++ b/l1-contracts/test/foundry/unit/concrete/Executor/Committing.t.sol @@ -330,7 +330,7 @@ contract CommittingTest is ExecutorTest { IExecutor.CommitBatchInfo memory correctNewCommitBatchInfo = newCommitBatchInfo; correctNewCommitBatchInfo.systemLogs = Utils.encodePacked(correctL2Logs); - correctNewCommitBatchInfo.pubdataCommitments = abi.encodePacked( + correctNewCommitBatchInfo.operatorDAInput = abi.encodePacked( "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00", bytes32(uint256(0xbeef)) ); @@ -404,7 +404,7 @@ contract CommittingTest is ExecutorTest { IExecutor.CommitBatchInfo[] memory correctCommitBatchInfoArray = new IExecutor.CommitBatchInfo[](1); correctCommitBatchInfoArray[0] = correctNewCommitBatchInfo; - correctCommitBatchInfoArray[0].pubdataCommitments = pubdataCommitment; + correctCommitBatchInfoArray[0].operatorDAInput = pubdataCommitment; vm.prank(validator); @@ -477,7 +477,7 @@ contract CommittingTest is ExecutorTest { IExecutor.CommitBatchInfo[] memory correctCommitBatchInfoArray = new IExecutor.CommitBatchInfo[](1); correctCommitBatchInfoArray[0] = correctNewCommitBatchInfo; - correctCommitBatchInfoArray[0].pubdataCommitments = pubdataCommitment; + correctCommitBatchInfoArray[0].operatorDAInput = pubdataCommitment; vm.prank(validator); @@ -526,7 +526,7 @@ contract CommittingTest is ExecutorTest { IExecutor.CommitBatchInfo[] memory correctCommitBatchInfoArray = new IExecutor.CommitBatchInfo[](1); correctCommitBatchInfoArray[0] = correctNewCommitBatchInfo; - correctCommitBatchInfoArray[0].pubdataCommitments = pubdataCommitment; + correctCommitBatchInfoArray[0].operatorDAInput = pubdataCommitment; vm.prank(validator); @@ -551,7 +551,7 @@ contract CommittingTest is ExecutorTest { IExecutor.CommitBatchInfo[] memory correctCommitBatchInfoArray = new IExecutor.CommitBatchInfo[](1); correctCommitBatchInfoArray[0] = correctNewCommitBatchInfo; - correctCommitBatchInfoArray[0].pubdataCommitments = pubdataCommitment; + correctCommitBatchInfoArray[0].operatorDAInput = pubdataCommitment; vm.prank(validator); @@ -576,7 +576,7 @@ contract CommittingTest is ExecutorTest { IExecutor.CommitBatchInfo[] memory correctCommitBatchInfoArray = new IExecutor.CommitBatchInfo[](1); correctCommitBatchInfoArray[0] = correctNewCommitBatchInfo; - correctCommitBatchInfoArray[0].pubdataCommitments = pubdataCommitment; + correctCommitBatchInfoArray[0].operatorDAInput = pubdataCommitment; vm.prank(validator); @@ -620,7 +620,7 @@ contract CommittingTest is ExecutorTest { IExecutor.CommitBatchInfo[] memory correctCommitBatchInfoArray = new IExecutor.CommitBatchInfo[](1); correctCommitBatchInfoArray[0] = correctNewCommitBatchInfo; - correctCommitBatchInfoArray[0].pubdataCommitments = pubdataCommitment; + correctCommitBatchInfoArray[0].operatorDAInput = pubdataCommitment; vm.prank(validator); @@ -657,7 +657,7 @@ contract CommittingTest is ExecutorTest { IExecutor.CommitBatchInfo[] memory correctCommitBatchInfoArray = new IExecutor.CommitBatchInfo[](1); correctCommitBatchInfoArray[0] = correctNewCommitBatchInfo; - correctCommitBatchInfoArray[0].pubdataCommitments = pubdataCommitment; + correctCommitBatchInfoArray[0].operatorDAInput = pubdataCommitment; vm.prank(validator); @@ -702,7 +702,7 @@ contract CommittingTest is ExecutorTest { IExecutor.CommitBatchInfo[] memory correctCommitBatchInfoArray = new IExecutor.CommitBatchInfo[](1); correctCommitBatchInfoArray[0] = correctNewCommitBatchInfo; - correctCommitBatchInfoArray[0].pubdataCommitments = pubdataCommitment; + correctCommitBatchInfoArray[0].operatorDAInput = pubdataCommitment; vm.prank(validator); @@ -765,7 +765,7 @@ contract CommittingTest is ExecutorTest { IExecutor.CommitBatchInfo[] memory correctCommitBatchInfoArray = new IExecutor.CommitBatchInfo[](1); correctCommitBatchInfoArray[0] = correctNewCommitBatchInfo; - correctCommitBatchInfoArray[0].pubdataCommitments = pubdataCommitment; + correctCommitBatchInfoArray[0].operatorDAInput = pubdataCommitment; vm.prank(validator); @@ -815,7 +815,7 @@ contract CommittingTest is ExecutorTest { IExecutor.CommitBatchInfo[] memory correctCommitBatchInfoArray = new IExecutor.CommitBatchInfo[](1); correctCommitBatchInfoArray[0] = correctNewCommitBatchInfo; - correctCommitBatchInfoArray[0].pubdataCommitments = pubdataCommitment; + correctCommitBatchInfoArray[0].operatorDAInput = pubdataCommitment; vm.prank(validator); diff --git a/l1-contracts/test/foundry/unit/concrete/Executor/ExecutorProof.t.sol b/l1-contracts/test/foundry/unit/concrete/Executor/ExecutorProof.t.sol index e1f99025a..516d8024a 100644 --- a/l1-contracts/test/foundry/unit/concrete/Executor/ExecutorProof.t.sol +++ b/l1-contracts/test/foundry/unit/concrete/Executor/ExecutorProof.t.sol @@ -96,7 +96,7 @@ contract ExecutorProofTest is Test { systemLogs: abi.encodePacked( hex"00000000000000000000000000000000000000000000800b000000000000000000000000000000000000000000000000000000000000000416914ac26bb9cafa0f1dfaeaab10745a9094e1b60c7076fedf21651d6a25b5740000000a000000000000000000000000000000000000800b0000000000000000000000000000000000000000000000000000000000000003000000000000000000000000651bcde0000000000000000000000000651bcde20001000a00000000000000000000000000000000000080010000000000000000000000000000000000000000000000000000000000000005167f4ca80269c9520ad951eeeda28dd3deb0715e9e2917461e81a60120a141830001000a00000000000000000000000000000000000080010000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000a0001000a00000000000000000000000000000000000080080000000000000000000000000000000000000000000000000000000000000000ee6ee8f50659bd8be3d86c32efb02baa5571cf3b46dd7ea3db733ae181747b8b0001000a0000000000000000000000000000000000008008000000000000000000000000000000000000000000000000000000000000000160fc5fb513ca8e6f6232a7410797954dcb6edbf9081768da24b483aca91c54db0001000a000000000000000000000000000000000000800800000000000000000000000000000000000000000000000000000000000000029a67073c2df8f53087fcfc32d82c98bba591da35df6ce1fb55a23b677d37f9fc000000000000000000000000000000000000000000008011000000000000000000000000000000000000000000000000000000000000000700000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000080110000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000801100000000000000000000000000000000000000000000000000000000000000090000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008011000000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008011000000000000000000000000000000000000000000000000000000000000000b0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008011000000000000000000000000000000000000000000000000000000000000000c0000000000000000000000000000000000000000000000000000000000000000" ), - pubdataCommitments: abi.encodePacked( + operatorDAInput: abi.encodePacked( hex"000000000a000100000000000000000000000000000000000000008001760f6100ddbd86c4d5a58532923e7424d33ffb44145a26171d9b2595a349450b0000000000000000000000000000000000000000000000000000000000000001000100010000000000000000000000000000000000008001a789fe4e2a955eee45d44f408f86203c8f643910bf4888d1fd1465cdbc6376d800000000000000000000000000000000000000000000000000000000000000010001000200000000000000000000000000000000000080016ba43e7c7df11e5a655f22c9bce1b37434afd2bf8fcdb10100a460e6a2c0cc83000000000000000000000000000000000000000000000000000000000000000100010003000000000000000000000000000000000000800156e569838658c17c756aa9f6e40de8f1c41b1a67fea5214ec47869882ecda9bd0000000000000000000000000000000000000000000000000000000000000001000100040000000000000000000000000000000000008001ab5d064ba75c02635fd6e4de7fd8420eda54c4bda05bd61edabe201f2066d38f00000000000000000000000000000000000000000000000000000000000000010001000500000000000000000000000000000000000080015bcb6d7c735023e0884297db5016a6c704e3490ed0671417639313ecea86795b00000000000000000000000000000000000000000000000000000000000000010001000600000000000000000000000000000000000080015ee51b5b7d47fae5811a9f777174bb08d81d78098c8bd9430a7618756a0ceb8b00000000000000000000000000000000000000000000000000000000000000010001000700000000000000000000000000000000000080011ea63171021b9ab0846efbe0a06f7882d76e24a4900c74c14fa1e0bdf313ed560000000000000000000000000000000000000000000000000000000000000001000100080000000000000000000000000000000000008001574537f1665cd9c894d8d9834d32ed291f49ae1165a0e12a79a4937f2425bf70000000000000000000000000000000000000000000000000000000000000000100010009000000000000000000000000000000000000800190558033c8a3f7c20c81e613e00a9d0e678a7a14923e94e7cb99c8621c7918090000000000000000000000000000000000000000000000000000000000000001000000000000000001000c3104003d1291725c657fe486d0e626f562842175a705a9704c0980b40e3d716b95bbf9e8000100005dd96deb789fbc05264165795bf652190645bfae1ce253ce1db17087a898fb1e240ebf0d53563011198fddab33312923ba20f3c56cf1ba18ca5be9c053000100022bd65a924da61271d1dd5080fc640601185125830805e0ceb42f4185e5118fb454a12a3d9e0c1fbb89230f67044cc191e4f18459261233f659c9e2ba5e000100008b9feb52993729436da78b2863dd56d8d757e19c01a2cdcf1940e45ca9979941fa93f5f699afeab75e8b25cfea22004a8d2ea49f057741c2f2b910996d00010001bdf9205fb9bd185829f2c6bec2a6f100b86eff579da4fc2a8f1a15ea4afee3cea48e96b9bddb544b4569e60736a1f1fe919e223fcc08f74acf3513be1200010001bdf9205fb9bd185829f2c6bec2a6f100b86eff579da4fc2a8f1a15ea4a8755061217b6a78f5d5f8af6e326e482ebdc57f7144108662d122252ddcc27e7000100045dddc527887dc39b9cd189d6f183f16217393a5d3d3165fead2daeaf4f2d6916280c572561a809555de4a87d7a56d5bcca2c246a389dbb2a24c5639bdb0001000153c0f36532563ba2a10f52b865e558cd1a5eef9a9edd01c1cb23b74aa772beb4f3e3b784609f4e205a09863c0587e63b4b47664022cb34896a1711416b00010003e7842b0b4f4fd8e665883fe9c158ba8d38347840f1da0a75aca1fc284ce2428454b48df9f5551500fc50b63af4741b1cd21d4cfddc69aa46cb78eff45b00010000f183703a165afed04326ad5786316f6fc65b27f1cf17459a52bd1f57f27f896b7429e070ca76e3e33165ec75f6c9f439ee37f3b58822494b1251c8247500010001bdf9205fb9bd185829f2c6bec2a6f100b86eff579da4fc2a8f1a15ea4a05ea3d0bb218598c42b2e25ae5f6cbc9369b273ee6610450cade89775646b2a08902000000000000000000000000000000008b71d4a184058d07fccac4348ae02a1f663403231b0a40fa2c8c0ff73bdca092890200000000000000000000000000000000ab63c4cebbd508a7d7184f0b9134453eea7a09ca749610d5576f8046241b9cde890200000000000000000000000000000000e58af14be53d8ac56f58ff3e5b07c239bfb549149f067597e9d028f35e3c2b77890200000000000000000000000000000000b78e94980fec3a5f68aa25d0d934084907688e537e82c2942af905aab21413ab890200000000000000000000000000000000c4db460819691e825328b532024bbecdc40394c74307a00bd245fc658b1bd34f0901908827f2052a14b24a10cae1f9e259ead06a89a1d74ff736a54f54ebcf05eeb30901d32d07305b87debd25698d4dfac4c2f986693a4e9d9baff7da37a7b5ca8d01cb0901e73042e5dacff2ce20a720c9c6d694576e4afa7bbbafdc4d409c63b7ca8027b70901760a7405795441aceea3be649a53d02785cb3487b7bd23e3b4888a935cee010d09011f3acf5d6d7bfeab8a7112771866e28c3714e0c315a81ec6a58ab4ad1c3d6eb10901c207b49d14deb3af9bc960d57074e27386285c73248abc5fa1d72aa6e8664fa40901644f0c4e15446d7e5ff363c944b55bd6801a1f38afd984c3427569530cb663210901743be0243628b8e7e8f04c00fc4f88efae001250a7482b31e6a0ec87ee3598e7090171e91721f9918576d760f02f03cac47c6f4003316031848e3c1d99e6e83a47434102d84e69f2f480002d5a6962cccee5d4adb48a36bbbf443a531721484381125937f3001ac5ff875b41022f496efbbdb2007b727eb806c926fb20c8ad087c57422977cebd06373e26d19b640e5fe32c85ff39a904faf736ce00a25420c1d9d705358c134cc601d9d184cb4dfdde7e1cac2bc3d4d38bf9ec44e6210ee6b280123bafc586f77764488cd24c6a77546e5a0fe8bdfb4fa203cfaffc36cce4dd5b8901000000000000000000000000651bcde08e7dd06ac5b73b473be6bc5a51030f4c7437657cb7b29bf376c564b8d1675a5e8903000000000000000000000000651bcde24ba84e1f37d041bc6e55ba396826cc494e84d4815b6db52690422eea7386314f00e8e77626586f73b955364c7b4bbf0bb7f7685ebd40e852b164633a4acbd3244c3de2202ccb626ad387d70722e64fbe44562e2f231a290c08532b8d6aba402ff50025fe002039e87b424de2772b82d935f14e2b657429a1bcc04612391ea0330c90ebddefdda48eb2aa7f66ecf7940a280e9ef3fb2e95db0995538440a62af79861004434720529e816fd2e40f8031a8d7471ebcd00351db0787346bcfe8dfad8d2b479093588d0e847efa73a10ce20e4799fb1e46642d65617c7e5213fa04989d92d8903000000000000000000000000651bcde287ded247e1660f827071c7f1371934589751085384fc9f4462c1f1897c5c3eef890100000000000000000000000000000001911dd2ad743ff237d411648a0fe32c6d74eec060716a2a74352f6b1c435b5d670016914ac26bb9cafa0f1dfaeaab10745a9094e1b60c7076fedf21651d6a25b574686a068c708f1bdbefd9e6e454ac2b520fd41c8dcf23ecd4cee978c22f1c1f5f09ff974fe8b575175cefa919a5ba1c0ddf4409be4b16695dc7bd12f6701b99bd2e70a152312ad6f01657413b2eae9287f6b9adad93d5fed1a0dd5e13ec74ce1163146509bfe426f2315a69cb452bf388cccd321eca2746a1adf793b489e5c8f61c40688b7ef3e53defc56c78facf513e511f9f5ba0eb50dbcc745afea3b860da75b394d2d1627b6e2ef54fb7b187d0af61e4532c238f387ecf9f0b466f1d54414100018e519b65c8901b344a480638beadb923fbd3462e475d39acebe559d65ed5cb11a1b25279f1918477c35eec1332ff07001d3f85cf854b70d7552f93ba8e88d581064ca4c0df6ac456c00a0e83898ccd464c63e5008aa1a498cc0646b78eb216d9eeeec76ed0eb0ee6c352f35ca5f0b2edc2ca17d211cc5cb905ba10142f042a6ac836d9cef9a6916635c9a1c1d2dc62a9fe83e2230b506b98e0fded46249008fe28b813907a05ae0d773d8f31e330200e9336e0159034c137ed645fb67ccca8a152312ad6f01657413b2eae9287f6b9adad93d5fee5d8f810abde496ccbeb45a4f3c06af828975163a006257cbf18cefebbfb4cd409025f40404a3d37bba024799ce32d7c2a833aec8474288a26b246afa32b07b4a3ce00577261707065642045746865720000000000000000000000000000000000001a09cf14f266dfe87c4b33e6d934de01f8f7242199fa8783178117218fa033f7ab005745544800000000000000000000000000000000000000000000000000000008289026c5fa173652bd62774824698a6848c63031f853d0e275174552f35df33000577261707065642045746865720000000000000000000000000000000000001a1e59309944cbc900ae848855e10bc929f78e86c2179d6e96cf52bfd520f039200031000000000000000000000000000000000000000000000000000000000000021653a735395136e5494c5426ba972b45e34d36ebcb86ac104c724ab375fcce90a18580ba6aeebc6e6b89d226c79be8927257a436ad11d9c0305b18e9d78cab8f75a3aec2096302b67e3815939e29476fb36a0d8299a1b25279f1918477c35eec1332ff07001d3f85cf85688525f98e4859a9c6939f2d2f92e6b1950ed57e56137d717aca1ccf9754f719a1c7ebe9226d26524400a8959a08f411a727ae7bb68f8febecd89ffe9d84708d24544d452de3e22e62b3b2b872e430839a15115818a152312ad6f01657413b2eae9287f6b9adad93d5fe3fb60af355125687beeb90c066ace76c442b0f963a6afd0e3316fcdd673ad22c09ff30c8a03ec44e5337a1f9d66763cf1b319fdc6d8bc4981e1f47edbd86210614b909ff0cbdceb634b81192417b64d114d535ad3bdba97d6d7e90ee2a79bf1c132d3c2d09ff5cd85060f4ff26eb5b68a6687aee76c1b7a77575fdc86ba49b4faf5041377a79b14de8989f2385a6e23f6bd05a80e0d9231870c15a000142e50adc0d84bff439d0086d9fbab9984f8b27aa208935238a60cc62e7c9bb2ea1709e94c96366b3c40ea4854837c18733e5ac1193b8d8e4070d2eca4441b0378b572bd949ab764fd71c002b759613c3e29d425cf4000100012730c940a81021004e899c6ee4bec02f0667757b9d75a8f0714ce6c157f5940b7664e4f69f01fc530db36965e33599a1348629f07ae2d724007ac36a71a16baac84db583d88e0f3a8c082e3632fcc0e15757f0dcf5234b87af41fdee4c0999c4fe698a8d824415979ab839e6913a975a3055a152312ad6f01657413b2eae9287f6b9adad93d5fe00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000" ) }); diff --git a/l1-contracts/test/foundry/unit/concrete/Executor/_Executor_Shared.t.sol b/l1-contracts/test/foundry/unit/concrete/Executor/_Executor_Shared.t.sol index 1089120e9..efc5cf7e3 100644 --- a/l1-contracts/test/foundry/unit/concrete/Executor/_Executor_Shared.t.sol +++ b/l1-contracts/test/foundry/unit/concrete/Executor/_Executor_Shared.t.sol @@ -22,6 +22,7 @@ import {Diamond} from "contracts/state-transition/libraries/Diamond.sol"; import {TestnetVerifier} from "contracts/state-transition/TestnetVerifier.sol"; import {DummyBridgehub} from "contracts/dev-contracts/test/DummyBridgehub.sol"; import {IL1AssetRouter} from "contracts/bridge/interfaces/IL1AssetRouter.sol"; +import {RollupL1DAValidator} from "da-contracts/RollupL1DAValidator.sol"; contract ExecutorTest is Test { address internal owner; @@ -38,6 +39,7 @@ contract ExecutorTest is Test { IExecutor.CommitBatchInfo internal newCommitBatchInfo; IExecutor.StoredBatchInfo internal newStoredBatchInfo; DummyEraBaseTokenBridge internal sharedBridge; + RollupL1DAValidator internal rollupL1DAValidator; uint256 eraChainId; @@ -45,7 +47,7 @@ contract ExecutorTest is Test { IExecutor.ProofInput internal proofInput; function getAdminSelectors() private view returns (bytes4[] memory) { - bytes4[] memory selectors = new bytes4[](11); + bytes4[] memory selectors = new bytes4[](12); selectors[0] = admin.setPendingAdmin.selector; selectors[1] = admin.acceptAdmin.selector; selectors[2] = admin.setValidator.selector; @@ -57,6 +59,7 @@ contract ExecutorTest is Test { selectors[8] = admin.executeUpgrade.selector; selectors[9] = admin.freezeDiamond.selector; selectors[10] = admin.unfreezeDiamond.selector; + selectors[11] = admin.setDAValidatorPair.selector; return selectors; } @@ -135,6 +138,7 @@ contract ExecutorTest is Test { eraChainId = 9; executor = new TestExecutor(); + rollupL1DAValidator = new RollupL1DAValidator(); admin = new AdminFacet(); getters = new GettersFacet(); mailbox = new MailboxFacet(eraChainId); @@ -231,6 +235,8 @@ contract ExecutorTest is Test { // Initiate the token multiplier to enable L1 -> L2 transactions. vm.prank(address(stateTransitionManager)); admin.setTokenMultiplier(1, 1); + vm.prank(address(owner)); + admin.setDAValidatorPair(address(rollupL1DAValidator), address(rollupL1DAValidator)); uint256[] memory recursiveAggregationInput; uint256[] memory serializedProof; @@ -252,7 +258,7 @@ contract ExecutorTest is Test { bootloaderHeapInitialContentsHash: Utils.randomBytes32("bootloaderHeapInitialContentsHash"), eventsQueueStateHash: Utils.randomBytes32("eventsQueueStateHash"), systemLogs: l2Logs, - pubdataCommitments: "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" + operatorDAInput: "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" }); vm.mockCall( diff --git a/l1-contracts/test/foundry/unit/concrete/Utils/Utils.sol b/l1-contracts/test/foundry/unit/concrete/Utils/Utils.sol index 1e68f972c..56175da6f 100644 --- a/l1-contracts/test/foundry/unit/concrete/Utils/Utils.sol +++ b/l1-contracts/test/foundry/unit/concrete/Utils/Utils.sol @@ -162,7 +162,7 @@ library Utils { bootloaderHeapInitialContentsHash: randomBytes32("bootloaderHeapInitialContentsHash"), eventsQueueStateHash: randomBytes32("eventsQueueStateHash"), systemLogs: abi.encode(randomBytes32("systemLogs")), - pubdataCommitments: abi.encodePacked(uint256(0)) + operatorDAInput: abi.encodePacked(uint256(0)) }); } diff --git a/system-contracts/SystemContractsHashes.json b/system-contracts/SystemContractsHashes.json index aa1f68b1f..5c927c10f 100644 --- a/system-contracts/SystemContractsHashes.json +++ b/system-contracts/SystemContractsHashes.json @@ -3,49 +3,49 @@ "contractName": "AccountCodeStorage", "bytecodePath": "artifacts-zk/contracts-preprocessed/AccountCodeStorage.sol/AccountCodeStorage.json", "sourceCodePath": "contracts-preprocessed/AccountCodeStorage.sol", - "bytecodeHash": "0x0100005df8e15edf079397113fbc3c25e0db74a17cb44ffc77e808c4f27a0d72", + "bytecodeHash": "0x0100005db7d0621192834d201f8bcd14c6ac987b95f422ca8bb28d500748f1fa", "sourceCodeHash": "0x69d2533e5481ff13e65f4442e650f4b90c46a48ac643cac9798bbbf421194353" }, { "contractName": "BootloaderUtilities", "bytecodePath": "artifacts-zk/contracts-preprocessed/BootloaderUtilities.sol/BootloaderUtilities.json", "sourceCodePath": "contracts-preprocessed/BootloaderUtilities.sol", - "bytecodeHash": "0x010007c76f320639c325a6a703d080823fbbe54a1ce3b8670a46211ec8b26931", + "bytecodeHash": "0x010007c7e006453f3693c1f1c7500b74c594e7a627076be9d2dcb35c1c268dc3", "sourceCodeHash": "0x26060f33c7c63bd1f8a1a2f3b368b97ef8dd939bc53e95090f2c556248b99dce" }, { "contractName": "ComplexUpgrader", "bytecodePath": "artifacts-zk/contracts-preprocessed/ComplexUpgrader.sol/ComplexUpgrader.json", "sourceCodePath": "contracts-preprocessed/ComplexUpgrader.sol", - "bytecodeHash": "0x0100004d3a75900dd45c0e587153d1f7e7fc965a44bf1951793d0884b8b27786", + "bytecodeHash": "0x0100004db8b96797e7d854f2c67c2f13d3920dcf82602f77a6ce0e2353304b37", "sourceCodeHash": "0xdde7c49a94cc3cd34c3e7ced1b5ba45e4740df68d26243871edbe393e7298f7a" }, { "contractName": "Compressor", "bytecodePath": "artifacts-zk/contracts-preprocessed/Compressor.sol/Compressor.json", "sourceCodePath": "contracts-preprocessed/Compressor.sol", - "bytecodeHash": "0x010001439c672adfa54477d8842deec0cc065c055f90cbc935f70af3b8e0e733", + "bytecodeHash": "0x0100014387fd8393671b5edd2cc5bb58f72d357c033a44c6274fe92abf19f96d", "sourceCodeHash": "0x63f5f3a541ac5b59736f9117b15f293346d1842fbfe75219f7961e73185315c5" }, { "contractName": "ContractDeployer", "bytecodePath": "artifacts-zk/contracts-preprocessed/ContractDeployer.sol/ContractDeployer.json", "sourceCodePath": "contracts-preprocessed/ContractDeployer.sol", - "bytecodeHash": "0x010004e598a39e0a153309dcbd96f7c85f20d9e9aa5db22e349625eb55768932", - "sourceCodeHash": "0x354b30f177b3b35e771cdd9bc900883dc222d169c3b1d479fd98a8555d3233f4" + "bytecodeHash": "0x010004e5219e70c32d67ed1df0c46983a83a382e482abb5c4310ad554f55f738", + "sourceCodeHash": "0x28208c532ed8851077a9bb0a87636215840ce964397ab0767692f956a0fd11b3" }, { "contractName": "Create2Factory", "bytecodePath": "artifacts-zk/contracts-preprocessed/Create2Factory.sol/Create2Factory.json", "sourceCodePath": "contracts-preprocessed/Create2Factory.sol", - "bytecodeHash": "0x01000049cfeaab22bc4ef772d33c93451ad685b9927b70eaec7d3ee5b5d839c2", + "bytecodeHash": "0x01000049cd4b556f8ebc05b0bd35d9996e0b65412343bcc8eb6ce14d958dd21f", "sourceCodeHash": "0x217e65f55c8add77982171da65e0db8cc10141ba75159af582973b332a4e098a" }, { "contractName": "DefaultAccount", "bytecodePath": "artifacts-zk/contracts-preprocessed/DefaultAccount.sol/DefaultAccount.json", "sourceCodePath": "contracts-preprocessed/DefaultAccount.sol", - "bytecodeHash": "0x0100055d2aad9586c8d16b7e3366c50a431811bd26639e0b7719fd68cf99e475", + "bytecodeHash": "0x0100055dbcf921fb36006fa42209bda58bc468eb33257b1782e854ed29273e64", "sourceCodeHash": "0xeb5ac8fc83e1c8619db058a9b6973958bd6ed1b6f4938f8f4541d702f12e085d" }, { @@ -55,74 +55,60 @@ "bytecodeHash": "0x0100000781e55a60f3f14fd7dd67e3c8caab896b7b0fca4a662583959299eede", "sourceCodeHash": "0xc88a4210dda96bc21fc852860fb74a4efeb0cc4101ffe6d928551cab46d15263" }, - { - "contractName": "GenesisUpgrade", - "bytecodePath": "artifacts-zk/contracts-preprocessed/GenesisUpgrade.sol/GenesisUpgrade.json", - "sourceCodePath": "contracts-preprocessed/GenesisUpgrade.sol", - "bytecodeHash": "0x010000894c70c95faa2197e866a6bf9a8154c6e154a878c6bb8b64d554dfed1b", - "sourceCodeHash": "0xa437698a10cba654424f7cc37d042955ff61dd46fcc07525a844bb9421bed85a" - }, { "contractName": "ImmutableSimulator", "bytecodePath": "artifacts-zk/contracts-preprocessed/ImmutableSimulator.sol/ImmutableSimulator.json", "sourceCodePath": "contracts-preprocessed/ImmutableSimulator.sol", - "bytecodeHash": "0x0100003b0b44f1f28230a2018bea8cb4accd7c778b539ab04e474ef9b03ee4f6", + "bytecodeHash": "0x0100003b91f0ceda986543b6b45811b72cb492cdcb80c42d8600185e33f72251", "sourceCodeHash": "0x4212e99cbc1722887cfb5b4cb967f278ac8642834786f0e3c6f3b324a9316815" }, { "contractName": "KnownCodesStorage", "bytecodePath": "artifacts-zk/contracts-preprocessed/KnownCodesStorage.sol/KnownCodesStorage.json", "sourceCodePath": "contracts-preprocessed/KnownCodesStorage.sol", - "bytecodeHash": "0x0100006f26e2ed08652705c48c41a61bd2e5d8142c860fae7abf66b09d66e9f4", + "bytecodeHash": "0x0100006f8342acd40c21d8e535e8ceb65d370ad76a116f3a893fa67452bb616f", "sourceCodeHash": "0x8da495a9fc5aa0d7d20a165a4fc8bc77012bec29c472015ea5ecc0a2bd706137" }, { "contractName": "L1Messenger", "bytecodePath": "artifacts-zk/contracts-preprocessed/L1Messenger.sol/L1Messenger.json", "sourceCodePath": "contracts-preprocessed/L1Messenger.sol", - "bytecodeHash": "0x01000293cb3bd62800fcbaf029e223708838be6bf1d8c78f8697f3f2187db629", + "bytecodeHash": "0x0100029361cc1606b2e55c12bef0a9ccbb36f70f6a12b41593b34053ea93f433", "sourceCodeHash": "0x3e4c749b52c9fd8e6040b836dac10df29305ee0fc4fc9418326d3197e1630c38" }, { "contractName": "L2BaseToken", "bytecodePath": "artifacts-zk/contracts-preprocessed/L2BaseToken.sol/L2BaseToken.json", "sourceCodePath": "contracts-preprocessed/L2BaseToken.sol", - "bytecodeHash": "0x010001059f2ab04ca8fc085056c58f5e4d00b59d95642122ed2cdb4737e9da34", + "bytecodeHash": "0x010001055346ab8d4eb1b48ef7e768a95930d4ef6300c57ca173f4a76d1a9258", "sourceCodeHash": "0x4cdafafd4cfdf410b31641e14487ea657be3af25e5ec1754fcd7ad67ec23d8be" }, - { - "contractName": "L2GenesisUpgrade", - "bytecodePath": "artifacts-zk/contracts-preprocessed/L2GenesisUpgrade.sol/L2GenesisUpgrade.json", - "sourceCodePath": "contracts-preprocessed/L2GenesisUpgrade.sol", - "bytecodeHash": "0x0100008909426fe28d9bc438ffe5d725759d6e1b491a0845a0a4acd6b02de0ce", - "sourceCodeHash": "0x14311ff42409c27616ded5c21c364c47cb4cabbe9e836afddc2859aea6a4186e" - }, { "contractName": "MsgValueSimulator", "bytecodePath": "artifacts-zk/contracts-preprocessed/MsgValueSimulator.sol/MsgValueSimulator.json", "sourceCodePath": "contracts-preprocessed/MsgValueSimulator.sol", - "bytecodeHash": "0x0100005dd595bacb1636ddd14ed49b9ba4bae91fe4239e63b199fdad740253b8", + "bytecodeHash": "0x0100005d606dc17844411ee44a09b08e574347fd92fb4df7d1739fe02ebae2cc", "sourceCodeHash": "0x4834adf62dbaefa1a1c15d36b5ad1bf2826e7d888a17be495f7ed4e4ea381aa8" }, { "contractName": "NonceHolder", "bytecodePath": "artifacts-zk/contracts-preprocessed/NonceHolder.sol/NonceHolder.json", "sourceCodePath": "contracts-preprocessed/NonceHolder.sol", - "bytecodeHash": "0x010000db3a5dfcbaf66043a50a7dc013f52e31c22109b51ad066cb8965329c12", + "bytecodeHash": "0x010000dbe03a15e6478090c69b0565c273a9cb034c8af48b70d8e71baf5ecf94", "sourceCodeHash": "0xaa2ed3a26af30032c00a612ac327e0cdf5288b7c932ae903462355f863f950cb" }, { "contractName": "PubdataChunkPublisher", "bytecodePath": "artifacts-zk/contracts-preprocessed/PubdataChunkPublisher.sol/PubdataChunkPublisher.json", "sourceCodePath": "contracts-preprocessed/PubdataChunkPublisher.sol", - "bytecodeHash": "0x010000475e28fb922228fbf579a3994b2c9904ba87b66be430ad2c6f73608c34", + "bytecodeHash": "0x01000047abbd0db8bc506c1cb48e3aab878da3e5ea1bbacf1d4b5f46391f2493", "sourceCodeHash": "0x0568a9a12bdac94c9e055ca303824a6bf4dc4aa503cfe9a2586c7d3dda8d45da" }, { "contractName": "SystemContext", "bytecodePath": "artifacts-zk/contracts-preprocessed/SystemContext.sol/SystemContext.json", "sourceCodePath": "contracts-preprocessed/SystemContext.sol", - "bytecodeHash": "0x010001a50222e0b69c767ace5447a13afbeb457a4673836727a7aabb87bda47b", + "bytecodeHash": "0x010001a55d8778874657090f2db3a8aeabd491a5f3352f04c89eadabdd92e6ba", "sourceCodeHash": "0xf23d12ad2f17ad3b26e909fabfdcfaf4e1d158923e7cb8eeb9b5965a0b464406" }, { @@ -192,35 +178,35 @@ "contractName": "bootloader_test", "bytecodePath": "bootloader/build/artifacts/bootloader_test.yul.zbin", "sourceCodePath": "bootloader/build/bootloader_test.yul", - "bytecodeHash": "0x010003cb00c945bfc58c7c02744dcc1b0e8337a25fede79b4868148fdaf51b2f", - "sourceCodeHash": "0xd2b421f88a1ed9f35d764fb64c536b9e550080529059ad01aa7175a67d0e7b44" + "bytecodeHash": "0x010003cb92f46b717a3351f085b9d0d7cf1b6c164f390487f29da5c3b1f272a1", + "sourceCodeHash": "0xbf798f55f3b5c3d4d29423278bd68c6bb6428f0290f6791b2e20963166b3b21a" }, { "contractName": "fee_estimate", "bytecodePath": "bootloader/build/artifacts/fee_estimate.yul.zbin", "sourceCodePath": "bootloader/build/fee_estimate.yul", - "bytecodeHash": "0x01000951004dadd5975442374e1b6d0a7387bad39ae5a245ca4e67a72f65703d", - "sourceCodeHash": "0x0447962176d45a4bfe5680e8fc71439c2328ca97c1fb92230a620683341ed3a5" + "bytecodeHash": "0x01000951d5e14249434340fe5e6be707157f16d66ca10d0e5fcc110cc674def4", + "sourceCodeHash": "0xc7cd680273e89b1dfc3c6941f69611894c885e26656adfc4586c4eb149285d9d" }, { "contractName": "gas_test", "bytecodePath": "bootloader/build/artifacts/gas_test.yul.zbin", "sourceCodePath": "bootloader/build/gas_test.yul", - "bytecodeHash": "0x010008d7c5f4dc0eae510afb2b50c77b84b05559c74071d37116eaa90737e5f9", - "sourceCodeHash": "0x4e106a67af235c3f3192cb0dd52a9f5d3a36054245545712e1de0541bd580032" + "bytecodeHash": "0x010008d7db21670fda613a703321bb109f192ef92a6cef40b07a35a661c4d563", + "sourceCodeHash": "0xaf85e223e2156440f007fed14c9fe8899d33ad2f0aeb7feab3f4fd81d759bfb6" }, { "contractName": "playground_batch", "bytecodePath": "bootloader/build/artifacts/playground_batch.yul.zbin", "sourceCodePath": "bootloader/build/playground_batch.yul", - "bytecodeHash": "0x010009576cd2d0b3ee3f825505f43ee9eb9c148d0ba21fcf8087964b5dff82d2", - "sourceCodeHash": "0xffe676bc40d7a8b5cba10a030695a3ccd9aff83b62c3a56db5344c1a4d80bd44" + "bytecodeHash": "0x0100095722e18e6831abbece78d3bbaac4fe187db091d6be75d0c6f59aff0f7f", + "sourceCodeHash": "0xac0a99374868ffafa2427f23a7fd1f5f8551402904efbdf84f38638cad00ec14" }, { "contractName": "proved_batch", "bytecodePath": "bootloader/build/artifacts/proved_batch.yul.zbin", "sourceCodePath": "bootloader/build/proved_batch.yul", - "bytecodeHash": "0x010008e7f8fc64f96ca96a6e3826e05a5197b479ba9accb6cb00630bc4ba4ac2", - "sourceCodeHash": "0x20b339396861eb9ad704db606b52d0461c29bbb92acabe54b1f6755fbe83fff6" + "bytecodeHash": "0x010008e75c912d19d915dc90467be59c81c8004271b03639354806f669f14ad3", + "sourceCodeHash": "0x25e4cdb4020792f534611de304297e7e0230ed7ea0510bc049862c2540cc458e" } ] From aa00e5f55caaf3901fff382dd385f3101c66b5db Mon Sep 17 00:00:00 2001 From: Raid Ateir Date: Thu, 27 Jun 2024 21:18:20 +0400 Subject: [PATCH 04/10] (fix): collision-resistant encoding + added documentation + small fixes --- .../contracts/bridge/L1NativeTokenVault.sol | 34 +- .../contracts/bridge/L1SharedBridge.sol | 299 +++++++++++------- .../bridge/interfaces/IL1SharedBridge.sol | 2 +- .../contracts/bridgehub/Bridgehub.sol | 16 +- .../L1SharedBridge/L1SharedBridgeBase.t.sol | 9 +- .../L1SharedBridge/L1SharedBridgeFails.t.sol | 4 +- .../unit_tests/l1_shared_bridge_test.spec.ts | 34 +- .../contracts/bridge/L2SharedBridge.sol | 11 +- 8 files changed, 246 insertions(+), 163 deletions(-) diff --git a/l1-contracts/contracts/bridge/L1NativeTokenVault.sol b/l1-contracts/contracts/bridge/L1NativeTokenVault.sol index 6e16c4ace..cec815560 100644 --- a/l1-contracts/contracts/bridge/L1NativeTokenVault.sol +++ b/l1-contracts/contracts/bridge/L1NativeTokenVault.sol @@ -47,7 +47,7 @@ contract L1NativeTokenVault is IL1NativeTokenVault, IL1AssetHandler, Ownable2Ste _; } - /// @notice Checks that the message sender is the shared bridge itself. + /// @notice Checks that the message sender is the native token vault itself. modifier onlySelf() { require(msg.sender == address(this), "NTV only"); _; @@ -62,8 +62,8 @@ contract L1NativeTokenVault is IL1NativeTokenVault, IL1AssetHandler, Ownable2Ste L1_SHARED_BRIDGE = _l1SharedBridge; } - /// @dev Initializes a contract for later use. Expected to be used in the proxy - /// @param _owner Address which can change pause / unpause the NTV + /// @dev Initializes a contract for later use. Expected to be used in the proxy. + /// @param _owner Address which can change pause / unpause the NTV. /// implementation. The owner is the Governor and separate from the ProxyAdmin from now on, so that the Governor can call the bridge. function initialize(address _owner) external initializer { require(_owner != address(0), "NTV owner 0"); @@ -75,7 +75,9 @@ contract L1NativeTokenVault is IL1NativeTokenVault, IL1AssetHandler, Ownable2Ste require(address(L1_SHARED_BRIDGE) == msg.sender, "NTV: ETH only accepted from Shared Bridge"); } - /// @dev Transfer tokens from shared bridge as part of migration process. + /// @notice Transfers tokens from shared bridge as part of the migration process. + /// @dev Both ETH and ERC20 tokens can be transferred. Exhausts balance of shared bridge after the first call. + /// @dev Calling second time for the same token will revert. /// @param _token The address of token to be transferred (address(1) for ether and contract address for ERC20). function transferFundsFromSharedBridge(address _token) external { if (_token == ETH_TOKEN_ADDRESS) { @@ -93,16 +95,18 @@ contract L1NativeTokenVault is IL1NativeTokenVault, IL1AssetHandler, Ownable2Ste } } - /// @dev Set chain token balance as part of migration process. + /// @notice Updates chain token balance within NTV to account for tokens transferred from the shared bridge (part of the migration process). + /// @dev Clears chain balance on the shared bridge after the first call. Subsequent calls will not affect the state. /// @param _token The address of token to be transferred (address(1) for ether and contract address for ERC20). /// @param _targetChainId The chain ID of the corresponding ZK chain. function transferBalancesFromSharedBridge(address _token, uint256 _targetChainId) external { uint256 sharedBridgeChainBalance = L1_SHARED_BRIDGE.chainBalance(_targetChainId, _token); chainBalance[_targetChainId][_token] = chainBalance[_targetChainId][_token] + sharedBridgeChainBalance; - L1_SHARED_BRIDGE.transferBalanceToNTV(_targetChainId, _token); + L1_SHARED_BRIDGE.clearChainBalance(_targetChainId, _token); } - /// @dev We want to be able to bridge native tokens automatically, this means registering them on the fly + /// @notice Registers tokens within the NTV. + /// @dev The goal was to allow bridging L1 native tokens automatically, by registering them on the fly. /// @notice Allows the bridge to register a token address for the vault. /// @notice No access control is ok, since the bridging of tokens should be permissionless. This requires permissionless registration. function registerToken(address _l1Token) external { @@ -115,7 +119,7 @@ contract L1NativeTokenVault is IL1NativeTokenVault, IL1AssetHandler, Ownable2Ste /// @inheritdoc IL1AssetHandler /// @notice Allows bridgehub to acquire mintValue for L1->L2 transactions. - /// @dev here _data is the _depositAmount and the _l2Receiver + /// @dev In case of native token vault _data is the tuple of _depositAmount and _l2Receiver. function bridgeBurn( uint256 _chainId, uint256, @@ -150,12 +154,15 @@ contract L1NativeTokenVault is IL1NativeTokenVault, IL1AssetHandler, Ownable2Ste chainBalance[_chainId][l1Token] += amount; // solhint-disable-next-line func-named-parameters - _bridgeMintData = abi.encode(amount, _prevMsgSender, _l2Receiver, getERC20Getters(l1Token), l1Token); // to do add l2Receiver in here + _bridgeMintData = abi.encode(amount, _prevMsgSender, _l2Receiver, getERC20Getters(l1Token), l1Token); // solhint-disable-next-line func-named-parameters emit BridgeBurn(_chainId, _assetId, _prevMsgSender, _l2Receiver, amount); } - /// @dev Transfers tokens from the depositor address to the smart contract address. + /// @notice Transfers tokens from the depositor address to the smart contract address. + /// @param _from The address of the depositor. + /// @param _token The ERC20 token to be transferred. + /// @param _amount The amount to be transferred. /// @return The difference between the contract balance before and after the transferring of funds. function _depositFunds(address _from, IERC20 _token, uint256 _amount) internal returns (uint256) { uint256 balanceBefore = _token.balanceOf(address(this)); @@ -174,7 +181,9 @@ contract L1NativeTokenVault is IL1NativeTokenVault, IL1AssetHandler, Ownable2Ste return balanceAfter - balanceBefore; } - /// @dev Receives and parses (name, symbol, decimals) from the token contract + /// @notice Receives and parses (name, symbol, decimals) from the token contract. + /// @param _token The address of token of interest. + /// @return Returns encoded name, symbol, and decimals for specific token. function getERC20Getters(address _token) public view returns (bytes memory) { if (_token == ETH_TOKEN_ADDRESS) { bytes memory name = bytes("Ether"); @@ -246,6 +255,9 @@ contract L1NativeTokenVault is IL1NativeTokenVault, IL1AssetHandler, Ownable2Ste } } + /// @notice Returns the parsed assetId. + /// @param _l1TokenAddress The address of the token to be parsed. + /// @return The asset ID. function getAssetId(address _l1TokenAddress) public view override returns (bytes32) { return keccak256(abi.encode(block.chainid, NATIVE_TOKEN_VAULT_VIRTUAL_ADDRESS, _l1TokenAddress)); } diff --git a/l1-contracts/contracts/bridge/L1SharedBridge.sol b/l1-contracts/contracts/bridge/L1SharedBridge.sol index d8871979a..a2f0c2e81 100644 --- a/l1-contracts/contracts/bridge/L1SharedBridge.sol +++ b/l1-contracts/contracts/bridge/L1SharedBridge.sol @@ -56,13 +56,13 @@ contract L1SharedBridge is IL1SharedBridge, ReentrancyGuard, Ownable2StepUpgrade /// than this value are considered to have been finalized prior to the upgrade and handled separately. uint256 internal eraPostLegacyBridgeUpgradeFirstBatch; - /// @dev Stores the zkSync Era batch number that processes the last deposit tx initiated by the legacy bridge + /// @dev Stores the zkSync Era batch number that processes the last deposit tx initiated by the legacy bridge. /// This variable (together with eraLegacyBridgeLastDepositTxNumber) is used to differentiate between pre-upgrade and post-upgrade deposits. Deposits processed in older batches /// than this value are considered to have been processed prior to the upgrade and handled separately. /// We use this both for Eth and erc20 token deposits, so we need to update the diamond and bridge simultaneously. uint256 internal eraLegacyBridgeLastDepositBatch; - /// @dev The tx number in the _eraLegacyBridgeLastDepositBatch of the last deposit tx initiated by the legacy bridge + /// @dev The tx number in the _eraLegacyBridgeLastDepositBatch of the last deposit tx initiated by the legacy bridge. /// This variable (together with eraLegacyBridgeLastDepositBatch) is used to differentiate between pre-upgrade and post-upgrade deposits. Deposits processed in older txs /// than this value are considered to have been processed prior to the upgrade and handled separately. /// We use this both for Eth and erc20 token deposits, so we need to update the diamond and bridge simultaneously. @@ -74,7 +74,7 @@ contract L1SharedBridge is IL1SharedBridge, ReentrancyGuard, Ownable2StepUpgrade /// @dev A mapping chainId => bridgeProxy. Used to store the bridge proxy's address, and to see if it has been deployed yet. mapping(uint256 chainId => address l2Bridge) public override l2BridgeAddress; - /// @dev A mapping chainId => L2 deposit transaction hash => keccak256(abi.encode(account, tokenAddress, amount)) + /// @dev A mapping chainId => L2 deposit transaction hash => keccak256(abi.encode(account, tokenAddress, amount)). /// @dev Tracks deposit transactions from L2 to enable users to claim their funds if a deposit fails. mapping(uint256 chainId => mapping(bytes32 l2DepositTxHash => bytes32 depositDataHash)) public @@ -93,17 +93,17 @@ contract L1SharedBridge is IL1SharedBridge, ReentrancyGuard, Ownable2StepUpgrade /// NOTE: this function may be removed in the future, don't rely on it! mapping(uint256 chainId => mapping(address l1Token => uint256 balance)) public chainBalance; - /// @dev A mapping assetId => assetHandlerAddress - /// @dev Tracks the address of Asset Handler contracts, where bridged funds are locked for each asset - /// @dev P.S. this liquidity was locked directly in SharedBridge before + /// @dev Maps asset ID to address of corresponding asset handler. + /// @dev Tracks the address of Asset Handler contracts, where bridged funds are locked for each asset. + /// @dev P.S. this liquidity was locked directly in SharedBridge before. mapping(bytes32 assetId => address assetHandlerAddress) public assetHandlerAddress; - /// @dev A mapping assetId => the asset deployment tracker address - /// @dev Tracks the address of Deployment Tracker contract on L1, which sets Asset Handlers on L2s (ZK chain) - /// @dev for the asset and stores respective addresses + /// @dev Maps asset ID to the asset deployment tracker address. + /// @dev Tracks the address of Deployment Tracker contract on L1, which sets Asset Handlers on L2s (ZK chain). + /// @dev For the asset and stores respective addresses. mapping(bytes32 assetId => address assetDeploymentTracker) public assetDeploymentTracker; - /// @dev Address of native token vault + /// @dev Address of native token vault. IL1NativeTokenVault public nativeTokenVault; /// @notice Checks that the message sender is the bridgehub. @@ -112,12 +112,6 @@ contract L1SharedBridge is IL1SharedBridge, ReentrancyGuard, Ownable2StepUpgrade _; } - /// @notice Checks that the message sender is the bridgehub. - modifier onlyThis() { - require(msg.sender == address(this), "ShB: only self"); - _; - } - /// @notice Checks that the message sender is the bridgehub or zkSync Era Diamond Proxy. modifier onlyBridgehubOrEra(uint256 _chainId) { require( @@ -148,10 +142,14 @@ contract L1SharedBridge is IL1SharedBridge, ReentrancyGuard, Ownable2StepUpgrade ERA_DIAMOND_PROXY = _eraDiamondProxy; } - /// @dev Initializes a contract bridge for later use. Expected to be used in the proxy - /// @dev Used for testing purposes only, as the contract has been initialized on mainnet - /// @param _owner Address which can change L2 token implementation and upgrade the bridge - /// implementation. The owner is the Governor and separate from the ProxyAdmin from now on, so that the Governor can call the bridge. + /// @dev Initializes a contract bridge for later use. Expected to be used in the proxy. + /// @dev Used for testing purposes only, as the contract has been initialized on mainnet. + /// @param _owner The address which can change L2 token implementation and upgrade the bridge implementation. + /// The owner is the Governor and separate from the ProxyAdmin from now on, so that the Governor can call the bridge. + /// @param _eraPostDiamondUpgradeFirstBatch The first batch number on the zkSync Era Diamond Proxy that was settled after diamond proxy upgrade. + /// @param _eraPostLegacyBridgeUpgradeFirstBatch The first batch number on the zkSync Era Diamond Proxy that was settled after legacy bridge upgrade. + /// @param _eraLegacyBridgeLastDepositBatch The the zkSync Era batch number that processes the last deposit tx initiated by the legacy bridge. + /// @param _eraLegacyBridgeLastDepositTxNumber The tx number in the _eraLegacyBridgeLastDepositBatch of the last deposit tx initiated by the legacy bridge. function initialize( address _owner, uint256 _eraPostDiamondUpgradeFirstBatch, @@ -169,11 +167,13 @@ contract L1SharedBridge is IL1SharedBridge, ReentrancyGuard, Ownable2StepUpgrade } } - /// @dev transfer token to shared bridge as part of upgrade + /// @notice Transfers tokens from shared bridge to native token vault. + /// @dev This function is part of the upgrade process used to transfer liquidity. + /// @param _token The address of the token to be transferred to NTV. function transferTokenToNTV(address _token) external { - require(msg.sender == address(nativeTokenVault), "ShB: not NTV"); + address ntvAddress = address(nativeTokenVault); + require(msg.sender == ntvAddress, "ShB: not NTV"); if (ETH_TOKEN_ADDRESS == _token) { - address ntvAddress = address(nativeTokenVault); uint256 amount = address(this).balance; bool callSuccess; // Low-level assembly call, to avoid any memory copying (save gas) @@ -182,44 +182,65 @@ contract L1SharedBridge is IL1SharedBridge, ReentrancyGuard, Ownable2StepUpgrade } require(callSuccess, "ShB: eth transfer failed"); } else { - IERC20(_token).safeTransfer(address(nativeTokenVault), IERC20(_token).balanceOf(address(this))); + IERC20(_token).safeTransfer(ntvAddress, IERC20(_token).balanceOf(address(this))); } } - /// @dev transfer balance to native token vault as part of upgrade - function transferBalanceToNTV(uint256 _chainId, address _token) external { + /// @notice Clears chain balance for specific token. + /// @dev This function is part of the upgrade process used to nullify chain balances once they are credited to NTV. + /// @param _chainId The ID of the ZK chain. + /// @param _token The address of the token which was previously deposit to shared bridge. + function clearChainBalance(uint256 _chainId, address _token) external { require(msg.sender == address(nativeTokenVault), "ShB: not NTV"); chainBalance[_chainId][_token] = 0; } - /// @dev Sets the L1ERC20Bridge contract address. Should be called only once. + /// @notice Sets the L1ERC20Bridge contract address. + /// @dev Should be called only once by the owner. + /// @param _legacyBridge The address of the legacy bridge. function setL1Erc20Bridge(address _legacyBridge) external onlyOwner { require(address(legacyBridge) == address(0), "ShB: legacy bridge already set"); require(_legacyBridge != address(0), "ShB: legacy bridge 0"); legacyBridge = IL1ERC20Bridge(_legacyBridge); } - /// @dev Sets the L1ERC20Bridge contract address. Should be called only once. + /// @notice Sets the L1ERC20Bridge contract address. + /// @dev Should be called only once by the owner. + /// @param _nativeTokenVault The address of the native token vault. function setNativeTokenVault(IL1NativeTokenVault _nativeTokenVault) external onlyOwner { require(address(nativeTokenVault) == address(0), "ShB: native token vault already set"); require(address(_nativeTokenVault) != address(0), "ShB: native token vault 0"); nativeTokenVault = _nativeTokenVault; } + /// @notice Sets the L1ERC20Bridge contract address. /// @dev Initializes the l2Bridge address by governance for a specific chain. function initializeChainGovernance(uint256 _chainId, address _l2BridgeAddress) external onlyOwner { l2BridgeAddress[_chainId] = _l2BridgeAddress; } - /// @dev Used to set the assedAddress for a given assetId. - function setAssetHandlerAddressInitial(bytes32 _additionalData, address _assetHandlerAddress) external { + /// @notice Used to set the asset handler address for a given asset ID. + /// @dev No access control on the caller, as msg.sender is encoded in the assetId. + /// @param _assetData In most cases this paramater is bytes32 encoded token address. However, it can include extra infromation used by custom asset handlers. + /// @param _assetHandlerAddress The address of the asset handler, which will hold the token of interest. + function setAssetHandlerAddressInitial(bytes32 _assetData, address _assetHandlerAddress) external { address sender = msg.sender == address(nativeTokenVault) ? NATIVE_TOKEN_VAULT_VIRTUAL_ADDRESS : msg.sender; - bytes32 assetId = keccak256(abi.encode(uint256(block.chainid), sender, _additionalData)); + bytes32 assetId = keccak256(abi.encode(uint256(block.chainid), sender, _assetData)); assetHandlerAddress[assetId] = _assetHandlerAddress; assetDeploymentTracker[assetId] = msg.sender; - emit AssetHandlerRegisteredInitial(assetId, _assetHandlerAddress, _additionalData, sender); + emit AssetHandlerRegisteredInitial(assetId, _assetHandlerAddress, _assetData, sender); } + /// @notice Used to set the asset handler address for a given asset ID on a remote ZK chain + /// @dev No access control on the caller, as msg.sender is encoded in the assetId. + /// @param _chainId The ZK chain ID. + /// @param _mintValue The value withdrawn by base token bridge to cover for l2 gas and l2 msg.value costs. + /// @param _l2TxGasLimit The L2 gas limit to be used in the corresponding L2 transaction. + /// @param _l2TxGasPerPubdataByte The gasPerPubdataByteLimit to be used in the corresponding L2 transaction. + /// @param _refundRecipient The address on L2 that will receive the refund for the transaction. + /// @param _assetId The encoding of asset ID. + /// @param _assetAddressOnCounterPart The address of the asset handler, which will hold the token of interest. + /// @return l2TxHash The L2 transaction hash of setting asset handler on remote chain. function setAssetHandlerAddressOnCounterPart( uint256 _chainId, uint256 _mintValue, @@ -240,7 +261,7 @@ contract L1SharedBridge is IL1SharedBridge, ReentrancyGuard, Ownable2StepUpgrade L2TransactionRequestDirect memory request = L2TransactionRequestDirect({ chainId: _chainId, l2Contract: l2BridgeAddress[_chainId], - mintValue: _mintValue, // l2 gas + l2 msg.Value the bridgehub will withdraw the mintValue from the base token bridge for gas + mintValue: _mintValue, // l2 gas + l2 msg.value the bridgehub will withdraw the mintValue from the base token bridge for gas l2Value: 0, // L2 msg.value, this contract doesn't support base token deposits or wrapping functionality, for direct deposits use bridgehub l2Calldata: l2Calldata, l2GasLimit: _l2TxGasLimit, @@ -278,12 +299,14 @@ contract L1SharedBridge is IL1SharedBridge, ReentrancyGuard, Ownable2StepUpgrade emit BridgehubDepositBaseTokenInitiated(_chainId, _prevMsgSender, _assetId, _amount); } - /// @notice Returns the address of asset handler and parsed assetId, if padded token address was passed + /// @notice Returns the address of asset handler and parsed assetId, if padded token address was passed. /// @dev For backwards compatibility we pad the l1Token to become a bytes32 assetId. - /// @dev We deal with this case here. We also register the asset. - /// @param _assetId bytes32 encoding of asset Id or padded address of the token + /// @dev If asset handler is not set for the asset, we also register the asset. + /// @param _assetId The encoding of asset ID or padded address of the token. + /// @return l1AssetHandler The address of asset handler for provided asset ID. + /// @return assetId The asset ID. function _getAssetProperties(bytes32 _assetId) internal returns (address l1AssetHandler, bytes32 assetId) { - // Check if the passed id is the address and assume NTV for the case + // Check if the passed ID is the address and assume NTV for the case assetId = uint256(_assetId) <= type(uint160).max ? keccak256(abi.encode(block.chainid, NATIVE_TOKEN_VAULT_VIRTUAL_ADDRESS, _assetId)) : _assetId; @@ -296,14 +319,12 @@ contract L1SharedBridge is IL1SharedBridge, ReentrancyGuard, Ownable2StepUpgrade } } - /// @notice Decodes the transfer input for legacy data and transfers allowance to NTV - /// @dev Is not applicable for custom asset handlers - /// @param _data encoded transfer data (address _l1Token, uint256 _depositAmount, address _l2Receiver) - /// @param _prevMsgSender address of the deposit initiator - function handleLegacyData( - bytes calldata _data, - address _prevMsgSender - ) external onlyThis returns (bytes32, bytes memory) { + /// @notice Decodes the transfer input for legacy data and transfers allowance to NTV. + /// @dev Is not applicable for custom asset handlers. + /// @param _data The encoded transfer data (address _l1Token, uint256 _depositAmount, address _l2Receiver). + /// @param _prevMsgSender The address of the deposit initiator. + /// @return Tuple of asset ID and encoded transfer data to conform with new encoding standard. + function _handleLegacyData(bytes calldata _data, address _prevMsgSender) internal returns (bytes32, bytes memory) { (address _l1Token, uint256 _depositAmount, address _l2Receiver) = abi.decode( _data, (address, uint256, address) @@ -313,6 +334,10 @@ contract L1SharedBridge is IL1SharedBridge, ReentrancyGuard, Ownable2StepUpgrade return (assetId, abi.encode(_depositAmount, _l2Receiver)); } + /// @notice Ensures that token is registered with native token vault. + /// @dev Only used when deposit is made with legacy data encoding format. + /// @param _l1Token The L1 token address which should be registered with native token vault. + /// @return assetId The asset ID of the token provided. function _ensureTokenRegisteredWithNTV(address _l1Token) internal returns (bytes32 assetId) { assetId = nativeTokenVault.getAssetId(_l1Token); if (nativeTokenVault.tokenAddress(assetId) == address(0)) { @@ -321,7 +346,10 @@ contract L1SharedBridge is IL1SharedBridge, ReentrancyGuard, Ownable2StepUpgrade } /// @notice Transfers allowance to Native Token Vault, if the asset is registered with it. Does nothing for ETH or non-registered tokens. - /// @dev assetId is not the padded address, but the correct encoded id (NTV stores respective format for IDs) + /// @dev assetId is not the padded address, but the correct encoded ID (NTV stores respective format for IDs). + /// @param _assetId The encoding of asset ID. + /// @param _amount The asset amount to be transferred to native token vault. + /// @param _prevMsgSender The `msg.sender` address from the external call that initiated current one. function _transferAllowanceToNTV(bytes32 _assetId, uint256 _amount, address _prevMsgSender) internal { address l1TokenAddress = nativeTokenVault.tokenAddress(_assetId); if (l1TokenAddress == address(0) || l1TokenAddress == ETH_TOKEN_ADDRESS) { @@ -346,6 +374,7 @@ contract L1SharedBridge is IL1SharedBridge, ReentrancyGuard, Ownable2StepUpgrade /// @param _prevMsgSender The `msg.sender` address from the external call that initiated current one. /// @param _l2Value The L2 `msg.value` from the L1 -> L2 deposit transaction. /// @param _data The calldata for the second bridge deposit. + /// @return request The data used by the bridgehub to create L2 transaction request to specific ZK chain. function bridgehubDeposit( uint256 _chainId, address _prevMsgSender, @@ -363,14 +392,13 @@ contract L1SharedBridge is IL1SharedBridge, ReentrancyGuard, Ownable2StepUpgrade bytes32 assetId; bytes memory transferData; bool legacyDeposit = false; - try this.handleLegacyData(_data, _prevMsgSender) returns ( - bytes32 assetIdDecoded, - bytes memory transferDataDecoded - ) { - (assetId, transferData) = (assetIdDecoded, transferDataDecoded); + bytes1 encodingVersion = _data[0]; + + if (encodingVersion == 0x01) { + (assetId, transferData) = abi.decode(_data[1:], (bytes32, bytes)); + } else { + (assetId, transferData) = _handleLegacyData(_data, _prevMsgSender); legacyDeposit = true; - } catch { - (assetId, transferData) = abi.decode(_data, (bytes32, bytes)); } require(BRIDGE_HUB.baseTokenAssetId(_chainId) != assetId, "ShB: baseToken deposit not supported"); @@ -388,7 +416,7 @@ contract L1SharedBridge is IL1SharedBridge, ReentrancyGuard, Ownable2StepUpgrade (uint256 _depositAmount, ) = abi.decode(transferData, (uint256, address)); txDataHash = keccak256(abi.encode(_prevMsgSender, nativeTokenVault.tokenAddress(assetId), _depositAmount)); } else { - txDataHash = keccak256(abi.encode(_prevMsgSender, assetId, transferData)); + txDataHash = keccak256(bytes.concat(bytes1(0x01), abi.encode(_prevMsgSender, assetId, transferData))); } request = _requestToBridge({ @@ -408,7 +436,13 @@ contract L1SharedBridge is IL1SharedBridge, ReentrancyGuard, Ownable2StepUpgrade }); } - /// @dev send the burn message to the asset + /// @notice Forwards the burn request for specific asset to respective asset handler. + /// @param _chainId The chain ID of the ZK chain to which deposit. + /// @param _l2Value The L2 `msg.value` from the L1 -> L2 deposit transaction. + /// @param _assetId The deposited asset ID. + /// @param _prevMsgSender The `msg.sender` address from the external call that initiated current one. + /// @param _transferData The encoded data, which is used by the asset handler to determine L2 recipient and amount. Might include extra information. + /// @return bridgeMintCalldata The calldata used by remote asset handler to mint tokens for recipient. function _burn( uint256 _chainId, uint256 _l2Value, @@ -426,7 +460,13 @@ contract L1SharedBridge is IL1SharedBridge, ReentrancyGuard, Ownable2StepUpgrade }); } - /// @dev The request data that is passed to the bridgehub + /// @dev The request data that is passed to the bridgehub. + /// @param _chainId The chain ID of the ZK chain to which deposit. + /// @param _prevMsgSender The `msg.sender` address from the external call that initiated current one. + /// @param _assetId The deposited asset ID. + /// @param _bridgeMintCalldata The calldata used by remote asset handler to mint tokens for recipient. + /// @param _txDataHash The keccak256 hash of 0x01 || abi.encode(bytes32, bytes) to identify deposits. + /// @return request The data used by the bridgehub to create L2 transaction request to specific ZK chain. function _requestToBridge( uint256 _chainId, address _prevMsgSender, @@ -449,7 +489,7 @@ contract L1SharedBridge is IL1SharedBridge, ReentrancyGuard, Ownable2StepUpgrade /// @notice Confirms the acceptance of a transaction by the Mailbox, as part of the L2 transaction process within Bridgehub. /// This function is utilized by `requestL2TransactionTwoBridges` to validate the execution of a transaction. /// @param _chainId The chain ID of the ZK chain to which confirm the deposit. - /// @param _txDataHash The keccak256 hash of abi.encode(msgSender, l1Token, amount) + /// @param _txDataHash The keccak256 hash of 0x01 || abi.encode(bytes32, bytes) to identify deposits. /// @param _txHash The hash of the L1->L2 transaction to confirm the deposit. function bridgehubConfirmL2Transaction( uint256 _chainId, @@ -461,19 +501,23 @@ contract L1SharedBridge is IL1SharedBridge, ReentrancyGuard, Ownable2StepUpgrade emit BridgehubDepositFinalized(_chainId, _txDataHash, _txHash); } - /// @dev Generate a calldata for calling the deposit finalization on the L2 bridge contract + /// @notice Generates a calldata for calling the deposit finalization on the L2 native token contract. + /// @param _l1Sender The address of the deposit initiator. + /// @param _assetId The deposited asset ID. + /// @param _transferData The encoded data, which is used by the asset handler to determine L2 recipient and amount. Might include extra information. + /// @return Returns calldata used on ZK chain. function _getDepositL2Calldata( address _l1Sender, bytes32 _assetId, - bytes memory _assetData + bytes memory _transferData ) internal view returns (bytes memory) { // First branch covers the case when asset is not registered with NTV (custom asset handler) // Second branch handles tokens registered with NTV and uses legacy calldata encoding if (nativeTokenVault.tokenAddress(_assetId) == address(0)) { - return abi.encodeCall(IL2Bridge.finalizeDeposit, (_assetId, _assetData)); + return abi.encodeCall(IL2Bridge.finalizeDeposit, (_assetId, _transferData)); } else { (uint256 _amount, , address _l2Receiver, bytes memory _gettersData, address _parsedL1Token) = abi.decode( - _assetData, + _transferData, (uint256, address, address, bytes, address) ); return @@ -484,21 +528,21 @@ contract L1SharedBridge is IL1SharedBridge, ReentrancyGuard, Ownable2StepUpgrade } } - /// @dev Withdraw funds from the initiated deposit, that failed when finalizing on L2 - /// @param _depositSender The address of the deposit initiator - /// @param _assetId The address of the deposited L1 ERC20 token - /// @param _assetData The amount of the deposit that failed. - /// @param _l2TxHash The L2 transaction hash of the failed deposit finalization - /// @param _l2BatchNumber The L2 batch number where the deposit finalization was processed - /// @param _l2MessageIndex The position in the L2 logs Merkle tree of the l2Log that was sent with the message - /// @param _l2TxNumberInBatch The L2 transaction number in a batch, in which the log was sent - /// @param _merkleProof The Merkle proof of the processing L1 -> L2 transaction with deposit finalization + /// @dev Withdraw funds from the initiated deposit, that failed when finalizing on L2. + /// @param _depositSender The address of the deposit initiator. + /// @param _assetId The address of the deposited L1 ERC20 token. + /// @param _transferData The encoded data, which is used by the asset handler to determine L2 recipient and amount. Might include extra information. + /// @param _l2TxHash The L2 transaction hash of the failed deposit finalization. + /// @param _l2BatchNumber The L2 batch number where the deposit finalization was processed. + /// @param _l2MessageIndex The position in the L2 logs Merkle tree of the l2Log that was sent with the message. + /// @param _l2TxNumberInBatch The L2 transaction number in a batch, in which the log was sent. + /// @param _merkleProof The Merkle proof of the processing L1 -> L2 transaction with deposit finalization. /// @dev Processes claims of failed deposit, whether they originated from the legacy bridge or the current system. function bridgeRecoverFailedTransfer( uint256 _chainId, address _depositSender, bytes32 _assetId, - bytes memory _assetData, + bytes memory _transferData, bytes32 _l2TxHash, uint256 _l2BatchNumber, uint256 _l2MessageIndex, @@ -522,15 +566,15 @@ contract L1SharedBridge is IL1SharedBridge, ReentrancyGuard, Ownable2StepUpgrade { bytes32 dataHash = depositHappened[_chainId][_l2TxHash]; address l1Token = nativeTokenVault.tokenAddress(_assetId); - (uint256 amount, address prevMsgSender) = abi.decode(_assetData, (uint256, address)); + (uint256 amount, address prevMsgSender) = abi.decode(_transferData, (uint256, address)); bytes32 txDataHash = keccak256(abi.encode(prevMsgSender, l1Token, amount)); require(dataHash == txDataHash, "ShB: d.it not hap"); } delete depositHappened[_chainId][_l2TxHash]; - IL1AssetHandler(assetHandlerAddress[_assetId]).bridgeRecoverFailedTransfer(_chainId, _assetId, _assetData); + IL1AssetHandler(assetHandlerAddress[_assetId]).bridgeRecoverFailedTransfer(_chainId, _assetId, _transferData); - emit ClaimedFailedDepositSharedBridge(_chainId, _depositSender, _assetId, _assetData); + emit ClaimedFailedDepositSharedBridge(_chainId, _depositSender, _assetId, _transferData); } /// @dev Determines if an eth withdrawal was initiated on zkSync Era before the upgrade to the Shared Bridge. @@ -575,13 +619,13 @@ contract L1SharedBridge is IL1SharedBridge, ReentrancyGuard, Ownable2StepUpgrade _l2BatchNumber == eraLegacyBridgeLastDepositBatch)); } - /// @notice Finalize the withdrawal and release funds - /// @param _chainId The chain ID of the transaction to check - /// @param _l2BatchNumber The L2 batch number where the withdrawal was processed - /// @param _l2MessageIndex The position in the L2 logs Merkle tree of the l2Log that was sent with the message - /// @param _l2TxNumberInBatch The L2 transaction number in the batch, in which the log was sent - /// @param _message The L2 withdraw data, stored in an L2 -> L1 message - /// @param _merkleProof The Merkle proof of the inclusion L2 -> L1 message about withdrawal initialization + /// @notice Finalize the withdrawal and release funds. + /// @param _chainId The chain ID of the transaction to check. + /// @param _l2BatchNumber The L2 batch number where the withdrawal was processed. + /// @param _l2MessageIndex The position in the L2 logs Merkle tree of the l2Log that was sent with the message. + /// @param _l2TxNumberInBatch The L2 transaction number in the batch, in which the log was sent. + /// @param _message The L2 withdraw data, stored in an L2 -> L1 message. + /// @param _merkleProof The Merkle proof of the inclusion L2 -> L1 message about withdrawal initialization. function finalizeWithdrawal( uint256 _chainId, uint256 _l2BatchNumber, @@ -606,8 +650,16 @@ contract L1SharedBridge is IL1SharedBridge, ReentrancyGuard, Ownable2StepUpgrade uint16 l2TxNumberInBatch; } - /// @dev Internal function that handles the logic for finalizing withdrawals, - /// serving both the current bridge system and the legacy ERC20 bridge. + /// @notice Internal function that handles the logic for finalizing withdrawals, supporting both the current bridge system and the legacy ERC20 bridge. + /// @param _chainId The chain ID of the transaction to check. + /// @param _l2BatchNumber The L2 batch number where the withdrawal was processed. + /// @param _l2MessageIndex The position in the L2 logs Merkle tree of the l2Log that was sent with the message. + /// @param _l2TxNumberInBatch The L2 transaction number in the batch, in which the log was sent. + /// @param _message The L2 withdraw data, stored in an L2 -> L1 message. + /// @param _merkleProof The Merkle proof of the inclusion L2 -> L1 message about withdrawal initialization. + /// @return l1Receiver The address to receive bridged assets. + /// @return assetId The bridged asset ID. + /// @return amount The amount of asset bridged. function _finalizeWithdrawal( uint256 _chainId, uint256 _l2BatchNumber, @@ -639,7 +691,13 @@ contract L1SharedBridge is IL1SharedBridge, ReentrancyGuard, Ownable2StepUpgrade emit WithdrawalFinalizedSharedBridge(_chainId, l1Receiver, assetId, amount); } - /// @dev Verifies the validity of a withdrawal message from L2 and returns details of the withdrawal. + /// @notice Verifies the validity of a withdrawal message from L2 and returns withdrawal details. + /// @param _chainId The chain ID of the transaction to check. + /// @param _messageParams The message params, which include batch number, message index, and L2 tx number in batch. + /// @param _message The L2 withdraw data, stored in an L2 -> L1 message. + /// @param _merkleProof The Merkle proof of the inclusion L2 -> L1 message about withdrawal initialization. + /// @return assetId The ID of the bridged asset. + /// @return transferData The transfer data used to finalize withdawal. function _checkWithdrawal( uint256 _chainId, MessageParams memory _messageParams, @@ -669,6 +727,13 @@ contract L1SharedBridge is IL1SharedBridge, ReentrancyGuard, Ownable2StepUpgrade require(success, "ShB withd w proof"); // withdrawal wrong proof } + /// @notice Parses the withdrawal message and returns withdrawal details. + /// @dev Currently, 3 different encoding versions are supported: legacy mailbox withdrawal, ERC20 bridge withdrawal, + /// @dev and the latest version supported by shared bridge. Selectors are used for versioning. + /// @param _chainId The ZK chain ID. + /// @param _l2ToL1message The encoded L2 -> L1 message. + /// @return assetId The ID of the bridged asset. + /// @return transferData The transfer data used to finalize withdawal. function _parseL2WithdrawalMessage( uint256 _chainId, bytes memory _l2ToL1message @@ -684,8 +749,6 @@ contract L1SharedBridge is IL1SharedBridge, ReentrancyGuard, Ownable2StepUpgrade require(_l2ToL1message.length >= 56, "ShB wrong msg len"); // wrong message length uint256 amount; address l1Receiver; - // uint256 l1ReceiverBytes; - // address parsedL1Receiver; (uint32 functionSignature, uint256 offset) = UnsafeBytes.readUint32(_l2ToL1message, 0); if (bytes4(functionSignature) == IMailbox.finalizeEthWithdrawal.selector) { @@ -718,7 +781,9 @@ contract L1SharedBridge is IL1SharedBridge, ReentrancyGuard, Ownable2StepUpgrade } } - /// @dev Receives and parses (name, symbol, decimals) from the token contract + /// @notice Receives and parses (name, symbol, decimals) from the token contract. + /// @param _token The address of token of interest. + /// @return Returns encoded name, symbol, and decimals for specific token. function getERC20Getters(address _token) public view returns (bytes memory) { if (_token == ETH_TOKEN_ADDRESS) { bytes memory name = bytes("Ether"); @@ -737,15 +802,15 @@ contract L1SharedBridge is IL1SharedBridge, ReentrancyGuard, Ownable2StepUpgrade SHARED BRIDGE TOKEN BRIDGING LEGACY FUNCTIONS //////////////////////////////////////////////////////////////*/ - /// @dev Withdraw funds from the initiated deposit, that failed when finalizing on L2 - /// @param _depositSender The address of the deposit initiator - /// @param _l1Asset The address of the deposited L1 ERC20 token + /// @dev Withdraw funds from the initiated deposit, that failed when finalizing on L2. + /// @param _depositSender The address of the deposit initiator. + /// @param _l1Asset The address of the deposited L1 ERC20 token. /// @param _amount The amount of the deposit that failed. - /// @param _l2TxHash The L2 transaction hash of the failed deposit finalization - /// @param _l2BatchNumber The L2 batch number where the deposit finalization was processed - /// @param _l2MessageIndex The position in the L2 logs Merkle tree of the l2Log that was sent with the message - /// @param _l2TxNumberInBatch The L2 transaction number in a batch, in which the log was sent - /// @param _merkleProof The Merkle proof of the processing L1 -> L2 transaction with deposit finalization + /// @param _l2TxHash The L2 transaction hash of the failed deposit finalization. + /// @param _l2BatchNumber The L2 batch number where the deposit finalization was processed. + /// @param _l2MessageIndex The position in the L2 logs Merkle tree of the l2Log that was sent with the message. + /// @param _l2TxNumberInBatch The L2 transaction number in a batch, in which the log was sent. + /// @param _merkleProof The Merkle proof of the processing L1 -> L2 transaction with deposit finalization. function claimFailedDeposit( uint256 _chainId, address _depositSender, @@ -763,7 +828,7 @@ contract L1SharedBridge is IL1SharedBridge, ReentrancyGuard, Ownable2StepUpgrade _chainId: _chainId, _depositSender: _depositSender, _assetId: assetId, - _assetData: transferData, + _transferData: transferData, _l2TxHash: _l2TxHash, _l2BatchNumber: _l2BatchNumber, _l2MessageIndex: _l2MessageIndex, @@ -781,11 +846,11 @@ contract L1SharedBridge is IL1SharedBridge, ReentrancyGuard, Ownable2StepUpgrade /// @dev If the token is bridged for the first time, the L2 token contract will be deployed. Note however, that the /// newly-deployed token does not support any custom logic, i.e. rebase tokens' functionality is not supported. /// @param _prevMsgSender The `msg.sender` address from the external call that initiated current one. - /// @param _l2Receiver The account address that should receive funds on L2 - /// @param _l1Token The L1 token address which is deposited - /// @param _amount The total amount of tokens to be bridged - /// @param _l2TxGasLimit The L2 gas limit to be used in the corresponding L2 transaction - /// @param _l2TxGasPerPubdataByte The gasPerPubdataByteLimit to be used in the corresponding L2 transaction + /// @param _l2Receiver The account address that should receive funds on L2. + /// @param _l1Token The L1 token address which is deposited. + /// @param _amount The total amount of tokens to be bridged. + /// @param _l2TxGasLimit The L2 gas limit to be used in the corresponding L2 transaction. + /// @param _l2TxGasPerPubdataByte The gasPerPubdataByteLimit to be used in the corresponding L2 transaction. /// @param _refundRecipient The address on L2 that will receive the refund for the transaction. /// @dev If the L2 deposit finalization transaction fails, the `_refundRecipient` will receive the `_l2Value`. /// Please note, the contract may change the refund recipient's address to eliminate sending funds to addresses @@ -860,15 +925,15 @@ contract L1SharedBridge is IL1SharedBridge, ReentrancyGuard, Ownable2StepUpgrade } /// @notice Finalizes the withdrawal for transactions initiated via the legacy ERC20 bridge. - /// @param _l2BatchNumber The L2 batch number where the withdrawal was processed - /// @param _l2MessageIndex The position in the L2 logs Merkle tree of the l2Log that was sent with the message - /// @param _l2TxNumberInBatch The L2 transaction number in the batch, in which the log was sent - /// @param _message The L2 withdraw data, stored in an L2 -> L1 message - /// @param _merkleProof The Merkle proof of the inclusion L2 -> L1 message about withdrawal initialization + /// @param _l2BatchNumber The L2 batch number where the withdrawal was processed. + /// @param _l2MessageIndex The position in the L2 logs Merkle tree of the l2Log that was sent with the message. + /// @param _l2TxNumberInBatch The L2 transaction number in the batch, in which the log was sent. + /// @param _message The L2 withdraw data, stored in an L2 -> L1 message. + /// @param _merkleProof The Merkle proof of the inclusion L2 -> L1 message about withdrawal initialization. /// - /// @return l1Receiver The address on L1 that will receive the withdrawn funds - /// @return l1Asset The address of the L1 token being withdrawn - /// @return amount The amount of the token being withdrawn + /// @return l1Receiver The address on L1 that will receive the withdrawn funds. + /// @return l1Asset The address of the L1 token being withdrawn. + /// @return amount The amount of the token being withdrawn. function finalizeWithdrawalLegacyErc20Bridge( uint256 _l2BatchNumber, uint256 _l2MessageIndex, @@ -892,14 +957,14 @@ contract L1SharedBridge is IL1SharedBridge, ReentrancyGuard, Ownable2StepUpgrade /// This function is specifically designed for maintaining backward-compatibility with legacy `claimFailedDeposit` /// method in `L1ERC20Bridge`. /// - /// @param _depositSender The address of the deposit initiator - /// @param _l1Asset The address of the deposited L1 ERC20 token + /// @param _depositSender The address of the deposit initiator. + /// @param _l1Asset The address of the deposited L1 ERC20 token. /// @param _amount The amount of the deposit that failed. - /// @param _l2TxHash The L2 transaction hash of the failed deposit finalization - /// @param _l2BatchNumber The L2 batch number where the deposit finalization was processed - /// @param _l2MessageIndex The position in the L2 logs Merkle tree of the l2Log that was sent with the message - /// @param _l2TxNumberInBatch The L2 transaction number in a batch, in which the log was sent - /// @param _merkleProof The Merkle proof of the processing L1 -> L2 transaction with deposit finalization + /// @param _l2TxHash The L2 transaction hash of the failed deposit finalization. + /// @param _l2BatchNumber The L2 batch number where the deposit finalization was processed. + /// @param _l2MessageIndex The position in the L2 logs Merkle tree of the l2Log that was sent with the message. + /// @param _l2TxNumberInBatch The L2 transaction number in a batch, in which the log was sent. + /// @param _merkleProof The Merkle proof of the processing L1 -> L2 transaction with deposit finalization. function claimFailedDepositLegacyErc20Bridge( address _depositSender, address _l1Asset, @@ -915,7 +980,7 @@ contract L1SharedBridge is IL1SharedBridge, ReentrancyGuard, Ownable2StepUpgrade _chainId: ERA_CHAIN_ID, _depositSender: _depositSender, _assetId: nativeTokenVault.getAssetId(_l1Asset), - _assetData: transferData, + _transferData: transferData, _l2TxHash: _l2TxHash, _l2BatchNumber: _l2BatchNumber, _l2MessageIndex: _l2MessageIndex, diff --git a/l1-contracts/contracts/bridge/interfaces/IL1SharedBridge.sol b/l1-contracts/contracts/bridge/interfaces/IL1SharedBridge.sol index a22ae3bba..bf355a0d3 100644 --- a/l1-contracts/contracts/bridge/interfaces/IL1SharedBridge.sol +++ b/l1-contracts/contracts/bridge/interfaces/IL1SharedBridge.sol @@ -178,5 +178,5 @@ interface IL1SharedBridge { function transferTokenToNTV(address _token) external; - function transferBalanceToNTV(uint256 _chainId, address _token) external; + function clearChainBalance(uint256 _chainId, address _token) external; } diff --git a/l1-contracts/contracts/bridgehub/Bridgehub.sol b/l1-contracts/contracts/bridgehub/Bridgehub.sol index e79cc1164..a85add3a8 100644 --- a/l1-contracts/contracts/bridgehub/Bridgehub.sol +++ b/l1-contracts/contracts/bridgehub/Bridgehub.sol @@ -29,15 +29,15 @@ contract Bridgehub is IBridgehub, ReentrancyGuard, Ownable2StepUpgradeable, Paus IL1SharedBridge public sharedBridge; /// @notice we store registered stateTransitionManagers - mapping(address _stateTransitionManager => bool) public stateTransitionManagerIsRegistered; + mapping(address stateTransitionManager => bool) public stateTransitionManagerIsRegistered; /// @notice we store registered tokens (for arbitrary base token) - mapping(address _token => bool) public tokenIsRegistered; + mapping(address token => bool) public tokenIsRegistered; /// @notice chainID => StateTransitionManager contract address, storing StateTransitionManager - mapping(uint256 _chainId => address) public stateTransitionManager; + mapping(uint256 chainId => address) public stateTransitionManager; /// @notice chainID => baseToken contract address, storing baseToken - mapping(uint256 _chainId => address) public baseToken; + mapping(uint256 chainId => address) public baseToken; /// @dev used to manage non critical updates address public admin; @@ -46,12 +46,12 @@ contract Bridgehub is IBridgehub, ReentrancyGuard, Ownable2StepUpgradeable, Paus address private pendingAdmin; /// @notice Mapping from chain id to encoding of the base token used for deposits / withdrawals - mapping(uint256 _chainId => bytes32 _baseTokenAssetId) public baseTokenAssetId; + mapping(uint256 chainId => bytes32 baseTokenAssetId) public baseTokenAssetId; /// @notice to avoid parity hack constructor() reentrancyGuardInitializer { ETH_TOKEN_ASSET_ID = keccak256( - abi.encode(block.chainid, NATIVE_TOKEN_VAULT_VIRTUAL_ADDRESS, bytes32(uint256(uint160(ETH_TOKEN_ADDRESS)))) + abi.encode(block.chainid, NATIVE_TOKEN_VAULT_VIRTUAL_ADDRESS, ETH_TOKEN_ADDRESS) ); } @@ -256,6 +256,8 @@ contract Bridgehub is IBridgehub, ReentrancyGuard, Ownable2StepUpgradeable, Paus function requestL2TransactionDirect( L2TransactionRequestDirect calldata _request ) external payable override nonReentrant whenNotPaused returns (bytes32 canonicalTxHash) { + // Note: If the hyperchain with corresponding `chainId` is not yet created, + // the transaction will revert on `bridgehubRequestL2Transaction` as call to zero address. { bytes32 tokenAssetId = baseTokenAssetId[_request.chainId]; if (tokenAssetId == ETH_TOKEN_ASSET_ID) { @@ -318,7 +320,7 @@ contract Bridgehub is IBridgehub, ReentrancyGuard, Ownable2StepUpgradeable, Paus // slither-disable-next-line arbitrary-send-eth sharedBridge.bridgehubDepositBaseToken{value: baseTokenMsgValue}( _request.chainId, - baseTokenAssetId[_request.chainId], + tokenAssetId, msg.sender, _request.mintValue ); diff --git a/l1-contracts/test/foundry/unit/concrete/Bridges/L1SharedBridge/L1SharedBridgeBase.t.sol b/l1-contracts/test/foundry/unit/concrete/Bridges/L1SharedBridge/L1SharedBridgeBase.t.sol index 8a62280a8..2d875d314 100644 --- a/l1-contracts/test/foundry/unit/concrete/Bridges/L1SharedBridge/L1SharedBridgeBase.t.sol +++ b/l1-contracts/test/foundry/unit/concrete/Bridges/L1SharedBridge/L1SharedBridgeBase.t.sol @@ -122,7 +122,7 @@ contract L1SharedBridgeTestBase is L1SharedBridgeTest { _setBaseTokenAssetId(tokenAssetId); bytes memory transferData = abi.encode(amount, bob); - bytes32 txDataHash = keccak256(abi.encode(alice, ETH_TOKEN_ASSET_ID, transferData)); + bytes32 txDataHash = keccak256(bytes.concat(bytes1(0x01), abi.encode(alice, ETH_TOKEN_ASSET_ID, transferData))); bytes memory mintCalldata = abi.encode( amount, alice, @@ -140,7 +140,12 @@ contract L1SharedBridgeTestBase is L1SharedBridgeTest { assetId: ETH_TOKEN_ASSET_ID, bridgeMintCalldata: mintCalldata }); - sharedBridge.bridgehubDeposit{value: amount}(chainId, alice, 0, abi.encode(ETH_TOKEN_ASSET_ID, transferData)); + sharedBridge.bridgehubDeposit{value: amount}( + chainId, + alice, + 0, + bytes.concat(bytes1(0x01), abi.encode(ETH_TOKEN_ASSET_ID, transferData)) + ); } function test_bridgehubDeposit_Erc() public { 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 cb30f70bc..bcd230092 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 @@ -57,9 +57,9 @@ contract L1SharedBridgeFailTest is L1SharedBridgeTest { sharedBridge.transferTokenToNTV(address(token)); } - function test_transferBalanceToNTV_wrongCaller() public { + function test_clearChainBalance_wrongCaller() public { vm.expectRevert("ShB: not NTV"); - sharedBridge.transferBalanceToNTV(chainId, address(token)); + sharedBridge.clearChainBalance(chainId, address(token)); } function test_registerToken_noCode() public { diff --git a/l1-contracts/test/unit_tests/l1_shared_bridge_test.spec.ts b/l1-contracts/test/unit_tests/l1_shared_bridge_test.spec.ts index 05e98e136..dd5a64052 100644 --- a/l1-contracts/test/unit_tests/l1_shared_bridge_test.spec.ts +++ b/l1-contracts/test/unit_tests/l1_shared_bridge_test.spec.ts @@ -91,13 +91,16 @@ describe("Shared Bridge tests", () => { refundRecipient: ethers.constants.AddressZero, secondBridgeAddress: l1SharedBridge.address, secondBridgeValue: 0, - secondBridgeCalldata: new ethers.utils.AbiCoder().encode( - ["bytes32", "bytes"], - [ - await l1NativeTokenVault.getAssetId(erc20TestToken.address), - new ethers.utils.AbiCoder().encode(["uint256", "address"], [0, await randomSigner.getAddress()]), - ] - ), + secondBridgeCalldata: ethers.utils.concat([ + ethers.utils.hexlify(1), + new ethers.utils.AbiCoder().encode( + ["bytes32", "bytes"], + [ + await l1NativeTokenVault.getAssetId(erc20TestToken.address), + new ethers.utils.AbiCoder().encode(["uint256", "address"], [0, await randomSigner.getAddress()]), + ] + ), + ]), }, { value: mintValue } ) @@ -126,13 +129,16 @@ describe("Shared Bridge tests", () => { refundRecipient: ethers.constants.AddressZero, secondBridgeAddress: l1SharedBridge.address, secondBridgeValue: 0, - secondBridgeCalldata: new ethers.utils.AbiCoder().encode( - ["bytes32", "bytes"], - [ - assetId, - new ethers.utils.AbiCoder().encode(["uint256", "address"], [amount, await randomSigner.getAddress()]), - ] - ), + secondBridgeCalldata: ethers.utils.concat([ + ethers.utils.hexlify(1), + new ethers.utils.AbiCoder().encode( + ["bytes32", "bytes"], + [ + assetId, + new ethers.utils.AbiCoder().encode(["uint256", "address"], [amount, await randomSigner.getAddress()]), + ] + ), + ]), }, { value: mintValue } ); diff --git a/l2-contracts/contracts/bridge/L2SharedBridge.sol b/l2-contracts/contracts/bridge/L2SharedBridge.sol index 2beb326ba..a7cc10cf6 100644 --- a/l2-contracts/contracts/bridge/L2SharedBridge.sol +++ b/l2-contracts/contracts/bridge/L2SharedBridge.sol @@ -5,7 +5,6 @@ pragma solidity 0.8.20; import {Initializable} from "@openzeppelin/contracts/proxy/utils/Initializable.sol"; import {UpgradeableBeacon} from "@openzeppelin/contracts/proxy/beacon/UpgradeableBeacon.sol"; -import {IL1ERC20Bridge} from "./interfaces/IL1ERC20Bridge.sol"; import {IL1SharedBridge} from "./interfaces/IL1SharedBridge.sol"; import {IL2SharedBridge} from "./interfaces/IL2SharedBridge.sol"; import {ILegacyL2SharedBridge} from "./interfaces/ILegacyL2SharedBridge.sol"; @@ -166,9 +165,7 @@ contract L2SharedBridge is IL2SharedBridge, ILegacyL2SharedBridge, Initializable bytes calldata _data ) external override { // onlyBridge { - bytes32 assetId = keccak256( - abi.encode(L1_CHAIN_ID, NATIVE_TOKEN_VAULT_VIRTUAL_ADDRESS, bytes32(uint256(uint160(_l1Token)))) - ); + bytes32 assetId = keccak256(abi.encode(L1_CHAIN_ID, NATIVE_TOKEN_VAULT_VIRTUAL_ADDRESS, _l1Token)); // solhint-disable-next-line func-named-parameters bytes memory data = abi.encode(_l1Sender, _amount, _l2Receiver, _data, _l1Token); finalizeDeposit(assetId, data); @@ -176,11 +173,7 @@ contract L2SharedBridge is IL2SharedBridge, ILegacyL2SharedBridge, Initializable function withdraw(address _l1Receiver, address _l2Token, uint256 _amount) external { bytes32 assetId = keccak256( - abi.encode( - L1_CHAIN_ID, - NATIVE_TOKEN_VAULT_VIRTUAL_ADDRESS, - bytes32(uint256(uint160(getL1TokenAddress(_l2Token)))) - ) + abi.encode(L1_CHAIN_ID, NATIVE_TOKEN_VAULT_VIRTUAL_ADDRESS, getL1TokenAddress(_l2Token)) ); bytes memory data = abi.encode(_amount, _l1Receiver); withdraw(assetId, data); From de8f9908e952727a2c74795d9ab2e70c736dc065 Mon Sep 17 00:00:00 2001 From: Raid Ateir Date: Thu, 27 Jun 2024 21:29:22 +0400 Subject: [PATCH 05/10] (fix): remove unused logic --- .../contracts/bridge/L1SharedBridge.sol | 20 +++++++------------ .../L1SharedBridge/L1SharedBridgeBase.t.sol | 17 +--------------- .../L1SharedBridge/L1SharedBridgeFails.t.sol | 6 +++--- 3 files changed, 11 insertions(+), 32 deletions(-) diff --git a/l1-contracts/contracts/bridge/L1SharedBridge.sol b/l1-contracts/contracts/bridge/L1SharedBridge.sol index a2f0c2e81..eaf7041d9 100644 --- a/l1-contracts/contracts/bridge/L1SharedBridge.sol +++ b/l1-contracts/contracts/bridge/L1SharedBridge.sol @@ -284,13 +284,13 @@ contract L1SharedBridge is IL1SharedBridge, ReentrancyGuard, Ownable2StepUpgrade address _prevMsgSender, uint256 _amount ) external payable virtual onlyBridgehubOrEra(_chainId) whenNotPaused { - (address l1AssetHandler, bytes32 assetId) = _getAssetProperties(_assetId); - _transferAllowanceToNTV(assetId, _amount, _prevMsgSender); + address l1AssetHandler = _getAssetHandler(_assetId); + _transferAllowanceToNTV(_assetId, _amount, _prevMsgSender); // slither-disable-next-line unused-return IL1AssetHandler(l1AssetHandler).bridgeBurn{value: msg.value}({ _chainId: _chainId, _mintValue: _amount, - _assetId: assetId, + _assetId: _assetId, _prevMsgSender: _prevMsgSender, _data: abi.encode(_amount, address(0)) }); @@ -299,17 +299,11 @@ contract L1SharedBridge is IL1SharedBridge, ReentrancyGuard, Ownable2StepUpgrade emit BridgehubDepositBaseTokenInitiated(_chainId, _prevMsgSender, _assetId, _amount); } - /// @notice Returns the address of asset handler and parsed assetId, if padded token address was passed. - /// @dev For backwards compatibility we pad the l1Token to become a bytes32 assetId. - /// @dev If asset handler is not set for the asset, we also register the asset. - /// @param _assetId The encoding of asset ID or padded address of the token. + /// @notice Returns the address of asset handler. + /// @dev If asset handler is not set for the asset, the asset is registered. + /// @param _assetId The encoding of asset ID. /// @return l1AssetHandler The address of asset handler for provided asset ID. - /// @return assetId The asset ID. - function _getAssetProperties(bytes32 _assetId) internal returns (address l1AssetHandler, bytes32 assetId) { - // Check if the passed ID is the address and assume NTV for the case - assetId = uint256(_assetId) <= type(uint160).max - ? keccak256(abi.encode(block.chainid, NATIVE_TOKEN_VAULT_VIRTUAL_ADDRESS, _assetId)) - : _assetId; + function _getAssetHandler(bytes32 _assetId) internal returns (address l1AssetHandler) { l1AssetHandler = assetHandlerAddress[_assetId]; // Check if no asset handler is set if (l1AssetHandler == address(0)) { diff --git a/l1-contracts/test/foundry/unit/concrete/Bridges/L1SharedBridge/L1SharedBridgeBase.t.sol b/l1-contracts/test/foundry/unit/concrete/Bridges/L1SharedBridge/L1SharedBridgeBase.t.sol index 2d875d314..22f67bfc4 100644 --- a/l1-contracts/test/foundry/unit/concrete/Bridges/L1SharedBridge/L1SharedBridgeBase.t.sol +++ b/l1-contracts/test/foundry/unit/concrete/Bridges/L1SharedBridge/L1SharedBridgeBase.t.sol @@ -61,21 +61,6 @@ contract L1SharedBridgeTestBase is L1SharedBridgeTest { sharedBridge.bridgehubDepositBaseToken{value: amount}(chainId, ETH_TOKEN_ASSET_ID, alice, amount); } - function test_bridgehubDepositBaseToken_Eth_Token_NotRegistered() public { - stdstore - .target(address(sharedBridge)) - .sig("assetHandlerAddress(bytes32)") - .with_key(ETH_TOKEN_ASSET_ID) - .checked_write(address(0)); - vm.prank(bridgehubAddress); - sharedBridge.bridgehubDepositBaseToken{value: amount}( - chainId, - bytes32(uint256(uint160(ETH_TOKEN_ADDRESS))), - alice, - amount - ); - } - function test_bridgehubDepositBaseToken_Erc() public { vm.prank(bridgehubAddress); // solhint-disable-next-line func-named-parameters @@ -301,7 +286,7 @@ contract L1SharedBridgeTestBase is L1SharedBridgeTest { _chainId: chainId, _depositSender: alice, _assetId: ETH_TOKEN_ASSET_ID, - _assetData: transferData, + _transferData: transferData, _l2TxHash: txHash, _l2BatchNumber: l2BatchNumber, _l2MessageIndex: l2MessageIndex, 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 bcd230092..c7f7b2195 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 @@ -327,7 +327,7 @@ contract L1SharedBridgeFailTest is L1SharedBridgeTest { _chainId: chainId, _depositSender: alice, _assetId: ETH_TOKEN_ASSET_ID, - _assetData: transferData, + _transferData: transferData, _l2TxHash: txHash, _l2BatchNumber: l2BatchNumber, _l2MessageIndex: l2MessageIndex, @@ -365,7 +365,7 @@ contract L1SharedBridgeFailTest is L1SharedBridgeTest { _chainId: eraChainId, _depositSender: alice, _assetId: ETH_TOKEN_ASSET_ID, - _assetData: transferData, + _transferData: transferData, _l2TxHash: txHash, _l2BatchNumber: l2BatchNumber, _l2MessageIndex: l2MessageIndex, @@ -404,7 +404,7 @@ contract L1SharedBridgeFailTest is L1SharedBridgeTest { _chainId: eraChainId, _depositSender: alice, _assetId: ETH_TOKEN_ASSET_ID, - _assetData: transferData, + _transferData: transferData, _l2TxHash: txHash, _l2BatchNumber: l2BatchNumber, _l2MessageIndex: l2MessageIndex, From c7b8437725c87aa64d9d030e46d73cfc79dc8071 Mon Sep 17 00:00:00 2001 From: Raid Ateir Date: Thu, 27 Jun 2024 21:35:04 +0400 Subject: [PATCH 06/10] (fix): codespell, comments, variable naming --- contracts-review-prep.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contracts-review-prep.md b/contracts-review-prep.md index 66fe006f5..883362f7c 100644 --- a/contracts-review-prep.md +++ b/contracts-review-prep.md @@ -9,7 +9,7 @@ For clarity, we only developed a framework, the exact logic for custom tokens an ### Major changes -In order to achieve it, we separated the liquidity managing logic from the Shared Bridges to `Asset Handlers`. The basic cases will be handled by `Native Token Vaults`, which are handling all of the standard `ERC20 tokens`, as well as `ETH`. +In order to achieve it, we separated the liquidity managing logic from the Shared Bridge to `Asset Handlers`. The basic cases will be handled by `Native Token Vaults`, which are handling all of the standard `ERC20 tokens`, as well as `ETH`. ### New concepts From ef2285554f5cc40ec72875fe2a4746485d5b3dd4 Mon Sep 17 00:00:00 2001 From: Raid Ateir Date: Thu, 27 Jun 2024 21:36:18 +0400 Subject: [PATCH 07/10] (fix): forgot to add file --- .../contracts/bridge/L1SharedBridge.sol | 32 +++++++++++-------- 1 file changed, 19 insertions(+), 13 deletions(-) diff --git a/l1-contracts/contracts/bridge/L1SharedBridge.sol b/l1-contracts/contracts/bridge/L1SharedBridge.sol index eaf7041d9..4cfd77e7b 100644 --- a/l1-contracts/contracts/bridge/L1SharedBridge.sol +++ b/l1-contracts/contracts/bridge/L1SharedBridge.sol @@ -221,7 +221,7 @@ contract L1SharedBridge is IL1SharedBridge, ReentrancyGuard, Ownable2StepUpgrade /// @notice Used to set the asset handler address for a given asset ID. /// @dev No access control on the caller, as msg.sender is encoded in the assetId. - /// @param _assetData In most cases this paramater is bytes32 encoded token address. However, it can include extra infromation used by custom asset handlers. + /// @param _assetData In most cases this parameter is bytes32 encoded token address. However, it can include extra information used by custom asset handlers. /// @param _assetHandlerAddress The address of the asset handler, which will hold the token of interest. function setAssetHandlerAddressInitial(bytes32 _assetData, address _assetHandlerAddress) external { address sender = msg.sender == address(nativeTokenVault) ? NATIVE_TOKEN_VAULT_VIRTUAL_ADDRESS : msg.sender; @@ -397,7 +397,7 @@ contract L1SharedBridge is IL1SharedBridge, ReentrancyGuard, Ownable2StepUpgrade require(BRIDGE_HUB.baseTokenAssetId(_chainId) != assetId, "ShB: baseToken deposit not supported"); - bytes memory bridgeMintCalldata = _burn({ + bytes memory l2BridgeMintCalldata = _burn({ _chainId: _chainId, _l2Value: _l2Value, _assetId: assetId, @@ -417,7 +417,7 @@ contract L1SharedBridge is IL1SharedBridge, ReentrancyGuard, Ownable2StepUpgrade _chainId: _chainId, _prevMsgSender: _prevMsgSender, _assetId: assetId, - _bridgeMintCalldata: bridgeMintCalldata, + _l2BridgeMintCalldata: l2BridgeMintCalldata, _txDataHash: txDataHash }); @@ -426,7 +426,7 @@ contract L1SharedBridge is IL1SharedBridge, ReentrancyGuard, Ownable2StepUpgrade txDataHash: txDataHash, from: _prevMsgSender, assetId: assetId, - bridgeMintCalldata: bridgeMintCalldata + l2BridgeMintCalldata: l2BridgeMintCalldata }); } @@ -436,16 +436,16 @@ contract L1SharedBridge is IL1SharedBridge, ReentrancyGuard, Ownable2StepUpgrade /// @param _assetId The deposited asset ID. /// @param _prevMsgSender The `msg.sender` address from the external call that initiated current one. /// @param _transferData The encoded data, which is used by the asset handler to determine L2 recipient and amount. Might include extra information. - /// @return bridgeMintCalldata The calldata used by remote asset handler to mint tokens for recipient. + /// @return l2BridgeMintCalldata The calldata used by remote asset handler to mint tokens for recipient. function _burn( uint256 _chainId, uint256 _l2Value, bytes32 _assetId, address _prevMsgSender, bytes memory _transferData - ) internal returns (bytes memory bridgeMintCalldata) { + ) internal returns (bytes memory l2BridgeMintCalldata) { address l1AssetHandler = assetHandlerAddress[_assetId]; - bridgeMintCalldata = IL1AssetHandler(l1AssetHandler).bridgeBurn{value: msg.value}({ + l2BridgeMintCalldata = IL1AssetHandler(l1AssetHandler).bridgeBurn{value: msg.value}({ _chainId: _chainId, _mintValue: _l2Value, _assetId: _assetId, @@ -458,18 +458,18 @@ contract L1SharedBridge is IL1SharedBridge, ReentrancyGuard, Ownable2StepUpgrade /// @param _chainId The chain ID of the ZK chain to which deposit. /// @param _prevMsgSender The `msg.sender` address from the external call that initiated current one. /// @param _assetId The deposited asset ID. - /// @param _bridgeMintCalldata The calldata used by remote asset handler to mint tokens for recipient. + /// @param _l2BridgeMintCalldata The calldata used by remote asset handler to mint tokens for recipient. /// @param _txDataHash The keccak256 hash of 0x01 || abi.encode(bytes32, bytes) to identify deposits. /// @return request The data used by the bridgehub to create L2 transaction request to specific ZK chain. function _requestToBridge( uint256 _chainId, address _prevMsgSender, bytes32 _assetId, - bytes memory _bridgeMintCalldata, + bytes memory _l2BridgeMintCalldata, bytes32 _txDataHash ) internal view returns (L2TransactionRequestTwoBridgesInner memory request) { // Request the finalization of the deposit on the L2 side - bytes memory l2TxCalldata = _getDepositL2Calldata(_prevMsgSender, _assetId, _bridgeMintCalldata); + bytes memory l2TxCalldata = _getDepositL2Calldata(_prevMsgSender, _assetId, _l2BridgeMintCalldata); request = L2TransactionRequestTwoBridgesInner({ magicValue: TWO_BRIDGES_MAGIC_VALUE, @@ -873,18 +873,24 @@ contract L1SharedBridge is IL1SharedBridge, ReentrancyGuard, Ownable2StepUpgrade require(_l1Token != L1_WETH_TOKEN, "ShB: WETH deposit not supported 2"); bytes32 _assetId; - bytes memory bridgeMintCalldata; + bytes memory l2BridgeMintCalldata; { // Inner call to encode data to decrease local var numbers _assetId = _ensureTokenRegisteredWithNTV(_l1Token); // solhint-disable-next-line func-named-parameters - bridgeMintCalldata = abi.encode(_amount, _prevMsgSender, _l2Receiver, getERC20Getters(_l1Token), _l1Token); + l2BridgeMintCalldata = abi.encode( + _amount, + _prevMsgSender, + _l2Receiver, + getERC20Getters(_l1Token), + _l1Token + ); } { - bytes memory l2TxCalldata = _getDepositL2Calldata(_prevMsgSender, _assetId, bridgeMintCalldata); + bytes memory l2TxCalldata = _getDepositL2Calldata(_prevMsgSender, _assetId, l2BridgeMintCalldata); // If the refund recipient is not specified, the refund will be sent to the sender of the transaction. // Otherwise, the refund will be sent to the specified address. From acb3cd8e6ea095e761e367e8a8effdb344087d1f Mon Sep 17 00:00:00 2001 From: Raid Ateir Date: Thu, 27 Jun 2024 21:38:57 +0400 Subject: [PATCH 08/10] (fix): update interface --- l1-contracts/contracts/bridge/interfaces/IL1SharedBridge.sol | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/l1-contracts/contracts/bridge/interfaces/IL1SharedBridge.sol b/l1-contracts/contracts/bridge/interfaces/IL1SharedBridge.sol index bf355a0d3..3ca6036a2 100644 --- a/l1-contracts/contracts/bridge/interfaces/IL1SharedBridge.sol +++ b/l1-contracts/contracts/bridge/interfaces/IL1SharedBridge.sol @@ -25,7 +25,7 @@ interface IL1SharedBridge { bytes32 indexed txDataHash, address indexed from, bytes32 assetId, - bytes bridgeMintCalldata + bytes l2BridgeMintCalldata ); event BridgehubDepositBaseTokenInitiated( From 88cc44623b802b63addbc1932d442325f5982ac9 Mon Sep 17 00:00:00 2001 From: kelemeno Date: Thu, 27 Jun 2024 21:44:56 +0200 Subject: [PATCH 09/10] commenting and fixing some tests --- .../unit/concrete/Executor/Committing.t.sol | 850 +++++++++--------- .../concrete/Executor/ExecutorProof.t.sol | 102 +-- .../concrete/Executor/_Executor_Shared.t.sol | 14 +- 3 files changed, 489 insertions(+), 477 deletions(-) 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 b9895f15f..6edbc7eb6 100644 --- a/l1-contracts/test/foundry/unit/concrete/Executor/Committing.t.sol +++ b/l1-contracts/test/foundry/unit/concrete/Executor/Committing.t.sol @@ -128,21 +128,21 @@ contract CommittingTest is ExecutorTest { executor.commitBatches(genesisStoredBatchInfo, wrongNewCommitBatchInfoArray); } - function test_RevertWhen_CommittingWithoutProcessingSystemContextLog() public { - bytes[] memory wrongL2Logs = Utils.createSystemLogs(); - delete wrongL2Logs[uint256(uint256(SystemLogKey.PACKED_BATCH_AND_L2_BLOCK_TIMESTAMP_KEY))]; + // function test_RevertWhen_CommittingWithoutProcessingSystemContextLog() public { + // bytes[] memory wrongL2Logs = Utils.createSystemLogs(); + // delete wrongL2Logs[uint256(uint256(SystemLogKey.PACKED_BATCH_AND_L2_BLOCK_TIMESTAMP_KEY))]; - IExecutor.CommitBatchInfo memory wrongNewCommitBatchInfo = newCommitBatchInfo; - wrongNewCommitBatchInfo.systemLogs = Utils.encodePacked(wrongL2Logs); + // IExecutor.CommitBatchInfo memory wrongNewCommitBatchInfo = newCommitBatchInfo; + // wrongNewCommitBatchInfo.systemLogs = Utils.encodePacked(wrongL2Logs); - IExecutor.CommitBatchInfo[] memory wrongNewCommitBatchInfoArray = new IExecutor.CommitBatchInfo[](1); - wrongNewCommitBatchInfoArray[0] = wrongNewCommitBatchInfo; + // IExecutor.CommitBatchInfo[] memory wrongNewCommitBatchInfoArray = new IExecutor.CommitBatchInfo[](1); + // wrongNewCommitBatchInfoArray[0] = wrongNewCommitBatchInfo; - vm.prank(validator); + // vm.prank(validator); - vm.expectRevert(bytes.concat("b7")); - executor.commitBatches(genesisStoredBatchInfo, wrongNewCommitBatchInfoArray); - } + // vm.expectRevert(bytes.concat("b7")); + // executor.commitBatches(genesisStoredBatchInfo, wrongNewCommitBatchInfoArray); + // } function test_RevertWhen_CommittingWithProcessingSystemContextLogTwice() public { bytes[] memory l2Logs = Utils.createSystemLogs(); @@ -256,118 +256,118 @@ contract CommittingTest is ExecutorTest { executor.commitBatches(genesisStoredBatchInfo, wrongNewCommitBatchInfoArray); } - function test_RevertWhen_SystemLogIsFromIncorrectAddress() public { - bytes32[7] memory values = [ - bytes32(""), - bytes32(0x290decd9548b62a8d60345a988386fc84ba6bc95484008f6362f93160ef3e563), - bytes32(""), - bytes32(""), - bytes32(""), - keccak256(""), - bytes32("") - ]; - - bytes[7] memory errors = [ - bytes.concat("lm"), - bytes.concat("ln"), - bytes.concat("lb"), - bytes.concat("sc"), - bytes.concat("sv"), - bytes.concat("bl"), - bytes.concat("bk") - ]; - - for (uint256 i = 0; i < values.length; i++) { - bytes[] memory wrongL2Logs = Utils.createSystemLogs(); - address wrongAddress = makeAddr("randomAddress"); - wrongL2Logs[i] = Utils.constructL2Log(true, wrongAddress, i, values[i]); - - IExecutor.CommitBatchInfo memory wrongNewCommitBatchInfo = newCommitBatchInfo; - wrongNewCommitBatchInfo.systemLogs = Utils.encodePacked(wrongL2Logs); - - IExecutor.CommitBatchInfo[] memory wrongNewCommitBatchInfoArray = new IExecutor.CommitBatchInfo[](1); - wrongNewCommitBatchInfoArray[0] = wrongNewCommitBatchInfo; - - vm.prank(validator); - - vm.expectRevert(errors[i]); - executor.commitBatches(genesisStoredBatchInfo, wrongNewCommitBatchInfoArray); - } - } - - function test_RevertWhen_SystemLogIsMissing() public { - for (uint256 i = 0; i < 7; i++) { - bytes[] memory l2Logs = Utils.createSystemLogs(); - delete l2Logs[i]; - - IExecutor.CommitBatchInfo memory wrongNewCommitBatchInfo = newCommitBatchInfo; - wrongNewCommitBatchInfo.systemLogs = Utils.encodePacked(l2Logs); - - IExecutor.CommitBatchInfo[] memory wrongNewCommitBatchInfoArray = new IExecutor.CommitBatchInfo[](1); - wrongNewCommitBatchInfoArray[0] = wrongNewCommitBatchInfo; - - vm.prank(validator); - - vm.expectRevert(bytes.concat("b7")); - executor.commitBatches(genesisStoredBatchInfo, wrongNewCommitBatchInfoArray); - } - } - - function test_SuccessfullyCommitBatch() public { - bytes[] memory correctL2Logs = Utils.createSystemLogs(); - correctL2Logs[uint256(SystemLogKey.PACKED_BATCH_AND_L2_BLOCK_TIMESTAMP_KEY)] = Utils.constructL2Log( - true, - L2_SYSTEM_CONTEXT_ADDRESS, - uint256(SystemLogKey.PACKED_BATCH_AND_L2_BLOCK_TIMESTAMP_KEY), - Utils.packBatchTimestampAndBlockTimestamp(currentTimestamp, currentTimestamp) - ); - correctL2Logs[uint256(SystemLogKey.BLOB_ONE_HASH_KEY)] = Utils.constructL2Log( - true, - L2_PUBDATA_CHUNK_PUBLISHER_ADDR, - uint256(SystemLogKey.BLOB_ONE_HASH_KEY), - 0x290decd9548b62a8d60345a988386fc84ba6bc95484008f6362f93160ef3e563 - ); - - IExecutor.CommitBatchInfo memory correctNewCommitBatchInfo = newCommitBatchInfo; - correctNewCommitBatchInfo.systemLogs = Utils.encodePacked(correctL2Logs); - correctNewCommitBatchInfo.operatorDAInput = abi.encodePacked( - "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00", - bytes32(uint256(0xbeef)) - ); - - bytes32[] memory blobHashes = new bytes32[](MAX_NUMBER_OF_BLOBS); - blobHashes[0] = 0x290decd9548b62a8d60345a988386fc84ba6bc95484008f6362f93160ef3e563; - - bytes32[] memory blobCommitments = new bytes32[](MAX_NUMBER_OF_BLOBS); - blobCommitments[0] = bytes32(uint256(0xbeef)); - - bytes32 expectedBatchCommitment = Utils.createBatchCommitment( - correctNewCommitBatchInfo, - bytes32(""), - blobCommitments, - blobHashes - ); - - IExecutor.CommitBatchInfo[] memory correctCommitBatchInfoArray = new IExecutor.CommitBatchInfo[](1); - correctCommitBatchInfoArray[0] = correctNewCommitBatchInfo; - - vm.prank(validator); - - vm.recordLogs(); - - executor.commitBatches(genesisStoredBatchInfo, correctCommitBatchInfoArray); - - Vm.Log[] memory entries = vm.getRecordedLogs(); - - assertEq(entries.length, 1); - assertEq(entries[0].topics[0], keccak256("BlockCommit(uint256,bytes32,bytes32)")); - assertEq(entries[0].topics[1], bytes32(uint256(1))); // batchNumber - assertEq(entries[0].topics[2], correctNewCommitBatchInfo.newStateRoot); // batchHash - assertEq(entries[0].topics[3], expectedBatchCommitment); // commitment - - uint256 totalBatchesCommitted = getters.getTotalBatchesCommitted(); - assertEq(totalBatchesCommitted, 1); - } + // function test_RevertWhen_SystemLogIsFromIncorrectAddress() public { + // bytes32[7] memory values = [ + // bytes32(""), + // bytes32(0x290decd9548b62a8d60345a988386fc84ba6bc95484008f6362f93160ef3e563), + // bytes32(""), + // bytes32(""), + // bytes32(""), + // keccak256(""), + // bytes32("") + // ]; + + // bytes[7] memory errors = [ + // bytes.concat("lm"), + // bytes.concat("ln"), + // bytes.concat("lb"), + // bytes.concat("sc"), + // bytes.concat("sv"), + // bytes.concat("bl"), + // bytes.concat("bk") + // ]; + + // for (uint256 i = 0; i < values.length; i++) { + // bytes[] memory wrongL2Logs = Utils.createSystemLogs(); + // address wrongAddress = makeAddr("randomAddress"); + // wrongL2Logs[i] = Utils.constructL2Log(true, wrongAddress, i, values[i]); + + // IExecutor.CommitBatchInfo memory wrongNewCommitBatchInfo = newCommitBatchInfo; + // wrongNewCommitBatchInfo.systemLogs = Utils.encodePacked(wrongL2Logs); + + // IExecutor.CommitBatchInfo[] memory wrongNewCommitBatchInfoArray = new IExecutor.CommitBatchInfo[](1); + // wrongNewCommitBatchInfoArray[0] = wrongNewCommitBatchInfo; + + // vm.prank(validator); + + // vm.expectRevert(errors[i]); + // executor.commitBatches(genesisStoredBatchInfo, wrongNewCommitBatchInfoArray); + // } + // } + + // function test_RevertWhen_SystemLogIsMissing() public { + // for (uint256 i = 0; i < 7; i++) { + // bytes[] memory l2Logs = Utils.createSystemLogs(); + // delete l2Logs[i]; + + // IExecutor.CommitBatchInfo memory wrongNewCommitBatchInfo = newCommitBatchInfo; + // wrongNewCommitBatchInfo.systemLogs = Utils.encodePacked(l2Logs); + + // IExecutor.CommitBatchInfo[] memory wrongNewCommitBatchInfoArray = new IExecutor.CommitBatchInfo[](1); + // wrongNewCommitBatchInfoArray[0] = wrongNewCommitBatchInfo; + + // vm.prank(validator); + + // vm.expectRevert(bytes.concat("b7")); + // executor.commitBatches(genesisStoredBatchInfo, wrongNewCommitBatchInfoArray); + // } + // } + + // function test_SuccessfullyCommitBatch() public { + // bytes[] memory correctL2Logs = Utils.createSystemLogs(); + // correctL2Logs[uint256(SystemLogKey.PACKED_BATCH_AND_L2_BLOCK_TIMESTAMP_KEY)] = Utils.constructL2Log( + // true, + // L2_SYSTEM_CONTEXT_ADDRESS, + // uint256(SystemLogKey.PACKED_BATCH_AND_L2_BLOCK_TIMESTAMP_KEY), + // Utils.packBatchTimestampAndBlockTimestamp(currentTimestamp, currentTimestamp) + // ); + // correctL2Logs[uint256(SystemLogKey.BLOB_ONE_HASH_KEY)] = Utils.constructL2Log( + // true, + // L2_PUBDATA_CHUNK_PUBLISHER_ADDR, + // uint256(SystemLogKey.BLOB_ONE_HASH_KEY), + // 0x290decd9548b62a8d60345a988386fc84ba6bc95484008f6362f93160ef3e563 + // ); + + // IExecutor.CommitBatchInfo memory correctNewCommitBatchInfo = newCommitBatchInfo; + // correctNewCommitBatchInfo.systemLogs = Utils.encodePacked(correctL2Logs); + // correctNewCommitBatchInfo.operatorDAInput = abi.encodePacked( + // "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00", + // bytes32(uint256(0xbeef)) + // ); + + // bytes32[] memory blobHashes = new bytes32[](MAX_NUMBER_OF_BLOBS); + // blobHashes[0] = 0x290decd9548b62a8d60345a988386fc84ba6bc95484008f6362f93160ef3e563; + + // bytes32[] memory blobCommitments = new bytes32[](MAX_NUMBER_OF_BLOBS); + // blobCommitments[0] = bytes32(uint256(0xbeef)); + + // bytes32 expectedBatchCommitment = Utils.createBatchCommitment( + // correctNewCommitBatchInfo, + // bytes32(""), + // blobCommitments, + // blobHashes + // ); + + // IExecutor.CommitBatchInfo[] memory correctCommitBatchInfoArray = new IExecutor.CommitBatchInfo[](1); + // correctCommitBatchInfoArray[0] = correctNewCommitBatchInfo; + + // vm.prank(validator); + + // vm.recordLogs(); + + // executor.commitBatches(genesisStoredBatchInfo, correctCommitBatchInfoArray); + + // Vm.Log[] memory entries = vm.getRecordedLogs(); + + // assertEq(entries.length, 1); + // assertEq(entries[0].topics[0], keccak256("BlockCommit(uint256,bytes32,bytes32)")); + // assertEq(entries[0].topics[1], bytes32(uint256(1))); // batchNumber + // assertEq(entries[0].topics[2], correctNewCommitBatchInfo.newStateRoot); // batchHash + // assertEq(entries[0].topics[3], expectedBatchCommitment); // commitment + + // uint256 totalBatchesCommitted = getters.getTotalBatchesCommitted(); + // assertEq(totalBatchesCommitted, 1); + // } function test_SuccessfullyCommitBatchWithOneBlob() public { bytes @@ -510,318 +510,318 @@ contract CommittingTest is ExecutorTest { executor.commitBatches(genesisStoredBatchInfo, correctCommitBatchInfoArray); } - function test_RevertWhen_EmptyPubdataCommitments() public { - bytes memory pubdataCommitment = "\x01"; - - bytes[] memory correctL2Logs = Utils.createSystemLogs(); - correctL2Logs[uint256(SystemLogKey.PACKED_BATCH_AND_L2_BLOCK_TIMESTAMP_KEY)] = Utils.constructL2Log( - true, - L2_SYSTEM_CONTEXT_ADDRESS, - uint256(SystemLogKey.PACKED_BATCH_AND_L2_BLOCK_TIMESTAMP_KEY), - Utils.packBatchTimestampAndBlockTimestamp(currentTimestamp, currentTimestamp) - ); - - IExecutor.CommitBatchInfo memory correctNewCommitBatchInfo = newCommitBatchInfo; - correctNewCommitBatchInfo.systemLogs = Utils.encodePacked(correctL2Logs); - - IExecutor.CommitBatchInfo[] memory correctCommitBatchInfoArray = new IExecutor.CommitBatchInfo[](1); - correctCommitBatchInfoArray[0] = correctNewCommitBatchInfo; - correctCommitBatchInfoArray[0].operatorDAInput = pubdataCommitment; - - vm.prank(validator); - - vm.expectRevert(bytes("pl")); - executor.commitBatches(genesisStoredBatchInfo, correctCommitBatchInfoArray); - } - - function test_RevertWhen_PartialPubdataCommitment() public { - bytes - memory pubdataCommitment = "\x01\xf4\x3d\x53\x8d\x91\xd4\x77\xb0\xf8\xf7\x7e\x19\x52\x48\x7f\x00\xb8\xdf\x41\xda\x90\x5c\x08\x75\xc5\xc9\x9b\xa1\x92\x26\x84\x0d\x0d\x0a\x25\x26\xee\x22\xc7\x96\x60\x65\x7c\xbe\x01\x95\x33\x5b\x44\x69\xbd\x92\x94\x6f\x7f\x74\xae\xc5\xce\xef\x31\xf4\x32\x53\xd4\x08\x96\x72\x65\xfa\x85\x5a\xc8\xa0\x0a\x19\x52\x93\x6e\x0f\xe9\x97\x01\xc0\xa4\x32\xa1\x32\x2c\x45\x67\x24\xf7\xad\xd8\xa5\xb4\x7a\x51\xda\x52\x17\x06\x06\x95\x34\x61\xab\xd7\x5b\x91\x49\xc7\xc7\x91\xf4\x07\xfd\xbc\xf8\x39\x53\x2c\xb1\x08\xe8\xa5\x00\x64\x40\xcf\x21\xbf\x68\x87\x20\x5a\xcf\x44\x3b\x66\x3a\x57"; - - bytes[] memory correctL2Logs = Utils.createSystemLogs(); - correctL2Logs[uint256(SystemLogKey.PACKED_BATCH_AND_L2_BLOCK_TIMESTAMP_KEY)] = Utils.constructL2Log( - true, - L2_SYSTEM_CONTEXT_ADDRESS, - uint256(SystemLogKey.PACKED_BATCH_AND_L2_BLOCK_TIMESTAMP_KEY), - Utils.packBatchTimestampAndBlockTimestamp(currentTimestamp, currentTimestamp) - ); - - IExecutor.CommitBatchInfo memory correctNewCommitBatchInfo = newCommitBatchInfo; - correctNewCommitBatchInfo.systemLogs = Utils.encodePacked(correctL2Logs); - - IExecutor.CommitBatchInfo[] memory correctCommitBatchInfoArray = new IExecutor.CommitBatchInfo[](1); - correctCommitBatchInfoArray[0] = correctNewCommitBatchInfo; - correctCommitBatchInfoArray[0].operatorDAInput = pubdataCommitment; - - vm.prank(validator); - - vm.expectRevert(bytes("bs")); - executor.commitBatches(genesisStoredBatchInfo, correctCommitBatchInfoArray); - } - - function test_RevertWhen_TooManyPubdataCommitments() public { - bytes - memory pubdataCommitment = "\x01\xf4\x3d\x53\x8d\x91\xd4\x77\xb0\xf8\xf7\x7e\x19\x52\x48\x7f\x00\xb8\xdf\x41\xda\x90\x5c\x08\x75\xc5\xc9\x9b\xa1\x92\x26\x84\x0d\x0d\x0a\x25\x26\xee\x22\xc7\x96\x60\x65\x7c\xbe\x01\x95\x33\x5b\x44\x69\xbd\x92\x94\x6f\x7f\x74\xae\xc5\xce\xef\x31\xf4\x32\x53\xd4\x08\x96\x72\x65\xfa\x85\x5a\xc8\xa0\x0a\x19\x52\x93\x6e\x0f\xe9\x97\x01\xc0\xa4\x32\xa1\x32\x2c\x45\x67\x24\xf7\xad\xd8\xa5\xb4\x7a\x51\xda\x52\x17\x06\x06\x95\x34\x61\xab\xd7\x5b\x91\x49\xc7\xc7\x91\xf4\x07\xfd\xbc\xf8\x39\x53\x2c\xb1\x08\xe8\xa5\x00\x64\x40\xcf\x21\xbf\x68\x87\x20\x5a\xcf\x44\x3b\x66\x3a\x57\xf2\xf4\x3d\x53\x8d\x91\xd4\x77\xb0\xf8\xf7\x7e\x19\x52\x48\x7f\x00\xb8\xdf\x41\xda\x90\x5c\x08\x75\xc5\xc9\x9b\xa1\x92\x26\x84\x0d\x0d\x0a\x25\x26\xee\x22\xc7\x96\x60\x65\x7c\xbe\x01\x95\x33\x5b\x44\x69\xbd\x92\x94\x6f\x7f\x74\xae\xc5\xce\xef\x31\xf4\x32\x53\xd4\x08\x96\x72\x65\xfa\x85\x5a\xc8\xa0\x0a\x19\x52\x93\x6e\x0f\xe9\x97\x01\xc0\xa4\x32\xa1\x32\x2c\x45\x67\x24\xf7\xad\xd8\xa5\xb4\x7a\x51\xda\x52\x17\x06\x06\x95\x34\x61\xab\xd7\x5b\x91\x49\xc7\xc7\x91\xf4\x07\xfd\xbc\xf8\x39\x53\x2c\xb1\x08\xe8\xa5\x00\x64\x40\xcf\x21\xbf\x68\x87\x20\x5a\xcf\x44\x3b\x66\x3a\x57\xf2\xf4\x3d\x53\x8d\x91\xd4\x77\xb0\xf8\xf7\x7e\x19\x52\x48\x7f\x00\xb8\xdf\x41\xda\x90\x5c\x08\x75\xc5\xc9\x9b\xa1\x92\x26\x84\x0d\x0d\x0a\x25\x26\xee\x22\xc7\x96\x60\x65\x7c\xbe\x01\x95\x33\x5b\x44\x69\xbd\x92\x94\x6f\x7f\x74\xae\xc5\xce\xef\x31\xf4\x32\x53\xd4\x08\x96\x72\x65\xfa\x85\x5a\xc8\xa0\x0a\x19\x52\x93\x6e\x0f\xe9\x97\x01\xc0\xa4\x32\xa1\x32\x2c\x45\x67\x24\xf7\xad\xd8\xa5\xb4\x7a\x51\xda\x52\x17\x06\x06\x95\x34\x61\xab\xd7\x5b\x91\x49\xc7\xc7\x91\xf4\x07\xfd\xbc\xf8\x39\x53\x2c\xb1\x08\xe8\xa5\x00\x64\x40\xcf\x21\xbf\x68\x87\x20\x5a\xcf\x44\x3b\x66\x3a\x57\xf2\x01\xf4\x3d\x53\x8d\x91\xd4\x77\xb0\xf8\xf7\x7e\x19\x52\x48\x7f\x00\xb8\xdf\x41\xda\x90\x5c\x08\x75\xc5\xc9\x9b\xa1\x92\x26\x84\x0d\x0d\x0a\x25\x26\xee\x22\xc7\x96\x60\x65\x7c\xbe\x01\x95\x33\x5b\x44\x69\xbd\x92\x94\x6f\x7f\x74\xae\xc5\xce\xef\x31\xf4\x32\x53\xd4\x08\x96\x72\x65\xfa\x85\x5a\xc8\xa0\x0a\x19\x52\x93\x6e\x0f\xe9\x97\x01\xc0\xa4\x32\xa1\x32\x2c\x45\x67\x24\xf7\xad\xd8\xa5\xb4\x7a\x51\xda\x52\x17\x06\x06\x95\x34\x61\xab\xd7\x5b\x91\x49\xc7\xc7\x91\xf4\x07\xfd\xbc\xf8\x39\x53\x2c\xb1\x08\xe8\xa5\x00\x64\x40\xcf\x21\xbf\x68\x87\x20\x5a\xcf\x44\x3b\x66\x3a\x57\xf2\xf4\x3d\x53\x8d\x91\xd4\x77\xb0\xf8\xf7\x7e\x19\x52\x48\x7f\x00\xb8\xdf\x41\xda\x90\x5c\x08\x75\xc5\xc9\x9b\xa1\x92\x26\x84\x0d\x0d\x0a\x25\x26\xee\x22\xc7\x96\x60\x65\x7c\xbe\x01\x95\x33\x5b\x44\x69\xbd\x92\x94\x6f\x7f\x74\xae\xc5\xce\xef\x31\xf4\x32\x53\xd4\x08\x96\x72\x65\xfa\x85\x5a\xc8\xa0\x0a\x19\x52\x93\x6e\x0f\xe9\x97\x01\xc0\xa4\x32\xa1\x32\x2c\x45\x67\x24\xf7\xad\xd8\xa5\xb4\x7a\x51\xda\x52\x17\x06\x06\x95\x34\x61\xab\xd7\x5b\x91\x49\xc7\xc7\x91\xf4\x07\xfd\xbc\xf8\x39\x53\x2c\xb1\x08\xe8\xa5\x00\x64\x40\xcf\x21\xbf\x68\x87\x20\x5a\xcf\x44\x3b\x66\x3a\x57\xf2\xf4\x3d\x53\x8d\x91\xd4\x77\xb0\xf8\xf7\x7e\x19\x52\x48\x7f\x00\xb8\xdf\x41\xda\x90\x5c\x08\x75\xc5\xc9\x9b\xa1\x92\x26\x84\x0d\x0d\x0a\x25\x26\xee\x22\xc7\x96\x60\x65\x7c\xbe\x01\x95\x33\x5b\x44\x69\xbd\x92\x94\x6f\x7f\x74\xae\xc5\xce\xef\x31\xf4\x32\x53\xd4\x08\x96\x72\x65\xfa\x85\x5a\xc8\xa0\x0a\x19\x52\x93\x6e\x0f\xe9\x97\x01\xc0\xa4\x32\xa1\x32\x2c\x45\x67\x24\xf7\xad\xd8\xa5\xb4\x7a\x51\xda\x52\x17\x06\x06\x95\x34\x61\xab\xd7\x5b\x91\x49\xc7\xc7\x91\xf4\x07\xfd\xbc\xf8\x39\x53\x2c\xb1\x08\xe8\xa5\x00\x64\x40\xcf\x21\xbf\x68\x87\x20\x5a\xcf\x44\x3b\x66\x3a\x57\xf2"; - - bytes[] memory correctL2Logs = Utils.createSystemLogs(); - correctL2Logs[uint256(SystemLogKey.PACKED_BATCH_AND_L2_BLOCK_TIMESTAMP_KEY)] = Utils.constructL2Log( - true, - L2_SYSTEM_CONTEXT_ADDRESS, - uint256(SystemLogKey.PACKED_BATCH_AND_L2_BLOCK_TIMESTAMP_KEY), - Utils.packBatchTimestampAndBlockTimestamp(currentTimestamp, currentTimestamp) - ); - - IExecutor.CommitBatchInfo memory correctNewCommitBatchInfo = newCommitBatchInfo; - correctNewCommitBatchInfo.systemLogs = Utils.encodePacked(correctL2Logs); - - IExecutor.CommitBatchInfo[] memory correctCommitBatchInfoArray = new IExecutor.CommitBatchInfo[](1); - correctCommitBatchInfoArray[0] = correctNewCommitBatchInfo; - correctCommitBatchInfoArray[0].operatorDAInput = pubdataCommitment; - - vm.prank(validator); - - vm.expectRevert(bytes("bd")); - executor.commitBatches(genesisStoredBatchInfo, correctCommitBatchInfoArray); - } - - function test_RevertWhen_NotEnoughPubdataCommitments() public { - bytes - memory pubdataCommitment = "\x01\xf4\x3d\x53\x8d\x91\xd4\x77\xb0\xf8\xf7\x7e\x19\x52\x48\x7f\x00\xb8\xdf\x41\xda\x90\x5c\x08\x75\xc5\xc9\x9b\xa1\x92\x26\x84\x0d\x0d\x0a\x25\x26\xee\x22\xc7\x96\x60\x65\x7c\xbe\x01\x95\x33\x5b\x44\x69\xbd\x92\x94\x6f\x7f\x74\xae\xc5\xce\xef\x31\xf4\x32\x53\xd4\x08\x96\x72\x65\xfa\x85\x5a\xc8\xa0\x0a\x19\x52\x93\x6e\x0f\xe9\x97\x01\xc0\xa4\x32\xa1\x32\x2c\x45\x67\x24\xf7\xad\xd8\xa5\xb4\x7a\x51\xda\x52\x17\x06\x06\x95\x34\x61\xab\xd7\x5b\x91\x49\xc7\xc7\x91\xf4\x07\xfd\xbc\xf8\x39\x53\x2c\xb1\x08\xe8\xa5\x00\x64\x40\xcf\x21\xbf\x68\x87\x20\x5a\xcf\x44\x3b\x66\x3a\x57\xf2"; - bytes32 versionedHash1 = 0xf39a869f62e75cf5f0bf914688a6b289caf2049435d8e68c5c5e6d05e44913f3; - bytes32 versionedHash2 = 0x290decd9548b62a8d60345a988386fc84ba6bc95484008f6362f93160ef3e563; - - vm.mockCall(blobVersionedHashRetriever, abi.encode(uint256(0)), abi.encode(versionedHash1)); - - vm.mockCall(blobVersionedHashRetriever, abi.encode(uint256(1)), abi.encode(versionedHash2)); - - vm.mockCall( - POINT_EVALUATION_PRECOMPILE_ADDR, - "\xf3\x9a\x86\x9f\x62\xe7\x5c\xf5\xf0\xbf\x91\x46\x88\xa6\xb2\x89\xca\xf2\x04\x94\x35\xd8\xe6\x8c\x5c\x5e\x6d\x05\xe4\x49\x13\xf3\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xf4\x3d\x53\x8d\x91\xd4\x77\xb0\xf8\xf7\x7e\x19\x52\x48\x7f\x00\xb8\xdf\x41\xda\x90\x5c\x08\x75\xc5\xc9\x9b\xa1\x92\x26\x84\x0d\x0d\x0a\x25\x26\xee\x22\xc7\x96\x60\x65\x7c\xbe\x01\x95\x33\x5b\x44\x69\xbd\x92\x94\x6f\x7f\x74\xae\xc5\xce\xef\x31\xf4\x32\x53\xd4\x08\x96\x72\x65\xfa\x85\x5a\xc8\xa0\x0a\x19\x52\x93\x6e\x0f\xe9\x97\x01\xc0\xa4\x32\xa1\x32\x2c\x45\x67\x24\xf7\xad\xd8\xa5\xb4\x7a\x51\xda\x52\x17\x06\x06\x95\x34\x61\xab\xd7\x5b\x91\x49\xc7\xc7\x91\xf4\x07\xfd\xbc\xf8\x39\x53\x2c\xb1\x08\xe8\xa5\x00\x64\x40\xcf\x21\xbf\x68\x87\x20\x5a\xcf\x44\x3b\x66\x3a\x57\xf2", - "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x10\x00\x73\xed\xa7\x53\x29\x9d\x7d\x48\x33\x39\xd8\x08\x09\xa1\xd8\x05\x53\xbd\xa4\x02\xff\xfe\x5b\xfe\xff\xff\xff\xff\x00\x00\x00\x01" - ); - - bytes[] memory correctL2Logs = Utils.createSystemLogs(); - correctL2Logs[uint256(SystemLogKey.PACKED_BATCH_AND_L2_BLOCK_TIMESTAMP_KEY)] = Utils.constructL2Log( - true, - L2_SYSTEM_CONTEXT_ADDRESS, - uint256(SystemLogKey.PACKED_BATCH_AND_L2_BLOCK_TIMESTAMP_KEY), - Utils.packBatchTimestampAndBlockTimestamp(currentTimestamp, currentTimestamp) - ); - - correctL2Logs[uint256(SystemLogKey.BLOB_ONE_HASH_KEY)] = Utils.constructL2Log( - true, - L2_PUBDATA_CHUNK_PUBLISHER_ADDR, - uint256(SystemLogKey.BLOB_ONE_HASH_KEY), - versionedHash1 - ); - - IExecutor.CommitBatchInfo memory correctNewCommitBatchInfo = newCommitBatchInfo; - correctNewCommitBatchInfo.systemLogs = Utils.encodePacked(correctL2Logs); - - IExecutor.CommitBatchInfo[] memory correctCommitBatchInfoArray = new IExecutor.CommitBatchInfo[](1); - correctCommitBatchInfoArray[0] = correctNewCommitBatchInfo; - correctCommitBatchInfoArray[0].operatorDAInput = pubdataCommitment; - - vm.prank(validator); - - vm.expectRevert(bytes("lh")); - executor.commitBatches(genesisStoredBatchInfo, correctCommitBatchInfoArray); - - vm.clearMockedCalls(); - } - - function test_RevertWhen_BlobDoesNotExist() public { - bytes - memory pubdataCommitment = "\x01\xf4\x3d\x53\x8d\x91\xd4\x77\xb0\xf8\xf7\x7e\x19\x52\x48\x7f\x00\xb8\xdf\x41\xda\x90\x5c\x08\x75\xc5\xc9\x9b\xa1\x92\x26\x84\x0d\x0d\x0a\x25\x26\xee\x22\xc7\x96\x60\x65\x7c\xbe\x01\x95\x33\x5b\x44\x69\xbd\x92\x94\x6f\x7f\x74\xae\xc5\xce\xef\x31\xf4\x32\x53\xd4\x08\x96\x72\x65\xfa\x85\x5a\xc8\xa0\x0a\x19\x52\x93\x6e\x0f\xe9\x97\x01\xc0\xa4\x32\xa1\x32\x2c\x45\x67\x24\xf7\xad\xd8\xa5\xb4\x7a\x51\xda\x52\x17\x06\x06\x95\x34\x61\xab\xd7\x5b\x91\x49\xc7\xc7\x91\xf4\x07\xfd\xbc\xf8\x39\x53\x2c\xb1\x08\xe8\xa5\x00\x64\x40\xcf\x21\xbf\x68\x87\x20\x5a\xcf\x44\x3b\x66\x3a\x57\xf2"; - bytes32 versionedHash1 = 0xf39a869f62e75cf5f0bf914688a6b289caf2049435d8e68c5c5e6d05e44913f3; - - vm.mockCall(blobVersionedHashRetriever, abi.encode(uint256(0)), abi.encode(bytes32(0))); - - bytes[] memory correctL2Logs = Utils.createSystemLogs(); - correctL2Logs[uint256(SystemLogKey.PACKED_BATCH_AND_L2_BLOCK_TIMESTAMP_KEY)] = Utils.constructL2Log( - true, - L2_SYSTEM_CONTEXT_ADDRESS, - uint256(SystemLogKey.PACKED_BATCH_AND_L2_BLOCK_TIMESTAMP_KEY), - Utils.packBatchTimestampAndBlockTimestamp(currentTimestamp, currentTimestamp) - ); - - correctL2Logs[uint256(SystemLogKey.BLOB_ONE_HASH_KEY)] = Utils.constructL2Log( - true, - L2_PUBDATA_CHUNK_PUBLISHER_ADDR, - uint256(SystemLogKey.BLOB_ONE_HASH_KEY), - versionedHash1 - ); - - IExecutor.CommitBatchInfo memory correctNewCommitBatchInfo = newCommitBatchInfo; - correctNewCommitBatchInfo.systemLogs = Utils.encodePacked(correctL2Logs); - - IExecutor.CommitBatchInfo[] memory correctCommitBatchInfoArray = new IExecutor.CommitBatchInfo[](1); - correctCommitBatchInfoArray[0] = correctNewCommitBatchInfo; - correctCommitBatchInfoArray[0].operatorDAInput = pubdataCommitment; - - vm.prank(validator); - - vm.expectRevert(bytes("vh")); - executor.commitBatches(genesisStoredBatchInfo, correctCommitBatchInfoArray); - - vm.clearMockedCalls(); - } - - function test_RevertWhen_SecondBlobSentWithoutCommitmentData() public { - bytes - memory pubdataCommitment = "\x01\xf4\x3d\x53\x8d\x91\xd4\x77\xb0\xf8\xf7\x7e\x19\x52\x48\x7f\x00\xb8\xdf\x41\xda\x90\x5c\x08\x75\xc5\xc9\x9b\xa1\x92\x26\x84\x0d\x0d\x0a\x25\x26\xee\x22\xc7\x96\x60\x65\x7c\xbe\x01\x95\x33\x5b\x44\x69\xbd\x92\x94\x6f\x7f\x74\xae\xc5\xce\xef\x31\xf4\x32\x53\xd4\x08\x96\x72\x65\xfa\x85\x5a\xc8\xa0\x0a\x19\x52\x93\x6e\x0f\xe9\x97\x01\xc0\xa4\x32\xa1\x32\x2c\x45\x67\x24\xf7\xad\xd8\xa5\xb4\x7a\x51\xda\x52\x17\x06\x06\x95\x34\x61\xab\xd7\x5b\x91\x49\xc7\xc7\x91\xf4\x07\xfd\xbc\xf8\x39\x53\x2c\xb1\x08\xe8\xa5\x00\x64\x40\xcf\x21\xbf\x68\x87\x20\x5a\xcf\x44\x3b\x66\x3a\x57\xf2"; - bytes32 versionedHash1 = 0xf39a869f62e75cf5f0bf914688a6b289caf2049435d8e68c5c5e6d05e44913f3; - - vm.mockCall(blobVersionedHashRetriever, abi.encode(uint256(0)), abi.encode(versionedHash1)); - - vm.mockCall(blobVersionedHashRetriever, abi.encode(uint256(1)), abi.encode(versionedHash1)); - - vm.mockCall( - POINT_EVALUATION_PRECOMPILE_ADDR, - "\xf3\x9a\x86\x9f\x62\xe7\x5c\xf5\xf0\xbf\x91\x46\x88\xa6\xb2\x89\xca\xf2\x04\x94\x35\xd8\xe6\x8c\x5c\x5e\x6d\x05\xe4\x49\x13\xf3\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xf4\x3d\x53\x8d\x91\xd4\x77\xb0\xf8\xf7\x7e\x19\x52\x48\x7f\x00\xb8\xdf\x41\xda\x90\x5c\x08\x75\xc5\xc9\x9b\xa1\x92\x26\x84\x0d\x0d\x0a\x25\x26\xee\x22\xc7\x96\x60\x65\x7c\xbe\x01\x95\x33\x5b\x44\x69\xbd\x92\x94\x6f\x7f\x74\xae\xc5\xce\xef\x31\xf4\x32\x53\xd4\x08\x96\x72\x65\xfa\x85\x5a\xc8\xa0\x0a\x19\x52\x93\x6e\x0f\xe9\x97\x01\xc0\xa4\x32\xa1\x32\x2c\x45\x67\x24\xf7\xad\xd8\xa5\xb4\x7a\x51\xda\x52\x17\x06\x06\x95\x34\x61\xab\xd7\x5b\x91\x49\xc7\xc7\x91\xf4\x07\xfd\xbc\xf8\x39\x53\x2c\xb1\x08\xe8\xa5\x00\x64\x40\xcf\x21\xbf\x68\x87\x20\x5a\xcf\x44\x3b\x66\x3a\x57\xf2", - "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x10\x00\x73\xed\xa7\x53\x29\x9d\x7d\x48\x33\x39\xd8\x08\x09\xa1\xd8\x05\x53\xbd\xa4\x02\xff\xfe\x5b\xfe\xff\xff\xff\xff\x00\x00\x00\x01" - ); - - bytes[] memory correctL2Logs = Utils.createSystemLogs(); - correctL2Logs[uint256(SystemLogKey.PACKED_BATCH_AND_L2_BLOCK_TIMESTAMP_KEY)] = Utils.constructL2Log( - true, - L2_SYSTEM_CONTEXT_ADDRESS, - uint256(SystemLogKey.PACKED_BATCH_AND_L2_BLOCK_TIMESTAMP_KEY), - Utils.packBatchTimestampAndBlockTimestamp(currentTimestamp, currentTimestamp) - ); - - correctL2Logs[uint256(SystemLogKey.BLOB_ONE_HASH_KEY)] = Utils.constructL2Log( - true, - L2_PUBDATA_CHUNK_PUBLISHER_ADDR, - uint256(SystemLogKey.BLOB_ONE_HASH_KEY), - versionedHash1 - ); - - IExecutor.CommitBatchInfo memory correctNewCommitBatchInfo = newCommitBatchInfo; - correctNewCommitBatchInfo.systemLogs = Utils.encodePacked(correctL2Logs); - - IExecutor.CommitBatchInfo[] memory correctCommitBatchInfoArray = new IExecutor.CommitBatchInfo[](1); - correctCommitBatchInfoArray[0] = correctNewCommitBatchInfo; - correctCommitBatchInfoArray[0].operatorDAInput = pubdataCommitment; - - vm.prank(validator); - - vm.expectRevert(bytes("lh")); - executor.commitBatches(genesisStoredBatchInfo, correctCommitBatchInfoArray); - - vm.clearMockedCalls(); - } - - function test_RevertWhen_SecondBlobLinearHashZeroWithCommitment() public { - bytes - memory pubdataCommitment = "\x01\xf4\x3d\x53\x8d\x91\xd4\x77\xb0\xf8\xf7\x7e\x19\x52\x48\x7f\x00\xb8\xdf\x41\xda\x90\x5c\x08\x75\xc5\xc9\x9b\xa1\x92\x26\x84\x0d\x0d\x0a\x25\x26\xee\x22\xc7\x96\x60\x65\x7c\xbe\x01\x95\x33\x5b\x44\x69\xbd\x92\x94\x6f\x7f\x74\xae\xc5\xce\xef\x31\xf4\x32\x53\xd4\x08\x96\x72\x65\xfa\x85\x5a\xc8\xa0\x0a\x19\x52\x93\x6e\x0f\xe9\x97\x01\xc0\xa4\x32\xa1\x32\x2c\x45\x67\x24\xf7\xad\xd8\xa5\xb4\x7a\x51\xda\x52\x17\x06\x06\x95\x34\x61\xab\xd7\x5b\x91\x49\xc7\xc7\x91\xf4\x07\xfd\xbc\xf8\x39\x53\x2c\xb1\x08\xe8\xa5\x00\x64\x40\xcf\x21\xbf\x68\x87\x20\x5a\xcf\x44\x3b\x66\x3a\x57\xf2\xf4\x3d\x53\x8d\x91\xd4\x77\xb0\xf8\xf7\x7e\x19\x52\x48\x7f\x00\xb8\xdf\x41\xda\x90\x5c\x08\x75\xc5\xc9\x9b\xa1\x92\x26\x84\x0d\x0d\x0a\x25\x26\xee\x22\xc7\x96\x60\x65\x7c\xbe\x01\x95\x33\x5b\x44\x69\xbd\x92\x94\x6f\x7f\x74\xae\xc5\xce\xef\x31\xf4\x32\x53\xd4\x08\x96\x72\x65\xfa\x85\x5a\xc8\xa0\x0a\x19\x52\x93\x6e\x0f\xe9\x97\x01\xc0\xa4\x32\xa1\x32\x2c\x45\x67\x24\xf7\xad\xd8\xa5\xb4\x7a\x51\xda\x52\x17\x06\x06\x95\x34\x61\xab\xd7\x5b\x91\x49\xc7\xc7\x91\xf4\x07\xfd\xbc\xf8\x39\x53\x2c\xb1\x08\xe8\xa5\x00\x64\x40\xcf\x21\xbf\x68\x87\x20\x5a\xcf\x44\x3b\x66\x3a\x57\xf2"; - bytes32 versionedHash1 = 0xf39a869f62e75cf5f0bf914688a6b289caf2049435d8e68c5c5e6d05e44913f3; - bytes32 versionedHash2 = 0x290decd9548b62a8d60345a988386fc84ba6bc95484008f6362f93160ef3e563; - - vm.mockCall(blobVersionedHashRetriever, abi.encode(uint256(0)), abi.encode(versionedHash1)); - - vm.mockCall(blobVersionedHashRetriever, abi.encode(uint256(0)), abi.encode(versionedHash1)); - - vm.mockCall(blobVersionedHashRetriever, abi.encode(uint256(1)), abi.encode(versionedHash2)); - - vm.mockCall(blobVersionedHashRetriever, abi.encode(uint256(2)), abi.encode(bytes32(0))); - - vm.mockCall( - POINT_EVALUATION_PRECOMPILE_ADDR, - "\xf3\x9a\x86\x9f\x62\xe7\x5c\xf5\xf0\xbf\x91\x46\x88\xa6\xb2\x89\xca\xf2\x04\x94\x35\xd8\xe6\x8c\x5c\x5e\x6d\x05\xe4\x49\x13\xf3\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xf4\x3d\x53\x8d\x91\xd4\x77\xb0\xf8\xf7\x7e\x19\x52\x48\x7f\x00\xb8\xdf\x41\xda\x90\x5c\x08\x75\xc5\xc9\x9b\xa1\x92\x26\x84\x0d\x0d\x0a\x25\x26\xee\x22\xc7\x96\x60\x65\x7c\xbe\x01\x95\x33\x5b\x44\x69\xbd\x92\x94\x6f\x7f\x74\xae\xc5\xce\xef\x31\xf4\x32\x53\xd4\x08\x96\x72\x65\xfa\x85\x5a\xc8\xa0\x0a\x19\x52\x93\x6e\x0f\xe9\x97\x01\xc0\xa4\x32\xa1\x32\x2c\x45\x67\x24\xf7\xad\xd8\xa5\xb4\x7a\x51\xda\x52\x17\x06\x06\x95\x34\x61\xab\xd7\x5b\x91\x49\xc7\xc7\x91\xf4\x07\xfd\xbc\xf8\x39\x53\x2c\xb1\x08\xe8\xa5\x00\x64\x40\xcf\x21\xbf\x68\x87\x20\x5a\xcf\x44\x3b\x66\x3a\x57\xf2", - "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x10\x00\x73\xed\xa7\x53\x29\x9d\x7d\x48\x33\x39\xd8\x08\x09\xa1\xd8\x05\x53\xbd\xa4\x02\xff\xfe\x5b\xfe\xff\xff\xff\xff\x00\x00\x00\x01" - ); - - vm.mockCall( - POINT_EVALUATION_PRECOMPILE_ADDR, - "\x29\x0d\xec\xd9\x54\x8b\x62\xa8\xd6\x03\x45\xa9\x88\x38\x6f\xc8\x4b\xa6\xbc\x95\x48\x40\x08\xf6\x36\x2f\x93\x16\x0e\xf3\xe5\x63\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xf4\x3d\x53\x8d\x91\xd4\x77\xb0\xf8\xf7\x7e\x19\x52\x48\x7f\x00\xb8\xdf\x41\xda\x90\x5c\x08\x75\xc5\xc9\x9b\xa1\x92\x26\x84\x0d\x0d\x0a\x25\x26\xee\x22\xc7\x96\x60\x65\x7c\xbe\x01\x95\x33\x5b\x44\x69\xbd\x92\x94\x6f\x7f\x74\xae\xc5\xce\xef\x31\xf4\x32\x53\xd4\x08\x96\x72\x65\xfa\x85\x5a\xc8\xa0\x0a\x19\x52\x93\x6e\x0f\xe9\x97\x01\xc0\xa4\x32\xa1\x32\x2c\x45\x67\x24\xf7\xad\xd8\xa5\xb4\x7a\x51\xda\x52\x17\x06\x06\x95\x34\x61\xab\xd7\x5b\x91\x49\xc7\xc7\x91\xf4\x07\xfd\xbc\xf8\x39\x53\x2c\xb1\x08\xe8\xa5\x00\x64\x40\xcf\x21\xbf\x68\x87\x20\x5a\xcf\x44\x3b\x66\x3a\x57\xf2", - "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x10\x00\x73\xed\xa7\x53\x29\x9d\x7d\x48\x33\x39\xd8\x08\x09\xa1\xd8\x05\x53\xbd\xa4\x02\xff\xfe\x5b\xfe\xff\xff\xff\xff\x00\x00\x00\x01" - ); - - bytes[] memory correctL2Logs = Utils.createSystemLogs(); - correctL2Logs[uint256(SystemLogKey.PACKED_BATCH_AND_L2_BLOCK_TIMESTAMP_KEY)] = Utils.constructL2Log( - true, - L2_SYSTEM_CONTEXT_ADDRESS, - uint256(SystemLogKey.PACKED_BATCH_AND_L2_BLOCK_TIMESTAMP_KEY), - Utils.packBatchTimestampAndBlockTimestamp(currentTimestamp, currentTimestamp) - ); - - correctL2Logs[uint256(SystemLogKey.BLOB_ONE_HASH_KEY)] = Utils.constructL2Log( - true, - L2_PUBDATA_CHUNK_PUBLISHER_ADDR, - uint256(SystemLogKey.BLOB_ONE_HASH_KEY), - versionedHash1 - ); - - correctL2Logs[uint256(SystemLogKey.BLOB_TWO_HASH_KEY)] = Utils.constructL2Log( - true, - L2_PUBDATA_CHUNK_PUBLISHER_ADDR, - uint256(SystemLogKey.BLOB_TWO_HASH_KEY), - bytes32(0) - ); - - IExecutor.CommitBatchInfo memory correctNewCommitBatchInfo = newCommitBatchInfo; - correctNewCommitBatchInfo.systemLogs = Utils.encodePacked(correctL2Logs); - - IExecutor.CommitBatchInfo[] memory correctCommitBatchInfoArray = new IExecutor.CommitBatchInfo[](1); - correctCommitBatchInfoArray[0] = correctNewCommitBatchInfo; - correctCommitBatchInfoArray[0].operatorDAInput = pubdataCommitment; - - vm.prank(validator); + // function test_RevertWhen_EmptyPubdataCommitments() public { + // bytes memory pubdataCommitment = "\x01"; + + // bytes[] memory correctL2Logs = Utils.createSystemLogs(); + // correctL2Logs[uint256(SystemLogKey.PACKED_BATCH_AND_L2_BLOCK_TIMESTAMP_KEY)] = Utils.constructL2Log( + // true, + // L2_SYSTEM_CONTEXT_ADDRESS, + // uint256(SystemLogKey.PACKED_BATCH_AND_L2_BLOCK_TIMESTAMP_KEY), + // Utils.packBatchTimestampAndBlockTimestamp(currentTimestamp, currentTimestamp) + // ); + + // IExecutor.CommitBatchInfo memory correctNewCommitBatchInfo = newCommitBatchInfo; + // correctNewCommitBatchInfo.systemLogs = Utils.encodePacked(correctL2Logs); - vm.expectRevert(bytes("bh")); - executor.commitBatches(genesisStoredBatchInfo, correctCommitBatchInfoArray); - } + // IExecutor.CommitBatchInfo[] memory correctCommitBatchInfoArray = new IExecutor.CommitBatchInfo[](1); + // correctCommitBatchInfoArray[0] = correctNewCommitBatchInfo; + // correctCommitBatchInfoArray[0].operatorDAInput = pubdataCommitment; - function test_RevertWhen_SecondBlobLinearHashNotZeroWithEmptyCommitment() public { - bytes - memory pubdataCommitment = "\x01\xf4\x3d\x53\x8d\x91\xd4\x77\xb0\xf8\xf7\x7e\x19\x52\x48\x7f\x00\xb8\xdf\x41\xda\x90\x5c\x08\x75\xc5\xc9\x9b\xa1\x92\x26\x84\x0d\x0d\x0a\x25\x26\xee\x22\xc7\x96\x60\x65\x7c\xbe\x01\x95\x33\x5b\x44\x69\xbd\x92\x94\x6f\x7f\x74\xae\xc5\xce\xef\x31\xf4\x32\x53\xd4\x08\x96\x72\x65\xfa\x85\x5a\xc8\xa0\x0a\x19\x52\x93\x6e\x0f\xe9\x97\x01\xc0\xa4\x32\xa1\x32\x2c\x45\x67\x24\xf7\xad\xd8\xa5\xb4\x7a\x51\xda\x52\x17\x06\x06\x95\x34\x61\xab\xd7\x5b\x91\x49\xc7\xc7\x91\xf4\x07\xfd\xbc\xf8\x39\x53\x2c\xb1\x08\xe8\xa5\x00\x64\x40\xcf\x21\xbf\x68\x87\x20\x5a\xcf\x44\x3b\x66\x3a\x57\xf2"; - bytes32 versionedHash1 = 0xf39a869f62e75cf5f0bf914688a6b289caf2049435d8e68c5c5e6d05e44913f3; + // vm.prank(validator); - vm.mockCall(blobVersionedHashRetriever, abi.encode(uint256(0)), abi.encode(versionedHash1)); + // vm.expectRevert(bytes("pl")); + // executor.commitBatches(genesisStoredBatchInfo, correctCommitBatchInfoArray); + // } + + // function test_RevertWhen_PartialPubdataCommitment() public { + // bytes + // memory pubdataCommitment = "\x01\xf4\x3d\x53\x8d\x91\xd4\x77\xb0\xf8\xf7\x7e\x19\x52\x48\x7f\x00\xb8\xdf\x41\xda\x90\x5c\x08\x75\xc5\xc9\x9b\xa1\x92\x26\x84\x0d\x0d\x0a\x25\x26\xee\x22\xc7\x96\x60\x65\x7c\xbe\x01\x95\x33\x5b\x44\x69\xbd\x92\x94\x6f\x7f\x74\xae\xc5\xce\xef\x31\xf4\x32\x53\xd4\x08\x96\x72\x65\xfa\x85\x5a\xc8\xa0\x0a\x19\x52\x93\x6e\x0f\xe9\x97\x01\xc0\xa4\x32\xa1\x32\x2c\x45\x67\x24\xf7\xad\xd8\xa5\xb4\x7a\x51\xda\x52\x17\x06\x06\x95\x34\x61\xab\xd7\x5b\x91\x49\xc7\xc7\x91\xf4\x07\xfd\xbc\xf8\x39\x53\x2c\xb1\x08\xe8\xa5\x00\x64\x40\xcf\x21\xbf\x68\x87\x20\x5a\xcf\x44\x3b\x66\x3a\x57"; - vm.mockCall(blobVersionedHashRetriever, abi.encode(uint256(1)), abi.encode(bytes32(0))); + // bytes[] memory correctL2Logs = Utils.createSystemLogs(); + // correctL2Logs[uint256(SystemLogKey.PACKED_BATCH_AND_L2_BLOCK_TIMESTAMP_KEY)] = Utils.constructL2Log( + // true, + // L2_SYSTEM_CONTEXT_ADDRESS, + // uint256(SystemLogKey.PACKED_BATCH_AND_L2_BLOCK_TIMESTAMP_KEY), + // Utils.packBatchTimestampAndBlockTimestamp(currentTimestamp, currentTimestamp) + // ); + + // IExecutor.CommitBatchInfo memory correctNewCommitBatchInfo = newCommitBatchInfo; + // correctNewCommitBatchInfo.systemLogs = Utils.encodePacked(correctL2Logs); + + // IExecutor.CommitBatchInfo[] memory correctCommitBatchInfoArray = new IExecutor.CommitBatchInfo[](1); + // correctCommitBatchInfoArray[0] = correctNewCommitBatchInfo; + // correctCommitBatchInfoArray[0].operatorDAInput = pubdataCommitment; + + // vm.prank(validator); + + // vm.expectRevert(bytes("bs")); + // executor.commitBatches(genesisStoredBatchInfo, correctCommitBatchInfoArray); + // } + + // function test_RevertWhen_TooManyPubdataCommitments() public { + // bytes + // memory pubdataCommitment = "\x01\xf4\x3d\x53\x8d\x91\xd4\x77\xb0\xf8\xf7\x7e\x19\x52\x48\x7f\x00\xb8\xdf\x41\xda\x90\x5c\x08\x75\xc5\xc9\x9b\xa1\x92\x26\x84\x0d\x0d\x0a\x25\x26\xee\x22\xc7\x96\x60\x65\x7c\xbe\x01\x95\x33\x5b\x44\x69\xbd\x92\x94\x6f\x7f\x74\xae\xc5\xce\xef\x31\xf4\x32\x53\xd4\x08\x96\x72\x65\xfa\x85\x5a\xc8\xa0\x0a\x19\x52\x93\x6e\x0f\xe9\x97\x01\xc0\xa4\x32\xa1\x32\x2c\x45\x67\x24\xf7\xad\xd8\xa5\xb4\x7a\x51\xda\x52\x17\x06\x06\x95\x34\x61\xab\xd7\x5b\x91\x49\xc7\xc7\x91\xf4\x07\xfd\xbc\xf8\x39\x53\x2c\xb1\x08\xe8\xa5\x00\x64\x40\xcf\x21\xbf\x68\x87\x20\x5a\xcf\x44\x3b\x66\x3a\x57\xf2\xf4\x3d\x53\x8d\x91\xd4\x77\xb0\xf8\xf7\x7e\x19\x52\x48\x7f\x00\xb8\xdf\x41\xda\x90\x5c\x08\x75\xc5\xc9\x9b\xa1\x92\x26\x84\x0d\x0d\x0a\x25\x26\xee\x22\xc7\x96\x60\x65\x7c\xbe\x01\x95\x33\x5b\x44\x69\xbd\x92\x94\x6f\x7f\x74\xae\xc5\xce\xef\x31\xf4\x32\x53\xd4\x08\x96\x72\x65\xfa\x85\x5a\xc8\xa0\x0a\x19\x52\x93\x6e\x0f\xe9\x97\x01\xc0\xa4\x32\xa1\x32\x2c\x45\x67\x24\xf7\xad\xd8\xa5\xb4\x7a\x51\xda\x52\x17\x06\x06\x95\x34\x61\xab\xd7\x5b\x91\x49\xc7\xc7\x91\xf4\x07\xfd\xbc\xf8\x39\x53\x2c\xb1\x08\xe8\xa5\x00\x64\x40\xcf\x21\xbf\x68\x87\x20\x5a\xcf\x44\x3b\x66\x3a\x57\xf2\xf4\x3d\x53\x8d\x91\xd4\x77\xb0\xf8\xf7\x7e\x19\x52\x48\x7f\x00\xb8\xdf\x41\xda\x90\x5c\x08\x75\xc5\xc9\x9b\xa1\x92\x26\x84\x0d\x0d\x0a\x25\x26\xee\x22\xc7\x96\x60\x65\x7c\xbe\x01\x95\x33\x5b\x44\x69\xbd\x92\x94\x6f\x7f\x74\xae\xc5\xce\xef\x31\xf4\x32\x53\xd4\x08\x96\x72\x65\xfa\x85\x5a\xc8\xa0\x0a\x19\x52\x93\x6e\x0f\xe9\x97\x01\xc0\xa4\x32\xa1\x32\x2c\x45\x67\x24\xf7\xad\xd8\xa5\xb4\x7a\x51\xda\x52\x17\x06\x06\x95\x34\x61\xab\xd7\x5b\x91\x49\xc7\xc7\x91\xf4\x07\xfd\xbc\xf8\x39\x53\x2c\xb1\x08\xe8\xa5\x00\x64\x40\xcf\x21\xbf\x68\x87\x20\x5a\xcf\x44\x3b\x66\x3a\x57\xf2\x01\xf4\x3d\x53\x8d\x91\xd4\x77\xb0\xf8\xf7\x7e\x19\x52\x48\x7f\x00\xb8\xdf\x41\xda\x90\x5c\x08\x75\xc5\xc9\x9b\xa1\x92\x26\x84\x0d\x0d\x0a\x25\x26\xee\x22\xc7\x96\x60\x65\x7c\xbe\x01\x95\x33\x5b\x44\x69\xbd\x92\x94\x6f\x7f\x74\xae\xc5\xce\xef\x31\xf4\x32\x53\xd4\x08\x96\x72\x65\xfa\x85\x5a\xc8\xa0\x0a\x19\x52\x93\x6e\x0f\xe9\x97\x01\xc0\xa4\x32\xa1\x32\x2c\x45\x67\x24\xf7\xad\xd8\xa5\xb4\x7a\x51\xda\x52\x17\x06\x06\x95\x34\x61\xab\xd7\x5b\x91\x49\xc7\xc7\x91\xf4\x07\xfd\xbc\xf8\x39\x53\x2c\xb1\x08\xe8\xa5\x00\x64\x40\xcf\x21\xbf\x68\x87\x20\x5a\xcf\x44\x3b\x66\x3a\x57\xf2\xf4\x3d\x53\x8d\x91\xd4\x77\xb0\xf8\xf7\x7e\x19\x52\x48\x7f\x00\xb8\xdf\x41\xda\x90\x5c\x08\x75\xc5\xc9\x9b\xa1\x92\x26\x84\x0d\x0d\x0a\x25\x26\xee\x22\xc7\x96\x60\x65\x7c\xbe\x01\x95\x33\x5b\x44\x69\xbd\x92\x94\x6f\x7f\x74\xae\xc5\xce\xef\x31\xf4\x32\x53\xd4\x08\x96\x72\x65\xfa\x85\x5a\xc8\xa0\x0a\x19\x52\x93\x6e\x0f\xe9\x97\x01\xc0\xa4\x32\xa1\x32\x2c\x45\x67\x24\xf7\xad\xd8\xa5\xb4\x7a\x51\xda\x52\x17\x06\x06\x95\x34\x61\xab\xd7\x5b\x91\x49\xc7\xc7\x91\xf4\x07\xfd\xbc\xf8\x39\x53\x2c\xb1\x08\xe8\xa5\x00\x64\x40\xcf\x21\xbf\x68\x87\x20\x5a\xcf\x44\x3b\x66\x3a\x57\xf2\xf4\x3d\x53\x8d\x91\xd4\x77\xb0\xf8\xf7\x7e\x19\x52\x48\x7f\x00\xb8\xdf\x41\xda\x90\x5c\x08\x75\xc5\xc9\x9b\xa1\x92\x26\x84\x0d\x0d\x0a\x25\x26\xee\x22\xc7\x96\x60\x65\x7c\xbe\x01\x95\x33\x5b\x44\x69\xbd\x92\x94\x6f\x7f\x74\xae\xc5\xce\xef\x31\xf4\x32\x53\xd4\x08\x96\x72\x65\xfa\x85\x5a\xc8\xa0\x0a\x19\x52\x93\x6e\x0f\xe9\x97\x01\xc0\xa4\x32\xa1\x32\x2c\x45\x67\x24\xf7\xad\xd8\xa5\xb4\x7a\x51\xda\x52\x17\x06\x06\x95\x34\x61\xab\xd7\x5b\x91\x49\xc7\xc7\x91\xf4\x07\xfd\xbc\xf8\x39\x53\x2c\xb1\x08\xe8\xa5\x00\x64\x40\xcf\x21\xbf\x68\x87\x20\x5a\xcf\x44\x3b\x66\x3a\x57\xf2"; + + // bytes[] memory correctL2Logs = Utils.createSystemLogs(); + // correctL2Logs[uint256(SystemLogKey.PACKED_BATCH_AND_L2_BLOCK_TIMESTAMP_KEY)] = Utils.constructL2Log( + // true, + // L2_SYSTEM_CONTEXT_ADDRESS, + // uint256(SystemLogKey.PACKED_BATCH_AND_L2_BLOCK_TIMESTAMP_KEY), + // Utils.packBatchTimestampAndBlockTimestamp(currentTimestamp, currentTimestamp) + // ); + + // IExecutor.CommitBatchInfo memory correctNewCommitBatchInfo = newCommitBatchInfo; + // correctNewCommitBatchInfo.systemLogs = Utils.encodePacked(correctL2Logs); - vm.mockCall( - POINT_EVALUATION_PRECOMPILE_ADDR, - "\xf3\x9a\x86\x9f\x62\xe7\x5c\xf5\xf0\xbf\x91\x46\x88\xa6\xb2\x89\xca\xf2\x04\x94\x35\xd8\xe6\x8c\x5c\x5e\x6d\x05\xe4\x49\x13\xf3\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xf4\x3d\x53\x8d\x91\xd4\x77\xb0\xf8\xf7\x7e\x19\x52\x48\x7f\x00\xb8\xdf\x41\xda\x90\x5c\x08\x75\xc5\xc9\x9b\xa1\x92\x26\x84\x0d\x0d\x0a\x25\x26\xee\x22\xc7\x96\x60\x65\x7c\xbe\x01\x95\x33\x5b\x44\x69\xbd\x92\x94\x6f\x7f\x74\xae\xc5\xce\xef\x31\xf4\x32\x53\xd4\x08\x96\x72\x65\xfa\x85\x5a\xc8\xa0\x0a\x19\x52\x93\x6e\x0f\xe9\x97\x01\xc0\xa4\x32\xa1\x32\x2c\x45\x67\x24\xf7\xad\xd8\xa5\xb4\x7a\x51\xda\x52\x17\x06\x06\x95\x34\x61\xab\xd7\x5b\x91\x49\xc7\xc7\x91\xf4\x07\xfd\xbc\xf8\x39\x53\x2c\xb1\x08\xe8\xa5\x00\x64\x40\xcf\x21\xbf\x68\x87\x20\x5a\xcf\x44\x3b\x66\x3a\x57\xf2", - "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x10\x00\x73\xed\xa7\x53\x29\x9d\x7d\x48\x33\x39\xd8\x08\x09\xa1\xd8\x05\x53\xbd\xa4\x02\xff\xfe\x5b\xfe\xff\xff\xff\xff\x00\x00\x00\x01" - ); - - bytes[] memory correctL2Logs = Utils.createSystemLogs(); - correctL2Logs[uint256(SystemLogKey.PACKED_BATCH_AND_L2_BLOCK_TIMESTAMP_KEY)] = Utils.constructL2Log( - true, - L2_SYSTEM_CONTEXT_ADDRESS, - uint256(SystemLogKey.PACKED_BATCH_AND_L2_BLOCK_TIMESTAMP_KEY), - Utils.packBatchTimestampAndBlockTimestamp(currentTimestamp, currentTimestamp) - ); + // IExecutor.CommitBatchInfo[] memory correctCommitBatchInfoArray = new IExecutor.CommitBatchInfo[](1); + // correctCommitBatchInfoArray[0] = correctNewCommitBatchInfo; + // correctCommitBatchInfoArray[0].operatorDAInput = pubdataCommitment; - correctL2Logs[uint256(SystemLogKey.BLOB_ONE_HASH_KEY)] = Utils.constructL2Log( - true, - L2_PUBDATA_CHUNK_PUBLISHER_ADDR, - uint256(SystemLogKey.BLOB_ONE_HASH_KEY), - versionedHash1 - ); + // vm.prank(validator); - correctL2Logs[uint256(SystemLogKey.BLOB_TWO_HASH_KEY)] = Utils.constructL2Log( - true, - L2_PUBDATA_CHUNK_PUBLISHER_ADDR, - uint256(SystemLogKey.BLOB_TWO_HASH_KEY), - versionedHash1 - ); + // vm.expectRevert(bytes("bd")); + // executor.commitBatches(genesisStoredBatchInfo, correctCommitBatchInfoArray); + // } - IExecutor.CommitBatchInfo memory correctNewCommitBatchInfo = newCommitBatchInfo; - correctNewCommitBatchInfo.systemLogs = Utils.encodePacked(correctL2Logs); + // function test_RevertWhen_NotEnoughPubdataCommitments() public { + // bytes + // memory pubdataCommitment = "\x01\xf4\x3d\x53\x8d\x91\xd4\x77\xb0\xf8\xf7\x7e\x19\x52\x48\x7f\x00\xb8\xdf\x41\xda\x90\x5c\x08\x75\xc5\xc9\x9b\xa1\x92\x26\x84\x0d\x0d\x0a\x25\x26\xee\x22\xc7\x96\x60\x65\x7c\xbe\x01\x95\x33\x5b\x44\x69\xbd\x92\x94\x6f\x7f\x74\xae\xc5\xce\xef\x31\xf4\x32\x53\xd4\x08\x96\x72\x65\xfa\x85\x5a\xc8\xa0\x0a\x19\x52\x93\x6e\x0f\xe9\x97\x01\xc0\xa4\x32\xa1\x32\x2c\x45\x67\x24\xf7\xad\xd8\xa5\xb4\x7a\x51\xda\x52\x17\x06\x06\x95\x34\x61\xab\xd7\x5b\x91\x49\xc7\xc7\x91\xf4\x07\xfd\xbc\xf8\x39\x53\x2c\xb1\x08\xe8\xa5\x00\x64\x40\xcf\x21\xbf\x68\x87\x20\x5a\xcf\x44\x3b\x66\x3a\x57\xf2"; + // bytes32 versionedHash1 = 0xf39a869f62e75cf5f0bf914688a6b289caf2049435d8e68c5c5e6d05e44913f3; + // bytes32 versionedHash2 = 0x290decd9548b62a8d60345a988386fc84ba6bc95484008f6362f93160ef3e563; + + // vm.mockCall(blobVersionedHashRetriever, abi.encode(uint256(0)), abi.encode(versionedHash1)); + + // vm.mockCall(blobVersionedHashRetriever, abi.encode(uint256(1)), abi.encode(versionedHash2)); + + // vm.mockCall( + // POINT_EVALUATION_PRECOMPILE_ADDR, + // "\xf3\x9a\x86\x9f\x62\xe7\x5c\xf5\xf0\xbf\x91\x46\x88\xa6\xb2\x89\xca\xf2\x04\x94\x35\xd8\xe6\x8c\x5c\x5e\x6d\x05\xe4\x49\x13\xf3\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xf4\x3d\x53\x8d\x91\xd4\x77\xb0\xf8\xf7\x7e\x19\x52\x48\x7f\x00\xb8\xdf\x41\xda\x90\x5c\x08\x75\xc5\xc9\x9b\xa1\x92\x26\x84\x0d\x0d\x0a\x25\x26\xee\x22\xc7\x96\x60\x65\x7c\xbe\x01\x95\x33\x5b\x44\x69\xbd\x92\x94\x6f\x7f\x74\xae\xc5\xce\xef\x31\xf4\x32\x53\xd4\x08\x96\x72\x65\xfa\x85\x5a\xc8\xa0\x0a\x19\x52\x93\x6e\x0f\xe9\x97\x01\xc0\xa4\x32\xa1\x32\x2c\x45\x67\x24\xf7\xad\xd8\xa5\xb4\x7a\x51\xda\x52\x17\x06\x06\x95\x34\x61\xab\xd7\x5b\x91\x49\xc7\xc7\x91\xf4\x07\xfd\xbc\xf8\x39\x53\x2c\xb1\x08\xe8\xa5\x00\x64\x40\xcf\x21\xbf\x68\x87\x20\x5a\xcf\x44\x3b\x66\x3a\x57\xf2", + // "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x10\x00\x73\xed\xa7\x53\x29\x9d\x7d\x48\x33\x39\xd8\x08\x09\xa1\xd8\x05\x53\xbd\xa4\x02\xff\xfe\x5b\xfe\xff\xff\xff\xff\x00\x00\x00\x01" + // ); + + // bytes[] memory correctL2Logs = Utils.createSystemLogs(); + // correctL2Logs[uint256(SystemLogKey.PACKED_BATCH_AND_L2_BLOCK_TIMESTAMP_KEY)] = Utils.constructL2Log( + // true, + // L2_SYSTEM_CONTEXT_ADDRESS, + // uint256(SystemLogKey.PACKED_BATCH_AND_L2_BLOCK_TIMESTAMP_KEY), + // Utils.packBatchTimestampAndBlockTimestamp(currentTimestamp, currentTimestamp) + // ); + + // correctL2Logs[uint256(SystemLogKey.BLOB_ONE_HASH_KEY)] = Utils.constructL2Log( + // true, + // L2_PUBDATA_CHUNK_PUBLISHER_ADDR, + // uint256(SystemLogKey.BLOB_ONE_HASH_KEY), + // versionedHash1 + // ); + + // IExecutor.CommitBatchInfo memory correctNewCommitBatchInfo = newCommitBatchInfo; + // correctNewCommitBatchInfo.systemLogs = Utils.encodePacked(correctL2Logs); + + // IExecutor.CommitBatchInfo[] memory correctCommitBatchInfoArray = new IExecutor.CommitBatchInfo[](1); + // correctCommitBatchInfoArray[0] = correctNewCommitBatchInfo; + // correctCommitBatchInfoArray[0].operatorDAInput = pubdataCommitment; - IExecutor.CommitBatchInfo[] memory correctCommitBatchInfoArray = new IExecutor.CommitBatchInfo[](1); - correctCommitBatchInfoArray[0] = correctNewCommitBatchInfo; - correctCommitBatchInfoArray[0].operatorDAInput = pubdataCommitment; + // vm.prank(validator); - vm.prank(validator); + // vm.expectRevert(bytes("lh")); + // executor.commitBatches(genesisStoredBatchInfo, correctCommitBatchInfoArray); - vm.expectRevert(bytes("bh")); - executor.commitBatches(genesisStoredBatchInfo, correctCommitBatchInfoArray); + // vm.clearMockedCalls(); + // } - vm.clearMockedCalls(); - } + // function test_RevertWhen_BlobDoesNotExist() public { + // bytes + // memory pubdataCommitment = "\x01\xf4\x3d\x53\x8d\x91\xd4\x77\xb0\xf8\xf7\x7e\x19\x52\x48\x7f\x00\xb8\xdf\x41\xda\x90\x5c\x08\x75\xc5\xc9\x9b\xa1\x92\x26\x84\x0d\x0d\x0a\x25\x26\xee\x22\xc7\x96\x60\x65\x7c\xbe\x01\x95\x33\x5b\x44\x69\xbd\x92\x94\x6f\x7f\x74\xae\xc5\xce\xef\x31\xf4\x32\x53\xd4\x08\x96\x72\x65\xfa\x85\x5a\xc8\xa0\x0a\x19\x52\x93\x6e\x0f\xe9\x97\x01\xc0\xa4\x32\xa1\x32\x2c\x45\x67\x24\xf7\xad\xd8\xa5\xb4\x7a\x51\xda\x52\x17\x06\x06\x95\x34\x61\xab\xd7\x5b\x91\x49\xc7\xc7\x91\xf4\x07\xfd\xbc\xf8\x39\x53\x2c\xb1\x08\xe8\xa5\x00\x64\x40\xcf\x21\xbf\x68\x87\x20\x5a\xcf\x44\x3b\x66\x3a\x57\xf2"; + // bytes32 versionedHash1 = 0xf39a869f62e75cf5f0bf914688a6b289caf2049435d8e68c5c5e6d05e44913f3; + + // vm.mockCall(blobVersionedHashRetriever, abi.encode(uint256(0)), abi.encode(bytes32(0))); + + // bytes[] memory correctL2Logs = Utils.createSystemLogs(); + // correctL2Logs[uint256(SystemLogKey.PACKED_BATCH_AND_L2_BLOCK_TIMESTAMP_KEY)] = Utils.constructL2Log( + // true, + // L2_SYSTEM_CONTEXT_ADDRESS, + // uint256(SystemLogKey.PACKED_BATCH_AND_L2_BLOCK_TIMESTAMP_KEY), + // Utils.packBatchTimestampAndBlockTimestamp(currentTimestamp, currentTimestamp) + // ); + + // correctL2Logs[uint256(SystemLogKey.BLOB_ONE_HASH_KEY)] = Utils.constructL2Log( + // true, + // L2_PUBDATA_CHUNK_PUBLISHER_ADDR, + // uint256(SystemLogKey.BLOB_ONE_HASH_KEY), + // versionedHash1 + // ); + + // IExecutor.CommitBatchInfo memory correctNewCommitBatchInfo = newCommitBatchInfo; + // correctNewCommitBatchInfo.systemLogs = Utils.encodePacked(correctL2Logs); + + // IExecutor.CommitBatchInfo[] memory correctCommitBatchInfoArray = new IExecutor.CommitBatchInfo[](1); + // correctCommitBatchInfoArray[0] = correctNewCommitBatchInfo; + // correctCommitBatchInfoArray[0].operatorDAInput = pubdataCommitment; + + // vm.prank(validator); + + // vm.expectRevert(bytes("vh")); + // executor.commitBatches(genesisStoredBatchInfo, correctCommitBatchInfoArray); + + // vm.clearMockedCalls(); + // } + + // function test_RevertWhen_SecondBlobSentWithoutCommitmentData() public { + // bytes + // memory pubdataCommitment = "\x01\xf4\x3d\x53\x8d\x91\xd4\x77\xb0\xf8\xf7\x7e\x19\x52\x48\x7f\x00\xb8\xdf\x41\xda\x90\x5c\x08\x75\xc5\xc9\x9b\xa1\x92\x26\x84\x0d\x0d\x0a\x25\x26\xee\x22\xc7\x96\x60\x65\x7c\xbe\x01\x95\x33\x5b\x44\x69\xbd\x92\x94\x6f\x7f\x74\xae\xc5\xce\xef\x31\xf4\x32\x53\xd4\x08\x96\x72\x65\xfa\x85\x5a\xc8\xa0\x0a\x19\x52\x93\x6e\x0f\xe9\x97\x01\xc0\xa4\x32\xa1\x32\x2c\x45\x67\x24\xf7\xad\xd8\xa5\xb4\x7a\x51\xda\x52\x17\x06\x06\x95\x34\x61\xab\xd7\x5b\x91\x49\xc7\xc7\x91\xf4\x07\xfd\xbc\xf8\x39\x53\x2c\xb1\x08\xe8\xa5\x00\x64\x40\xcf\x21\xbf\x68\x87\x20\x5a\xcf\x44\x3b\x66\x3a\x57\xf2"; + // bytes32 versionedHash1 = 0xf39a869f62e75cf5f0bf914688a6b289caf2049435d8e68c5c5e6d05e44913f3; + + // vm.mockCall(blobVersionedHashRetriever, abi.encode(uint256(0)), abi.encode(versionedHash1)); + + // vm.mockCall(blobVersionedHashRetriever, abi.encode(uint256(1)), abi.encode(versionedHash1)); + + // vm.mockCall( + // POINT_EVALUATION_PRECOMPILE_ADDR, + // "\xf3\x9a\x86\x9f\x62\xe7\x5c\xf5\xf0\xbf\x91\x46\x88\xa6\xb2\x89\xca\xf2\x04\x94\x35\xd8\xe6\x8c\x5c\x5e\x6d\x05\xe4\x49\x13\xf3\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xf4\x3d\x53\x8d\x91\xd4\x77\xb0\xf8\xf7\x7e\x19\x52\x48\x7f\x00\xb8\xdf\x41\xda\x90\x5c\x08\x75\xc5\xc9\x9b\xa1\x92\x26\x84\x0d\x0d\x0a\x25\x26\xee\x22\xc7\x96\x60\x65\x7c\xbe\x01\x95\x33\x5b\x44\x69\xbd\x92\x94\x6f\x7f\x74\xae\xc5\xce\xef\x31\xf4\x32\x53\xd4\x08\x96\x72\x65\xfa\x85\x5a\xc8\xa0\x0a\x19\x52\x93\x6e\x0f\xe9\x97\x01\xc0\xa4\x32\xa1\x32\x2c\x45\x67\x24\xf7\xad\xd8\xa5\xb4\x7a\x51\xda\x52\x17\x06\x06\x95\x34\x61\xab\xd7\x5b\x91\x49\xc7\xc7\x91\xf4\x07\xfd\xbc\xf8\x39\x53\x2c\xb1\x08\xe8\xa5\x00\x64\x40\xcf\x21\xbf\x68\x87\x20\x5a\xcf\x44\x3b\x66\x3a\x57\xf2", + // "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x10\x00\x73\xed\xa7\x53\x29\x9d\x7d\x48\x33\x39\xd8\x08\x09\xa1\xd8\x05\x53\xbd\xa4\x02\xff\xfe\x5b\xfe\xff\xff\xff\xff\x00\x00\x00\x01" + // ); + + // bytes[] memory correctL2Logs = Utils.createSystemLogs(); + // correctL2Logs[uint256(SystemLogKey.PACKED_BATCH_AND_L2_BLOCK_TIMESTAMP_KEY)] = Utils.constructL2Log( + // true, + // L2_SYSTEM_CONTEXT_ADDRESS, + // uint256(SystemLogKey.PACKED_BATCH_AND_L2_BLOCK_TIMESTAMP_KEY), + // Utils.packBatchTimestampAndBlockTimestamp(currentTimestamp, currentTimestamp) + // ); + + // correctL2Logs[uint256(SystemLogKey.BLOB_ONE_HASH_KEY)] = Utils.constructL2Log( + // true, + // L2_PUBDATA_CHUNK_PUBLISHER_ADDR, + // uint256(SystemLogKey.BLOB_ONE_HASH_KEY), + // versionedHash1 + // ); + + // IExecutor.CommitBatchInfo memory correctNewCommitBatchInfo = newCommitBatchInfo; + // correctNewCommitBatchInfo.systemLogs = Utils.encodePacked(correctL2Logs); + + // IExecutor.CommitBatchInfo[] memory correctCommitBatchInfoArray = new IExecutor.CommitBatchInfo[](1); + // correctCommitBatchInfoArray[0] = correctNewCommitBatchInfo; + // correctCommitBatchInfoArray[0].operatorDAInput = pubdataCommitment; + + // vm.prank(validator); + + // vm.expectRevert(bytes("lh")); + // executor.commitBatches(genesisStoredBatchInfo, correctCommitBatchInfoArray); + + // vm.clearMockedCalls(); + // } + + // function test_RevertWhen_SecondBlobLinearHashZeroWithCommitment() public { + // bytes + // memory pubdataCommitment = "\x01\xf4\x3d\x53\x8d\x91\xd4\x77\xb0\xf8\xf7\x7e\x19\x52\x48\x7f\x00\xb8\xdf\x41\xda\x90\x5c\x08\x75\xc5\xc9\x9b\xa1\x92\x26\x84\x0d\x0d\x0a\x25\x26\xee\x22\xc7\x96\x60\x65\x7c\xbe\x01\x95\x33\x5b\x44\x69\xbd\x92\x94\x6f\x7f\x74\xae\xc5\xce\xef\x31\xf4\x32\x53\xd4\x08\x96\x72\x65\xfa\x85\x5a\xc8\xa0\x0a\x19\x52\x93\x6e\x0f\xe9\x97\x01\xc0\xa4\x32\xa1\x32\x2c\x45\x67\x24\xf7\xad\xd8\xa5\xb4\x7a\x51\xda\x52\x17\x06\x06\x95\x34\x61\xab\xd7\x5b\x91\x49\xc7\xc7\x91\xf4\x07\xfd\xbc\xf8\x39\x53\x2c\xb1\x08\xe8\xa5\x00\x64\x40\xcf\x21\xbf\x68\x87\x20\x5a\xcf\x44\x3b\x66\x3a\x57\xf2\xf4\x3d\x53\x8d\x91\xd4\x77\xb0\xf8\xf7\x7e\x19\x52\x48\x7f\x00\xb8\xdf\x41\xda\x90\x5c\x08\x75\xc5\xc9\x9b\xa1\x92\x26\x84\x0d\x0d\x0a\x25\x26\xee\x22\xc7\x96\x60\x65\x7c\xbe\x01\x95\x33\x5b\x44\x69\xbd\x92\x94\x6f\x7f\x74\xae\xc5\xce\xef\x31\xf4\x32\x53\xd4\x08\x96\x72\x65\xfa\x85\x5a\xc8\xa0\x0a\x19\x52\x93\x6e\x0f\xe9\x97\x01\xc0\xa4\x32\xa1\x32\x2c\x45\x67\x24\xf7\xad\xd8\xa5\xb4\x7a\x51\xda\x52\x17\x06\x06\x95\x34\x61\xab\xd7\x5b\x91\x49\xc7\xc7\x91\xf4\x07\xfd\xbc\xf8\x39\x53\x2c\xb1\x08\xe8\xa5\x00\x64\x40\xcf\x21\xbf\x68\x87\x20\x5a\xcf\x44\x3b\x66\x3a\x57\xf2"; + // bytes32 versionedHash1 = 0xf39a869f62e75cf5f0bf914688a6b289caf2049435d8e68c5c5e6d05e44913f3; + // bytes32 versionedHash2 = 0x290decd9548b62a8d60345a988386fc84ba6bc95484008f6362f93160ef3e563; + + // vm.mockCall(blobVersionedHashRetriever, abi.encode(uint256(0)), abi.encode(versionedHash1)); + + // vm.mockCall(blobVersionedHashRetriever, abi.encode(uint256(0)), abi.encode(versionedHash1)); + + // vm.mockCall(blobVersionedHashRetriever, abi.encode(uint256(1)), abi.encode(versionedHash2)); + + // vm.mockCall(blobVersionedHashRetriever, abi.encode(uint256(2)), abi.encode(bytes32(0))); + + // vm.mockCall( + // POINT_EVALUATION_PRECOMPILE_ADDR, + // "\xf3\x9a\x86\x9f\x62\xe7\x5c\xf5\xf0\xbf\x91\x46\x88\xa6\xb2\x89\xca\xf2\x04\x94\x35\xd8\xe6\x8c\x5c\x5e\x6d\x05\xe4\x49\x13\xf3\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xf4\x3d\x53\x8d\x91\xd4\x77\xb0\xf8\xf7\x7e\x19\x52\x48\x7f\x00\xb8\xdf\x41\xda\x90\x5c\x08\x75\xc5\xc9\x9b\xa1\x92\x26\x84\x0d\x0d\x0a\x25\x26\xee\x22\xc7\x96\x60\x65\x7c\xbe\x01\x95\x33\x5b\x44\x69\xbd\x92\x94\x6f\x7f\x74\xae\xc5\xce\xef\x31\xf4\x32\x53\xd4\x08\x96\x72\x65\xfa\x85\x5a\xc8\xa0\x0a\x19\x52\x93\x6e\x0f\xe9\x97\x01\xc0\xa4\x32\xa1\x32\x2c\x45\x67\x24\xf7\xad\xd8\xa5\xb4\x7a\x51\xda\x52\x17\x06\x06\x95\x34\x61\xab\xd7\x5b\x91\x49\xc7\xc7\x91\xf4\x07\xfd\xbc\xf8\x39\x53\x2c\xb1\x08\xe8\xa5\x00\x64\x40\xcf\x21\xbf\x68\x87\x20\x5a\xcf\x44\x3b\x66\x3a\x57\xf2", + // "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x10\x00\x73\xed\xa7\x53\x29\x9d\x7d\x48\x33\x39\xd8\x08\x09\xa1\xd8\x05\x53\xbd\xa4\x02\xff\xfe\x5b\xfe\xff\xff\xff\xff\x00\x00\x00\x01" + // ); + + // vm.mockCall( + // POINT_EVALUATION_PRECOMPILE_ADDR, + // "\x29\x0d\xec\xd9\x54\x8b\x62\xa8\xd6\x03\x45\xa9\x88\x38\x6f\xc8\x4b\xa6\xbc\x95\x48\x40\x08\xf6\x36\x2f\x93\x16\x0e\xf3\xe5\x63\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xf4\x3d\x53\x8d\x91\xd4\x77\xb0\xf8\xf7\x7e\x19\x52\x48\x7f\x00\xb8\xdf\x41\xda\x90\x5c\x08\x75\xc5\xc9\x9b\xa1\x92\x26\x84\x0d\x0d\x0a\x25\x26\xee\x22\xc7\x96\x60\x65\x7c\xbe\x01\x95\x33\x5b\x44\x69\xbd\x92\x94\x6f\x7f\x74\xae\xc5\xce\xef\x31\xf4\x32\x53\xd4\x08\x96\x72\x65\xfa\x85\x5a\xc8\xa0\x0a\x19\x52\x93\x6e\x0f\xe9\x97\x01\xc0\xa4\x32\xa1\x32\x2c\x45\x67\x24\xf7\xad\xd8\xa5\xb4\x7a\x51\xda\x52\x17\x06\x06\x95\x34\x61\xab\xd7\x5b\x91\x49\xc7\xc7\x91\xf4\x07\xfd\xbc\xf8\x39\x53\x2c\xb1\x08\xe8\xa5\x00\x64\x40\xcf\x21\xbf\x68\x87\x20\x5a\xcf\x44\x3b\x66\x3a\x57\xf2", + // "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x10\x00\x73\xed\xa7\x53\x29\x9d\x7d\x48\x33\x39\xd8\x08\x09\xa1\xd8\x05\x53\xbd\xa4\x02\xff\xfe\x5b\xfe\xff\xff\xff\xff\x00\x00\x00\x01" + // ); + + // bytes[] memory correctL2Logs = Utils.createSystemLogs(); + // correctL2Logs[uint256(SystemLogKey.PACKED_BATCH_AND_L2_BLOCK_TIMESTAMP_KEY)] = Utils.constructL2Log( + // true, + // L2_SYSTEM_CONTEXT_ADDRESS, + // uint256(SystemLogKey.PACKED_BATCH_AND_L2_BLOCK_TIMESTAMP_KEY), + // Utils.packBatchTimestampAndBlockTimestamp(currentTimestamp, currentTimestamp) + // ); + + // correctL2Logs[uint256(SystemLogKey.BLOB_ONE_HASH_KEY)] = Utils.constructL2Log( + // true, + // L2_PUBDATA_CHUNK_PUBLISHER_ADDR, + // uint256(SystemLogKey.BLOB_ONE_HASH_KEY), + // versionedHash1 + // ); + + // correctL2Logs[uint256(SystemLogKey.BLOB_TWO_HASH_KEY)] = Utils.constructL2Log( + // true, + // L2_PUBDATA_CHUNK_PUBLISHER_ADDR, + // uint256(SystemLogKey.BLOB_TWO_HASH_KEY), + // bytes32(0) + // ); + + // IExecutor.CommitBatchInfo memory correctNewCommitBatchInfo = newCommitBatchInfo; + // correctNewCommitBatchInfo.systemLogs = Utils.encodePacked(correctL2Logs); + + // IExecutor.CommitBatchInfo[] memory correctCommitBatchInfoArray = new IExecutor.CommitBatchInfo[](1); + // correctCommitBatchInfoArray[0] = correctNewCommitBatchInfo; + // correctCommitBatchInfoArray[0].operatorDAInput = pubdataCommitment; + + // vm.prank(validator); + + // vm.expectRevert(bytes("bh")); + // executor.commitBatches(genesisStoredBatchInfo, correctCommitBatchInfoArray); + // } + + // function test_RevertWhen_SecondBlobLinearHashNotZeroWithEmptyCommitment() public { + // bytes + // memory pubdataCommitment = "\x01\xf4\x3d\x53\x8d\x91\xd4\x77\xb0\xf8\xf7\x7e\x19\x52\x48\x7f\x00\xb8\xdf\x41\xda\x90\x5c\x08\x75\xc5\xc9\x9b\xa1\x92\x26\x84\x0d\x0d\x0a\x25\x26\xee\x22\xc7\x96\x60\x65\x7c\xbe\x01\x95\x33\x5b\x44\x69\xbd\x92\x94\x6f\x7f\x74\xae\xc5\xce\xef\x31\xf4\x32\x53\xd4\x08\x96\x72\x65\xfa\x85\x5a\xc8\xa0\x0a\x19\x52\x93\x6e\x0f\xe9\x97\x01\xc0\xa4\x32\xa1\x32\x2c\x45\x67\x24\xf7\xad\xd8\xa5\xb4\x7a\x51\xda\x52\x17\x06\x06\x95\x34\x61\xab\xd7\x5b\x91\x49\xc7\xc7\x91\xf4\x07\xfd\xbc\xf8\x39\x53\x2c\xb1\x08\xe8\xa5\x00\x64\x40\xcf\x21\xbf\x68\x87\x20\x5a\xcf\x44\x3b\x66\x3a\x57\xf2"; + // bytes32 versionedHash1 = 0xf39a869f62e75cf5f0bf914688a6b289caf2049435d8e68c5c5e6d05e44913f3; + + // vm.mockCall(blobVersionedHashRetriever, abi.encode(uint256(0)), abi.encode(versionedHash1)); + + // vm.mockCall(blobVersionedHashRetriever, abi.encode(uint256(1)), abi.encode(bytes32(0))); + + // vm.mockCall( + // POINT_EVALUATION_PRECOMPILE_ADDR, + // "\xf3\x9a\x86\x9f\x62\xe7\x5c\xf5\xf0\xbf\x91\x46\x88\xa6\xb2\x89\xca\xf2\x04\x94\x35\xd8\xe6\x8c\x5c\x5e\x6d\x05\xe4\x49\x13\xf3\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xf4\x3d\x53\x8d\x91\xd4\x77\xb0\xf8\xf7\x7e\x19\x52\x48\x7f\x00\xb8\xdf\x41\xda\x90\x5c\x08\x75\xc5\xc9\x9b\xa1\x92\x26\x84\x0d\x0d\x0a\x25\x26\xee\x22\xc7\x96\x60\x65\x7c\xbe\x01\x95\x33\x5b\x44\x69\xbd\x92\x94\x6f\x7f\x74\xae\xc5\xce\xef\x31\xf4\x32\x53\xd4\x08\x96\x72\x65\xfa\x85\x5a\xc8\xa0\x0a\x19\x52\x93\x6e\x0f\xe9\x97\x01\xc0\xa4\x32\xa1\x32\x2c\x45\x67\x24\xf7\xad\xd8\xa5\xb4\x7a\x51\xda\x52\x17\x06\x06\x95\x34\x61\xab\xd7\x5b\x91\x49\xc7\xc7\x91\xf4\x07\xfd\xbc\xf8\x39\x53\x2c\xb1\x08\xe8\xa5\x00\x64\x40\xcf\x21\xbf\x68\x87\x20\x5a\xcf\x44\x3b\x66\x3a\x57\xf2", + // "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x10\x00\x73\xed\xa7\x53\x29\x9d\x7d\x48\x33\x39\xd8\x08\x09\xa1\xd8\x05\x53\xbd\xa4\x02\xff\xfe\x5b\xfe\xff\xff\xff\xff\x00\x00\x00\x01" + // ); + + // bytes[] memory correctL2Logs = Utils.createSystemLogs(); + // correctL2Logs[uint256(SystemLogKey.PACKED_BATCH_AND_L2_BLOCK_TIMESTAMP_KEY)] = Utils.constructL2Log( + // true, + // L2_SYSTEM_CONTEXT_ADDRESS, + // uint256(SystemLogKey.PACKED_BATCH_AND_L2_BLOCK_TIMESTAMP_KEY), + // Utils.packBatchTimestampAndBlockTimestamp(currentTimestamp, currentTimestamp) + // ); + + // correctL2Logs[uint256(SystemLogKey.BLOB_ONE_HASH_KEY)] = Utils.constructL2Log( + // true, + // L2_PUBDATA_CHUNK_PUBLISHER_ADDR, + // uint256(SystemLogKey.BLOB_ONE_HASH_KEY), + // versionedHash1 + // ); + + // correctL2Logs[uint256(SystemLogKey.BLOB_TWO_HASH_KEY)] = Utils.constructL2Log( + // true, + // L2_PUBDATA_CHUNK_PUBLISHER_ADDR, + // uint256(SystemLogKey.BLOB_TWO_HASH_KEY), + // versionedHash1 + // ); + + // IExecutor.CommitBatchInfo memory correctNewCommitBatchInfo = newCommitBatchInfo; + // correctNewCommitBatchInfo.systemLogs = Utils.encodePacked(correctL2Logs); + + // IExecutor.CommitBatchInfo[] memory correctCommitBatchInfoArray = new IExecutor.CommitBatchInfo[](1); + // correctCommitBatchInfoArray[0] = correctNewCommitBatchInfo; + // correctCommitBatchInfoArray[0].operatorDAInput = pubdataCommitment; + + // vm.prank(validator); + + // vm.expectRevert(bytes("bh")); + // executor.commitBatches(genesisStoredBatchInfo, correctCommitBatchInfoArray); + + // vm.clearMockedCalls(); + // } } diff --git a/l1-contracts/test/foundry/unit/concrete/Executor/ExecutorProof.t.sol b/l1-contracts/test/foundry/unit/concrete/Executor/ExecutorProof.t.sol index 516d8024a..f15b93177 100644 --- a/l1-contracts/test/foundry/unit/concrete/Executor/ExecutorProof.t.sol +++ b/l1-contracts/test/foundry/unit/concrete/Executor/ExecutorProof.t.sol @@ -71,59 +71,59 @@ contract ExecutorProofTest is Test { executor = TestExecutorFacet(diamondProxy); utilsFacet = UtilsFacet(diamondProxy); } - + // todo /// This test is based on a block generated in a local system. - function test_Hashes() public { - utilsFacet.util_setL2DefaultAccountBytecodeHash( - 0x0100065d134a862a777e50059f5e0fbe68b583f3617a67820f7edda0d7f253a0 - ); - utilsFacet.util_setL2BootloaderBytecodeHash(0x010009416e909e0819593a9806bbc841d25c5cdfed3f4a1523497c6814e5194a); - utilsFacet.util_setZkPorterAvailability(false); + // function test_Hashes() public { + // utilsFacet.util_setL2DefaultAccountBytecodeHash( + // 0x0100065d134a862a777e50059f5e0fbe68b583f3617a67820f7edda0d7f253a0 + // ); + // utilsFacet.util_setL2BootloaderBytecodeHash(0x010009416e909e0819593a9806bbc841d25c5cdfed3f4a1523497c6814e5194a); + // utilsFacet.util_setZkPorterAvailability(false); - IExecutor.CommitBatchInfo memory nextBatch = IExecutor.CommitBatchInfo({ - // ignored - batchNumber: 1, - // ignored - timestamp: 100, - indexRepeatedStorageChanges: 84, - newStateRoot: 0x9cf7bb72401a56039ca097cabed20a72221c944ed9b0e515c083c04663ab45a6, - // ignored - numberOfLayer1Txs: 10, - // ignored - priorityOperationsHash: 0x167f4ca80269c9520ad951eeeda28dd3deb0715e9e2917461e81a60120a14183, - bootloaderHeapInitialContentsHash: 0x540442e48142fa061a81822184f7790e7b69dea92153d38ef623802c6f0411c0, - eventsQueueStateHash: 0xda42ab7994d4695a25f4ea8a9a485a592b7a31c20d5dae6363828de86d8826ea, - systemLogs: abi.encodePacked( - hex"00000000000000000000000000000000000000000000800b000000000000000000000000000000000000000000000000000000000000000416914ac26bb9cafa0f1dfaeaab10745a9094e1b60c7076fedf21651d6a25b5740000000a000000000000000000000000000000000000800b0000000000000000000000000000000000000000000000000000000000000003000000000000000000000000651bcde0000000000000000000000000651bcde20001000a00000000000000000000000000000000000080010000000000000000000000000000000000000000000000000000000000000005167f4ca80269c9520ad951eeeda28dd3deb0715e9e2917461e81a60120a141830001000a00000000000000000000000000000000000080010000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000a0001000a00000000000000000000000000000000000080080000000000000000000000000000000000000000000000000000000000000000ee6ee8f50659bd8be3d86c32efb02baa5571cf3b46dd7ea3db733ae181747b8b0001000a0000000000000000000000000000000000008008000000000000000000000000000000000000000000000000000000000000000160fc5fb513ca8e6f6232a7410797954dcb6edbf9081768da24b483aca91c54db0001000a000000000000000000000000000000000000800800000000000000000000000000000000000000000000000000000000000000029a67073c2df8f53087fcfc32d82c98bba591da35df6ce1fb55a23b677d37f9fc000000000000000000000000000000000000000000008011000000000000000000000000000000000000000000000000000000000000000700000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000080110000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000801100000000000000000000000000000000000000000000000000000000000000090000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008011000000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008011000000000000000000000000000000000000000000000000000000000000000b0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008011000000000000000000000000000000000000000000000000000000000000000c0000000000000000000000000000000000000000000000000000000000000000" - ), - operatorDAInput: abi.encodePacked( - hex"000000000a000100000000000000000000000000000000000000008001760f6100ddbd86c4d5a58532923e7424d33ffb44145a26171d9b2595a349450b0000000000000000000000000000000000000000000000000000000000000001000100010000000000000000000000000000000000008001a789fe4e2a955eee45d44f408f86203c8f643910bf4888d1fd1465cdbc6376d800000000000000000000000000000000000000000000000000000000000000010001000200000000000000000000000000000000000080016ba43e7c7df11e5a655f22c9bce1b37434afd2bf8fcdb10100a460e6a2c0cc83000000000000000000000000000000000000000000000000000000000000000100010003000000000000000000000000000000000000800156e569838658c17c756aa9f6e40de8f1c41b1a67fea5214ec47869882ecda9bd0000000000000000000000000000000000000000000000000000000000000001000100040000000000000000000000000000000000008001ab5d064ba75c02635fd6e4de7fd8420eda54c4bda05bd61edabe201f2066d38f00000000000000000000000000000000000000000000000000000000000000010001000500000000000000000000000000000000000080015bcb6d7c735023e0884297db5016a6c704e3490ed0671417639313ecea86795b00000000000000000000000000000000000000000000000000000000000000010001000600000000000000000000000000000000000080015ee51b5b7d47fae5811a9f777174bb08d81d78098c8bd9430a7618756a0ceb8b00000000000000000000000000000000000000000000000000000000000000010001000700000000000000000000000000000000000080011ea63171021b9ab0846efbe0a06f7882d76e24a4900c74c14fa1e0bdf313ed560000000000000000000000000000000000000000000000000000000000000001000100080000000000000000000000000000000000008001574537f1665cd9c894d8d9834d32ed291f49ae1165a0e12a79a4937f2425bf70000000000000000000000000000000000000000000000000000000000000000100010009000000000000000000000000000000000000800190558033c8a3f7c20c81e613e00a9d0e678a7a14923e94e7cb99c8621c7918090000000000000000000000000000000000000000000000000000000000000001000000000000000001000c3104003d1291725c657fe486d0e626f562842175a705a9704c0980b40e3d716b95bbf9e8000100005dd96deb789fbc05264165795bf652190645bfae1ce253ce1db17087a898fb1e240ebf0d53563011198fddab33312923ba20f3c56cf1ba18ca5be9c053000100022bd65a924da61271d1dd5080fc640601185125830805e0ceb42f4185e5118fb454a12a3d9e0c1fbb89230f67044cc191e4f18459261233f659c9e2ba5e000100008b9feb52993729436da78b2863dd56d8d757e19c01a2cdcf1940e45ca9979941fa93f5f699afeab75e8b25cfea22004a8d2ea49f057741c2f2b910996d00010001bdf9205fb9bd185829f2c6bec2a6f100b86eff579da4fc2a8f1a15ea4afee3cea48e96b9bddb544b4569e60736a1f1fe919e223fcc08f74acf3513be1200010001bdf9205fb9bd185829f2c6bec2a6f100b86eff579da4fc2a8f1a15ea4a8755061217b6a78f5d5f8af6e326e482ebdc57f7144108662d122252ddcc27e7000100045dddc527887dc39b9cd189d6f183f16217393a5d3d3165fead2daeaf4f2d6916280c572561a809555de4a87d7a56d5bcca2c246a389dbb2a24c5639bdb0001000153c0f36532563ba2a10f52b865e558cd1a5eef9a9edd01c1cb23b74aa772beb4f3e3b784609f4e205a09863c0587e63b4b47664022cb34896a1711416b00010003e7842b0b4f4fd8e665883fe9c158ba8d38347840f1da0a75aca1fc284ce2428454b48df9f5551500fc50b63af4741b1cd21d4cfddc69aa46cb78eff45b00010000f183703a165afed04326ad5786316f6fc65b27f1cf17459a52bd1f57f27f896b7429e070ca76e3e33165ec75f6c9f439ee37f3b58822494b1251c8247500010001bdf9205fb9bd185829f2c6bec2a6f100b86eff579da4fc2a8f1a15ea4a05ea3d0bb218598c42b2e25ae5f6cbc9369b273ee6610450cade89775646b2a08902000000000000000000000000000000008b71d4a184058d07fccac4348ae02a1f663403231b0a40fa2c8c0ff73bdca092890200000000000000000000000000000000ab63c4cebbd508a7d7184f0b9134453eea7a09ca749610d5576f8046241b9cde890200000000000000000000000000000000e58af14be53d8ac56f58ff3e5b07c239bfb549149f067597e9d028f35e3c2b77890200000000000000000000000000000000b78e94980fec3a5f68aa25d0d934084907688e537e82c2942af905aab21413ab890200000000000000000000000000000000c4db460819691e825328b532024bbecdc40394c74307a00bd245fc658b1bd34f0901908827f2052a14b24a10cae1f9e259ead06a89a1d74ff736a54f54ebcf05eeb30901d32d07305b87debd25698d4dfac4c2f986693a4e9d9baff7da37a7b5ca8d01cb0901e73042e5dacff2ce20a720c9c6d694576e4afa7bbbafdc4d409c63b7ca8027b70901760a7405795441aceea3be649a53d02785cb3487b7bd23e3b4888a935cee010d09011f3acf5d6d7bfeab8a7112771866e28c3714e0c315a81ec6a58ab4ad1c3d6eb10901c207b49d14deb3af9bc960d57074e27386285c73248abc5fa1d72aa6e8664fa40901644f0c4e15446d7e5ff363c944b55bd6801a1f38afd984c3427569530cb663210901743be0243628b8e7e8f04c00fc4f88efae001250a7482b31e6a0ec87ee3598e7090171e91721f9918576d760f02f03cac47c6f4003316031848e3c1d99e6e83a47434102d84e69f2f480002d5a6962cccee5d4adb48a36bbbf443a531721484381125937f3001ac5ff875b41022f496efbbdb2007b727eb806c926fb20c8ad087c57422977cebd06373e26d19b640e5fe32c85ff39a904faf736ce00a25420c1d9d705358c134cc601d9d184cb4dfdde7e1cac2bc3d4d38bf9ec44e6210ee6b280123bafc586f77764488cd24c6a77546e5a0fe8bdfb4fa203cfaffc36cce4dd5b8901000000000000000000000000651bcde08e7dd06ac5b73b473be6bc5a51030f4c7437657cb7b29bf376c564b8d1675a5e8903000000000000000000000000651bcde24ba84e1f37d041bc6e55ba396826cc494e84d4815b6db52690422eea7386314f00e8e77626586f73b955364c7b4bbf0bb7f7685ebd40e852b164633a4acbd3244c3de2202ccb626ad387d70722e64fbe44562e2f231a290c08532b8d6aba402ff50025fe002039e87b424de2772b82d935f14e2b657429a1bcc04612391ea0330c90ebddefdda48eb2aa7f66ecf7940a280e9ef3fb2e95db0995538440a62af79861004434720529e816fd2e40f8031a8d7471ebcd00351db0787346bcfe8dfad8d2b479093588d0e847efa73a10ce20e4799fb1e46642d65617c7e5213fa04989d92d8903000000000000000000000000651bcde287ded247e1660f827071c7f1371934589751085384fc9f4462c1f1897c5c3eef890100000000000000000000000000000001911dd2ad743ff237d411648a0fe32c6d74eec060716a2a74352f6b1c435b5d670016914ac26bb9cafa0f1dfaeaab10745a9094e1b60c7076fedf21651d6a25b574686a068c708f1bdbefd9e6e454ac2b520fd41c8dcf23ecd4cee978c22f1c1f5f09ff974fe8b575175cefa919a5ba1c0ddf4409be4b16695dc7bd12f6701b99bd2e70a152312ad6f01657413b2eae9287f6b9adad93d5fed1a0dd5e13ec74ce1163146509bfe426f2315a69cb452bf388cccd321eca2746a1adf793b489e5c8f61c40688b7ef3e53defc56c78facf513e511f9f5ba0eb50dbcc745afea3b860da75b394d2d1627b6e2ef54fb7b187d0af61e4532c238f387ecf9f0b466f1d54414100018e519b65c8901b344a480638beadb923fbd3462e475d39acebe559d65ed5cb11a1b25279f1918477c35eec1332ff07001d3f85cf854b70d7552f93ba8e88d581064ca4c0df6ac456c00a0e83898ccd464c63e5008aa1a498cc0646b78eb216d9eeeec76ed0eb0ee6c352f35ca5f0b2edc2ca17d211cc5cb905ba10142f042a6ac836d9cef9a6916635c9a1c1d2dc62a9fe83e2230b506b98e0fded46249008fe28b813907a05ae0d773d8f31e330200e9336e0159034c137ed645fb67ccca8a152312ad6f01657413b2eae9287f6b9adad93d5fee5d8f810abde496ccbeb45a4f3c06af828975163a006257cbf18cefebbfb4cd409025f40404a3d37bba024799ce32d7c2a833aec8474288a26b246afa32b07b4a3ce00577261707065642045746865720000000000000000000000000000000000001a09cf14f266dfe87c4b33e6d934de01f8f7242199fa8783178117218fa033f7ab005745544800000000000000000000000000000000000000000000000000000008289026c5fa173652bd62774824698a6848c63031f853d0e275174552f35df33000577261707065642045746865720000000000000000000000000000000000001a1e59309944cbc900ae848855e10bc929f78e86c2179d6e96cf52bfd520f039200031000000000000000000000000000000000000000000000000000000000000021653a735395136e5494c5426ba972b45e34d36ebcb86ac104c724ab375fcce90a18580ba6aeebc6e6b89d226c79be8927257a436ad11d9c0305b18e9d78cab8f75a3aec2096302b67e3815939e29476fb36a0d8299a1b25279f1918477c35eec1332ff07001d3f85cf85688525f98e4859a9c6939f2d2f92e6b1950ed57e56137d717aca1ccf9754f719a1c7ebe9226d26524400a8959a08f411a727ae7bb68f8febecd89ffe9d84708d24544d452de3e22e62b3b2b872e430839a15115818a152312ad6f01657413b2eae9287f6b9adad93d5fe3fb60af355125687beeb90c066ace76c442b0f963a6afd0e3316fcdd673ad22c09ff30c8a03ec44e5337a1f9d66763cf1b319fdc6d8bc4981e1f47edbd86210614b909ff0cbdceb634b81192417b64d114d535ad3bdba97d6d7e90ee2a79bf1c132d3c2d09ff5cd85060f4ff26eb5b68a6687aee76c1b7a77575fdc86ba49b4faf5041377a79b14de8989f2385a6e23f6bd05a80e0d9231870c15a000142e50adc0d84bff439d0086d9fbab9984f8b27aa208935238a60cc62e7c9bb2ea1709e94c96366b3c40ea4854837c18733e5ac1193b8d8e4070d2eca4441b0378b572bd949ab764fd71c002b759613c3e29d425cf4000100012730c940a81021004e899c6ee4bec02f0667757b9d75a8f0714ce6c157f5940b7664e4f69f01fc530db36965e33599a1348629f07ae2d724007ac36a71a16baac84db583d88e0f3a8c082e3632fcc0e15757f0dcf5234b87af41fdee4c0999c4fe698a8d824415979ab839e6913a975a3055a152312ad6f01657413b2eae9287f6b9adad93d5fe00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000" - ) - }); - LogProcessingOutput memory logOutput = executor.processL2Logs( - nextBatch, - 0x0000000000000000000000000000000000000000000000000000000000000000 - ); - assertEq( - logOutput.stateDiffHash, - 0x9a67073c2df8f53087fcfc32d82c98bba591da35df6ce1fb55a23b677d37f9fc, - "stateDiffHash computation failed" - ); + // IExecutor.CommitBatchInfo memory nextBatch = IExecutor.CommitBatchInfo({ + // // ignored + // batchNumber: 1, + // // ignored + // timestamp: 100, + // indexRepeatedStorageChanges: 84, + // newStateRoot: 0x9cf7bb72401a56039ca097cabed20a72221c944ed9b0e515c083c04663ab45a6, + // // ignored + // numberOfLayer1Txs: 10, + // // ignored + // priorityOperationsHash: 0x167f4ca80269c9520ad951eeeda28dd3deb0715e9e2917461e81a60120a14183, + // bootloaderHeapInitialContentsHash: 0x540442e48142fa061a81822184f7790e7b69dea92153d38ef623802c6f0411c0, + // eventsQueueStateHash: 0xda42ab7994d4695a25f4ea8a9a485a592b7a31c20d5dae6363828de86d8826ea, + // systemLogs: abi.encodePacked( + // hex"00000000000000000000000000000000000000000000800b000000000000000000000000000000000000000000000000000000000000000416914ac26bb9cafa0f1dfaeaab10745a9094e1b60c7076fedf21651d6a25b5740000000a000000000000000000000000000000000000800b0000000000000000000000000000000000000000000000000000000000000003000000000000000000000000651bcde0000000000000000000000000651bcde20001000a00000000000000000000000000000000000080010000000000000000000000000000000000000000000000000000000000000005167f4ca80269c9520ad951eeeda28dd3deb0715e9e2917461e81a60120a141830001000a00000000000000000000000000000000000080010000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000a0001000a00000000000000000000000000000000000080080000000000000000000000000000000000000000000000000000000000000000ee6ee8f50659bd8be3d86c32efb02baa5571cf3b46dd7ea3db733ae181747b8b0001000a0000000000000000000000000000000000008008000000000000000000000000000000000000000000000000000000000000000160fc5fb513ca8e6f6232a7410797954dcb6edbf9081768da24b483aca91c54db0001000a000000000000000000000000000000000000800800000000000000000000000000000000000000000000000000000000000000029a67073c2df8f53087fcfc32d82c98bba591da35df6ce1fb55a23b677d37f9fc000000000000000000000000000000000000000000008011000000000000000000000000000000000000000000000000000000000000000700000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000080110000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000801100000000000000000000000000000000000000000000000000000000000000090000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008011000000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008011000000000000000000000000000000000000000000000000000000000000000b0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008011000000000000000000000000000000000000000000000000000000000000000c0000000000000000000000000000000000000000000000000000000000000000" + // ), + // operatorDAInput: abi.encodePacked( + // hex"000000000a000100000000000000000000000000000000000000008001760f6100ddbd86c4d5a58532923e7424d33ffb44145a26171d9b2595a349450b0000000000000000000000000000000000000000000000000000000000000001000100010000000000000000000000000000000000008001a789fe4e2a955eee45d44f408f86203c8f643910bf4888d1fd1465cdbc6376d800000000000000000000000000000000000000000000000000000000000000010001000200000000000000000000000000000000000080016ba43e7c7df11e5a655f22c9bce1b37434afd2bf8fcdb10100a460e6a2c0cc83000000000000000000000000000000000000000000000000000000000000000100010003000000000000000000000000000000000000800156e569838658c17c756aa9f6e40de8f1c41b1a67fea5214ec47869882ecda9bd0000000000000000000000000000000000000000000000000000000000000001000100040000000000000000000000000000000000008001ab5d064ba75c02635fd6e4de7fd8420eda54c4bda05bd61edabe201f2066d38f00000000000000000000000000000000000000000000000000000000000000010001000500000000000000000000000000000000000080015bcb6d7c735023e0884297db5016a6c704e3490ed0671417639313ecea86795b00000000000000000000000000000000000000000000000000000000000000010001000600000000000000000000000000000000000080015ee51b5b7d47fae5811a9f777174bb08d81d78098c8bd9430a7618756a0ceb8b00000000000000000000000000000000000000000000000000000000000000010001000700000000000000000000000000000000000080011ea63171021b9ab0846efbe0a06f7882d76e24a4900c74c14fa1e0bdf313ed560000000000000000000000000000000000000000000000000000000000000001000100080000000000000000000000000000000000008001574537f1665cd9c894d8d9834d32ed291f49ae1165a0e12a79a4937f2425bf70000000000000000000000000000000000000000000000000000000000000000100010009000000000000000000000000000000000000800190558033c8a3f7c20c81e613e00a9d0e678a7a14923e94e7cb99c8621c7918090000000000000000000000000000000000000000000000000000000000000001000000000000000001000c3104003d1291725c657fe486d0e626f562842175a705a9704c0980b40e3d716b95bbf9e8000100005dd96deb789fbc05264165795bf652190645bfae1ce253ce1db17087a898fb1e240ebf0d53563011198fddab33312923ba20f3c56cf1ba18ca5be9c053000100022bd65a924da61271d1dd5080fc640601185125830805e0ceb42f4185e5118fb454a12a3d9e0c1fbb89230f67044cc191e4f18459261233f659c9e2ba5e000100008b9feb52993729436da78b2863dd56d8d757e19c01a2cdcf1940e45ca9979941fa93f5f699afeab75e8b25cfea22004a8d2ea49f057741c2f2b910996d00010001bdf9205fb9bd185829f2c6bec2a6f100b86eff579da4fc2a8f1a15ea4afee3cea48e96b9bddb544b4569e60736a1f1fe919e223fcc08f74acf3513be1200010001bdf9205fb9bd185829f2c6bec2a6f100b86eff579da4fc2a8f1a15ea4a8755061217b6a78f5d5f8af6e326e482ebdc57f7144108662d122252ddcc27e7000100045dddc527887dc39b9cd189d6f183f16217393a5d3d3165fead2daeaf4f2d6916280c572561a809555de4a87d7a56d5bcca2c246a389dbb2a24c5639bdb0001000153c0f36532563ba2a10f52b865e558cd1a5eef9a9edd01c1cb23b74aa772beb4f3e3b784609f4e205a09863c0587e63b4b47664022cb34896a1711416b00010003e7842b0b4f4fd8e665883fe9c158ba8d38347840f1da0a75aca1fc284ce2428454b48df9f5551500fc50b63af4741b1cd21d4cfddc69aa46cb78eff45b00010000f183703a165afed04326ad5786316f6fc65b27f1cf17459a52bd1f57f27f896b7429e070ca76e3e33165ec75f6c9f439ee37f3b58822494b1251c8247500010001bdf9205fb9bd185829f2c6bec2a6f100b86eff579da4fc2a8f1a15ea4a05ea3d0bb218598c42b2e25ae5f6cbc9369b273ee6610450cade89775646b2a08902000000000000000000000000000000008b71d4a184058d07fccac4348ae02a1f663403231b0a40fa2c8c0ff73bdca092890200000000000000000000000000000000ab63c4cebbd508a7d7184f0b9134453eea7a09ca749610d5576f8046241b9cde890200000000000000000000000000000000e58af14be53d8ac56f58ff3e5b07c239bfb549149f067597e9d028f35e3c2b77890200000000000000000000000000000000b78e94980fec3a5f68aa25d0d934084907688e537e82c2942af905aab21413ab890200000000000000000000000000000000c4db460819691e825328b532024bbecdc40394c74307a00bd245fc658b1bd34f0901908827f2052a14b24a10cae1f9e259ead06a89a1d74ff736a54f54ebcf05eeb30901d32d07305b87debd25698d4dfac4c2f986693a4e9d9baff7da37a7b5ca8d01cb0901e73042e5dacff2ce20a720c9c6d694576e4afa7bbbafdc4d409c63b7ca8027b70901760a7405795441aceea3be649a53d02785cb3487b7bd23e3b4888a935cee010d09011f3acf5d6d7bfeab8a7112771866e28c3714e0c315a81ec6a58ab4ad1c3d6eb10901c207b49d14deb3af9bc960d57074e27386285c73248abc5fa1d72aa6e8664fa40901644f0c4e15446d7e5ff363c944b55bd6801a1f38afd984c3427569530cb663210901743be0243628b8e7e8f04c00fc4f88efae001250a7482b31e6a0ec87ee3598e7090171e91721f9918576d760f02f03cac47c6f4003316031848e3c1d99e6e83a47434102d84e69f2f480002d5a6962cccee5d4adb48a36bbbf443a531721484381125937f3001ac5ff875b41022f496efbbdb2007b727eb806c926fb20c8ad087c57422977cebd06373e26d19b640e5fe32c85ff39a904faf736ce00a25420c1d9d705358c134cc601d9d184cb4dfdde7e1cac2bc3d4d38bf9ec44e6210ee6b280123bafc586f77764488cd24c6a77546e5a0fe8bdfb4fa203cfaffc36cce4dd5b8901000000000000000000000000651bcde08e7dd06ac5b73b473be6bc5a51030f4c7437657cb7b29bf376c564b8d1675a5e8903000000000000000000000000651bcde24ba84e1f37d041bc6e55ba396826cc494e84d4815b6db52690422eea7386314f00e8e77626586f73b955364c7b4bbf0bb7f7685ebd40e852b164633a4acbd3244c3de2202ccb626ad387d70722e64fbe44562e2f231a290c08532b8d6aba402ff50025fe002039e87b424de2772b82d935f14e2b657429a1bcc04612391ea0330c90ebddefdda48eb2aa7f66ecf7940a280e9ef3fb2e95db0995538440a62af79861004434720529e816fd2e40f8031a8d7471ebcd00351db0787346bcfe8dfad8d2b479093588d0e847efa73a10ce20e4799fb1e46642d65617c7e5213fa04989d92d8903000000000000000000000000651bcde287ded247e1660f827071c7f1371934589751085384fc9f4462c1f1897c5c3eef890100000000000000000000000000000001911dd2ad743ff237d411648a0fe32c6d74eec060716a2a74352f6b1c435b5d670016914ac26bb9cafa0f1dfaeaab10745a9094e1b60c7076fedf21651d6a25b574686a068c708f1bdbefd9e6e454ac2b520fd41c8dcf23ecd4cee978c22f1c1f5f09ff974fe8b575175cefa919a5ba1c0ddf4409be4b16695dc7bd12f6701b99bd2e70a152312ad6f01657413b2eae9287f6b9adad93d5fed1a0dd5e13ec74ce1163146509bfe426f2315a69cb452bf388cccd321eca2746a1adf793b489e5c8f61c40688b7ef3e53defc56c78facf513e511f9f5ba0eb50dbcc745afea3b860da75b394d2d1627b6e2ef54fb7b187d0af61e4532c238f387ecf9f0b466f1d54414100018e519b65c8901b344a480638beadb923fbd3462e475d39acebe559d65ed5cb11a1b25279f1918477c35eec1332ff07001d3f85cf854b70d7552f93ba8e88d581064ca4c0df6ac456c00a0e83898ccd464c63e5008aa1a498cc0646b78eb216d9eeeec76ed0eb0ee6c352f35ca5f0b2edc2ca17d211cc5cb905ba10142f042a6ac836d9cef9a6916635c9a1c1d2dc62a9fe83e2230b506b98e0fded46249008fe28b813907a05ae0d773d8f31e330200e9336e0159034c137ed645fb67ccca8a152312ad6f01657413b2eae9287f6b9adad93d5fee5d8f810abde496ccbeb45a4f3c06af828975163a006257cbf18cefebbfb4cd409025f40404a3d37bba024799ce32d7c2a833aec8474288a26b246afa32b07b4a3ce00577261707065642045746865720000000000000000000000000000000000001a09cf14f266dfe87c4b33e6d934de01f8f7242199fa8783178117218fa033f7ab005745544800000000000000000000000000000000000000000000000000000008289026c5fa173652bd62774824698a6848c63031f853d0e275174552f35df33000577261707065642045746865720000000000000000000000000000000000001a1e59309944cbc900ae848855e10bc929f78e86c2179d6e96cf52bfd520f039200031000000000000000000000000000000000000000000000000000000000000021653a735395136e5494c5426ba972b45e34d36ebcb86ac104c724ab375fcce90a18580ba6aeebc6e6b89d226c79be8927257a436ad11d9c0305b18e9d78cab8f75a3aec2096302b67e3815939e29476fb36a0d8299a1b25279f1918477c35eec1332ff07001d3f85cf85688525f98e4859a9c6939f2d2f92e6b1950ed57e56137d717aca1ccf9754f719a1c7ebe9226d26524400a8959a08f411a727ae7bb68f8febecd89ffe9d84708d24544d452de3e22e62b3b2b872e430839a15115818a152312ad6f01657413b2eae9287f6b9adad93d5fe3fb60af355125687beeb90c066ace76c442b0f963a6afd0e3316fcdd673ad22c09ff30c8a03ec44e5337a1f9d66763cf1b319fdc6d8bc4981e1f47edbd86210614b909ff0cbdceb634b81192417b64d114d535ad3bdba97d6d7e90ee2a79bf1c132d3c2d09ff5cd85060f4ff26eb5b68a6687aee76c1b7a77575fdc86ba49b4faf5041377a79b14de8989f2385a6e23f6bd05a80e0d9231870c15a000142e50adc0d84bff439d0086d9fbab9984f8b27aa208935238a60cc62e7c9bb2ea1709e94c96366b3c40ea4854837c18733e5ac1193b8d8e4070d2eca4441b0378b572bd949ab764fd71c002b759613c3e29d425cf4000100012730c940a81021004e899c6ee4bec02f0667757b9d75a8f0714ce6c157f5940b7664e4f69f01fc530db36965e33599a1348629f07ae2d724007ac36a71a16baac84db583d88e0f3a8c082e3632fcc0e15757f0dcf5234b87af41fdee4c0999c4fe698a8d824415979ab839e6913a975a3055a152312ad6f01657413b2eae9287f6b9adad93d5fe00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000" + // ) + // }); + // LogProcessingOutput memory logOutput = executor.processL2Logs( + // nextBatch, + // 0x0000000000000000000000000000000000000000000000000000000000000000 + // ); + // assertEq( + // logOutput.stateDiffHash, + // 0x9a67073c2df8f53087fcfc32d82c98bba591da35df6ce1fb55a23b677d37f9fc, + // "stateDiffHash computation failed" + // ); - bytes32 nextCommitment = executor.createBatchCommitment( - nextBatch, - logOutput.stateDiffHash, - new bytes32[](6), - new bytes32[](6) - ); - assertEq( - nextCommitment, - 0xa1dcde434352cda8e331e721232ff2d457d4074efae1e3d06ef5b10ffada0c9a, - "nextCommitment computation failed" - ); + // bytes32 nextCommitment = executor.createBatchCommitment( + // nextBatch, + // logOutput.stateDiffHash, + // new bytes32[](6), + // new bytes32[](6) + // ); + // assertEq( + // nextCommitment, + // 0xa1dcde434352cda8e331e721232ff2d457d4074efae1e3d06ef5b10ffada0c9a, + // "nextCommitment computation failed" + // ); - bytes32 prevCommitment = 0x6ebf945305689a8c3ac993df7f002d41d311a762cd6bf39bb054ead8d1f54404; - uint256 result = executor.getBatchProofPublicInput(prevCommitment, nextCommitment); - assertEq(result, 0xAC7931F2C11013FC24963E41B86E5325A79F1150350CB41E4F0876A7, "getBatchProofPublicInput"); - } + // bytes32 prevCommitment = 0x6ebf945305689a8c3ac993df7f002d41d311a762cd6bf39bb054ead8d1f54404; + // uint256 result = executor.getBatchProofPublicInput(prevCommitment, nextCommitment); + // assertEq(result, 0xAC7931F2C11013FC24963E41B86E5325A79F1150350CB41E4F0876A7, "getBatchProofPublicInput"); + // } } diff --git a/l1-contracts/test/foundry/unit/concrete/Executor/_Executor_Shared.t.sol b/l1-contracts/test/foundry/unit/concrete/Executor/_Executor_Shared.t.sol index efc5cf7e3..b345c1fd3 100644 --- a/l1-contracts/test/foundry/unit/concrete/Executor/_Executor_Shared.t.sol +++ b/l1-contracts/test/foundry/unit/concrete/Executor/_Executor_Shared.t.sol @@ -16,13 +16,14 @@ import {GettersFacet} from "contracts/state-transition/chain-deps/facets/Getters import {AdminFacet} from "contracts/state-transition/chain-deps/facets/Admin.sol"; import {MailboxFacet} from "contracts/state-transition/chain-deps/facets/Mailbox.sol"; import {InitializeData} from "contracts/state-transition/chain-interfaces/IDiamondInit.sol"; -import {IExecutor} from "contracts/state-transition/chain-interfaces/IExecutor.sol"; +import {IExecutor, TOTAL_BLOBS_IN_COMMITMENT} from "contracts/state-transition/chain-interfaces/IExecutor.sol"; import {IVerifier} from "contracts/state-transition/chain-interfaces/IVerifier.sol"; import {Diamond} from "contracts/state-transition/libraries/Diamond.sol"; import {TestnetVerifier} from "contracts/state-transition/TestnetVerifier.sol"; import {DummyBridgehub} from "contracts/dev-contracts/test/DummyBridgehub.sol"; import {IL1AssetRouter} from "contracts/bridge/interfaces/IL1AssetRouter.sol"; import {RollupL1DAValidator} from "da-contracts/RollupL1DAValidator.sol"; +import {L1DAValidatorOutput} from "da-contracts/IL1DAValidator.sol"; contract ExecutorTest is Test { address internal owner; @@ -237,6 +238,17 @@ contract ExecutorTest is Test { admin.setTokenMultiplier(1, 1); vm.prank(address(owner)); admin.setDAValidatorPair(address(rollupL1DAValidator), address(rollupL1DAValidator)); + L1DAValidatorOutput memory l1DAValidatorOutput = L1DAValidatorOutput({ + stateDiffHash: Utils.randomBytes32("stateDiffHash"), + blobsLinearHashes: new bytes32[](TOTAL_BLOBS_IN_COMMITMENT), + blobsOpeningCommitments: new bytes32[](TOTAL_BLOBS_IN_COMMITMENT) + }); + // todo we should not mock this. + vm.mockCall( + address(rollupL1DAValidator), + abi.encodeWithSelector(rollupL1DAValidator.checkDA.selector), + abi.encode(l1DAValidatorOutput) + ); uint256[] memory recursiveAggregationInput; uint256[] memory serializedProof; From 42791131d616d253de3098aa836b4b76f4bbfbf3 Mon Sep 17 00:00:00 2001 From: kelemeno Date: Thu, 27 Jun 2024 23:07:25 +0200 Subject: [PATCH 10/10] test fixes --- l1-contracts/src.ts/deploy.ts | 3 +- .../L1SharedBridge/L1SharedBridgeLegacy.t.sol | 2 +- system-contracts/SystemContractsHashes.json | 67 ++++++++++--------- 3 files changed, 40 insertions(+), 32 deletions(-) diff --git a/l1-contracts/src.ts/deploy.ts b/l1-contracts/src.ts/deploy.ts index f8d3eed47..8d5dbd808 100644 --- a/l1-contracts/src.ts/deploy.ts +++ b/l1-contracts/src.ts/deploy.ts @@ -1091,11 +1091,12 @@ export class Deployer { // console.log("bridgehubData", bridgehubData) // console.log("this.addresses.ChainAssetInfo", this.addresses.ChainAssetInfo) - const sharedBridgeData = ethers.utils.defaultAbiCoder.encode( + let sharedBridgeData = ethers.utils.defaultAbiCoder.encode( ["bytes32", "bytes"], [await bridgehub.stmAssetInfoFromChainId(this.chainId), bridgehubData] ); + sharedBridgeData = "0x01" + sharedBridgeData.slice(2); const receipt = await this.executeDirectOrGovernance( useGovernance, bridgehub, 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 fac3ca74d..4a3753ab4 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 @@ -189,7 +189,7 @@ contract L1AssetRouterLegacyTest is L1AssetRouterTest { sharedBridge.claimFailedDepositLegacyErc20Bridge({ _depositSender: alice, - _l1Token: address(token), + _l1Asset: address(token), _amount: amount, _l2TxHash: txHash, _l2BatchNumber: l2BatchNumber, diff --git a/system-contracts/SystemContractsHashes.json b/system-contracts/SystemContractsHashes.json index 5c927c10f..24c2f113e 100644 --- a/system-contracts/SystemContractsHashes.json +++ b/system-contracts/SystemContractsHashes.json @@ -3,49 +3,49 @@ "contractName": "AccountCodeStorage", "bytecodePath": "artifacts-zk/contracts-preprocessed/AccountCodeStorage.sol/AccountCodeStorage.json", "sourceCodePath": "contracts-preprocessed/AccountCodeStorage.sol", - "bytecodeHash": "0x0100005db7d0621192834d201f8bcd14c6ac987b95f422ca8bb28d500748f1fa", + "bytecodeHash": "0x0100005d4ee21317582cc48a5560f75c3d33befb5084e888bb5edd9f6537de5f", "sourceCodeHash": "0x69d2533e5481ff13e65f4442e650f4b90c46a48ac643cac9798bbbf421194353" }, { "contractName": "BootloaderUtilities", "bytecodePath": "artifacts-zk/contracts-preprocessed/BootloaderUtilities.sol/BootloaderUtilities.json", "sourceCodePath": "contracts-preprocessed/BootloaderUtilities.sol", - "bytecodeHash": "0x010007c7e006453f3693c1f1c7500b74c594e7a627076be9d2dcb35c1c268dc3", + "bytecodeHash": "0x010007c764294726a7918959e0738ab6e3700cb8aa122b743ce3e721da0a4206", "sourceCodeHash": "0x26060f33c7c63bd1f8a1a2f3b368b97ef8dd939bc53e95090f2c556248b99dce" }, { "contractName": "ComplexUpgrader", "bytecodePath": "artifacts-zk/contracts-preprocessed/ComplexUpgrader.sol/ComplexUpgrader.json", "sourceCodePath": "contracts-preprocessed/ComplexUpgrader.sol", - "bytecodeHash": "0x0100004db8b96797e7d854f2c67c2f13d3920dcf82602f77a6ce0e2353304b37", + "bytecodeHash": "0x0100004ddb8ba24c55768031bd3372f5ef238b0e41a58edac6791f26f9f14931", "sourceCodeHash": "0xdde7c49a94cc3cd34c3e7ced1b5ba45e4740df68d26243871edbe393e7298f7a" }, { "contractName": "Compressor", "bytecodePath": "artifacts-zk/contracts-preprocessed/Compressor.sol/Compressor.json", "sourceCodePath": "contracts-preprocessed/Compressor.sol", - "bytecodeHash": "0x0100014387fd8393671b5edd2cc5bb58f72d357c033a44c6274fe92abf19f96d", - "sourceCodeHash": "0x63f5f3a541ac5b59736f9117b15f293346d1842fbfe75219f7961e73185315c5" + "bytecodeHash": "0x0100013ff068d4e7562b3dcc718a8ea68975c9ccc0ab5992afd549465056b73a", + "sourceCodeHash": "0xb0cec0016f481ce023478f71727fbc0d82e967ddc0508e4d47f5c52292a3f790" }, { "contractName": "ContractDeployer", "bytecodePath": "artifacts-zk/contracts-preprocessed/ContractDeployer.sol/ContractDeployer.json", "sourceCodePath": "contracts-preprocessed/ContractDeployer.sol", - "bytecodeHash": "0x010004e5219e70c32d67ed1df0c46983a83a382e482abb5c4310ad554f55f738", - "sourceCodeHash": "0x28208c532ed8851077a9bb0a87636215840ce964397ab0767692f956a0fd11b3" + "bytecodeHash": "0x010004e58e794c183fbbeeaf34bfabdfd56a50d57869e462575770a3fe7691b2", + "sourceCodeHash": "0x1657e45c2ff4d6a892afaf71dab71bb8dc7db2c6863e66240e83dfdd2535420d" }, { "contractName": "Create2Factory", "bytecodePath": "artifacts-zk/contracts-preprocessed/Create2Factory.sol/Create2Factory.json", "sourceCodePath": "contracts-preprocessed/Create2Factory.sol", - "bytecodeHash": "0x01000049cd4b556f8ebc05b0bd35d9996e0b65412343bcc8eb6ce14d958dd21f", + "bytecodeHash": "0x010000490cf65a199ed90b4be668cadb11714bd4aa97e63cf02f45b1693433c5", "sourceCodeHash": "0x217e65f55c8add77982171da65e0db8cc10141ba75159af582973b332a4e098a" }, { "contractName": "DefaultAccount", "bytecodePath": "artifacts-zk/contracts-preprocessed/DefaultAccount.sol/DefaultAccount.json", "sourceCodePath": "contracts-preprocessed/DefaultAccount.sol", - "bytecodeHash": "0x0100055dbcf921fb36006fa42209bda58bc468eb33257b1782e854ed29273e64", + "bytecodeHash": "0x0100055df3908fa6efcfa0bdfce813d4224f4657b696bcfdea0c1dbac659ecf4", "sourceCodeHash": "0xeb5ac8fc83e1c8619db058a9b6973958bd6ed1b6f4938f8f4541d702f12e085d" }, { @@ -59,57 +59,64 @@ "contractName": "ImmutableSimulator", "bytecodePath": "artifacts-zk/contracts-preprocessed/ImmutableSimulator.sol/ImmutableSimulator.json", "sourceCodePath": "contracts-preprocessed/ImmutableSimulator.sol", - "bytecodeHash": "0x0100003b91f0ceda986543b6b45811b72cb492cdcb80c42d8600185e33f72251", + "bytecodeHash": "0x0100003b6402d656c45382d8668810b82688b5989fa94889ca948198bf4a043e", "sourceCodeHash": "0x4212e99cbc1722887cfb5b4cb967f278ac8642834786f0e3c6f3b324a9316815" }, { "contractName": "KnownCodesStorage", "bytecodePath": "artifacts-zk/contracts-preprocessed/KnownCodesStorage.sol/KnownCodesStorage.json", "sourceCodePath": "contracts-preprocessed/KnownCodesStorage.sol", - "bytecodeHash": "0x0100006f8342acd40c21d8e535e8ceb65d370ad76a116f3a893fa67452bb616f", + "bytecodeHash": "0x0100006f5b7bbb0c83af8041272c720233400b931582d6e2ce0cca1423312cd7", "sourceCodeHash": "0x8da495a9fc5aa0d7d20a165a4fc8bc77012bec29c472015ea5ecc0a2bd706137" }, { "contractName": "L1Messenger", "bytecodePath": "artifacts-zk/contracts-preprocessed/L1Messenger.sol/L1Messenger.json", "sourceCodePath": "contracts-preprocessed/L1Messenger.sol", - "bytecodeHash": "0x0100029361cc1606b2e55c12bef0a9ccbb36f70f6a12b41593b34053ea93f433", - "sourceCodeHash": "0x3e4c749b52c9fd8e6040b836dac10df29305ee0fc4fc9418326d3197e1630c38" + "bytecodeHash": "0x010001af4fe5fa496b6803598618fcc0390416e313019791443539948762d6fc", + "sourceCodeHash": "0x70939e2586e0c9990edf42dea859733f1e8888ad16f4c35d81a06437aa39123d" }, { "contractName": "L2BaseToken", "bytecodePath": "artifacts-zk/contracts-preprocessed/L2BaseToken.sol/L2BaseToken.json", "sourceCodePath": "contracts-preprocessed/L2BaseToken.sol", - "bytecodeHash": "0x010001055346ab8d4eb1b48ef7e768a95930d4ef6300c57ca173f4a76d1a9258", + "bytecodeHash": "0x01000105b2883a0d42d793791caeb8b49c7d051310a794555985e1aa549b58e7", "sourceCodeHash": "0x4cdafafd4cfdf410b31641e14487ea657be3af25e5ec1754fcd7ad67ec23d8be" }, + { + "contractName": "L2GenesisUpgrade", + "bytecodePath": "artifacts-zk/contracts-preprocessed/L2GenesisUpgrade.sol/L2GenesisUpgrade.json", + "sourceCodePath": "contracts-preprocessed/L2GenesisUpgrade.sol", + "bytecodeHash": "0x01000097f3c1aefa865ffb06d4c177146adbad59916e611b455d87619655e9a5", + "sourceCodeHash": "0xcb190d0dfd41bbc809409a8aa04a4847b86edfe010b1d75e23b4c8d07b13a9d0" + }, { "contractName": "MsgValueSimulator", "bytecodePath": "artifacts-zk/contracts-preprocessed/MsgValueSimulator.sol/MsgValueSimulator.json", "sourceCodePath": "contracts-preprocessed/MsgValueSimulator.sol", - "bytecodeHash": "0x0100005d606dc17844411ee44a09b08e574347fd92fb4df7d1739fe02ebae2cc", + "bytecodeHash": "0x0100005d70df14ce63bcf32362a8199c432cf133d703890c840af103ec5cb09b", "sourceCodeHash": "0x4834adf62dbaefa1a1c15d36b5ad1bf2826e7d888a17be495f7ed4e4ea381aa8" }, { "contractName": "NonceHolder", "bytecodePath": "artifacts-zk/contracts-preprocessed/NonceHolder.sol/NonceHolder.json", "sourceCodePath": "contracts-preprocessed/NonceHolder.sol", - "bytecodeHash": "0x010000dbe03a15e6478090c69b0565c273a9cb034c8af48b70d8e71baf5ecf94", + "bytecodeHash": "0x010000dbd5f58f23701d6596e4eef723cd65b5b1fd9ba8dbcacce14d2f6cce4d", "sourceCodeHash": "0xaa2ed3a26af30032c00a612ac327e0cdf5288b7c932ae903462355f863f950cb" }, { "contractName": "PubdataChunkPublisher", "bytecodePath": "artifacts-zk/contracts-preprocessed/PubdataChunkPublisher.sol/PubdataChunkPublisher.json", "sourceCodePath": "contracts-preprocessed/PubdataChunkPublisher.sol", - "bytecodeHash": "0x01000047abbd0db8bc506c1cb48e3aab878da3e5ea1bbacf1d4b5f46391f2493", - "sourceCodeHash": "0x0568a9a12bdac94c9e055ca303824a6bf4dc4aa503cfe9a2586c7d3dda8d45da" + "bytecodeHash": "0x0100004ba6dab6985c0accefd8810e896bc010c7a3b341ebbed2420fd671be53", + "sourceCodeHash": "0xc442fd1abb821c95e8229f4ef1575f789e89d60d1001489f5ac9250155cd11dc" }, { "contractName": "SystemContext", "bytecodePath": "artifacts-zk/contracts-preprocessed/SystemContext.sol/SystemContext.json", "sourceCodePath": "contracts-preprocessed/SystemContext.sol", - "bytecodeHash": "0x010001a55d8778874657090f2db3a8aeabd491a5f3352f04c89eadabdd92e6ba", - "sourceCodeHash": "0xf23d12ad2f17ad3b26e909fabfdcfaf4e1d158923e7cb8eeb9b5965a0b464406" + "bytecodeHash": "0x010001a71e6d2534b665dec853d7567199a5ebc1e7d07b99e6ff5c72dc2817cd", + "sourceCodeHash": "0x532a962209042f948e8a13e3f4cf12b6d53631e0fc5fa53083c7e2d8062771c0" }, { "contractName": "EventWriter", @@ -178,35 +185,35 @@ "contractName": "bootloader_test", "bytecodePath": "bootloader/build/artifacts/bootloader_test.yul.zbin", "sourceCodePath": "bootloader/build/bootloader_test.yul", - "bytecodeHash": "0x010003cb92f46b717a3351f085b9d0d7cf1b6c164f390487f29da5c3b1f272a1", - "sourceCodeHash": "0xbf798f55f3b5c3d4d29423278bd68c6bb6428f0290f6791b2e20963166b3b21a" + "bytecodeHash": "0x010003cb1d65a503f1a932d45ca82c84776cd2a9f49f85e28c097e2366b5cb4d", + "sourceCodeHash": "0x67832e063a8f4b0cb03d6a5ecffb415e6648b42ad70dc7b9ff9faddb4301f261" }, { "contractName": "fee_estimate", "bytecodePath": "bootloader/build/artifacts/fee_estimate.yul.zbin", "sourceCodePath": "bootloader/build/fee_estimate.yul", - "bytecodeHash": "0x01000951d5e14249434340fe5e6be707157f16d66ca10d0e5fcc110cc674def4", - "sourceCodeHash": "0xc7cd680273e89b1dfc3c6941f69611894c885e26656adfc4586c4eb149285d9d" + "bytecodeHash": "0x01000955ae93c0ecf1364fb14b8e00dda7d629b2cf2008138ea14e96879149a5", + "sourceCodeHash": "0x368cf51b2dfe5df659f54b1fe9d8a8209c95f5575ce38a702f36d15f62760c16" }, { "contractName": "gas_test", "bytecodePath": "bootloader/build/artifacts/gas_test.yul.zbin", "sourceCodePath": "bootloader/build/gas_test.yul", - "bytecodeHash": "0x010008d7db21670fda613a703321bb109f192ef92a6cef40b07a35a661c4d563", - "sourceCodeHash": "0xaf85e223e2156440f007fed14c9fe8899d33ad2f0aeb7feab3f4fd81d759bfb6" + "bytecodeHash": "0x010008dbd0be9670c1794aa853c3416ecac12fa6f2cf266805bc794957c0d60a", + "sourceCodeHash": "0xd41166a9ebfc0a78a804c5800dbc07f76610a9e75af0b76d1bcc785f0b9b22e7" }, { "contractName": "playground_batch", "bytecodePath": "bootloader/build/artifacts/playground_batch.yul.zbin", "sourceCodePath": "bootloader/build/playground_batch.yul", - "bytecodeHash": "0x0100095722e18e6831abbece78d3bbaac4fe187db091d6be75d0c6f59aff0f7f", - "sourceCodeHash": "0xac0a99374868ffafa2427f23a7fd1f5f8551402904efbdf84f38638cad00ec14" + "bytecodeHash": "0x0100095b2d93f58753ead867e0aa65e916d9ef4a0aebc736b73618d657bb3e37", + "sourceCodeHash": "0xeaf2fb07781de2995948631e42be33beb39c8b19cd7ac77cf3b646f63a112554" }, { "contractName": "proved_batch", "bytecodePath": "bootloader/build/artifacts/proved_batch.yul.zbin", "sourceCodePath": "bootloader/build/proved_batch.yul", - "bytecodeHash": "0x010008e75c912d19d915dc90467be59c81c8004271b03639354806f669f14ad3", - "sourceCodeHash": "0x25e4cdb4020792f534611de304297e7e0230ed7ea0510bc049862c2540cc458e" + "bytecodeHash": "0x010008ebe92cafb31d44d1855fe97af98550f0f58bced18f29a7d74efd863b3f", + "sourceCodeHash": "0xca32ad22a2c4a76f1b00091e6862d0c59d1327ee9e25a04bf1c314c724900fad" } ]