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

fix: sync layer compatibility #2976

Merged
merged 12 commits into from
Oct 2, 2024
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
20 changes: 6 additions & 14 deletions core/bin/external_node/src/config/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,11 @@ pub(crate) struct RemoteENConfig {
// the `l2_erc20_bridge_addr` and `l2_shared_bridge_addr` are basically the same contract, but with
// a different name, with names adapted only for consistency.
pub l1_shared_bridge_proxy_addr: Option<Address>,
/// Contract address that serves as a shared bridge on L2.
/// It is expected that `L2SharedBridge` is used before gateway upgrade, and `L2AssetRouter` is used after.
pub l2_shared_bridge_addr: Option<Address>,
/// Address of `L2SharedBridge` that was used before gateway upgrade.
/// `None` if chain genesis used post-gateway protocol version.
pub l2_legacy_shared_bridge_addr: Option<Address>,
pub l1_erc20_bridge_proxy_addr: Option<Address>,
pub l2_erc20_bridge_addr: Option<Address>,
Expand All @@ -122,7 +126,6 @@ pub(crate) struct RemoteENConfig {
pub dummy_verifier: bool,

pub user_facing_bridgehub: Option<Address>,
pub l2_native_token_vault_proxy_addr: Option<Address>,
}

impl RemoteENConfig {
Expand All @@ -135,14 +138,6 @@ impl RemoteENConfig {
.get_testnet_paymaster()
.rpc_context("get_testnet_paymaster")
.await?;
let l2_native_token_vault_proxy_addr = client
.get_native_token_vault_proxy_addr()
.rpc_context("get_native_token_vault")
.await?;
let l2_legacy_shared_bridge_addr = client
.get_legacy_shared_bridge()
.rpc_context("get_legacy_shared_bridge")
.await?;
let genesis = client.genesis_config().rpc_context("genesis").await.ok();
let ecosystem_contracts = client
.get_ecosystem_contracts()
Expand Down Expand Up @@ -208,7 +203,7 @@ impl RemoteENConfig {
l2_erc20_bridge_addr: l2_erc20_default_bridge,
l1_shared_bridge_proxy_addr: bridges.l1_shared_default_bridge,
l2_shared_bridge_addr: l2_erc20_shared_bridge,
l2_legacy_shared_bridge_addr,
l2_legacy_shared_bridge_addr: bridges.l2_legacy_shared_bridge,
l1_weth_bridge_addr: bridges.l1_weth_bridge,
l2_weth_bridge_addr: bridges.l2_weth_bridge,
base_token_addr,
Expand All @@ -220,7 +215,6 @@ impl RemoteENConfig {
.as_ref()
.map(|a| a.dummy_verifier)
.unwrap_or_default(),
l2_native_token_vault_proxy_addr,
})
}

Expand All @@ -243,7 +237,6 @@ impl RemoteENConfig {
l2_legacy_shared_bridge_addr: Some(Address::repeat_byte(7)),
l1_batch_commit_data_generator_mode: L1BatchCommitmentMode::Rollup,
dummy_verifier: true,
l2_native_token_vault_proxy_addr: Some(Address::repeat_byte(7)),
}
}
}
Expand Down Expand Up @@ -1415,6 +1408,7 @@ impl From<&ExternalNodeConfig> for InternalApiConfig {
l2_shared_default_bridge: config.remote.l2_shared_bridge_addr,
l1_weth_bridge: config.remote.l1_weth_bridge_addr,
l2_weth_bridge: config.remote.l2_weth_bridge_addr,
l2_legacy_shared_bridge: config.remote.l2_legacy_shared_bridge_addr,
},
bridgehub_proxy_addr: config.remote.bridgehub_proxy_addr,
state_transition_proxy_addr: config.remote.state_transition_proxy_addr,
Expand All @@ -1428,8 +1422,6 @@ impl From<&ExternalNodeConfig> for InternalApiConfig {
filters_disabled: config.optional.filters_disabled,
dummy_verifier: config.remote.dummy_verifier,
l1_batch_commit_data_generator_mode: config.remote.l1_batch_commit_data_generator_mode,
l2_native_token_vault_proxy_addr: config.remote.l2_native_token_vault_proxy_addr,
l2_legacy_shared_bridge_addr: config.remote.l2_legacy_shared_bridge_addr,
}
}
}
Expand Down
13 changes: 1 addition & 12 deletions core/bin/external_node/src/node_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -192,18 +192,7 @@ impl ExternalNodeBuilder {
const OPTIONAL_BYTECODE_COMPRESSION: bool = true;

let persistence_layer = OutputHandlerLayer::new(
self.config
.remote
.l2_shared_bridge_addr
.expect("L2 shared bridge address is not set"),
self.config
.remote
.l2_native_token_vault_proxy_addr
.expect("L2 native token vault proxy address is not set"),
self.config
.remote
.l2_legacy_shared_bridge_addr
.expect("L2 legacy shared bridge address is not set"),
self.config.remote.l2_legacy_shared_bridge_addr,
self.config.optional.l2_block_seal_queue_capacity,
)
.with_pre_insert_txs(true) // EN requires txs to be pre-inserted.
Expand Down
10 changes: 1 addition & 9 deletions core/bin/zksync_server/src/node_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -240,15 +240,7 @@ impl MainNodeBuilder {
let wallets = self.wallets.clone();
let sk_config = try_load_config!(self.configs.state_keeper_config);
let persistence_layer = OutputHandlerLayer::new(
self.contracts_config
.l2_shared_bridge_addr
.context("L2 shared bridge address")?,
self.contracts_config
.l2_native_token_vault_proxy_addr
.context("L2 native token vault proxy address")?,
self.contracts_config
.l2_legacy_shared_bridge_addr
.context("L2 legacy shared bridge address")?,
self.contracts_config.l2_legacy_shared_bridge_addr,
sk_config.l2_block_seal_queue_capacity,
)
.with_protective_reads_persistence_enabled(sk_config.protective_reads_persistence_enabled);
Expand Down
8 changes: 4 additions & 4 deletions core/lib/basic_types/src/protocol_version.rs
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,8 @@ impl ProtocolVersionId {
ProtocolVersionId::Version22 => VmVersion::Vm1_4_2,
ProtocolVersionId::Version23 => VmVersion::Vm1_5_0SmallBootloaderMemory,
ProtocolVersionId::Version24 => VmVersion::Vm1_5_0IncreasedBootloaderMemory,
ProtocolVersionId::Version25 => VmVersion::VmSyncLayer,
ProtocolVersionId::Version26 => VmVersion::VmSyncLayer,
ProtocolVersionId::Version25 => VmVersion::VmGateway,
ProtocolVersionId::Version26 => VmVersion::VmGateway,
}
}

Expand Down Expand Up @@ -280,8 +280,8 @@ impl From<ProtocolVersionId> for VmVersion {
ProtocolVersionId::Version22 => VmVersion::Vm1_4_2,
ProtocolVersionId::Version23 => VmVersion::Vm1_5_0SmallBootloaderMemory,
ProtocolVersionId::Version24 => VmVersion::Vm1_5_0IncreasedBootloaderMemory,
ProtocolVersionId::Version25 => VmVersion::VmSyncLayer,
ProtocolVersionId::Version26 => VmVersion::VmSyncLayer,
ProtocolVersionId::Version25 => VmVersion::VmGateway,
ProtocolVersionId::Version26 => VmVersion::VmGateway,
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion core/lib/basic_types/src/vm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ pub enum VmVersion {
Vm1_4_2,
Vm1_5_0SmallBootloaderMemory,
Vm1_5_0IncreasedBootloaderMemory,
VmSyncLayer,
VmGateway,
}

impl VmVersion {
Expand Down
9 changes: 6 additions & 3 deletions core/lib/config/src/configs/contracts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,12 @@ pub struct ContractsConfig {
pub diamond_proxy_addr: Address,
pub validator_timelock_addr: Address,
pub l1_shared_bridge_proxy_addr: Option<Address>,
/// Contract address that serves as a shared bridge on L2.
/// It is expected that `L2SharedBridge` is used before gateway upgrade, and `L2AssetRouter` is used after.
pub l2_shared_bridge_addr: Option<Address>,
/// Address of `L2SharedBridge` that was used before gateway upgrade.
/// `None` if chain genesis used post-gateway protocol version.
/// If present it will be used as L2 token deployer address.
pub l2_legacy_shared_bridge_addr: Option<Address>,
pub l1_erc20_bridge_proxy_addr: Option<Address>,
pub l2_erc20_bridge_addr: Option<Address>,
Expand All @@ -44,7 +49,6 @@ pub struct ContractsConfig {
// FIXME: maybe refactor
pub user_facing_bridgehub_proxy_addr: Option<Address>,
pub user_facing_diamond_proxy_addr: Option<Address>,
pub l2_native_token_vault_proxy_addr: Option<Address>,

pub l2_da_validator_addr: Option<Address>,

Expand All @@ -62,7 +66,7 @@ impl ContractsConfig {
l2_erc20_bridge_addr: Some(Address::repeat_byte(0x0c)),
l1_shared_bridge_proxy_addr: Some(Address::repeat_byte(0x0e)),
l2_shared_bridge_addr: Some(Address::repeat_byte(0x0f)),
l2_legacy_shared_bridge_addr: Some(Address::repeat_byte(0x10)),
l2_legacy_shared_bridge_addr: Some(Address::repeat_byte(0xff)),
l1_weth_bridge_proxy_addr: Some(Address::repeat_byte(0x0b)),
l2_weth_bridge_addr: Some(Address::repeat_byte(0x0c)),
l2_testnet_paymaster_addr: Some(Address::repeat_byte(0x11)),
Expand All @@ -72,7 +76,6 @@ impl ContractsConfig {
ecosystem_contracts: Some(EcosystemContracts::for_tests()),
user_facing_bridgehub_proxy_addr: Some(Address::repeat_byte(0x15)),
user_facing_diamond_proxy_addr: Some(Address::repeat_byte(0x16)),
l2_native_token_vault_proxy_addr: Some(Address::repeat_byte(0x0d)),
chain_admin_addr: Some(Address::repeat_byte(0x18)),
l2_da_validator_addr: Some(Address::repeat_byte(0x19)),
}
Expand Down
1 change: 0 additions & 1 deletion core/lib/config/src/testonly.rs
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,6 @@ impl Distribution<configs::ContractsConfig> for EncodeDist {
ecosystem_contracts: self.sample(rng),
user_facing_bridgehub_proxy_addr: rng.gen(),
user_facing_diamond_proxy_addr: rng.gen(),
l2_native_token_vault_proxy_addr: rng.gen(),
l2_da_validator_addr: rng.gen(),
base_token_addr: self.sample_opt(|| rng.gen()),
chain_admin_addr: self.sample_opt(|| rng.gen()),
Expand Down
Loading
Loading