Skip to content
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
2 changes: 1 addition & 1 deletion contracts
Submodule contracts updated 84 files
+1 −1 .github/workflows/slither.yaml
+0 −1 .gitignore
+3 −1 .prettierignore
+423 −353 AllContractsHashes.json
+35 −19 configs/genesis/zksync-os/latest.json
+133 −0 l1-contracts/AGENTS.md
+2 −0 l1-contracts/contracts/bridge/asset-tracker/IL1AssetTracker.sol
+6 −0 l1-contracts/contracts/bridge/asset-tracker/IL2AssetTracker.sol
+1 −0 l1-contracts/contracts/bridge/asset-tracker/L1AssetTracker.sol
+2 −0 l1-contracts/contracts/bridge/asset-tracker/L2AssetTracker.sol
+10 −8 l1-contracts/contracts/common/L1ContractErrors.sol
+2 −1 l1-contracts/contracts/interop/InteropCenter.sol
+2 −0 l1-contracts/contracts/interop/InteropErrors.sol
+38 −0 l1-contracts/contracts/l2-system/zksync-os/SystemContext.sol
+0 −506 l1-contracts/contracts/state-transition/chain-deps/GatewayCTMDeployer.sol
+225 −0 l1-contracts/contracts/state-transition/chain-deps/gateway-ctm-deployer/GatewayCTMDeployer.sol
+30 −0 l1-contracts/contracts/state-transition/chain-deps/gateway-ctm-deployer/GatewayCTMDeployerCTM.sol
+168 −0 l1-contracts/contracts/state-transition/chain-deps/gateway-ctm-deployer/GatewayCTMDeployerCTMBase.sol
+30 −0 l1-contracts/contracts/state-transition/chain-deps/gateway-ctm-deployer/GatewayCTMDeployerCTMZKsyncOS.sol
+46 −0 l1-contracts/contracts/state-transition/chain-deps/gateway-ctm-deployer/GatewayCTMDeployerDA.sol
+37 −0 l1-contracts/contracts/state-transition/chain-deps/gateway-ctm-deployer/GatewayCTMDeployerProxyAdmin.sol
+46 −0 ...ontracts/contracts/state-transition/chain-deps/gateway-ctm-deployer/GatewayCTMDeployerValidatorTimelock.sol
+57 −0 l1-contracts/contracts/state-transition/chain-deps/gateway-ctm-deployer/GatewayCTMDeployerVerifiers.sol
+66 −0 ...ontracts/contracts/state-transition/chain-deps/gateway-ctm-deployer/GatewayCTMDeployerVerifiersZKsyncOS.sol
+892 −273 l1-contracts/deploy-scripts/gateway/GatewayCTMDeployerHelper.sol
+78 −31 l1-contracts/deploy-scripts/gateway/GatewayVotePreparation.s.sol
+1 −1 l1-contracts/deploy-scripts/utils/Types.sol
+34 −5 l1-contracts/deploy-scripts/utils/Utils.sol
+1 −1 l1-contracts/deploy-scripts/utils/bytecode/BytecodeUtils.s.sol
+2 −5 l1-contracts/deploy-scripts/utils/deploy/Create2FactoryUtils.s.sol
+53 −0 l1-contracts/deploy-scripts/utils/deploy/L1L2DeployUtils.sol
+3 −3 l1-contracts/package.json
+134 −46 l1-contracts/selectors
+47 −0 l1-contracts/test/foundry/l1/integration/AssetRouterTest.t.sol
+191 −4 l1-contracts/test/foundry/l1/integration/AssetTrackerTest.t.sol
+136 −14 l1-contracts/test/foundry/l1/integration/BridgehubNormalTest.t.sol
+21 −2 l1-contracts/test/foundry/l1/integration/Bridgehub_7702.t.sol
+38 −14 l1-contracts/test/foundry/l1/integration/ChainRegistrationSender.t.sol
+22 −0 l1-contracts/test/foundry/l1/integration/DeploymentTest.t.sol
+92 −3 l1-contracts/test/foundry/l1/integration/L1ChainAssetHandlerTest.t.sol
+132 −2 l1-contracts/test/foundry/l1/integration/L1GatewayTests.t.sol
+0 −46 l1-contracts/test/foundry/l1/integration/l2-tests-abstract/GW_CTMDeployer.t.sol
+127 −0 ...s/test/foundry/l1/integration/l2-tests-abstract/L2AssetRouterAttributesEncodingRegressionTestAbstract.t.sol
+134 −0 ...undry/l1/integration/l2-tests-abstract/L2AssetRouterReceiveMessageAccessControlRegressionTestAbstract.t.sol
+216 −0 ...dry/l1/integration/l2-tests-abstract/L2AssetRouterReceiveMessageValueForwardingRegressionTestAbstract.t.sol
+45 −4 l1-contracts/test/foundry/l1/integration/l2-tests-abstract/L2AssetTracker.t.sol
+139 −0 l1-contracts/test/foundry/l1/integration/l2-tests-abstract/L2BridgehubAliasRegressionTestAbstract.t.sol
+13 −3 l1-contracts/test/foundry/l1/integration/l2-tests-abstract/L2Erc20TestAbstract.t.sol
+50 −20 l1-contracts/test/foundry/l1/integration/l2-tests-abstract/L2GatewayTestAbstract.t.sol
+180 −0 ...ntracts/test/foundry/l1/integration/l2-tests-abstract/L2InteropDestinationChainRegressionTestAbstract.t.sol
+26 −2 l1-contracts/test/foundry/l1/integration/l2-tests-abstract/L2InteropExecuteBundleTestAbstract.t.sol
+292 −0 ...tracts/test/foundry/l1/integration/l2-tests-abstract/L2InteropHandlerReentrancyRegressionTestAbstract.t.sol
+203 −8 l1-contracts/test/foundry/l1/integration/l2-tests-abstract/L2InteropHandlerTestAbstract.t.sol
+674 −0 ...tracts/test/foundry/l1/integration/l2-tests-abstract/L2InteropIndirectCallValueRegressionTestAbstract.t.sol
+55 −4 l1-contracts/test/foundry/l1/integration/l2-tests-abstract/L2InteropLibraryBasicTestAbstract.t.sol
+14 −2 l1-contracts/test/foundry/l1/integration/l2-tests-abstract/L2InteropNativeTokenDifferentBaseTestAbstract.t.sol
+20 −5 l1-contracts/test/foundry/l1/integration/l2-tests-abstract/L2InteropNativeTokenSimpleTestAbstract.t.sol
+48 −5 l1-contracts/test/foundry/l1/integration/l2-tests-abstract/L2InteropTestUtils.sol
+53 −3 l1-contracts/test/foundry/l1/integration/l2-tests-abstract/L2InteropUnbundleTestAbstract.t.sol
+630 −1 l1-contracts/test/foundry/l1/integration/l2-tests-abstract/L2NativeTokenVaultTestAbstract.t.sol
+0 −55 l1-contracts/test/foundry/l1/integration/l2-tests-in-l1-context/GW_CTMDeployerL1Test.t.sol
+62 −0 ...ts/test/foundry/l1/integration/l2-tests-in-l1-context/L2AssetRouterAttributesEncodingRegressionL1Test.t.sol
+66 −0 ...oundry/l1/integration/l2-tests-in-l1-context/L2AssetRouterReceiveMessageAccessControlRegressionL1Test.t.sol
+64 −0 ...ndry/l1/integration/l2-tests-in-l1-context/L2AssetRouterReceiveMessageValueForwardingRegressionL1Test.t.sol
+59 −0 l1-contracts/test/foundry/l1/integration/l2-tests-in-l1-context/L2BridgehubAliasRegressionL1Test.t.sol
+63 −0 ...ontracts/test/foundry/l1/integration/l2-tests-in-l1-context/L2InteropDestinationChainRegressionL1Test.t.sol
+61 −0 ...ntracts/test/foundry/l1/integration/l2-tests-in-l1-context/L2InteropHandlerReentrancyRegressionL1Test.t.sol
+63 −0 ...ntracts/test/foundry/l1/integration/l2-tests-in-l1-context/L2InteropIndirectCallValueRegressionL1Test.t.sol
+3 −3 l1-contracts/test/foundry/l1/integration/upgrade-envs/script-out/local-core.toml
+72 −80 l1-contracts/test/foundry/l1/integration/upgrade-envs/script-out/local-ctm.toml
+738 −0 l1-contracts/test/foundry/l1/unit/concrete/Bridge/AssetTracker/GWAssetTracker.t.sol
+248 −0 l1-contracts/test/foundry/l1/unit/concrete/Bridgehub/L1MessageRoot_PlaceholderRegressionTest.t.sol
+265 −0 l1-contracts/test/foundry/l1/unit/concrete/Bridgehub/L2MessageVerificationDepthRegression.t.sol
+33 −5 l1-contracts/test/foundry/l1/unit/concrete/Bridgehub/MessageRoot.t.sol
+246 −0 l1-contracts/test/foundry/l1/unit/concrete/GatewayCTMDeployer/GatewayCTMDeployerZKsyncOS.t.sol
+101 −0 l1-contracts/test/foundry/l1/unit/concrete/Libraries/UnsafeBytes.t.sol
+171 −72 l1-contracts/test/foundry/l2/unit/GatewayCTMDeployer/GatewayCTMDeployer.t.sol
+110 −0 l1-contracts/test/foundry/unit/utils/GatewayCTMDeployerTestUtils.sol
+126 −0 l1-contracts/test/foundry/zksync-os/unit/SystemContextTest.t.sol
+3 −3 l1-contracts/zkstack-out/IDeployCTM.sol/IDeployCTM.json
+25 −0 l1-contracts/zkstack-out/IL2AssetTracker.sol/IL2AssetTracker.json
+41 −19 tools/zksync-os-genesis-gen/src/consts.rs
+10 −5 tools/zksync-os-genesis-gen/src/genesis.rs
+11 −2 tools/zksync-os-genesis-gen/src/utils.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
use std::str::FromStr;

