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

chore: Use latest release contracts #376

Merged
merged 17 commits into from
Nov 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
6 changes: 5 additions & 1 deletion .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,8 @@ build/
dist/
volumes/
.tslintrc.js
bellman-cuda
bellman-cuda

# Ignore contract submodules
contracts
etc/system-contracts
4 changes: 4 additions & 0 deletions .markdownlintignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,6 @@
# Ignore submodule
bellman-cuda

# Ignore contract submodules
contracts
etc/system-contracts
3 changes: 2 additions & 1 deletion .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@ bellman-cuda
sdk/zksync-rs/CHANGELOG.md
CHANGELOG.md

# ignore era-contracts, since they have their own formatting CI
# Ignore contract submodules
contracts
etc/system-contracts
3 changes: 3 additions & 0 deletions .solhintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Ignore contract submodules
contracts
etc/system-contracts
2 changes: 1 addition & 1 deletion contracts
Submodule contracts updated 224 files
20 changes: 19 additions & 1 deletion core/lib/multivm/src/versions/vm_latest/tests/upgrade.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@ fn test_protocol_upgrade_is_first() {
.build();

let bytecode_hash = hash_bytecode(&read_test_contract());
vm.vm
.storage
.borrow_mut()
.set_value(get_known_code_key(&bytecode_hash), u256_to_h256(1.into()));

// Here we just use some random transaction of protocol upgrade type:
let protocol_upgrade_transaction = get_forced_deploy_tx(&[ForceDeployment {
Expand All @@ -49,6 +53,20 @@ fn test_protocol_upgrade_is_first() {
input: vec![],
}]);

// Another random upgrade transaction
let another_protocol_upgrade_transaction = get_forced_deploy_tx(&[ForceDeployment {
// The bytecode hash to put on an address
bytecode_hash,
// The address on which to deploy the bytecodehash to
address: H160::random(),
// Whether to run the constructor on the force deployment
call_constructor: false,
// The value with which to initialize a contract
value: U256::zero(),
// The constructor calldata
input: vec![],
}]);

let normal_l1_transaction = vm.rich_accounts[0]
.get_deploy_tx(&read_test_contract(), None, TxType::L1 { serial_id: 0 })
.tx;
Expand All @@ -60,7 +78,7 @@ fn test_protocol_upgrade_is_first() {
// Test 1: there must be only one system transaction in block
vm.vm.push_transaction(protocol_upgrade_transaction.clone());
vm.vm.push_transaction(normal_l1_transaction.clone());
vm.vm.push_transaction(protocol_upgrade_transaction.clone());
vm.vm.push_transaction(another_protocol_upgrade_transaction);

vm.vm.execute(VmExecutionMode::OneTx);
vm.vm.execute(VmExecutionMode::OneTx);
Expand Down
2 changes: 1 addition & 1 deletion core/lib/zksync_core/src/eth_watch/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use zksync_dal::{ConnectionPool, StorageProcessor};
use zksync_types::protocol_version::{ProtocolUpgradeTx, ProtocolUpgradeTxCommonData};
use zksync_types::web3::types::{Address, BlockNumber};
use zksync_types::{
ethabi::{encode, Contract, Hash, Token},
ethabi::{encode, Hash, Token},
l1::{L1Tx, OpProcessingType, PriorityQueueType},
web3::types::Log,
Execute, L1TxCommonData, PriorityOpId, ProtocolUpgrade, ProtocolVersion, ProtocolVersionId,
Expand Down
2 changes: 1 addition & 1 deletion core/lib/zksync_core/src/state_keeper/io/seal_logic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ impl UpdatesManager {
.blocks_dal()
.insert_l1_batch(
&l1_batch,
&finished_batch.final_bootloader_memory.as_ref().unwrap(),
finished_batch.final_bootloader_memory.as_ref().unwrap(),
self.l1_batch.l1_gas_count,
&events_queue,
&finished_batch.final_execution_state.storage_refunds,
Expand Down
2 changes: 1 addition & 1 deletion core/tests/ts-integration/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"chalk": "^4.0.0",
"ethereumjs-abi": "^0.6.8",
"ethers": "~5.7.0",
"hardhat": "^2.12.4",
"hardhat": "=2.16.0",
"jest": "^29.0.3",
"jest-matcher-utils": "^29.0.3",
"node-fetch": "^2.6.1",
Expand Down
1 change: 1 addition & 0 deletions core/tests/ts-integration/scripts/compile-yul.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import * as hre from 'hardhat';
import * as fs from 'fs';
// eslint-disable-next-line @typescript-eslint/no-unused-vars
import { exec as _exec, spawn as _spawn } from 'child_process';

import { getZksolcUrl, saltFromUrl } from '@matterlabs/hardhat-zksync-solc';
Expand Down
5 changes: 2 additions & 3 deletions core/tests/ts-integration/src/system.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { BigNumber, BytesLike } from 'ethers';
import { ethers } from 'ethers';
import { Provider, utils, Contract } from 'zksync-web3';
import { BigNumber, BytesLike, ethers } from 'ethers';
import { Provider, utils } from 'zksync-web3';

const L1_CONTRACTS_FOLDER = `${process.env.ZKSYNC_HOME}/contracts/ethereum/artifacts/cache/solpp-generated-contracts`;
const DIAMOND_UPGRADE_INIT_ABI = new ethers.utils.Interface(
Expand Down
2 changes: 1 addition & 1 deletion core/tests/upgrade-test/tests/upgrade.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ describe('Upgrade test', function () {

// Run again.
utils.background(
'cd $ZKSYNC_HOME && cargo run --bin zksync_server --release -- --components=api,tree,eth,data_fetcher,state_keeper &>> upgrade.log',
'cd $ZKSYNC_HOME && cargo run --bin zksync_server --release -- --components=api,tree,eth,data_fetcher,state_keeper &> upgrade.log',
[null, logs, logs]
);
await utils.sleep(10);
Expand Down
4 changes: 2 additions & 2 deletions etc/ERC20/hardhat.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import '@matterlabs/hardhat-zksync-solc';

export default {
zksolc: {
version: '1.3.1',
version: '1.3.16',
compilerSource: 'binary',
settings: {
isSystem: true
Expand All @@ -14,6 +14,6 @@ export default {
}
},
solidity: {
version: '0.8.16'
version: '0.8.20'
}
};
5 changes: 3 additions & 2 deletions etc/ERC20/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@
"main": "index.js",
"license": "MIT",
"devDependencies": {
"@matterlabs/hardhat-zksync-solc": "^0.3.15",
"hardhat": "=2.12.4"
"@matterlabs/hardhat-zksync-deploy": "^0.6.1",
"@matterlabs/hardhat-zksync-solc": "0.4.2",
"hardhat": "=2.16.0"
},
"scripts": {
"build": "hardhat compile"
Expand Down
2 changes: 1 addition & 1 deletion etc/contracts-test-data/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"license": "MIT",
"dependencies": {
"@openzeppelin/contracts": "^4.8.0",
"hardhat": "2.12.4"
"hardhat": "=2.16.0"
},
"devDependencies": {
"@matterlabs/hardhat-zksync-solc": "^0.3.15"
Expand Down
3 changes: 2 additions & 1 deletion etc/lint-config/sol.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ module.exports = {
//
// TODO (ZKS-329): Turn on the majority of the rules and make the solhint comply with them.
"state-visibility": "off",
"func-visibility": ["warn", { "ignoreConstructors": true }],
"var-name-mixedcase": "off",
"avoid-call-value": "off",
"no-empty-blocks": "off",
Expand All @@ -20,6 +21,6 @@ module.exports = {
"func-name-mixedcase": "off",
"no-unused-vars": "off",
"max-states-count": "off",
"compiler-version": ["warn", "^0.7.0"]
"compiler-version": ["warn", "^0.8.0"]
}
};
2 changes: 1 addition & 1 deletion etc/system-contracts
Submodule system-contracts updated 111 files
2 changes: 1 addition & 1 deletion infrastructure/protocol-upgrade/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"@types/node": "^14.6.1",
"@types/node-fetch": "^2.5.7",
"@types/tabtab": "^3.0.1",
"hardhat": "=2.12.4",
"hardhat": "=2.16.0",
"typescript": "^4.3.5",
"l2-zksync-contracts": "link:../../contracts/zksync",
"l1-zksync-contracts": "link:../../contracts/ethereum",
Expand Down
10 changes: 3 additions & 7 deletions infrastructure/protocol-upgrade/src/l1upgrade/deployer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@ export async function callFacetDeployer(
create2Address: string,
nonce: string,
executor: boolean,
governance: boolean,
diamondCut: boolean,
admin: boolean,
getters: boolean,
mailbox: boolean,
file: string
Expand All @@ -19,11 +18,8 @@ export async function callFacetDeployer(
if (executor) {
argsString += ' --executor';
}
if (governance) {
argsString += ' --governance';
}
if (diamondCut) {
argsString += ' --diamondCut';
if (admin) {
argsString += ' --admin';
}
if (getters) {
argsString += ' --getters';
Expand Down
53 changes: 14 additions & 39 deletions infrastructure/protocol-upgrade/src/l1upgrade/facets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,7 @@ async function deployAllFacets(
environment: string
) {
const file = getFacetsFileName(environment);
await callFacetDeployer(
l1RpcProvider,
privateKey,
gasPrice,
create2Address,
nonce,
true,
true,
true,
true,
true,
file
);
await callFacetDeployer(l1RpcProvider, privateKey, gasPrice, create2Address, nonce, true, true, true, true, file);
}

async function deployFacetsAndMergeFiles(
Expand All @@ -35,8 +23,7 @@ async function deployFacetsAndMergeFiles(
create2Address: string,
nonce: string,
executor: boolean,
governance: boolean,
diamondCut: boolean,
admin: boolean,
getters: boolean,
mailbox: boolean,
environment
Expand All @@ -51,8 +38,7 @@ async function deployFacetsAndMergeFiles(
create2Address,
nonce,
executor,
governance,
diamondCut,
admin,
getters,
mailbox,
tmpFacetsFile
Expand All @@ -77,9 +63,9 @@ async function generateFacetCuts(l1RpcProvider?: string, zksyncAddress?: string,
if (gettersAddress) {
gettersAddress = gettersAddress['address'];
}
let diamondCutAddress = facets['DiamondCutFacet'];
if (diamondCutAddress) {
diamondCutAddress = diamondCutAddress['address'];
let adminAddress = facets['AdminFacet'];
if (adminAddress) {
adminAddress = adminAddress['address'];
}
let mailboxAddress = facets['MailboxFacet'];
if (mailboxAddress) {
Expand All @@ -89,41 +75,35 @@ async function generateFacetCuts(l1RpcProvider?: string, zksyncAddress?: string,
if (executorAddress) {
executorAddress = executorAddress['address'];
}
let governanceAddress = facets['GovernanceFacet'];
if (governanceAddress) {
governanceAddress = governanceAddress['address'];
}

await callGenerateFacetCuts(
zksyncAddress,
getFacetCutsFileName(environment),
l1RpcProvider,
diamondCutAddress,
adminAddress,
gettersAddress,
mailboxAddress,
executorAddress,
governanceAddress
executorAddress
);
}

async function callGenerateFacetCuts(
zksyncAddress: string,
file: string,
l1RpcProvider?: string,
diamondCutAddress?: string,
adminAddress?: string,
gettersAddress?: string,
mailboxAddress?: string,
executorAddress?: string,
governanceAddress?: string
executorAddress?: string
) {
const cwd = process.cwd();
process.chdir(`${process.env.ZKSYNC_HOME}/contracts/ethereum/`);
let argsString = '';
if (l1RpcProvider) {
argsString += ` --l1Rpc ${l1RpcProvider}`;
}
if (diamondCutAddress) {
argsString += ` --diamond-cut-facet-address ${diamondCutAddress}`;
if (adminAddress) {
argsString += ` --admin-address ${adminAddress}`;
}
if (gettersAddress) {
argsString += ` --getters-address ${gettersAddress}`;
Expand All @@ -134,9 +114,6 @@ async function callGenerateFacetCuts(
if (executorAddress) {
argsString += ` --executor-address ${executorAddress}`;
}
if (governanceAddress) {
argsString += ` --governance-address ${governanceAddress}`;
}

argsString += ` --zkSyncAddress ${zksyncAddress}`;
argsString += ` --file ${file}`;
Expand Down Expand Up @@ -196,8 +173,7 @@ command
.option('--nonce <nonce>')
.option('--l1rpc <l1Rpc>')
.option('--executor')
.option('--governance')
.option('--diamond-cut')
.option('--admin')
.option('--getters')
.option('--mailbox')
.action(async (cmd) => {
Expand All @@ -208,8 +184,7 @@ command
cmd.create2Address,
cmd.nonce,
cmd.executor,
cmd.governance,
cmd.diamondCut,
cmd.admin,
cmd.getters,
cmd.mailbox,
cmd.environment
Expand Down
2 changes: 1 addition & 1 deletion infrastructure/zk/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
"@types/node-fetch": "^2.5.7",
"@types/pg": "^8.10.3",
"@types/tabtab": "^3.0.1",
"hardhat": "=2.12.4",
"hardhat": "=2.16.0",
"typescript": "^4.3.5"
}
}
7 changes: 1 addition & 6 deletions infrastructure/zk/src/compiler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,7 @@ export async function compileTestContracts() {
export async function compileSystemContracts() {
await utils.spawn('yarn workspace zksync-erc20 build');

process.chdir('etc/system-contracts');
await utils.spawn('yarn');
await utils.spawn('yarn hardhat compile');
await utils.spawn('yarn preprocess');
await utils.spawn('yarn hardhat run ./scripts/compile-yul.ts');
process.chdir('../..');
await utils.spawn('yarn workspace system-contracts build');
}

export async function compileAll() {
Expand Down
Loading