Skip to content

Commit 9445a68

Browse files
feat: Additional gateway upgrade testing (#3449)
## What ❔ - Add server feature to automatically switch l2 shared bridge as well. Also, l2 wrapped base token is also fetched from L1 upon upgrade. This reduces the risk of misconfiguration. - Added WIP tool for zkstack to generate the calldata for the admin. It will have to be prettified before going public, but it is in `dev` so it is okay ## 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 `zkstack dev fmt` and `zkstack dev lint`.
1 parent 1f1cbf0 commit 9445a68

File tree

43 files changed

+1506
-622
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+1506
-622
lines changed

core/bin/external_node/src/config/mod.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,7 @@ pub(crate) struct RemoteENConfig {
128128
pub l2_weth_bridge_addr: Option<Address>,
129129
pub l2_testnet_paymaster_addr: Option<Address>,
130130
pub l2_timestamp_asserter_addr: Option<Address>,
131+
pub l1_wrapped_base_token_store: Option<Address>,
131132
pub base_token_addr: Address,
132133
pub l1_batch_commit_data_generator_mode: L1BatchCommitmentMode,
133134
pub dummy_verifier: bool,
@@ -195,6 +196,9 @@ impl RemoteENConfig {
195196
l1_bytecodes_supplier_addr: ecosystem_contracts
196197
.as_ref()
197198
.and_then(|a| a.l1_bytecodes_supplier_addr),
199+
l1_wrapped_base_token_store: ecosystem_contracts
200+
.as_ref()
201+
.and_then(|a| a.l1_wrapped_base_token_store),
198202
l1_diamond_proxy_addr,
199203
l2_testnet_paymaster_addr,
200204
l1_erc20_bridge_proxy_addr: bridges.l1_erc20_default_bridge,
@@ -235,6 +239,7 @@ impl RemoteENConfig {
235239
l2_shared_bridge_addr: Some(Address::repeat_byte(6)),
236240
l2_legacy_shared_bridge_addr: Some(Address::repeat_byte(7)),
237241
l1_batch_commit_data_generator_mode: L1BatchCommitmentMode::Rollup,
242+
l1_wrapped_base_token_store: None,
238243
dummy_verifier: true,
239244
l2_timestamp_asserter_addr: None,
240245
}
@@ -1477,6 +1482,7 @@ impl From<&ExternalNodeConfig> for InternalApiConfig {
14771482
l2_weth_bridge: config.remote.l2_weth_bridge_addr,
14781483
},
14791484
l1_bytecodes_supplier_addr: config.remote.l1_bytecodes_supplier_addr,
1485+
l1_wrapped_base_token_store: config.remote.l1_wrapped_base_token_store,
14801486
l1_bridgehub_proxy_addr: config.remote.l1_bridgehub_proxy_addr,
14811487
l1_state_transition_proxy_addr: config.remote.l1_state_transition_proxy_addr,
14821488
l1_transparent_proxy_admin_addr: config.remote.l1_transparent_proxy_admin_addr,

core/lib/config/src/configs/contracts.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@ pub struct EcosystemContracts {
99
pub state_transition_proxy_addr: Address,
1010
pub transparent_proxy_admin_addr: Address,
1111
pub l1_bytecodes_supplier_addr: Option<Address>,
12+
// Note that on the contract side of things this contract is called `L2WrappedBaseTokenStore`,
13+
// while on the server side for consistency with the conventions, where the prefix denotes
14+
// the location of the contracts we call it `l1_wrapped_base_token_store`
15+
pub l1_wrapped_base_token_store: Option<Address>,
1216
}
1317

1418
impl EcosystemContracts {
@@ -18,6 +22,7 @@ impl EcosystemContracts {
1822
state_transition_proxy_addr: Address::repeat_byte(0x15),
1923
transparent_proxy_admin_addr: Address::repeat_byte(0x15),
2024
l1_bytecodes_supplier_addr: Some(Address::repeat_byte(0x16)),
25+
l1_wrapped_base_token_store: Some(Address::repeat_byte(0x17)),
2126
}
2227
}
2328
}
@@ -50,8 +55,6 @@ pub struct ContractsConfig {
5055
pub base_token_addr: Option<Address>,
5156
pub l1_base_token_asset_id: Option<H256>,
5257

53-
pub l2_predeployed_wrapped_base_token_address: Option<Address>,
54-
5558
pub chain_admin_addr: Option<Address>,
5659
pub l2_da_validator_addr: Option<Address>,
5760
}
@@ -76,7 +79,6 @@ impl ContractsConfig {
7679
governance_addr: Address::repeat_byte(0x13),
7780
base_token_addr: Some(Address::repeat_byte(0x14)),
7881
l1_base_token_asset_id: Some(H256::repeat_byte(0x15)),
79-
l2_predeployed_wrapped_base_token_address: Some(Address::repeat_byte(0x1b)),
8082
ecosystem_contracts: Some(EcosystemContracts::for_tests()),
8183
chain_admin_addr: Some(Address::repeat_byte(0x18)),
8284
l2_da_validator_addr: Some(Address::repeat_byte(0x1a)),

core/lib/config/src/testonly.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,6 @@ impl Distribution<configs::ContractsConfig> for EncodeDist {
268268
ecosystem_contracts: self.sample(rng),
269269
base_token_addr: self.sample_opt(|| rng.gen()),
270270
l1_base_token_asset_id: self.sample_opt(|| rng.gen()),
271-
l2_predeployed_wrapped_base_token_address: self.sample_opt(|| rng.gen()),
272271
chain_admin_addr: self.sample_opt(|| rng.gen()),
273272
l2_da_validator_addr: self.sample_opt(|| rng.gen()),
274273
}
@@ -763,6 +762,7 @@ impl Distribution<configs::EcosystemContracts> for EncodeDist {
763762
state_transition_proxy_addr: rng.gen(),
764763
transparent_proxy_admin_addr: rng.gen(),
765764
l1_bytecodes_supplier_addr: rng.gen(),
765+
l1_wrapped_base_token_store: rng.gen(),
766766
}
767767
}
768768
}

core/lib/contracts/src/lib.rs

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,15 @@ const GETTERS_FACET_CONTRACT_FILE: (&str, &str) = (
6161
);
6262

6363
const MULTICALL3_CONTRACT_FILE: (&str, &str) = ("dev-contracts", "Multicall3.sol/Multicall3.json");
64+
const L1_ASSET_ROUTER_FILE: (&str, &str) = (
65+
"bridge/asset-router",
66+
"L1AssetRouter.sol/L1AssetRouter.json",
67+
);
68+
const L2_WRAPPED_BASE_TOKEN_STORE: (&str, &str) = (
69+
"bridge",
70+
"L2WrappedBaseTokenStore.sol/L2WrappedBaseTokenStore.json",
71+
);
72+
6473
const VERIFIER_CONTRACT_FILE: (&str, &str) = ("state-transition", "Verifier.sol/Verifier.json");
6574
const DUAL_VERIFIER_CONTRACT_FILE: (&str, &str) = (
6675
"state-transition/verifiers",
@@ -180,6 +189,14 @@ pub fn multicall_contract() -> Contract {
180189
load_contract_for_both_compilers(MULTICALL3_CONTRACT_FILE)
181190
}
182191

192+
pub fn l1_asset_router_contract() -> Contract {
193+
load_contract_for_both_compilers(L1_ASSET_ROUTER_FILE)
194+
}
195+
196+
pub fn wrapped_base_token_store_contract() -> Contract {
197+
load_contract_for_both_compilers(L2_WRAPPED_BASE_TOKEN_STORE)
198+
}
199+
183200
pub fn verifier_contract() -> Contract {
184201
let path = format!("{}/{}", FORGE_PATH_PREFIX, DUAL_VERIFIER_CONTRACT_FILE.1);
185202
let zksync_home = home_path();
@@ -201,7 +218,7 @@ pub fn l1_messenger_contract() -> Contract {
201218
}
202219

203220
pub fn l2_message_root() -> Contract {
204-
load_contract("contracts/l1-contracts/zkout/MessageRoot.sol/MessageRoot.json")
221+
load_contract("contracts/l1-contracts/out/MessageRoot.sol/MessageRoot.json")
205222
}
206223

207224
pub fn l2_rollup_da_validator_bytecode() -> Vec<u8> {

core/lib/dal/.sqlx/query-00054de8d2b60eb0a74759c52797a1d2e9cadecd1cb64987c121aa6f8c6d2771.json

Lines changed: 0 additions & 12 deletions
This file was deleted.

core/lib/dal/.sqlx/query-33d49ec6028974fa8b46d7bf1f79e41923477ed8dc179ca0e1fe64b4700e6572.json

Lines changed: 20 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

core/lib/dal/.sqlx/query-43dcdb8a54ed62b10ca429c1a3c7bb90e737ffe0a6c930bbffcab24ff26f70b7.json

Lines changed: 0 additions & 12 deletions
This file was deleted.

core/lib/dal/.sqlx/query-abbe96ba26a046a2c000cd9b9b4e54b2a3ba8db825a3131aa36e17f0f0fadc87.json

Lines changed: 0 additions & 34 deletions
This file was deleted.

core/lib/dal/src/eth_sender_dal.rs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,25 @@ impl EthSenderDal<'_, '_> {
8686
Ok(count.try_into().unwrap())
8787
}
8888

89+
pub async fn get_unconfirmed_txs_count(&mut self) -> DalResult<usize> {
90+
let count = sqlx::query!(
91+
r#"
92+
SELECT
93+
COUNT(*)
94+
FROM
95+
eth_txs
96+
WHERE
97+
confirmed_eth_tx_history_id IS NULL
98+
"#
99+
)
100+
.instrument("get_unconfirmed_txs_count")
101+
.fetch_one(self.storage)
102+
.await?
103+
.count
104+
.unwrap();
105+
Ok(count.try_into().unwrap())
106+
}
107+
89108
pub async fn get_eth_l1_batches(&mut self) -> sqlx::Result<L1BatchEthSenderStats> {
90109
struct EthTxRow {
91110
number: i64,

0 commit comments

Comments
 (0)