use ethers::types::{Address, H256, U256};
use serde::{Deserialize, Serialize};

use crate::{
forge_interface::deploy_ecosystem::input::InitialDeploymentConfig, traits::FileConfigTrait,
ContractsConfig, ContractsGenesisConfig,
ContractsConfig,
};

#[derive(Debug, Clone, Serialize, Deserialize)]
Expand All @@ -16,13 +14,6 @@ pub struct GatewayContractsConfig {
pub create2_factory_salt: H256,
pub create2_factory_addr: Option<Address>,
pub validator_timelock_execution_delay: U256,
pub genesis_root: H256,
pub genesis_rollup_leaf_index: U256,
pub genesis_batch_commitment: H256,
pub latest_protocol_version: U256,
pub default_aa_hash: H256,
pub bootloader_hash: H256,
pub evm_emulator_hash: Option<H256>,
pub avail_l1_da_validator: Option<Address>,
pub bridgehub_proxy_address: Address,
}
Expand Down Expand Up @@ -52,15 +43,14 @@ impl GatewayVotePreparationConfig {
#[allow(clippy::too_many_arguments)]
pub fn new(
initial_deployment_config: &InitialDeploymentConfig,
genesis_input: &ContractsGenesisConfig,
external_contracts_config: &ContractsConfig, // from external context
external_contracts_config: &ContractsConfig,
era_chain_id: U256,
gateway_chain_id: U256,
owner_address: Address,
testnet_verifier: bool,
is_zk_sync_os: bool,
refund_recipient: Address,
) -> anyhow::Result<Self> {
) -> Self {
let contracts = GatewayContractsConfig {
governance_security_council_address: Address::zero(),
governance_min_delay: U256::from(initial_deployment_config.governance_min_delay),
Expand All @@ -70,17 +60,6 @@ impl GatewayVotePreparationConfig {
validator_timelock_execution_delay: U256::from(
initial_deployment_config.validator_timelock_execution_delay,
),
genesis_root: H256::from_str(&genesis_input.genesis_root_hash()?)?,
genesis_rollup_leaf_index: U256::from(genesis_input.rollup_last_leaf_index()?),
genesis_batch_commitment: H256::from_str(&genesis_input.genesis_commitment()?)?,
latest_protocol_version: genesis_input.protocol_semantic_version()?.pack(),
default_aa_hash: H256::from_str(&genesis_input.default_aa_hash()?)?,
bootloader_hash: H256::from_str(&genesis_input.bootloader_hash()?)?,
evm_emulator_hash: genesis_input
.evm_emulator_hash()?
.as_ref()
.map(|hash| H256::from_str(&hash.to_string()))
.transpose()?,
avail_l1_da_validator: external_contracts_config.l1.avail_l1_da_validator_addr,
bridgehub_proxy_address: external_contracts_config
.ecosystem_contracts
Expand All @@ -91,7 +70,7 @@ impl GatewayVotePreparationConfig {
token_weth_address: initial_deployment_config.token_weth_address,
};

Ok(Self {
Self {
era_chain_id,
owner_address,
testnet_verifier,
Expand All @@ -107,6 +86,6 @@ impl GatewayVotePreparationConfig {
.force_deployments_data
.clone()
.unwrap_or_default(),
})
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,16 @@ pub enum ValidiumTypeInternal {
EigenDA,
}

impl ValidiumTypeInternal {
pub fn as_str(&self) -> &str {
match self {
ValidiumTypeInternal::NoDA => "NoDA",
ValidiumTypeInternal::Avail => "Avail",
ValidiumTypeInternal::EigenDA => "EigenDA",
}
}
}

#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize, EnumIter, Display, ValueEnum)]
pub enum AvailClientTypeInternal {
FullClient,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,15 @@ pub struct ConvertToGatewayArgs {

#[clap(long, default_value_t = false)]
pub only_save_calldata: bool,

/// L1 RPC URL. If not provided, will be read from chain secrets config.
#[clap(long)]
pub l1_rpc_url: Option<String>,

/// Skip applying gateway config overrides (overrides/gateway.yaml).
/// By default, the gateway.yaml file is required.
#[clap(long, default_value_t = false)]
pub no_gateway_overrides: bool,
}

fn parse_decimal_u256(s: &str) -> Result<U256, String> {
Expand All @@ -60,21 +69,26 @@ fn parse_decimal_u256(s: &str) -> Result<U256, String> {
}

pub async fn run(convert_to_gw_args: ConvertToGatewayArgs, shell: &Shell) -> anyhow::Result<()> {
let args = convert_to_gw_args.forge_args;
let args = convert_to_gw_args.forge_args.clone();
let ecosystem_config = ZkStackConfig::ecosystem(shell)?;
let chain_config = ecosystem_config
.load_current_chain()
.context(MSG_CHAIN_NOT_INITIALIZED)?;
let l1_url = chain_config.get_secrets_config().await?.l1_rpc_url()?;
let l1_url = match convert_to_gw_args.l1_rpc_url {
Some(url) => url,
None => chain_config.get_secrets_config().await?.l1_rpc_url()?,
};
let chain_contracts_config = chain_config.get_contracts_config()?;
let contracts_config = chain_config.get_contracts_genesis_config().await?;
override_config(
shell,
&ecosystem_config
.default_configs_path_for_ctm(chain_config.vm_option)
.join(PATH_TO_GATEWAY_OVERRIDE_CONFIG),
&chain_config,
)?;

if !convert_to_gw_args.no_gateway_overrides {
override_config(
shell,
&ecosystem_config
.default_configs_path_for_ctm(chain_config.vm_option)
.join(PATH_TO_GATEWAY_OVERRIDE_CONFIG),
&chain_config,
)?;
}

let chain_deployer_wallet = chain_config
.get_wallets_config()?
Expand Down Expand Up @@ -141,15 +155,14 @@ pub async fn run(convert_to_gw_args: ConvertToGatewayArgs, shell: &Shell) -> any
&chain_deployer_wallet,
GatewayVotePreparationConfig::new(
&ecosystem_config.get_initial_deployment_config().unwrap(),
&contracts_config,
&chain_contracts_config,
ecosystem_config.era_chain_id.as_u64().into(),
chain_config.chain_id.as_u64().into(),
ecosystem_config.get_contracts_config()?.l1.governance_addr,
ecosystem_config.prover_version == ProverMode::NoProofs,
chain_config.vm_option.is_zksync_os(),
chain_deployer_wallet.address,
)?,
),
l1_url.clone(),
convert_to_gw_args
.ctm_chain_id
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
use anyhow::Context;
use clap::Parser;
use ethers::contract::BaseContract;
use lazy_static::lazy_static;
use serde::{Deserialize, Serialize};
use xshell::Shell;
use zkstack_cli_common::{
config::global_config,
Expand Down Expand Up @@ -28,13 +30,28 @@ lazy_static! {
BaseContract::from(DEPLOYGATEWAYTRANSACTIONFILTERERABI_ABI.clone());
}

pub async fn run(args: ForgeScriptArgs, shell: &Shell) -> anyhow::Result<()> {
#[derive(Debug, Serialize, Deserialize, Parser)]
pub struct CreateTxFiltererArgs {
/// All ethereum environment related arguments
#[clap(flatten)]
#[serde(flatten)]
pub forge_args: ForgeScriptArgs,

/// L1 RPC URL. If not provided, will be read from chain secrets config.
#[clap(long)]
pub l1_rpc_url: Option<String>,
}

pub async fn run(args: CreateTxFiltererArgs, shell: &Shell) -> anyhow::Result<()> {
let chain_name = global_config().chain_name.clone();
let ecosystem_config = ZkStackConfig::ecosystem(shell)?;
let chain_config = ecosystem_config
.load_chain(chain_name)
.context(MSG_CHAIN_NOT_INITIALIZED)?;
let l1_url = chain_config.get_secrets_config().await?.l1_rpc_url()?;
let l1_url = match args.l1_rpc_url {
Some(url) => url,
None => chain_config.get_secrets_config().await?.l1_rpc_url()?,
};
let mut chain_contracts_config = chain_config.get_contracts_config()?;

let chain_deployer_wallet = chain_config
Expand All @@ -44,7 +61,7 @@ pub async fn run(args: ForgeScriptArgs, shell: &Shell) -> anyhow::Result<()> {

let output: GatewayTxFiltererOutput = deploy_gateway_tx_filterer(
shell,
args.clone(),
args.forge_args.clone(),
&chain_config,
&chain_deployer_wallet,
&chain_contracts_config,
Expand All @@ -54,7 +71,7 @@ pub async fn run(args: ForgeScriptArgs, shell: &Shell) -> anyhow::Result<()> {

set_transaction_filterer(
shell,
&args,
&args.forge_args,
&chain_config.path_to_foundry_scripts(),
AdminScriptMode::Broadcast(chain_config.get_wallets_config()?.governor),
chain_config.chain_id.as_u64(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ use crate::{
abi::GATEWAYUTILSABI_ABI,
admin_functions::AdminScriptMode,
commands::chain::{
args::init::da_configs::ValidiumTypeInternal,
gateway::{
gateway_common::{extract_and_wait_for_priority_ops, get_migration_transaction},
migrate_from_gateway::{
Expand Down Expand Up @@ -63,6 +64,18 @@ pub struct FinalizeChainMigrationToGatewayArgs {
pub deploy_paymaster: Option<bool>,
#[clap(long, default_missing_value = "true", num_args = 0..=1)]
pub tx_status: Option<bool>,

/// L1 RPC URL. If not provided, will be read from chain secrets config.
#[clap(long)]
pub l1_rpc_url: Option<String>,

/// Gateway RPC URL. If not provided, will be read from gateway chain's general config.
#[clap(long)]
pub gateway_rpc_url: Option<String>,

/// Validium type for the chain. If not provided, will be read from chain's general config.
#[clap(long)]
pub validium_type: Option<ValidiumTypeInternal>,
}

lazy_static! {
Expand All @@ -83,6 +96,9 @@ impl FinalizeChainMigrationToGatewayArgs {
gateway_chain_name: self.gateway_chain_name,
deploy_paymaster,
tx_status: self.tx_status.unwrap_or(true),
l1_rpc_url: self.l1_rpc_url,
gateway_rpc_url: self.gateway_rpc_url,
validium_type: self.validium_type,
}
}
}
Expand All @@ -93,6 +109,9 @@ pub struct FinalizeChainMigrationToGatewayArgsFinal {
pub gateway_chain_name: String,
pub deploy_paymaster: bool,
pub tx_status: bool,
pub l1_rpc_url: Option<String>,
pub gateway_rpc_url: Option<String>,
pub validium_type: Option<ValidiumTypeInternal>,
}

pub async fn run(args: FinalizeChainMigrationToGatewayArgs, shell: &Shell) -> anyhow::Result<()> {
Expand Down Expand Up @@ -131,14 +150,22 @@ pub async fn run_inner(
chain_config: &ChainConfig,
gateway_chain_config: &ChainConfig,
) -> anyhow::Result<()> {
let l1_rpc_url = chain_config.get_secrets_config().await?.l1_rpc_url()?;
let l1_rpc_url = match &args.l1_rpc_url {
Some(url) => url.clone(),
None => chain_config.get_secrets_config().await?.l1_rpc_url()?,
};
let l1_provider = get_ethers_provider(&l1_rpc_url)?;

let general_config = gateway_chain_config.get_general_config().await?;
let gateway_chain_id = gateway_chain_config.chain_id.as_u64();
let gw_rpc_url = general_config.l2_http_url()?;
let gateway_provider = get_ethers_provider(&gw_rpc_url)?;
let gateway_zk_client = get_zk_client(&gw_rpc_url, chain_config.chain_id.as_u64())?;
let gateway_rpc_url = match &args.gateway_rpc_url {
Some(url) => url.clone(),
None => {
let general_config = gateway_chain_config.get_general_config().await?;
general_config.l2_http_url()?
}
};
let gateway_provider = get_ethers_provider(&gateway_rpc_url)?;
let gateway_zk_client = get_zk_client(&gateway_rpc_url, chain_config.chain_id.as_u64())?;

let mut contracts_config = chain_config.get_contracts_config()?;

Expand Down Expand Up @@ -217,13 +244,21 @@ pub async fn run_inner(
ecosystem_config,
&mut contracts_config,
&args.forge_args,
l1_rpc_url,
l1_rpc_url.clone(),
args.deploy_paymaster,
args.validium_type.clone(),
)
.await?;

// Set the DA validator pair on the Gateway
let context = get_migrate_to_gateway_context(chain_config, gateway_chain_config, true).await?;
let context = get_migrate_to_gateway_context(
chain_config,
gateway_chain_config,
true,
l1_rpc_url,
gateway_rpc_url,
)
.await?;

let (_, l2_da_validator_commitment_scheme) =
context.l1_zk_chain.get_da_validator_pair().await?;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,17 @@ impl MigrationDirection {
}
}

#[derive(Debug, clap::Parser)]
pub struct NotifyServerArgs {
/// All ethereum environment related arguments
#[clap(flatten)]
pub forge_args: ForgeScriptArgs,

/// L1 RPC URL. If not provided, will be read from chain secrets config.
#[clap(long)]
pub l1_rpc_url: Option<String>,
}

#[derive(Debug, Eq, PartialEq, Copy, Clone)]
pub enum NotificationReceivedState {
NotAllBatchesCommitted,
Expand Down Expand Up @@ -469,18 +480,21 @@ pub(crate) async fn await_for_tx_to_complete(
}

pub(crate) async fn notify_server(
args: ForgeScriptArgs,
args: NotifyServerArgs,
shell: &Shell,
direction: MigrationDirection,
) -> anyhow::Result<()> {
let chain_config = ZkStackConfig::current_chain(shell)?;

let l1_url = chain_config.get_secrets_config().await?.l1_rpc_url()?;
let l1_url = match args.l1_rpc_url {
Some(url) => url,
None => chain_config.get_secrets_config().await?.l1_rpc_url()?,
};
let contracts = chain_config.get_contracts_config()?;

let calls = get_notify_server_calls(
shell,
&args,
&args.forge_args,
&chain_config.path_to_foundry_scripts(),
NotifyServerCallsArgs {
l1_bridgehub_addr: contracts.ecosystem_contracts.bridgehub_proxy_addr,
Expand Down
Loading
Loading