@@ -39,7 +39,10 @@ use crate::{
3939 admin_call_builder:: AdminCallBuilder ,
4040 gateway:: {
4141 constants:: DEFAULT_MAX_L1_GAS_PRICE_FOR_PRIORITY_TXS ,
42- gateway_common:: extract_and_wait_for_priority_ops,
42+ gateway_common:: {
43+ extract_and_wait_for_priority_ops, get_gateway_migration_state,
44+ GatewayMigrationProgressState , MigrationDirection ,
45+ } ,
4346 } ,
4447 init:: get_l1_da_validator,
4548 utils:: send_tx,
@@ -85,6 +88,32 @@ pub async fn run(args: MigrateFromGatewayArgs, shell: &Shell) -> anyhow::Result<
8588 . ctm
8689 . diamond_cut_data ;
8790
91+ let gateway_general_config = gateway_chain_config. get_general_config ( ) . await ?;
92+ let gw_rpc_url = gateway_general_config. l2_http_url ( ) ?;
93+
94+ let state = get_gateway_migration_state (
95+ l1_url. clone ( ) ,
96+ chain_contracts_config
97+ . ecosystem_contracts
98+ . bridgehub_proxy_addr ,
99+ chain_config. chain_id . as_u64 ( ) ,
100+ chain_config
101+ . get_general_config ( )
102+ . await ?
103+ . l2_http_url ( )
104+ . context ( "L2 RPC URL must be provided for cross checking" ) ?,
105+ gw_rpc_url. clone ( ) ,
106+ MigrationDirection :: FromGateway ,
107+ )
108+ . await ?;
109+
110+ if state != GatewayMigrationProgressState :: ServerReady {
111+ anyhow:: bail!(
112+ "Chain is not ready for starting the migration from Gateway. Current state: {:?}" ,
113+ state
114+ ) ;
115+ }
116+
88117 let start_migrate_from_gateway_call = start_migrate_chain_from_gateway (
89118 shell,
90119 & args. forge_args ,
@@ -108,8 +137,6 @@ pub async fn run(args: MigrateFromGatewayArgs, shell: &Shell) -> anyhow::Result<
108137 let ( calldata, value) =
109138 AdminCallBuilder :: new ( start_migrate_from_gateway_call. calls ) . compile_full_calldata ( ) ;
110139
111- let general_config = gateway_chain_config. get_general_config ( ) . await ?;
112- let gw_rpc_url = general_config. l2_http_url ( ) ?;
113140 let gateway_provider = get_ethers_provider ( & gw_rpc_url) ?;
114141 let gateway_zk_client = get_zk_client ( & gw_rpc_url, chain_config. chain_id . as_u64 ( ) ) ?;
115142
0 commit comments