diff --git a/.github/workflows/ci-core-lint-reusable.yml b/.github/workflows/ci-core-lint-reusable.yml index 4dea4fb741ab..541049cdeb0c 100644 --- a/.github/workflows/ci-core-lint-reusable.yml +++ b/.github/workflows/ci-core-lint-reusable.yml @@ -37,5 +37,3 @@ jobs: ci_run zk lint ts --check ci_run zk lint md --check ci_run zk db check-sqlx-data - - diff --git a/.gitignore b/.gitignore index d377f92fe055..9e1b4c3b8fd9 100644 --- a/.gitignore +++ b/.gitignore @@ -40,7 +40,6 @@ Cargo.lock !/etc/env/configs/ext-node.toml !/etc/env/configs/ext-node-docker.toml /etc/env/l1-inits -!/etc/env/l1-inits/.init.env /etc/env/l2-inits !/etc/env/base !/etc/env/file_based diff --git a/.gitmodules b/.gitmodules index f415ffe6d51c..445344c3f204 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,4 +1,3 @@ [submodule "contracts"] path = contracts url = https://github.com/matter-labs/era-contracts.git -branch = kl-factory diff --git a/.solhintignore b/.solhintignore index f3681cfc4260..9e42f99d7425 100644 --- a/.solhintignore +++ b/.solhintignore @@ -1,3 +1,2 @@ -lib/ # Ignore contract submodules -contracts +contracts \ No newline at end of file diff --git a/core/lib/constants/src/contracts.rs b/core/lib/constants/src/contracts.rs index 924a80590674..328f5db8a965 100644 --- a/core/lib/constants/src/contracts.rs +++ b/core/lib/constants/src/contracts.rs @@ -135,6 +135,6 @@ pub const SHARED_BRIDGE_ETHER_TOKEN_ADDRESS: Address = H160([ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, ]); -// Default `ERA_CHAIN_ID`. All hyperchains start with this chain id and later on -// it is changed to the proper one +// Default `ERA_CHAIN_ID`. All hyperchains start with this chain id and later on during their registration +// an "initial upgrade" transaction overrides it with the correct value. pub const DEFAULT_ERA_CHAIN_ID: u32 = 270; diff --git a/core/lib/zksync_core/src/consistency_checker/mod.rs b/core/lib/zksync_core/src/consistency_checker/mod.rs index 5b84a332168a..11c1ce09c29a 100644 --- a/core/lib/zksync_core/src/consistency_checker/mod.rs +++ b/core/lib/zksync_core/src/consistency_checker/mod.rs @@ -419,7 +419,6 @@ impl ConsistencyChecker { } } - // TODO: Add support for post shared bridge commits let commit_function = if local.is_pre_boojum() { &*PRE_BOOJUM_COMMIT_FUNCTION } else if local.is_pre_shared_bridge() { @@ -430,7 +429,7 @@ impl ConsistencyChecker { } else { self.contract .function("commitBatchesSharedBridge") - .context("L1 contract does not have `commitBatches` function") + .context("L1 contract does not have `commitBatchesSharedBridge` function") .map_err(CheckError::Internal)? }; diff --git a/core/node/block_reverter/src/lib.rs b/core/node/block_reverter/src/lib.rs index 52d81f2c9f6f..37fc634efd39 100644 --- a/core/node/block_reverter/src/lib.rs +++ b/core/node/block_reverter/src/lib.rs @@ -346,19 +346,36 @@ impl BlockReverter { .expect("Private key is required to send revert transaction"), ); let chain_id = web3.eth().chain_id().await.unwrap().as_u64(); - let zksync_chain_id = std::env::var("CHAIN_ETH_ZKSYNC_NETWORK_ID") + let hyperchain_id = std::env::var("CHAIN_ETH_ZKSYNC_NETWORK_ID") .ok() .and_then(|val| val.parse::().ok()) - .expect("Hyperchain chain id has to be set in config"); - let revert_function = contract.function("revertBatchesSharedBridge").expect( - "Either `revertBlocks` or `revertBatches` function must be present in contract", - ); - let data = revert_function - .encode_input(&[ - Token::Uint(zksync_chain_id.into()), - Token::Uint(last_l1_batch_to_keep.0.into()), - ]) - .unwrap(); + .expect("`CHAIN_ETH_ZKSYNC_NETWORK_ID` has to be set in config"); + let era_chain_id = std::env::var("CONTRACTS_ERA_CHAIN_ID") + .ok() + .and_then(|val| val.parse::().ok()) + .expect("`CONTRACTS_ERA_CHAIN_ID` has to be set in config"); + + // It is expected that for all new chains `revertBatchesSharedBridge` can be used. + // For Era we are using `revertBatches` function for backwards compatibility in case the migration + // to the shared bridge is not yet complete. + let data = if hyperchain_id == era_chain_id { + let revert_function = contract + .function("revertBatches") + .expect("`revertBatches` function must be present in contract"); + revert_function + .encode_input(&[Token::Uint(last_l1_batch_to_keep.0.into())]) + .unwrap() + } else { + let revert_function = contract + .function("revertBatchesSharedBridge") + .expect("`revertBatchesSharedBridge` function must be present in contract"); + revert_function + .encode_input(&[ + Token::Uint(hyperchain_id.into()), + Token::Uint(last_l1_batch_to_keep.0.into()), + ]) + .unwrap() + }; let base_fee = web3 .eth() diff --git a/core/tests/ts-integration/tests/base-token.test.ts b/core/tests/ts-integration/tests/base-token.test.ts index 00c7196ea854..57747d7a6d5f 100644 --- a/core/tests/ts-integration/tests/base-token.test.ts +++ b/core/tests/ts-integration/tests/base-token.test.ts @@ -131,8 +131,8 @@ describe('base ERC20 contract checks', () => { const finalAliceBalance = await alice.getBalance(); const finalBobBalance = await bob.getBalance(); - await expect(finalAliceBalance).bnToBeEq(initialAliceBalance); - await expect(finalBobBalance).bnToBeEq(initialBobBalance); + expect(finalAliceBalance).bnToBeEq(initialAliceBalance); + expect(finalBobBalance).bnToBeEq(initialBobBalance); }); test('Can perform a withdrawal', async () => { diff --git a/etc/env/base/eth_sender.toml b/etc/env/base/eth_sender.toml index a72f43184a38..d67689130be6 100644 --- a/etc/env/base/eth_sender.toml +++ b/etc/env/base/eth_sender.toml @@ -48,7 +48,7 @@ max_acceptable_priority_fee_in_gwei = 100000000000 proof_loading_mode = "OldProofFromDb" -pubdata_sending_mode = "Calldata" +pubdata_sending_mode = "Blobs" [eth_sender.gas_adjuster] # Priority fee to be used by GasAdjuster (in wei). diff --git a/etc/env/configs/dev.toml b/etc/env/configs/dev.toml index 15c61d1774cb..9d57c45984f0 100644 --- a/etc/env/configs/dev.toml +++ b/etc/env/configs/dev.toml @@ -1,3 +1,3 @@ __imports__ = [ "base", "l1-inits/.init.env", "l2-inits/dev.init.env" ] -ETH_SENDER_SENDER_PUBDATA_SENDING_MODE = "Calldata" +ETH_SENDER_SENDER_PUBDATA_SENDING_MODE = "Blobs" diff --git a/etc/env/file_based/genesis.yaml b/etc/env/file_based/genesis.yaml index 5ec89c7fc89b..20560c4faf60 100644 --- a/etc/env/file_based/genesis.yaml +++ b/etc/env/file_based/genesis.yaml @@ -1,7 +1,7 @@ genesis_root: 0xb749a312a6f3ece4d43c5a02730587e133fd4ff4f90edf27d866f49946302abe genesis_rollup_leaf_index: '46' genesis_batch_commitment: 0x7c15b7e70795ba6d07ffa67482343d6b07fad0941d4fd7fe8a748b4da764c006 -genesis_protocol_version: 24 +genesis_protocol_version: 23 default_aa_hash: 0x0100055be0b42ec7b676a62a67507bad5db7b30ccbce9640ba9db9e37cc8d499 bootloader_hash: 0x010008095dfd6a873af3909665f4d7929d3bf86baf725277618f85135e4054d2 l1_chain_id: '9' diff --git a/etc/env/l1-inits/.init.env b/etc/env/l1-inits/.init.env deleted file mode 100644 index 030f00463bb5..000000000000 --- a/etc/env/l1-inits/.init.env +++ /dev/null @@ -1,23 +0,0 @@ -CONTRACTS_CREATE2_FACTORY_ADDR=0x3c4CE2E9D8b03BbCd568E47465A483EE86893c49 -CONTRACTS_VERIFIER_ADDR=0xe13FC437FaD465090508605147F126CECb1035b5 -CONTRACTS_L1_MULTICALL3_ADDR=0x61b02E2B8fa1E32c3e848fC9EBa79C74031BB1f7 -CONTRACTS_L1_WETH_TOKEN_ADDR=0x3c0E6C514fC91CcD894CadaBd0cB848332053c9c -CONTRACTS_BRIDGEHUB_PROXY_ADDR=0xf1800905Db394B0Ace133DF9bd5DDAbCBf4bB341 -CONTRACTS_BRIDGEHUB_IMPL_ADDR=0x1C5F7a780F1FA8cDb630F32fb09FaDb7C3D14ED2 -CONTRACTS_STATE_TRANSITION_PROXY_ADDR=0x56f2620c7F758fF2d7395BC1C58aF060EF659d40 -CONTRACTS_STATE_TRANSITION_IMPL_ADDR=0xEfF7513351AdceCd80397694cC9bbCDE88452A47 -CONTRACTS_DIAMOND_INIT_ADDR=0xedDf8706aF1F0B6Df12700f6a782e28aeBA6E04D -CONTRACTS_DEFAULT_UPGRADE_ADDR=0x593a368be5e874BDe3d1c151D1467133710d5E96 -CONTRACTS_GENESIS_UPGRADE_ADDR=0xc229e6f080016d5D2FB0139DAC46C9ce34A24037 -CONTRACTS_GOVERNANCE_ADDR=0x3d3e21d97a1e79Fa6a201aBB96f10e074cFA127e -CONTRACTS_ADMIN_FACET_ADDR=0x5d1F171BA5a38E1c7A360c19d3a9161167DA13De -CONTRACTS_EXECUTOR_FACET_ADDR=0x4C044FF10D381Af0a5095533590fDd72F4a9B33D -CONTRACTS_GETTERS_FACET_ADDR=0x02bF94409b6470150Ad9494E5F4F6aeF2BDF8c6F -CONTRACTS_MAILBOX_FACET_ADDR=0x2f192A3b1B5265d0aE427F1f8C273578299693B6 -CONTRACTS_VALIDATOR_TIMELOCK_ADDR=0xB5662957e1E596A95de848B27E5aa01A6E5385EC -CONTRACTS_TRANSPARENT_PROXY_ADMIN_ADDR=0x105D8C7CF88a8166Cd7e1DbD84dD689080F718Cd -CONTRACTS_L1_SHARED_BRIDGE_PROXY_ADDR=0x9e83d460923F947408bf02D418fFD33E4772327C -CONTRACTS_L1_SHARED_BRIDGE_IMPL_ADDR=0x791452e15CcCAD9Fb2C934cf9a473C6b420088d6 -CONTRACTS_L1_ERC20_BRIDGE_PROXY_ADDR=0xb9dE96697ec0639099aDdDab3B525402878230dD -CONTRACTS_L1_ERC20_BRIDGE_IMPL_ADDR=0xDE874525aF8e19A8575119c48941396eb598C1b6 -CONTRACTS_BLOB_VERSIONED_HASH_RETRIEVER_ADDR=0x1BfD81902974808D2d7A85f34bDe441a35EEb1FC \ No newline at end of file diff --git a/etc/tokens/test.json b/etc/tokens/test.json index 5e7d9978bf53..fe51488c7066 100644 --- a/etc/tokens/test.json +++ b/etc/tokens/test.json @@ -1,27 +1 @@ -[ - { - "name": "ChainLink Token (goerli)", - "symbol": "LINK", - "decimals": 18, - "address": "0x63bfb2118771bd0da7A6936667A7BB705A06c1bA" - }, - { - "name": "wBTC", - "symbol": "wBTC", - "decimals": 8, - "address": "0xCA063A2AB07491eE991dCecb456D1265f842b568" - }, - { - "name": "USD Coin (goerli)", - "symbol": "USDC", - "decimals": 6, - "address": "0xd35CCeEAD182dcee0F148EbaC9447DA2c4D449c4" - }, - { - "name": "DAI", - "symbol": "DAI", - "decimals": 18, - "address": "0x5C221E77624690fff6dd741493D735a17716c26B" - } - ] - \ No newline at end of file +[] diff --git a/infrastructure/zk/src/contract.ts b/infrastructure/zk/src/contract.ts index 2f92a8c656ec..847c11e58b7e 100644 --- a/infrastructure/zk/src/contract.ts +++ b/infrastructure/zk/src/contract.ts @@ -47,30 +47,6 @@ export async function initializeGovernance(): Promise { await utils.spawn(`yarn l1-contracts initialize-governance ${args.join(' ')} | tee initializeGovernance.log`); } -export async function deployWeth( - command: 'dev' | 'new', - name?: string, - symbol?: string, - decimals?: string, - args: any = [] -): Promise { - // let destinationFile = 'localhost'; - // if (args.includes('--envFile')) { - // destinationFile = args[args.indexOf('--envFile') + 1]; - // args.splice(args.indexOf('--envFile'), 2); - // } - await utils.spawn(`yarn --silent --cwd contracts/l1-contracts deploy-weth ' - ${args.join(' ')} | tee deployL1.log`); - - const deployLog = fs.readFileSync('deployL1.log').toString(); - const l1DeploymentEnvVars = ['CONTRACTS_L1_WETH_TOKEN_ADDR']; - updateContractsEnv( - `etc/env/l1-inits/${process.env.L1_ENV_NAME ? process.env.L1_ENV_NAME : '.init'}.env`, - deployLog, - l1DeploymentEnvVars - ); -} - export async function deployL2(args: any[] = [], includePaymaster?: boolean): Promise { await utils.confirmAction(); diff --git a/infrastructure/zk/src/env.ts b/infrastructure/zk/src/env.ts index cc0991e686a9..3fecf466f12a 100644 --- a/infrastructure/zk/src/env.ts +++ b/infrastructure/zk/src/env.ts @@ -97,6 +97,7 @@ export function load() { export function modify(variable: string, value: string, initEnv: string, withReload = true) { const assignedVariable = value.startsWith(`${variable}=`) ? value : `${variable}=${value}`; fs.mkdirSync('etc/env/l2-inits', { recursive: true }); + fs.mkdirSync('etc/env/l1-inits', { recursive: true }); if (!fs.existsSync(initEnv)) { fs.writeFileSync(initEnv, assignedVariable); return; diff --git a/infrastructure/zk/src/hyperchain_wizard.ts b/infrastructure/zk/src/hyperchain_wizard.ts index e6aad897e4e5..9ed0c5a7bc63 100644 --- a/infrastructure/zk/src/hyperchain_wizard.ts +++ b/infrastructure/zk/src/hyperchain_wizard.ts @@ -13,7 +13,6 @@ import fetch from 'node-fetch'; import { up } from './up'; import * as Handlebars from 'handlebars'; import { ProverType, setupProver } from './prover_setup'; -// import { DeploymentMode } from './contract'; import { announced } from './utils'; const title = chalk.blueBright; @@ -141,7 +140,7 @@ async function setHyperchainMetadata(runObservability: boolean) { ]; const results: any = await enquirer.prompt(questions); - // kl to do add random chainId generation here if user does not want to pick chainId. + // TODO(EVM-574): add random chainId generation here if user does not want to pick chainId. let deployer, governor, ethOperator, feeReceiver: ethers.Wallet | undefined; let feeReceiverAddress, l1Rpc, l1Id, databaseUrl, databaseProverUrl; @@ -305,9 +304,6 @@ async function setHyperchainMetadata(runObservability: boolean) { await announced('Ensuring databases are up', db.wait({ core: true, prover: false })); } - // testTokens and weth will be done for the shared bridge. - // await initializeTestERC20s(); - console.log('\n'); printAddressInfo('Deployer', deployer.address); @@ -427,31 +423,6 @@ function printAddressInfo(name: string, address: string) { console.log(''); } -// async function initializeTestERC20s() { -// // TODO: For now selecting NO breaks server-core deployment, should be always YES or create empty-mock file for v2-core -// // PLA-595 -// const questions: BasePromptOptions[] = [ -// { -// message: -// 'Do you want to deploy some test ERC20s to your hyperchain? NB: Temporary broken, always select YES', -// name: 'deployERC20s', -// type: 'confirm' -// } -// ]; - -// const results: any = await enquirer.prompt(questions); - -// if (results.deployERC20s) { -// env.modify('DEPLOY_TEST_TOKENS', 'true', 'etc/env/l1-inits/.init.env'); -// console.log( -// warning( -// `The addresses for the generated test ECR20 tokens will be available at the /etc/tokens/${getEnv( -// process.env.CHAIN_ETH_NETWORK! -// )}.json file.` -// ) -// ); -// } -// } async function startServer() { const YES_DEFAULT = 'Yes (default components)'; const YES_CUSTOM = 'Yes (custom components)'; @@ -767,7 +738,7 @@ async function configDemoHyperchain(cmd: Command) { skipEnvSetup: cmd.skipEnvSetup, skipSubmodulesCheckout: false, testTokenOptions: { envFile: process.env.CHAIN_ETH_NETWORK! }, - // TODO set the proper values + // TODO(EVM-573): support Validium mode runObservability: false, validiumMode: false }); diff --git a/infrastructure/zk/src/init.ts b/infrastructure/zk/src/init.ts index 8e37cf04dcee..69b9f770fd0a 100644 --- a/infrastructure/zk/src/init.ts +++ b/infrastructure/zk/src/init.ts @@ -156,7 +156,7 @@ const lightweightInitCmdAction = async (): Promise => { await announced('Reloading env', env.reload()); await announced('Running server genesis setup', server.genesisFromBinary()); await announced('Deploying localhost ERC20 and Weth tokens', run.deployERC20AndWeth({ command: 'dev' })); - // TODO set proper values + // TODO(EVM-573): support Validium mode await announced('Deploying L1 contracts', contract.redeployL1(false, DeploymentMode.Rollup)); await announced('Deploying L2 contracts', contract.deployL2ThroughL1({ includePaymaster: true })); await announced('Initializing governance', contract.initializeGovernance()); diff --git a/infrastructure/zk/src/reinit.ts b/infrastructure/zk/src/reinit.ts index a20e27130260..899064bc0d90 100644 --- a/infrastructure/zk/src/reinit.ts +++ b/infrastructure/zk/src/reinit.ts @@ -3,7 +3,6 @@ import { Command } from 'commander'; import { up } from './up'; import { announced } from './utils'; import { initDevCmdAction, initHyperCmdAction } from './init'; -// import { DeploymentMode } from './contract'; const reinitDevCmdAction = async (): Promise => { await announced('Setting up containers', up(false)); @@ -13,7 +12,7 @@ const reinitDevCmdAction = async (): Promise => { skipEnvSetup: true, skipSubmodulesCheckout: true, skipTestTokenDeployment: true, - // TODO set proper values + // TODO(EVM-573): support Validium mode runObservability: true, validiumMode: false }); diff --git a/infrastructure/zk/src/run.ts b/infrastructure/zk/src/run.ts index 178eea0adbbc..73cf9bb1bfdd 100644 --- a/infrastructure/zk/src/run.ts +++ b/infrastructure/zk/src/run.ts @@ -43,43 +43,6 @@ export async function deployERC20AndWeth({ } } -export async function deployWeth({ envFile }: { envFile?: string }) { - const destinationFile = envFile || process.env.CHAIN_ETH_NETWORK!; - const privateKey = process.env.DEPLOYER_PRIVATE_KEY; - const args = [privateKey ? `--private-key ${privateKey}` : '']; - await utils.spawn(`yarn --silent --cwd contracts/l1-contracts deploy-erc20 add-multi ' - [ - { "name": "Wrapped Ether", "symbol": "WETH", "decimals": 18, "implementation": "WETH9"} - ]' ${args.join(' ')} > deployedTokens.log`); - let newlyDeployedTokens: Token[]; - try { - newlyDeployedTokens = JSON.parse( - fs.readFileSync('deployedTokens.log', { - encoding: 'utf-8' - }) - ); - } catch (e) { - console.log('No new tokens deployed'); - return; - } - const alreadyDeployedToken: Token[] = JSON.parse( - fs.readFileSync(`./etc/tokens/${destinationFile}.json`, { - encoding: 'utf-8' - }) - ); - const finalTokens: Token[] = alreadyDeployedToken - .filter((token) => newlyDeployedTokens.find((newToken) => newToken.symbol === token.symbol) === undefined) - .concat(newlyDeployedTokens); - fs.writeFileSync(`./etc/tokens/${destinationFile}.json`, JSON.stringify(finalTokens, null, 2)); - const WETH = getTokens(destinationFile).find((token) => token.symbol === 'WETH')!; - env.modify( - 'CONTRACTS_L1_WETH_TOKEN_ADDR', - `CONTRACTS_L1_WETH_TOKEN_ADDR=${WETH.address}`, - `etc/env/l1-inits/${process.env.L1_ENV_NAME ? process.env.L1_ENV_NAME : '.init'}.env` - ); - return; -} - export type Token = { address: string | null; name: string;