diff --git a/system-contracts/contracts/Constants.sol b/system-contracts/contracts/Constants.sol index 0f8e2307f..1f911975f 100644 --- a/system-contracts/contracts/Constants.sol +++ b/system-contracts/contracts/Constants.sol @@ -17,7 +17,7 @@ import {IPubdataChunkPublisher} from "./interfaces/IPubdataChunkPublisher.sol"; /// @dev All the system contracts introduced by zkSync have their addresses /// started from 2^15 in order to avoid collision with Ethereum precompiles. -uint160 constant SYSTEM_CONTRACTS_OFFSET = {{SYSTEM_CONTRACTS_OFFSET}}; // 2^15 +uint160 constant SYSTEM_CONTRACTS_OFFSET = 0x8000; // 2^15 /// @dev Unlike the value above, it is not overridden for the purpose of testing and /// is identical to the constant value actually used as the system contracts offset on diff --git a/system-contracts/scripts/preprocess-system-contracts.ts b/system-contracts/scripts/preprocess-system-contracts.ts index acecee1ac..9be3518c4 100644 --- a/system-contracts/scripts/preprocess-system-contracts.ts +++ b/system-contracts/scripts/preprocess-system-contracts.ts @@ -1,3 +1,4 @@ +import * as fs from "fs"; import { existsSync, mkdirSync, writeFileSync } from "fs"; import path from "path"; import { renderFile } from "template-file"; @@ -16,15 +17,18 @@ async function preprocess(testMode: boolean) { console.log("\x1b[31mWarning: test mode for the preprocessing being used!\x1b[0m"); params.SYSTEM_CONTRACTS_OFFSET = "0x9000"; } + const substring = "uint160 constant SYSTEM_CONTRACTS_OFFSET = 0x8000;" + const replacingSubstring = `uint160 constant SYSTEM_CONTRACTS_OFFSET = ${params.SYSTEM_CONTRACTS_OFFSET};` const contracts = await glob( [`${CONTRACTS_DIR}/**/*.sol`, `${CONTRACTS_DIR}/**/*.yul`, `${CONTRACTS_DIR}/**/*.zasm`], { onlyFiles: true } ); - for (const contract of contracts) { - const preprocessed = await renderFile(contract, params); - const fileName = `${OUTPUT_DIR}/${contract.slice(CONTRACTS_DIR.length)}`; + for (const contractPath of contracts) { + let contract = fs.readFileSync(contractPath,'utf8'); + const preprocessed = await contract.replace(substring, replacingSubstring); + const fileName = `${OUTPUT_DIR}/${contractPath.slice(CONTRACTS_DIR.length)}`; const directory = path.dirname(fileName); if (!existsSync(directory)) { mkdirSync(directory, { recursive: true });