Skip to content

Commit

Permalink
Merge pull request #2650 from matter-labs/sb-sync-kl-sync-layer-reorg
Browse files Browse the repository at this point in the history
chore: Use contracts from kl sync layer reorg
  • Loading branch information
StanislavBreadless authored Aug 14, 2024
2 parents b210b71 + 453e175 commit 2bd57d5
Show file tree
Hide file tree
Showing 12 changed files with 53 additions and 55 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/ci-core-reusable.yml
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ jobs:
ci_run cat /tmp/sccache_log.txt || true
integration:
name: Integration (consensus=${{ matrix.consensus }}, base_token=${{ matrix.base_token }}, sync_layer = ${{ matrix.sync_layer }})
name: Integration (consensus=${{ matrix.consensus }}, base_token=${{ matrix.base_token }}, gateway = ${{ matrix.gateway }})
strategy:
# In matrix jobs, fail-fast is true by default.
# To be consistent with the rest of the workflow we disable it explicitly.
Expand All @@ -151,7 +151,7 @@ jobs:
# FIXME: support custom tokens
base_token: ["Eth"]
# FIXME: run tests even when not using synclayer
sync_layer: [true]
gateway: [true]
env:
SERVER_COMPONENTS: "api,tree,eth,state_keeper,housekeeper,commitment_generator,vm_runner_protective_reads,vm_runner_bwip,da_dispatcher${{ matrix.consensus && ',consensus' || '' }}${{ matrix.base_token == 'Custom' && ',base_token_ratio_persister' || '' }}"

Expand Down
2 changes: 1 addition & 1 deletion contracts
Submodule contracts updated 131 files
8 changes: 4 additions & 4 deletions core/lib/contracts/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -415,10 +415,10 @@ impl BaseSystemContracts {
BaseSystemContracts::load_with_bootloader(bootloader_bytecode)
}

