Skip to content

Commit

Permalink
feat(shared bridge): preparation for shared bridge migration (server) (
Browse files Browse the repository at this point in the history
…#1012)

## What ❔

This PR aims to reduce the diff between main and #298 to simplify the
future review.

The changes do not affect current server behavior.
Only changes related to the zkSync server went into this PR.

What didn't go into this PR:

- various variable renamings
- integration tests
- changes that depend on the future version of era-contracts

Where applicable, stubs and dummy (for now) config variables were
introduced, which can be replaced/populated later.

## Why ❔

Breaking up a PR into smaller chunks should be easier to review.

## 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 `zk spellcheck`.
- [ ] Linkcheck has been run via `zk linkcheck`.

---------

Co-authored-by: Bence Haromi <[email protected]>
Co-authored-by: Bence Haromi <[email protected]>
  • Loading branch information
3 people authored Feb 20, 2024
1 parent dc2b827 commit 2a766a7
Show file tree
Hide file tree
Showing 36 changed files with 722 additions and 607 deletions.
4 changes: 4 additions & 0 deletions checks-config/era.dic
Original file line number Diff line number Diff line change
Expand Up @@ -411,6 +411,10 @@ prode
StorageBatchInfo
CommitBatchInfo
IExecutor
SetChainId
setChainId
SetChainIdUpgrade
state_transition_manager_contract

// Names
Vyper
Expand Down
5 changes: 5 additions & 0 deletions core/bin/external_node/src/config/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ const BYTES_IN_MEGABYTE: usize = 1_024 * 1_024;
/// This part of the external node config is fetched directly from the main node.
#[derive(Debug, Deserialize, Clone, PartialEq)]
pub struct RemoteENConfig {
pub bridgehub_proxy_addr: Option<Address>,
pub diamond_proxy_addr: Address,
pub l1_erc20_bridge_proxy_addr: Address,
pub l2_erc20_bridge_addr: Address,
Expand All @@ -49,6 +50,8 @@ impl RemoteENConfig {
.get_testnet_paymaster()
.rpc_context("get_testnet_paymaster")
.await?;
// In case EN is connected to the old server version without `get_bridgehub_contract` method.
let bridgehub_proxy_addr = client.get_bridgehub_contract().await.ok().flatten();
let diamond_proxy_addr = client
.get_main_contract()
.rpc_context("get_main_contract")
Expand All @@ -60,6 +63,7 @@ impl RemoteENConfig {
let l1_chain_id = L1ChainId(l1_chain_id.as_u64());

Ok(Self {
bridgehub_proxy_addr,
diamond_proxy_addr,
l2_testnet_paymaster_addr,
l1_erc20_bridge_proxy_addr: bridges.l1_erc20_default_bridge,
Expand Down Expand Up @@ -558,6 +562,7 @@ impl From<ExternalNodeConfig> for InternalApiConfig {
l1_weth_bridge: config.remote.l1_weth_bridge_proxy_addr,
l2_weth_bridge: config.remote.l2_weth_bridge_addr,
},
bridgehub_proxy_addr: config.remote.bridgehub_proxy_addr,
diamond_proxy_addr: config.remote.diamond_proxy_addr,
l2_testnet_paymaster_addr: config.remote.l2_testnet_paymaster_addr,
req_entities_limit: config.optional.req_entities_limit,
Expand Down
5 changes: 5 additions & 0 deletions core/bin/zksync_server/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@ struct Cli {
/// Generate genesis block for the first contract deployment using temporary DB.
#[arg(long)]
genesis: bool,
/// Wait for the `setChainId` event during genesis.
/// If `--genesis` is not set, this flag is ignored.
#[arg(long)]
set_chain_id: bool,
/// Rebuild tree.
#[arg(long)]
rebuild_tree: bool,
Expand Down Expand Up @@ -142,6 +146,7 @@ async fn main() -> anyhow::Result<()> {
&network,
&contracts,
&eth_client.web3_url,
opt.set_chain_id,
)
.await
.context("genesis_init")?;
Expand Down
12 changes: 12 additions & 0 deletions core/lib/config/src/configs/contracts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,13 @@ pub struct ContractsConfig {
pub fri_recursion_leaf_level_vk_hash: H256,
pub prover_at_genesis: ProverAtGenesis,
pub snark_wrapper_vk_hash: H256,

// These contracts will be used after shared bridge integration.
pub bridgehub_proxy_addr: Option<Address>,
pub bridgehub_impl_addr: Option<Address>,
pub state_transition_proxy_addr: Option<Address>,
pub state_transition_impl_addr: Option<Address>,
pub transparent_proxy_admin_addr: Option<Address>,
}

impl ContractsConfig {
Expand All @@ -52,6 +59,7 @@ impl ContractsConfig {
mailbox_facet_addr: Address::repeat_byte(0x01),
executor_facet_addr: Address::repeat_byte(0x02),
admin_facet_addr: Address::repeat_byte(0x03),
transparent_proxy_admin_addr: Some(Address::repeat_byte(0x04)),
getters_facet_addr: Address::repeat_byte(0x05),
verifier_addr: Address::repeat_byte(0x06),
diamond_init_addr: Address::repeat_byte(0x07),
Expand All @@ -77,6 +85,10 @@ impl ContractsConfig {
governance_addr: Address::repeat_byte(0x13),
prover_at_genesis: ProverAtGenesis::Fri,
snark_wrapper_vk_hash: H256::repeat_byte(0x09),
bridgehub_proxy_addr: Some(Address::repeat_byte(0x14)),
bridgehub_impl_addr: Some(Address::repeat_byte(0x15)),
state_transition_proxy_addr: Some(Address::repeat_byte(0x16)),
state_transition_impl_addr: Some(Address::repeat_byte(0x17)),
}
}
}
5 changes: 5 additions & 0 deletions core/lib/config/src/testonly.rs
Original file line number Diff line number Diff line change
Expand Up @@ -363,6 +363,11 @@ impl RandomConfig for configs::ContractsConfig {
fri_recursion_leaf_level_vk_hash: g.gen(),
prover_at_genesis: g.gen(),
snark_wrapper_vk_hash: g.gen(),
bridgehub_impl_addr: g.gen(),
bridgehub_proxy_addr: g.gen(),
state_transition_proxy_addr: g.gen(),
state_transition_impl_addr: g.gen(),
transparent_proxy_admin_addr: g.gen(),
}
}
}
Expand Down
Loading

0 comments on commit 2a766a7

Please sign in to comment.