Skip to content

Commit

Permalink
feat(vm)!: Release v19 - remove allowlist (matter-labs#747)
Browse files Browse the repository at this point in the history
## What ❔

This upgrade contains mainly contract changes (more description of those
[here](matter-labs/era-contracts#133)), while
the changes that impacted `zksync-era` repo mainly refer to the changes
in how the testing / contract preprocessing is done: now, the system
contracts are preprocessed into the `contracts-preprocessed` folder and
then all the artifacts should be taken from there

## Why ❔

<!-- Why are these changes done? What goal do they contribute to? What
are the principles behind them? -->
<!-- Example: PR templates ensure PR reviewers, observers, and future
iterators are in context about the evolution of repos. -->

## Checklist

<!-- Check your PR fulfills the following items. -->
<!-- For draft PRs check the boxes as you complete them. -->

- [ ] PR title corresponds to the body of PR (we generate changelog
entries from PRs).
- [ ] Tests for the changes have been added / updated.
- [ ] Documentation comments have been added / updated.
- [ ] Code has been formatted via `zk fmt` and `zk lint`.
- [ ] Spellcheck has been run via `cargo spellcheck
--cfg=./spellcheck/era.cfg --code 1`.
  • Loading branch information
StanislavBreadless authored Jan 2, 2024
1 parent 1426b1b commit 0e2bc56
Show file tree
Hide file tree
Showing 44 changed files with 3,064 additions and 63 deletions.
4 changes: 2 additions & 2 deletions .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ contracts/.git
!infrastructure/zk
!sdk/zksync-rs
!contracts/system-contracts/bootloader/build/artifacts
!contracts/system-contracts/contracts/artifacts
!contracts/system-contracts/contracts/precompiles/artifacts
!contracts/system-contracts/contracts-preprocessed/artifacts
!contracts/system-contracts/contracts-preprocessed/precompiles/artifacts
!contracts/system-contracts/artifacts-zk
!etc/multivm_bootloaders
!cargo
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/vm-perf-comparison.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ jobs:
ci_run zk
ci_run zk compiler system-contracts
ci_run cargo bench --package vm-benchmark --bench iai | tee base-iai
ci_run yarn workspace system-contracts clean
- name: checkout PR
run: git checkout --force FETCH_HEAD --recurse-submodules
Expand Down
2 changes: 1 addition & 1 deletion contracts
Submodule contracts updated 111 files
4 changes: 2 additions & 2 deletions core/bin/system-constants-generator/src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -164,8 +164,8 @@ pub(super) fn get_l1_txs(number_of_txs: usize) -> (Vec<Transaction>, Vec<Transac

fn read_bootloader_test_code(test: &str) -> Vec<u8> {
read_zbin_bytecode(format!(
"contracts/system-contracts/bootloader/tests/artifacts/{}.yul/{}.yul.zbin",
test, test
"contracts/system-contracts/bootloader/tests/artifacts/{}.yul.zbin",
test
))
}

Expand Down
22 changes: 17 additions & 5 deletions core/lib/contracts/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ pub fn load_contract<P: AsRef<Path> + std::fmt::Debug>(path: P) -> Contract {

pub fn load_sys_contract(contract_name: &str) -> Contract {
load_contract(format!(
"contracts/system-contracts/artifacts-zk/cache-zk/solpp-generated-contracts/{0}.sol/{0}.json",
"contracts/system-contracts/artifacts-zk/contracts-preprocessed/{0}.sol/{0}.json",
contract_name
))
}
Expand Down Expand Up @@ -211,11 +211,11 @@ impl SystemContractsRepo {
) -> Vec<u8> {
match lang {
ContractLanguage::Sol => read_bytecode_from_path(self.root.join(format!(
"artifacts-zk/cache-zk/solpp-generated-contracts/{0}{1}.sol/{1}.json",
"artifacts-zk/contracts-preprocessed/{0}{1}.sol/{1}.json",
directory, name
))),
ContractLanguage::Yul => read_zbin_bytecode_from_path(self.root.join(format!(
"contracts/{0}artifacts/{1}.yul/{1}.yul.zbin",
"contracts-preprocessed/{0}artifacts/{1}.yul.zbin",
directory, name
))),
}
Expand All @@ -224,8 +224,8 @@ impl SystemContractsRepo {

pub fn read_bootloader_code(bootloader_type: &str) -> Vec<u8> {
read_zbin_bytecode(format!(
"contracts/system-contracts/bootloader/build/artifacts/{}.yul/{}.yul.zbin",
bootloader_type, bootloader_type
"contracts/system-contracts/bootloader/build/artifacts/{}.yul.zbin",
bootloader_type
))
}

Expand Down Expand Up @@ -365,6 +365,11 @@ impl BaseSystemContracts {
BaseSystemContracts::load_with_bootloader(bootloader_bytecode)
}

pub fn playground_post_allowlist_removal() -> Self {
let bootloader_bytecode = read_zbin_bytecode("etc/multivm_bootloaders/vm_remove_allowlist/playground_batch.yul/playground_batch.yul.zbin");
BaseSystemContracts::load_with_bootloader(bootloader_bytecode)
}

/// BaseSystemContracts with playground bootloader - used for handling eth_calls.
pub fn estimate_gas() -> Self {
let bootloader_bytecode = read_bootloader_code("fee_estimate");
Expand Down Expand Up @@ -399,6 +404,13 @@ impl BaseSystemContracts {
BaseSystemContracts::load_with_bootloader(bootloader_bytecode)
}

pub fn estimate_gas_post_allowlist_removal() -> Self {
let bootloader_bytecode = read_zbin_bytecode(
"etc/multivm_bootloaders/vm_remove_allowlist/fee_estimate.yul/fee_estimate.yul.zbin",
);
BaseSystemContracts::load_with_bootloader(bootloader_bytecode)
}

pub fn hashes(&self) -> BaseSystemContractsHashes {
BaseSystemContractsHashes {
bootloader: self.bootloader.hash,
Expand Down
4 changes: 2 additions & 2 deletions core/lib/multivm/src/versions/vm_1_3_2/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -221,8 +221,8 @@ pub fn create_test_block_params() -> (BlockContext, BlockProperties) {

pub fn read_bootloader_test_code(test: &str) -> Vec<u8> {
read_zbin_bytecode(format!(
"contracts/system-contracts/bootloader/tests/artifacts/{}.yul/{}.yul.zbin",
test, test
"contracts/system-contracts/bootloader/tests/artifacts/{}.yul.zbin",
test
))
}

Expand Down
4 changes: 2 additions & 2 deletions core/lib/multivm/src/versions/vm_latest/tests/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@ pub(crate) fn read_test_contract() -> Vec<u8> {

pub(crate) fn get_bootloader(test: &str) -> SystemContractCode {
let bootloader_code = read_zbin_bytecode(format!(
"contracts/system-contracts/bootloader/tests/artifacts/{}.yul/{}.yul.zbin",
test, test
"contracts/system-contracts/bootloader/tests/artifacts/{}.yul.zbin",
test
));

let bootloader_hash = hash_bytecode(&bootloader_code);
Expand Down
4 changes: 2 additions & 2 deletions core/lib/multivm/src/versions/vm_m5/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ pub fn create_test_block_params() -> (BlockContext, BlockProperties) {

pub fn read_bootloader_test_code(test: &str) -> Vec<u8> {
read_zbin_bytecode(format!(
"contracts/system-contracts/bootloader/tests/artifacts/{}.yul/{}.yul.zbin",
test, test
"contracts/system-contracts/bootloader/tests/artifacts/{}.yul.zbin",
test
))
}
4 changes: 2 additions & 2 deletions core/lib/multivm/src/versions/vm_m6/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -258,8 +258,8 @@ pub fn create_test_block_params() -> (BlockContext, BlockProperties) {

pub fn read_bootloader_test_code(test: &str) -> Vec<u8> {
read_zbin_bytecode(format!(
"contracts/system-contracts/bootloader/tests/artifacts/{}.yul/{}.yul.zbin",
test, test
"contracts/system-contracts/bootloader/tests/artifacts/{}.yul.zbin",
test
))
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@ pub(crate) fn read_test_contract() -> Vec<u8> {

pub(crate) fn get_bootloader(test: &str) -> SystemContractCode {
let bootloader_code = read_zbin_bytecode(format!(
"contracts/system-contracts/bootloader/tests/artifacts/{}.yul/{}.yul.zbin",
test, test
"contracts/system-contracts/bootloader/tests/artifacts/{}.yul.zbin",
test
));

let bootloader_hash = hash_bytecode(&bootloader_code);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@ pub(crate) fn read_test_contract() -> Vec<u8> {

pub(crate) fn get_bootloader(test: &str) -> SystemContractCode {
let bootloader_code = read_zbin_bytecode(format!(
"contracts/system-contracts/bootloader/tests/artifacts/{}.yul/{}.yul.zbin",
test, test
"contracts/system-contracts/bootloader/tests/artifacts/{}.yul.zbin",
test
));

let bootloader_hash = hash_bytecode(&bootloader_code);
Expand Down
7 changes: 5 additions & 2 deletions core/lib/types/src/protocol_version.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,15 +41,16 @@ pub enum ProtocolVersionId {
Version17,
Version18,
Version19,
Version20,
}

impl ProtocolVersionId {
pub fn latest() -> Self {
Self::Version18
Self::Version19
}

pub fn next() -> Self {
Self::Version19
Self::Version20
}

/// Returns VM version to be used by API for this protocol version.
Expand All @@ -76,6 +77,7 @@ impl ProtocolVersionId {
ProtocolVersionId::Version17 => VmVersion::VmVirtualBlocksRefundsEnhancement,
ProtocolVersionId::Version18 => VmVersion::VmBoojumIntegration,
ProtocolVersionId::Version19 => VmVersion::VmBoojumIntegration,
ProtocolVersionId::Version20 => VmVersion::VmBoojumIntegration,
}
}

Expand Down Expand Up @@ -695,6 +697,7 @@ impl From<ProtocolVersionId> for VmVersion {
ProtocolVersionId::Version17 => VmVersion::VmVirtualBlocksRefundsEnhancement,
ProtocolVersionId::Version18 => VmVersion::VmBoojumIntegration,
ProtocolVersionId::Version19 => VmVersion::VmBoojumIntegration,
ProtocolVersionId::Version20 => VmVersion::VmBoojumIntegration,
}
}
}
Expand Down
9 changes: 8 additions & 1 deletion core/lib/zksync_core/src/api_server/tx_sender/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ pub struct MultiVMBaseSystemContracts {
pub(crate) post_virtual_blocks_finish_upgrade_fix: BaseSystemContracts,
/// Contracts to be used for post-boojum protocol versions.
pub(crate) post_boojum: BaseSystemContracts,
/// Contracts to be used after the allow-list removal upgrade
pub(crate) post_allowlist_removal: BaseSystemContracts,
}

impl MultiVMBaseSystemContracts {
Expand All @@ -78,7 +80,10 @@ impl MultiVMBaseSystemContracts {
| ProtocolVersionId::Version15
| ProtocolVersionId::Version16
| ProtocolVersionId::Version17 => self.post_virtual_blocks_finish_upgrade_fix,
ProtocolVersionId::Version18 | ProtocolVersionId::Version19 => self.post_boojum,
ProtocolVersionId::Version18 => self.post_boojum,
ProtocolVersionId::Version19 | ProtocolVersionId::Version20 => {
self.post_allowlist_removal
}
}
}
}
Expand Down Expand Up @@ -109,13 +114,15 @@ impl ApiContracts {
post_virtual_blocks_finish_upgrade_fix:
BaseSystemContracts::estimate_gas_post_virtual_blocks_finish_upgrade_fix(),
post_boojum: BaseSystemContracts::estimate_gas_post_boojum(),
post_allowlist_removal: BaseSystemContracts::estimate_gas_post_allowlist_removal(),
},
eth_call: MultiVMBaseSystemContracts {
pre_virtual_blocks: BaseSystemContracts::playground_pre_virtual_blocks(),
post_virtual_blocks: BaseSystemContracts::playground_post_virtual_blocks(),
post_virtual_blocks_finish_upgrade_fix:
BaseSystemContracts::playground_post_virtual_blocks_finish_upgrade_fix(),
post_boojum: BaseSystemContracts::playground_post_boojum(),
post_allowlist_removal: BaseSystemContracts::playground_post_allowlist_removal(),
},
}
}
Expand Down
14 changes: 2 additions & 12 deletions core/tests/ts-integration/tests/custom-erc20-bridge.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { spawn as _spawn } from 'child_process';
import * as zksync from 'zksync-web3';
import * as ethers from 'ethers';
import { scaledGasPrice } from '../src/helpers';
import { L1ERC20BridgeFactory, TransparentUpgradeableProxyFactory, AllowListFactory } from 'l1-contracts/typechain';
import { L1ERC20BridgeFactory, TransparentUpgradeableProxyFactory } from 'l1-contracts/typechain';
import { sleep } from 'zk/build/utils';

describe('Tests for the custom bridge behavior', () => {
Expand All @@ -36,18 +36,11 @@ describe('Tests for the custom bridge behavior', () => {
});
await transferTx.wait();

let allowList = new AllowListFactory(alice._signerL1());
let allowListContract = await allowList.deploy(alice.address);
await allowListContract.deployTransaction.wait(2);

// load the l1bridge contract
let l1bridgeFactory = new L1ERC20BridgeFactory(alice._signerL1());
const gasPrice = await scaledGasPrice(alice);

let l1Bridge = await l1bridgeFactory.deploy(
process.env.CONTRACTS_DIAMOND_PROXY_ADDR!,
allowListContract.address
);
let l1Bridge = await l1bridgeFactory.deploy(process.env.CONTRACTS_DIAMOND_PROXY_ADDR!);
await l1Bridge.deployTransaction.wait(2);
let l1BridgeProxyFactory = new TransparentUpgradeableProxyFactory(alice._signerL1());
let l1BridgeProxy = await l1BridgeProxyFactory.deploy(l1Bridge.address, bob.address, '0x');
Expand All @@ -62,9 +55,6 @@ describe('Tests for the custom bridge behavior', () => {
let command = `${baseCommandL1} initialize-bridges ${args}`;
await spawn(command);

const setAccessModeTx = await allowListContract.setAccessMode(l1BridgeProxy.address, 2);
await setAccessModeTx.wait();

let l1bridge2 = new L1ERC20BridgeFactory(alice._signerL1()).attach(l1BridgeProxy.address);

const maxAttempts = 200;
Expand Down
2 changes: 1 addition & 1 deletion core/tests/ts-integration/tests/system.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,7 @@ describe('System behavior checks', () => {
function bootloaderUtilsContract() {
const BOOTLOADER_UTILS_ADDRESS = '0x000000000000000000000000000000000000800c';
const BOOTLOADER_UTILS = new ethers.utils.Interface(
require(`${process.env.ZKSYNC_HOME}/contracts/system-contracts/artifacts-zk/cache-zk/solpp-generated-contracts/BootloaderUtilities.sol/BootloaderUtilities.json`).abi
require(`${process.env.ZKSYNC_HOME}/contracts/system-contracts/artifacts-zk/contracts-preprocessed/BootloaderUtilities.sol/BootloaderUtilities.json`).abi
);

return new ethers.Contract(BOOTLOADER_UTILS_ADDRESS, BOOTLOADER_UTILS, alice);
Expand Down
4 changes: 2 additions & 2 deletions core/tests/upgrade-test/tests/upgrade.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ const L2_FORCE_DEPLOY_UPGRADER_ABI = new ethers.utils.Interface(
require(`${process.env.ZKSYNC_HOME}/contracts/l2-contracts/artifacts-zk/cache-zk/solpp-generated-contracts/ForceDeployUpgrader.sol/ForceDeployUpgrader.json`).abi
);
const COMPLEX_UPGRADER_ABI = new ethers.utils.Interface(
require(`${process.env.ZKSYNC_HOME}/contracts/system-contracts/artifacts-zk/cache-zk/solpp-generated-contracts/ComplexUpgrader.sol/ComplexUpgrader.json`).abi
require(`${process.env.ZKSYNC_HOME}/contracts/system-contracts/artifacts-zk/contracts-preprocessed/ComplexUpgrader.sol/ComplexUpgrader.json`).abi
);
const COUNTER_BYTECODE =
require(`${process.env.ZKSYNC_HOME}/core/tests/ts-integration/artifacts-zk/contracts/counter/counter.sol/Counter.json`).deployedBytecode;
Expand Down Expand Up @@ -130,7 +130,7 @@ describe('Upgrade test', function () {
});

step('Send l1 tx for saving new bootloader', async () => {
const path = `${process.env.ZKSYNC_HOME}/contracts/system-contracts/bootloader/build/artifacts/playground_batch.yul/playground_batch.yul.zbin`;
const path = `${process.env.ZKSYNC_HOME}/contracts/system-contracts/bootloader/build/artifacts/playground_batch.yul.zbin`;
const bootloaderCode = ethers.utils.hexlify(fs.readFileSync(path));
bootloaderHash = ethers.utils.hexlify(hashBytecode(bootloaderCode));
const txHandle = await tester.syncWallet.requestExecute({
Expand Down
4 changes: 2 additions & 2 deletions docker/external-node/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ COPY --from=builder /usr/src/zksync/target/release/block_reverter /usr/bin
COPY --from=builder /usr/local/cargo/bin/sqlx /usr/bin
COPY --from=builder /usr/src/zksync/docker/external-node/entrypoint.sh /usr/bin
COPY contracts/system-contracts/bootloader/build/artifacts/ /contracts/system-contracts/bootloader/build/artifacts/
COPY contracts/system-contracts/contracts/artifacts/ /contracts/system-contracts/contracts/artifacts/
COPY contracts/system-contracts/contracts/precompiles/artifacts/ /contracts/system-contracts/contracts/precompiles/artifacts/
COPY contracts/system-contracts/contracts-preprocessed/artifacts/ /contracts/system-contracts/contracts-preprocessed/artifacts/
COPY contracts/system-contracts/contracts-preprocessed/precompiles/artifacts/ /contracts/system-contracts/contracts-preprocessed/precompiles/artifacts/
COPY contracts/system-contracts/artifacts-zk /contracts/system-contracts/artifacts-zk
COPY contracts/l1-contracts/artifacts/ /contracts/l1-contracts/artifacts/
COPY contracts/l2-contracts/artifacts-zk/ /contracts/l2-contracts/artifacts-zk/
Expand Down
4 changes: 2 additions & 2 deletions docker/server-v2/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ COPY --from=builder /usr/src/zksync/target/release/zksync_server /usr/bin
COPY --from=builder /usr/src/zksync/target/release/block_reverter /usr/bin
COPY --from=builder /usr/src/zksync/target/release/merkle_tree_consistency_checker /usr/bin
COPY contracts/system-contracts/bootloader/build/artifacts/ /contracts/system-contracts/bootloader/build/artifacts/
COPY contracts/system-contracts/contracts/artifacts/ /contracts/system-contracts/contracts/artifacts/
COPY contracts/system-contracts/contracts/precompiles/artifacts/ /contracts/system-contracts/contracts/precompiles/artifacts/
COPY contracts/system-contracts/contracts-preprocessed/artifacts/ /contracts/system-contracts/contracts-preprocessed/artifacts/
COPY contracts/system-contracts/contracts-preprocessed/precompiles/artifacts/ /contracts/system-contracts/contracts-preprocessed/precompiles/artifacts/
COPY contracts/system-contracts/artifacts-zk /contracts/system-contracts/artifacts-zk
COPY contracts/l1-contracts/artifacts/ /contracts/l1-contracts/artifacts/
COPY contracts/l2-contracts/artifacts-zk/ /contracts/l2-contracts/artifacts-zk/
Expand Down
1 change: 1 addition & 0 deletions etc/multivm_bootloaders/vm_remove_allowlist/commit
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
fa45ef1d2b04c640395ec1f34f76ef03f8d19849
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
5 changes: 5 additions & 0 deletions etc/upgrades/1702392522-allowlist-removal/common.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"name": "allowlist-removal",
"creationTimestamp": 1702392522,
"protocolVersion": "19"
}
Loading

0 comments on commit 0e2bc56

Please sign in to comment.