pub fn playground_sync_layer() -> Self {
pub fn playground_gateway() -> Self {
let bootloader_bytecode = read_zbin_bytecode(
"contracts/system-contracts/bootloader/build/artifacts/playground_batch.yul.zbin",
// "etc/multivm_bootloaders/vm_sync_layer/playground_batch.yul/playground_batch.yul.zbin",
// "etc/multivm_bootloaders/vm_gateway/playground_batch.yul/playground_batch.yul.zbin",
);
BaseSystemContracts::load_with_bootloader(bootloader_bytecode)
}
Expand Down Expand Up @@ -486,10 +486,10 @@ impl BaseSystemContracts {
BaseSystemContracts::load_with_bootloader(bootloader_bytecode)
}

pub fn estimate_gas_sync_layer() -> Self {
pub fn estimate_gas_gateway() -> Self {
let bootloader_bytecode = read_zbin_bytecode(
"contracts/system-contracts/bootloader/build/artifacts/fee_estimate.yul.zbin",
// "etc/multivm_bootloaders/vm_sync_layer/fee_estimate.yul/fee_estimate.yul.zbin",
// "etc/multivm_bootloaders/vm_gateway/fee_estimate.yul/fee_estimate.yul.zbin",
);
BaseSystemContracts::load_with_bootloader(bootloader_bytecode)
}
Expand Down
8 changes: 4 additions & 4 deletions core/node/api_server/src/tx_sender/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ pub struct MultiVMBaseSystemContracts {
/// Contracts to be used after the 1.5.0 upgrade
pub(crate) vm_1_5_0_increased_memory: BaseSystemContracts,
/// Contracts to be used after the 1.5.0 upgrade
pub(crate) sync_layer: BaseSystemContracts,
pub(crate) gateway: BaseSystemContracts,
}

impl MultiVMBaseSystemContracts {
Expand Down Expand Up @@ -138,7 +138,7 @@ impl MultiVMBaseSystemContracts {
ProtocolVersionId::Version21 | ProtocolVersionId::Version22 => self.post_1_4_2,
ProtocolVersionId::Version23 => self.vm_1_5_0_small_memory,
ProtocolVersionId::Version24 => self.vm_1_5_0_increased_memory,
ProtocolVersionId::Version25 | ProtocolVersionId::Version26 => self.sync_layer,
ProtocolVersionId::Version25 | ProtocolVersionId::Version26 => self.gateway,
}
}
}
Expand Down Expand Up @@ -182,7 +182,7 @@ impl ApiContracts {
vm_1_5_0_small_memory: BaseSystemContracts::estimate_gas_1_5_0_small_memory(),
vm_1_5_0_increased_memory:
BaseSystemContracts::estimate_gas_post_1_5_0_increased_memory(),
sync_layer: BaseSystemContracts::estimate_gas_sync_layer(),
gateway: BaseSystemContracts::estimate_gas_gateway(),
},
eth_call: MultiVMBaseSystemContracts {
pre_virtual_blocks: BaseSystemContracts::playground_pre_virtual_blocks(),
Expand All @@ -196,7 +196,7 @@ impl ApiContracts {
vm_1_5_0_small_memory: BaseSystemContracts::playground_1_5_0_small_memory(),
vm_1_5_0_increased_memory:
BaseSystemContracts::playground_post_1_5_0_increased_memory(),
sync_layer: BaseSystemContracts::playground_sync_layer(),
gateway: BaseSystemContracts::playground_gateway(),
},
}
}
Expand Down
2 changes: 1 addition & 1 deletion core/node/api_server/src/web3/namespaces/zks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,7 @@ impl ZksNamespace {

// Create a client for pinging the RPC.
let client: Client<L2> = Client::http(
std::env::var("SYNC_LAYER_API_WEB3_JSON_RPC_HTTP_URL")
std::env::var("GATEWAY_API_WEB3_JSON_RPC_HTTP_URL")
.unwrap()
.parse()
.unwrap(),
Expand Down
4 changes: 2 additions & 2 deletions etc/env/base/chain.toml
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,8 @@ fee_model_version = "V2"
validation_computational_gas_limit = 300000
save_call_traces = true

bootloader_hash = "0x010008eb70b467979695d3f240d8db04b1b179dd02c0d7fd45a027fb4bd9ecaf"
default_aa_hash = "0x0100055de356de05b75c83195567a6688d9050a17b58ccc5c5c91d05cd2bfb6d"
bootloader_hash = "0x010008eb2ba1ec6290b553a401b9609363d9cc89796b3dd1aad8fb24cd88702e"
default_aa_hash = "0x0100055dbf6d8f56faa896e4cc8e987aa24aaaee5fe85fc17243d908b9b74f69"

protective_reads_persistence_enabled = false

Expand Down
4 changes: 2 additions & 2 deletions etc/env/base/contracts.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ RECURSION_NODE_LEVEL_VK_HASH = "0x1186ec268d49f1905f8d9c1e9d39fc33e98c74f91d91a2
RECURSION_LEAF_LEVEL_VK_HASH = "0x101e08b00193e529145ee09823378ef51a3bc8966504064f1f6ba3f1ba863210"
RECURSION_CIRCUITS_SET_VKS_HASH = "0x18c1639094f58177409186e8c48d9f577c9410901d2f1d486b3e7d6cf553ae4c"
GENESIS_TX_HASH = "0xb99ebfea46cbe05a21cd80fe5597d97b204befc52a16303f579c607dc1ac2e2e"
GENESIS_ROOT = "0x53b2db8a7a5954757679b80a3403f077b7e1b8f398383a0075d95eadae08366c"
GENESIS_BATCH_COMMITMENT = "0x8933c43b571c2bd43bc73fbaaa2ea8de7e07fcedcbd58935400f1c18620c396f"
GENESIS_ROOT = "0x405ddf3e881479826ae5e09316adde62c0251510723570b7a26a0092d84a87d2"
GENESIS_BATCH_COMMITMENT = "0x97a8d80434646aa54503cf65a9b5282fb166399af69e7bb43c95b2587657ef28"
PRIORITY_TX_MAX_GAS_LIMIT = 72000000
DEPLOY_L2_BRIDGE_COUNTERPART_GAS_LIMIT = 10000000
GENESIS_ROLLUP_LEAF_INDEX = "71"
Expand Down
76 changes: 37 additions & 39 deletions infrastructure/zk/src/contract.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,44 +11,44 @@ export async function build(zkSyncNetwork: boolean): Promise<void> {
}

const syncLayerEnvVars = [
'SYNC_LAYER_CREATE2_FACTORY_ADDR',
'GATEWAY_CREATE2_FACTORY_ADDR',

'SYNC_LAYER_STATE_TRANSITION_PROXY_ADDR',
'SYNC_LAYER_STATE_TRANSITION_IMPL_ADDR',
'GATEWAY_STATE_TRANSITION_PROXY_ADDR',
'GATEWAY_STATE_TRANSITION_IMPL_ADDR',

'SYNC_LAYER_DIAMOND_INIT_ADDR',
'SYNC_LAYER_DEFAULT_UPGRADE_ADDR',
'SYNC_LAYER_GENESIS_UPGRADE_ADDR',
'SYNC_LAYER_GOVERNANCE_ADDR',
'SYNC_LAYER_ADMIN_FACET_ADDR',
'SYNC_LAYER_EXECUTOR_FACET_ADDR',
'SYNC_LAYER_GETTERS_FACET_ADDR',
'SYNC_LAYER_MAILBOX_FACET_ADDR',
'GATEWAY_DIAMOND_INIT_ADDR',
'GATEWAY_DEFAULT_UPGRADE_ADDR',
'GATEWAY_GENESIS_UPGRADE_ADDR',
'GATEWAY_GOVERNANCE_ADDR',
'GATEWAY_ADMIN_FACET_ADDR',
'GATEWAY_EXECUTOR_FACET_ADDR',
'GATEWAY_GETTERS_FACET_ADDR',
'GATEWAY_MAILBOX_FACET_ADDR',

'SYNC_LAYER_VERIFIER_ADDR',
'SYNC_LAYER_VALIDATOR_TIMELOCK_ADDR',
'GATEWAY_VERIFIER_ADDR',
'GATEWAY_VALIDATOR_TIMELOCK_ADDR',

// 'SYNC_LAYER_TRANSPARENT_PROXY_ADMIN_ADDR',
// 'GATEWAY_TRANSPARENT_PROXY_ADMIN_ADDR',

'SYNC_LAYER_L1_MULTICALL3_ADDR',
'SYNC_LAYER_BLOB_VERSIONED_HASH_RETRIEVER_ADDR',
'GATEWAY_L1_MULTICALL3_ADDR',
'GATEWAY_BLOB_VERSIONED_HASH_RETRIEVER_ADDR',

'SYNC_LAYER_API_WEB3_JSON_RPC_HTTP_URL',
'SYNC_LAYER_CHAIN_ID',
'GATEWAY_API_WEB3_JSON_RPC_HTTP_URL',
'GATEWAY_CHAIN_ID',

'SYNC_LAYER_BRIDGEHUB_IMPL_ADDR',
'SYNC_LAYER_BRIDGEHUB_PROXY_ADDR',
'GATEWAY_BRIDGEHUB_IMPL_ADDR',
'GATEWAY_BRIDGEHUB_PROXY_ADDR',

// 'SYNC_LAYER_TRANSPARENT_PROXY_ADMIN_ADDR',
// 'GATEWAY_TRANSPARENT_PROXY_ADMIN_ADDR',

// 'SYNC_LAYER_L1_SHARED_BRIDGE_IMPL_ADDR',
// 'SYNC_LAYER_L1_SHARED_BRIDGE_PROXY_ADDR',
// 'SYNC_LAYER_L1_ERC20_BRIDGE_IMPL_ADDR',
// 'SYNC_LAYER_L1_ERC20_BRIDGE_PROXY_ADDR',
// 'GATEWAY_L1_SHARED_BRIDGE_IMPL_ADDR',
// 'GATEWAY_L1_SHARED_BRIDGE_PROXY_ADDR',
// 'GATEWAY_L1_ERC20_BRIDGE_IMPL_ADDR',
// 'GATEWAY_L1_ERC20_BRIDGE_PROXY_ADDR',
'CONTRACTS_STM_ASSET_INFO',

'SYNC_LAYER_DIAMOND_PROXY_ADDR',
'SYNC_LAYER_L1_RELAYED_SL_DA_VALIDATOR'
'GATEWAY_DIAMOND_PROXY_ADDR',
'GATEWAY_L1_RELAYED_SL_DA_VALIDATOR'
];

const USER_FACING_ENV_VARS = ['CONTRACTS_USER_FACING_DIAMOND_PROXY_ADDR', 'CONTRACTS_USER_FACING_BRIDGEHUB_PROXY_ADDR'];
Expand All @@ -63,15 +63,15 @@ export async function prepareSyncLayer(): Promise<void> {
);

const paramsFromEnv = [
`SYNC_LAYER_API_WEB3_JSON_RPC_HTTP_URL=${process.env.API_WEB3_JSON_RPC_HTTP_URL}`,
`SYNC_LAYER_CHAIN_ID=${process.env.CHAIN_ETH_ZKSYNC_NETWORK_ID}`
`GATEWAY_API_WEB3_JSON_RPC_HTTP_URL=${process.env.API_WEB3_JSON_RPC_HTTP_URL}`,
`GATEWAY_CHAIN_ID=${process.env.CHAIN_ETH_ZKSYNC_NETWORK_ID}`
].join('\n');

const deployLog =
fs
.readFileSync('sync-layer-prep.log')
.toString()
.replace(/CONTRACTS/g, 'SYNC_LAYER') +
.replace(/CONTRACTS/g, 'GATEWAY') +
'\n' +
paramsFromEnv;

Expand Down Expand Up @@ -102,14 +102,14 @@ async function migrateToSyncLayer() {
const migrationLog = fs
.readFileSync('sync-layer-migration.log')
.toString()
.replace(/CONTRACTS/g, 'SYNC_LAYER');
.replace(/CONTRACTS/g, 'GATEWAY');

const envFile = `etc/env/l2-inits/${process.env.ZKSYNC_ENV!}.init.env`;
console.log('Writing to', envFile);

// FIXME: consider creating new sync_layer_* variable.
updateContractsEnv(envFile, migrationLog, ['SYNC_LAYER_DIAMOND_PROXY_ADDR']);
env.modify('CONTRACTS_DIAMOND_PROXY_ADDR', process.env.SYNC_LAYER_DIAMOND_PROXY_ADDR!, envFile, true);
updateContractsEnv(envFile, migrationLog, ['GATEWAY_DIAMOND_PROXY_ADDR']);
env.modify('CONTRACTS_DIAMOND_PROXY_ADDR', process.env.GATEWAY_DIAMOND_PROXY_ADDR!, envFile, true);
}

async function prepareValidatorsOnSyncLayer() {
Expand All @@ -125,7 +125,7 @@ async function recoverFromFailedMigrationToSyncLayer(failedTxSLHash: string) {
/// FIXME: generally we should use a different approach for config maintaining within sync layer
/// the chain should retain both "sync_layer" and "contracts_" contracts and be able to switch between them
async function updateConfigOnSyncLayer() {
const specialParams = ['SYNC_LAYER_API_WEB3_JSON_RPC_HTTP_URL', 'SYNC_LAYER_CHAIN_ID'];
const specialParams = ['GATEWAY_API_WEB3_JSON_RPC_HTTP_URL', 'GATEWAY_CHAIN_ID'];

const envFile = `etc/env/l2-inits/${process.env.ZKSYNC_ENV!}.init.env`;

Expand All @@ -140,15 +140,13 @@ async function updateConfigOnSyncLayer() {
if (specialParams.includes(envVar)) {
continue;
}
const contractsVar = envVar.replace(/SYNC_LAYER/g, 'CONTRACTS');
const contractsVar = envVar.replace(/GATEWAY/g, 'CONTRACTS');
env.modify(contractsVar, process.env[envVar]!, envFile, false);
}
env.modify('BRIDGE_LAYER_WEB3_URL', process.env.ETH_CLIENT_WEB3_URL!, envFile, false);
env.modify('ETH_CLIENT_WEB3_URL', process.env.SYNC_LAYER_API_WEB3_JSON_RPC_HTTP_URL!, envFile, false);
env.modify('ETH_CLIENT_WEB3_URL', process.env.GATEWAY_API_WEB3_JSON_RPC_HTTP_URL!, envFile, false);
env.modify('L1_RPC_ADDRESS', process.env.ETH_CLIENT_WEB3_URL!, envFile, false);
env.modify('ETH_CLIENT_CHAIN_ID', process.env.SYNC_LAYER_CHAIN_ID!, envFile, false);

console.log('b');
env.modify('ETH_CLIENT_CHAIN_ID', process.env.GATEWAY_CHAIN_ID!, envFile, false);

env.modify('CHAIN_ETH_NETWORK', 'localhostL2', envFile, false);

Expand Down

0 comments on commit 2bd57d5

Please sign in to comment.