Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Evm equivalence yul new #28

Open
wants to merge 69 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
69 commits
Select commit Hold shift + click to select a range
2ff4e59
Add Evm Equivalence support
jrchatruc Aug 7, 2024
dfadb34
Merge branch 'dev' into evm-equivalence-yul-new
jrchatruc Aug 8, 2024
aa30514
fmt
jrchatruc Aug 9, 2024
04f5920
Update support for evm simulator with latest changes
IAvecilla Aug 9, 2024
7487de0
Revert solidity version update
IAvecilla Aug 12, 2024
fb58ebb
Update solidity contracts version
IAvecilla Aug 12, 2024
90e7043
Calculate evm simulator address from compiled file when deploying
IAvecilla Aug 12, 2024
6b78beb
Comment out assert in bootloader to deploy evm contracts
IAvecilla Aug 14, 2024
7cce99c
Remove solhint line added by mistake
IAvecilla Aug 15, 2024
8eeffba
Update contracts to emit events on evm deployment
IAvecilla Aug 16, 2024
c662106
Merge remote-tracking branch 'origin/dev' into evm-equivalence-yul-new
IAvecilla Aug 19, 2024
be47154
Fix typos
IAvecilla Aug 19, 2024
207320e
Update tests and delete todos
IAvecilla Aug 20, 2024
3ee830c
Merge remote-tracking branch 'origin/dev' into evm-equivalence-yul-new
IAvecilla Aug 20, 2024
6a9d835
Remove evm constants contract
IAvecilla Aug 20, 2024
cb3ad25
Remove asserts from bootloader (#26)
gianbelinche Aug 20, 2024
81dd19a
Merge remote-tracking branch 'origin/dev' into evm-equivalence-yul-new
IAvecilla Aug 20, 2024
7d8300b
Remove old contracts constants not longer used
IAvecilla Aug 21, 2024
e6b7a83
Fix some typos and outdated comments
IAvecilla Aug 21, 2024
4ba25a3
Add interface for evm gas manager
IAvecilla Aug 21, 2024
668bcac
Simplify check for warm slots in evm gas manager
IAvecilla Aug 21, 2024
2c59ee8
Check nonce equals zero for evm deploy
IAvecilla Aug 21, 2024
fbc8f8f
Fix trivial lint checks
IAvecilla Aug 21, 2024
ef1affd
Disable some solidity hints for conflicting system contracts
IAvecilla Aug 21, 2024
b1c7e00
Fix most of the l1 contracts foundry tests
IAvecilla Aug 21, 2024
e37175d
Change test hashes
gianbelinche Aug 21, 2024
cd2babb
Fix hardhat tests
gianbelinche Aug 22, 2024
0dd4a0b
Merge branch 'dev' into evm-equivalence-yul-new
IAvecilla Aug 22, 2024
2f1181f
Use modifier in evm gas manager to only modify callstack by system env
IAvecilla Aug 22, 2024
e4e8605
Merge branch 'dev' into evm-equivalence-yul-new
IAvecilla Aug 23, 2024
59834ab
Fix lint errores
IAvecilla Aug 23, 2024
1117c05
Fix typos
IAvecilla Aug 23, 2024
2579d68
Fix another typo
IAvecilla Aug 23, 2024
0ecbe61
Check for the `to` address to be zero when dispatching to createEVM o…
jrchatruc Aug 23, 2024
0ac4617
Fix format
IAvecilla Aug 26, 2024
9cd43a2
Update lock file
IAvecilla Aug 26, 2024
6bdc843
Fix compiler version for compile yul script
IAvecilla Aug 27, 2024
7f6da78
Delete debug logs
IAvecilla Aug 27, 2024
ca6b3cb
Download solc compiler when not found in cache
IAvecilla Aug 27, 2024
ad52dd8
Fix lint errors
IAvecilla Aug 27, 2024
01c0bd5
Update contracts hashes
IAvecilla Aug 27, 2024
1d36192
Remove download compiler step since old hardhat version already does it
IAvecilla Aug 27, 2024
5774d9e
Update system contract hashes
IAvecilla Aug 27, 2024
4d15c5e
Get the original lock file from dev to mantain correct versions
IAvecilla Aug 27, 2024
0922be9
Update system contracts hashes
IAvecilla Aug 27, 2024
0a17e16
Add evm simulatro bytecode hash to the test deployer
IAvecilla Aug 27, 2024
a420bf4
Merge branch 'dev' into evm-equivalence-yul-new
IAvecilla Aug 28, 2024
8e0aa26
Update evm interpreter contract to make sys calls when required
IAvecilla Aug 29, 2024
2d95a3b
Add modifier for functions that need to be called only by sys calls
IAvecilla Aug 29, 2024
f3af763
Update increment nonce function to yield unauthorized error
IAvecilla Aug 29, 2024
75f9287
Fix lint errors
IAvecilla Aug 29, 2024
d56209b
Update system contracts hashes
IAvecilla Aug 29, 2024
dc1a608
Merge branch 'dev' into evm-equivalence-yul-new
IAvecilla Aug 29, 2024
5e6211a
Add preprocess script and template files
jrchatruc Sep 10, 2024
d1f5c40
Merge branch 'dev' into evm-equivalence-yul-new
IAvecilla Sep 10, 2024
fe5d5f5
Move evm interpreter files for preprocessing to a new directory
IAvecilla Sep 10, 2024
4d005d3
Bring missing system contract changes
jrchatruc Sep 10, 2024
99bcbb4
Format
jrchatruc Sep 10, 2024
8aa9cdb
Fix lints and codespells
jrchatruc Sep 10, 2024
e017b4e
More lints
jrchatruc Sep 10, 2024
0671291
Fix contract hashes
jrchatruc Sep 10, 2024
0f1383a
Fix foundry L1 tests
jrchatruc Sep 10, 2024
361d19a
Revert fetch deployed code len optimization (#31)
jrchatruc Sep 11, 2024
220e983
[EVM-Equivalence-YUL] Optimize EvmGasManager (#30)
0xVolosnikov Sep 12, 2024
32c05a1
[EVM-Equivalence-YUL] Fix overflow checks (#29)
IAvecilla Sep 13, 2024
1722402
Fix l1 hardhat test adding evm simulator code hash
IAvecilla Sep 16, 2024
2edbd69
fix: Revert consumeEvmFrame EvmGasManager optimization (#32)
0xVolosnikov Sep 17, 2024
62e0e04
chore: Initial cleanup in EvmInterpreter (#33)
0xVolosnikov Sep 23, 2024
6f791dd
Fix EVM branch in getCodeHash (#34)
0xVolosnikov Sep 23, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,12 @@ contract CustomUpgradeTest is BaseZkSyncUpgrade {
(uint32 newMinorVersion, bool isPatchOnly) = _setNewProtocolVersion(_proposedUpgrade.newProtocolVersion);
_upgradeL1Contract(_proposedUpgrade.l1ContractsUpgradeCalldata);
_upgradeVerifier(_proposedUpgrade.verifier, _proposedUpgrade.verifierParams);
_setBaseSystemContracts(_proposedUpgrade.bootloaderHash, _proposedUpgrade.defaultAccountHash, isPatchOnly);
_setBaseSystemContracts(
_proposedUpgrade.bootloaderHash,
_proposedUpgrade.defaultAccountHash,
_proposedUpgrade.evmSimulatorHash,
isPatchOnly
);

bytes32 txHash;
txHash = _setL2SystemContractUpgrade(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,14 @@ contract ExecutorProvingTest is ExecutorFacet {
}

/// Sets the DefaultAccount Hash and Bootloader Hash.
function setHashes(bytes32 l2DefaultAccountBytecodeHash, bytes32 l2BootloaderBytecodeHash) external {
function setHashes(
bytes32 l2DefaultAccountBytecodeHash,
bytes32 l2BootloaderBytecodeHash,
bytes32 l2EvmSimulatorBytecode
) external {
s.l2DefaultAccountBytecodeHash = l2DefaultAccountBytecodeHash;
s.l2BootloaderBytecodeHash = l2BootloaderBytecodeHash;
s.l2EvmSimulatorBytecodeHash = l2EvmSimulatorBytecode;
s.zkPorterIsAvailable = false;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -356,6 +356,7 @@ contract StateTransitionManager is IStateTransitionManager, ReentrancyGuard, Own
factoryDeps: bytesEmptyArray,
bootloaderHash: bytes32(0),
defaultAccountHash: bytes32(0),
evmSimulatorHash: bytes32(0),
verifier: address(0),
verifierParams: VerifierParams({
recursionNodeLevelVkHash: bytes32(0),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ contract DiamondInit is ZkSyncHyperchainBase, IDiamondInit {
s.__DEPRECATED_verifierParams = _initializeData.verifierParams;
s.l2BootloaderBytecodeHash = _initializeData.l2BootloaderBytecodeHash;
s.l2DefaultAccountBytecodeHash = _initializeData.l2DefaultAccountBytecodeHash;
s.l2EvmSimulatorBytecodeHash = _initializeData.l2EvmSimulatorBytecodeHash;
s.priorityTxMaxGasLimit = _initializeData.priorityTxMaxGasLimit;
s.feeParams = _initializeData.feeParams;
s.blobVersionedHashRetriever = _initializeData.blobVersionedHashRetriever;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,9 @@ struct ZkSyncHyperchainStorage {
/// @notice Bytecode hash of default account (bytecode for EOA).
/// @dev Used as an input to zkp-circuit.
bytes32 l2DefaultAccountBytecodeHash;
/// @notice Bytecode hash of evm simulator.
/// @dev Used as an input to zkp-circuit.
bytes32 l2EvmSimulatorBytecodeHash;
/// @dev Indicates that the porter may be touched on L2 transactions.
/// @dev Used as an input to zkp-circuit.
bool zkPorterIsAvailable;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -600,13 +600,13 @@ contract ExecutorFacet is ZkSyncHyperchainBase, IExecutor {

function _batchMetaParameters() internal view returns (bytes memory) {
bytes32 l2DefaultAccountBytecodeHash = s.l2DefaultAccountBytecodeHash;
bytes32 l2EvmSimulatorBytecodeHash = s.l2EvmSimulatorBytecodeHash;
return
abi.encodePacked(
s.zkPorterIsAvailable,
s.l2BootloaderBytecodeHash,
l2DefaultAccountBytecodeHash,
// VM 1.5.0 requires us to pass the EVM simulator code hash. For now it is the same as the default account.
l2DefaultAccountBytecodeHash
l2EvmSimulatorBytecodeHash
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,11 @@ contract GettersFacet is ZkSyncHyperchainBase, IGetters, ILegacyGetters {
return s.l2DefaultAccountBytecodeHash;
}

/// @inheritdoc IGetters
function getL2EvmSimulatorBytecodeHash() external view returns (bytes32) {
return s.l2EvmSimulatorBytecodeHash;
}

/// @inheritdoc IGetters
function getVerifierParams() external view returns (VerifierParams memory) {
return s.__DEPRECATED_verifierParams;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ struct InitializeData {
VerifierParams verifierParams;
bytes32 l2BootloaderBytecodeHash;
bytes32 l2DefaultAccountBytecodeHash;
bytes32 l2EvmSimulatorBytecodeHash;
uint256 priorityTxMaxGasLimit;
FeeParams feeParams;
address blobVersionedHashRetriever;
Expand All @@ -53,6 +54,7 @@ struct InitializeDataNewChain {
VerifierParams verifierParams;
bytes32 l2BootloaderBytecodeHash;
bytes32 l2DefaultAccountBytecodeHash;
bytes32 l2EvmSimulatorBytecodeHash;
uint256 priorityTxMaxGasLimit;
FeeParams feeParams;
address blobVersionedHashRetriever;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,9 @@ interface IGetters is IZkSyncHyperchainBase {
/// @return Bytecode hash of default account (bytecode for EOA).
function getL2DefaultAccountBytecodeHash() external view returns (bytes32);

/// @return Bytecode hash of EVM simulator.
function getL2EvmSimulatorBytecodeHash() external view returns (bytes32);

/// @return Verifier parameters.
/// @dev This function is deprecated and will soon be removed.
function getVerifierParams() external view returns (VerifierParams memory);
Expand Down
40 changes: 38 additions & 2 deletions l1-contracts/contracts/upgrades/BaseZkSyncUpgrade.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
// SPDX-License-Identifier: MIT

// solhint-disable reason-string, gas-custom-errors

pragma solidity 0.8.24;

import {SafeCast} from "@openzeppelin/contracts-v4/utils/math/SafeCast.sol";
Expand Down Expand Up @@ -33,6 +35,7 @@ struct ProposedUpgrade {
bytes[] factoryDeps;
bytes32 bootloaderHash;
bytes32 defaultAccountHash;
bytes32 evmSimulatorHash;
address verifier;
VerifierParams verifierParams;
bytes l1ContractsUpgradeCalldata;
Expand All @@ -54,6 +57,8 @@ abstract contract BaseZkSyncUpgrade is ZkSyncHyperchainBase {
/// @notice Сhanges to the bytecode that is used in L2 as a default account
event NewL2DefaultAccountBytecodeHash(bytes32 indexed previousBytecodeHash, bytes32 indexed newBytecodeHash);

event NewL2EvmSimulatorBytecodeHash(bytes32 indexed previousBytecodeHash, bytes32 indexed newBytecodeHash);

/// @notice Verifier address changed
event NewVerifier(address indexed oldVerifier, address indexed newVerifier);

Expand All @@ -79,7 +84,12 @@ abstract contract BaseZkSyncUpgrade is ZkSyncHyperchainBase {
(uint32 newMinorVersion, bool isPatchOnly) = _setNewProtocolVersion(_proposedUpgrade.newProtocolVersion);
_upgradeL1Contract(_proposedUpgrade.l1ContractsUpgradeCalldata);
_upgradeVerifier(_proposedUpgrade.verifier, _proposedUpgrade.verifierParams);
_setBaseSystemContracts(_proposedUpgrade.bootloaderHash, _proposedUpgrade.defaultAccountHash, isPatchOnly);
_setBaseSystemContracts(
_proposedUpgrade.bootloaderHash,
_proposedUpgrade.defaultAccountHash,
_proposedUpgrade.evmSimulatorHash,
isPatchOnly
);

txHash = _setL2SystemContractUpgrade(
_proposedUpgrade.l2ProtocolUpgradeTx,
Expand Down Expand Up @@ -115,6 +125,26 @@ abstract contract BaseZkSyncUpgrade is ZkSyncHyperchainBase {
emit NewL2DefaultAccountBytecodeHash(previousDefaultAccountBytecodeHash, _l2DefaultAccountBytecodeHash);
}

/// @notice Change default account bytecode hash, that is used on L2
/// @param _l2EvmSimulatorBytecodeHash The hash of default account L2 bytecode
/// @param _patchOnly Whether only the patch part of the protocol version semver has changed
function _setL2EvmSimulatorBytecodeHash(bytes32 _l2EvmSimulatorBytecodeHash, bool _patchOnly) private {
if (_l2EvmSimulatorBytecodeHash == bytes32(0)) {
return;
}

require(!_patchOnly, "Patch only upgrade can not set new default account");

L2ContractHelper.validateBytecodeHash(_l2EvmSimulatorBytecodeHash);

// Save previous value into the stack to put it into the event later
bytes32 previousL2EvmSimulatorBytecodeHash = s.l2EvmSimulatorBytecodeHash;

// Change the default account bytecode hash
s.l2EvmSimulatorBytecodeHash = _l2EvmSimulatorBytecodeHash;
emit NewL2EvmSimulatorBytecodeHash(previousL2EvmSimulatorBytecodeHash, _l2EvmSimulatorBytecodeHash);
}

/// @notice Change bootloader bytecode hash, that is used on L2
/// @param _l2BootloaderBytecodeHash The hash of bootloader L2 bytecode
/// @param _patchOnly Whether only the patch part of the protocol version semver has changed
Expand Down Expand Up @@ -185,9 +215,15 @@ abstract contract BaseZkSyncUpgrade is ZkSyncHyperchainBase {
/// @param _bootloaderHash The hash of the new bootloader bytecode. If zero, it will not be updated.
/// @param _defaultAccountHash The hash of the new default account bytecode. If zero, it will not be updated.
/// @param _patchOnly Whether only the patch part of the protocol version semver has changed.
function _setBaseSystemContracts(bytes32 _bootloaderHash, bytes32 _defaultAccountHash, bool _patchOnly) internal {
function _setBaseSystemContracts(
bytes32 _bootloaderHash,
bytes32 _defaultAccountHash,
bytes32 _evmSimulatorHash,
bool _patchOnly
) internal {
_setL2BootloaderBytecodeHash(_bootloaderHash, _patchOnly);
_setL2DefaultAccountBytecodeHash(_defaultAccountHash, _patchOnly);
_setL2EvmSimulatorBytecodeHash(_evmSimulatorHash, _patchOnly);
}

/// @notice Sets the hash of the L2 system contract upgrade transaction for the next batch to be committed
Expand Down
2 changes: 2 additions & 0 deletions l1-contracts/deploy-scripts/DeployL1.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ contract DeployL1Script is Script {
bytes diamondCutData;
bytes32 bootloaderHash;
bytes32 defaultAAHash;
bytes32 evmSimulatorHash;
}

struct TokensConfig {
Expand Down Expand Up @@ -442,6 +443,7 @@ contract DeployL1Script is Script {
verifierParams: verifierParams,
l2BootloaderBytecodeHash: config.contracts.bootloaderHash,
l2DefaultAccountBytecodeHash: config.contracts.defaultAAHash,
l2EvmSimulatorBytecodeHash: config.contracts.evmSimulatorHash,
priorityTxMaxGasLimit: config.contracts.priorityTxMaxGasLimit,
feeParams: feeParams,
blobVersionedHashRetriever: addresses.blobVersionedHashRetriever
Expand Down
8 changes: 6 additions & 2 deletions l1-contracts/scripts/token-migration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -233,11 +233,15 @@ export async function transferTokensOnForkedNetwork(deployer: Deployer) {
const erc20contract = IERC20Factory.connect(tokenAddress, provider);
console.log(`Migrating token ${tokenAddress}`);
console.log(
`Balance before: ${await erc20contract.balanceOf(deployer.addresses.Bridges.ERC20BridgeProxy)}, ${await erc20contract.balanceOf(deployer.addresses.Bridges.SharedBridgeProxy)}`
`Balance before: ${await erc20contract.balanceOf(
deployer.addresses.Bridges.ERC20BridgeProxy
)}, ${await erc20contract.balanceOf(deployer.addresses.Bridges.SharedBridgeProxy)}`
);
await transferTokens(deployer, tokenAddress);
console.log(
`Balance after: ${await erc20contract.balanceOf(deployer.addresses.Bridges.ERC20BridgeProxy)}, ${await erc20contract.balanceOf(deployer.addresses.Bridges.SharedBridgeProxy)}`
`Balance after: ${await erc20contract.balanceOf(
deployer.addresses.Bridges.ERC20BridgeProxy
)}, ${await erc20contract.balanceOf(deployer.addresses.Bridges.SharedBridgeProxy)}`
);
}
for (const tokenAddress of tokenList) {
Expand Down
11 changes: 9 additions & 2 deletions l1-contracts/scripts/upgrade-consistency-checker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,9 @@ const expectedGenesisRoot = "0xabdb766b18a479a5c783a4b80e12686bc8ea3cc2d8a305049
const expectedRecursionNodeLevelVkHash = "0xf520cd5b37e74e19fdb369c8d676a04dce8a19457497ac6686d2bb95d94109c8";
const expectedRecursionLeafLevelVkHash = "0xf9664f4324c1400fa5c3822d667f30e873f53f1b8033180cd15fe41c1e2355c6";
const expectedRecursionCircuitsSetVksHash = "0x0000000000000000000000000000000000000000000000000000000000000000";
const expectedBootloaderHash = "0x010008e742608b21bf7eb23c1a9d0602047e3618b464c9b59c0fba3b3d7ab66e";
const expectedDefaultAccountHash = "0x01000563374c277a2c1e34659a2a1e87371bb6d852ce142022d497bfb50b9e32";
const expectedBootloaderHash = "0x010008e7894d0dd14681c76bdb4d5e4e7f6b51bfe40c957d50eed3fec829fdb0";
const expectedDefaultAccountHash = "0x0100058deb36e1f2eeb48bf3846d0e8eb38e9176754b73116bb41a472459a4dd";
const expectedEvmSimulatorHash = "0x01000f197081a9906cc411d0698c4961aeb5c74877f37f7071681da6e8ef3f31";

const validatorOne = process.env.ETH_SENDER_SENDER_OPERATOR_COMMIT_ETH_ADDR!;
const validatorTwo = process.env.ETH_SENDER_SENDER_OPERATOR_BLOBS_ETH_ADDR!;
Expand Down Expand Up @@ -221,6 +222,7 @@ async function extractProxyInitializationData(contract: ethers.Contract, data: s
recursionCircuitsSetVksHash,
l2BootloaderBytecodeHash,
l2DefaultAccountBytecodeHash,
l2EvmSimulatorBytecodeHash,
// priorityTxMaxGasLimit,

// // We unpack fee params
Expand All @@ -240,6 +242,7 @@ async function extractProxyInitializationData(contract: ethers.Contract, data: s
"bytes32",
"bytes32",
"bytes32",
"bytes32",
"uint256",
"uint256",
"uint256",
Expand Down Expand Up @@ -276,6 +279,10 @@ async function extractProxyInitializationData(contract: ethers.Contract, data: s
throw new Error("L2 default account bytecode hash is not correct");
}

if (l2EvmSimulatorBytecodeHash.toLowerCase() !== expectedEvmSimulatorHash.toLowerCase()) {
throw new Error("L2 default account bytecode hash is not correct");
}

console.log("STM init data correct!");
}

Expand Down
5 changes: 5 additions & 0 deletions l1-contracts/scripts/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,11 @@ export function readSystemContractsBytecode(fileName: string) {
return JSON.parse(artifact.toString()).bytecode;
}

export function readEvmSimulatorbytecode() {
const systemContractsPath = path.join(process.env.ZKSYNC_HOME as string, "contracts/system-contracts");
return fs.readFileSync(`${systemContractsPath}/contracts-preprocessed/artifacts/EvmInterpreter.yul.zbin`);
}

// eslint-disable-next-line @typescript-eslint/no-explicit-any
export function print(name: string, data: any) {
console.log(`${name}:\n`, JSON.stringify(data, null, 4), "\n");
Expand Down
1 change: 1 addition & 0 deletions l1-contracts/src.ts/deploy-process.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import { ADDRESS_ONE } from "../src.ts/utils";

export const L2_BOOTLOADER_BYTECODE_HASH = "0x1000100000000000000000000000000000000000000000000000000000000000";
export const L2_DEFAULT_ACCOUNT_BYTECODE_HASH = "0x1001000000000000000000000000000000000000000000000000000000000000";
export const L2_EVM_SIMULATOR_BYTECODE_HASH = "0x1010000000000000000000000000000000000000000000000000000000000000";

export async function initialBridgehubDeployment(
deployer: Deployer,
Expand Down
4 changes: 4 additions & 0 deletions l1-contracts/src.ts/deploy-test-process.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import { Deployer } from "./deploy";
import {
L2_BOOTLOADER_BYTECODE_HASH,
L2_DEFAULT_ACCOUNT_BYTECODE_HASH,
L2_EVM_SIMULATOR_BYTECODE_HASH,
initialBridgehubDeployment,
registerHyperchain,
} from "./deploy-process";
Expand Down Expand Up @@ -65,6 +66,7 @@ export async function defaultDeployerForTests(deployWallet: Wallet, ownerAddress
addresses: addressConfig,
bootloaderBytecodeHash: L2_BOOTLOADER_BYTECODE_HASH,
defaultAccountBytecodeHash: L2_DEFAULT_ACCOUNT_BYTECODE_HASH,
evmSimulatorBytecodeHash: L2_EVM_SIMULATOR_BYTECODE_HASH,
});
}

Expand All @@ -76,6 +78,7 @@ export async function defaultEraDeployerForTests(deployWallet: Wallet, ownerAddr
addresses: addressConfig,
bootloaderBytecodeHash: L2_BOOTLOADER_BYTECODE_HASH,
defaultAccountBytecodeHash: L2_DEFAULT_ACCOUNT_BYTECODE_HASH,
evmSimulatorBytecodeHash: L2_EVM_SIMULATOR_BYTECODE_HASH,
});
const l2_rpc_addr = "http://localhost:3050";
const web3Provider = new zkethers.Provider(l2_rpc_addr);
Expand Down Expand Up @@ -315,6 +318,7 @@ export class EraDeployer extends Deployer {
verifierParams,
l2BootloaderBytecodeHash: L2_BOOTLOADER_BYTECODE_HASH,
l2DefaultAccountBytecodeHash: L2_DEFAULT_ACCOUNT_BYTECODE_HASH,
l2EvmSimulatorBytecodeHash: L2_EVM_SIMULATOR_BYTECODE_HASH,
priorityTxMaxGasLimit,
feeParams,
blobVersionedHashRetriever: this.addresses.BlobVersionedHashRetriever,
Expand Down
4 changes: 3 additions & 1 deletion l1-contracts/src.ts/deploy-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,9 @@ export async function deployBytecodeViaCreate2(

const gasUsed = receipt.gasUsed;
log(
`${contractName} deployed, gasUsed: ${gasUsed.toString()}, tx hash: ${tx.hash}, expected address: ${expectedAddress}`
`${contractName} deployed, gasUsed: ${gasUsed.toString()}, tx hash: ${
tx.hash
}, expected address: ${expectedAddress}`
);

const deployedBytecodeAfter = await deployWallet.provider.getCode(expectedAddress);
Expand Down
7 changes: 7 additions & 0 deletions l1-contracts/src.ts/deploy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {
packSemver,
readBatchBootloaderBytecode,
readSystemContractsBytecode,
readEvmSimulatorbytecode,
unpackStringSemVer,
} from "../scripts/utils";
import { getTokens } from "./deploy-token";
Expand Down Expand Up @@ -43,6 +44,7 @@ import type { Contract, Overrides } from "@ethersproject/contracts";

let L2_BOOTLOADER_BYTECODE_HASH: string;
let L2_DEFAULT_ACCOUNT_BYTECODE_HASH: string;
let L2_EVM_SIMULATOR_BYTECODE_HASH: string;

export interface DeployerConfig {
deployWallet: Wallet;
Expand All @@ -51,6 +53,7 @@ export interface DeployerConfig {
verbose?: boolean;
bootloaderBytecodeHash?: string;
defaultAccountBytecodeHash?: string;
evmSimulatorBytecodeHash?: string;
}

export interface Operation {
Expand Down Expand Up @@ -78,6 +81,9 @@ export class Deployer {
L2_DEFAULT_ACCOUNT_BYTECODE_HASH = config.defaultAccountBytecodeHash
? config.defaultAccountBytecodeHash
: hexlify(hashL2Bytecode(readSystemContractsBytecode("DefaultAccount")));
L2_EVM_SIMULATOR_BYTECODE_HASH = config.evmSimulatorBytecodeHash
? config.evmSimulatorBytecodeHash
: hexlify(hashL2Bytecode(readEvmSimulatorbytecode()));
this.ownerAddress = config.ownerAddress != null ? config.ownerAddress : this.deployWallet.address;
this.chainId = parseInt(process.env.CHAIN_ETH_ZKSYNC_NETWORK_ID!);
}
Expand Down Expand Up @@ -105,6 +111,7 @@ export class Deployer {
verifierParams,
L2_BOOTLOADER_BYTECODE_HASH,
L2_DEFAULT_ACCOUNT_BYTECODE_HASH,
L2_EVM_SIMULATOR_BYTECODE_HASH,
this.addresses.StateTransition.Verifier,
this.addresses.BlobVersionedHashRetriever,
+priorityTxMaxGasLimit,
Expand Down
1 change: 1 addition & 0 deletions l1-contracts/src.ts/diamondCut.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ export interface InitializeData {
allowList: BigNumberish;
l2BootloaderBytecodeHash: string;
l2DefaultAccountBytecodeHash: string;
l2EvmSimulatorBytecodeHash: string;
priorityTxMaxGasLimit: BigNumberish;
}

Expand Down
Loading
Loading