@@ -40,7 +40,10 @@ use crate::{
4040 args:: init:: da_configs:: ValidiumTypeInternal ,
4141 gateway:: {
4242 constants:: DEFAULT_MAX_L1_GAS_PRICE_FOR_PRIORITY_TXS ,
43- gateway_common:: extract_and_wait_for_priority_ops,
43+ gateway_common:: {
44+ extract_and_wait_for_priority_ops, get_gateway_migration_state,
45+ GatewayMigrationProgressState , MigrationDirection ,
46+ } ,
4447 } ,
4548 init:: get_l1_da_validator,
4649 utils:: send_tx,
@@ -101,6 +104,37 @@ pub async fn run(args: MigrateFromGatewayArgs, shell: &Shell) -> anyhow::Result<
101104 . ctm
102105 . diamond_cut_data ;
103106
107+ let gw_rpc_url = match args. gateway_rpc_url {
108+ Some ( url) => url,
109+ None => {
110+ let general_config = gateway_chain_config. get_general_config ( ) . await ?;
111+ general_config. l2_http_url ( ) ?
112+ }
113+ } ;
114+
115+ let state = get_gateway_migration_state (
116+ l1_url. clone ( ) ,
117+ chain_contracts_config
118+ . ecosystem_contracts
119+ . bridgehub_proxy_addr ,
120+ chain_config. chain_id . as_u64 ( ) ,
121+ chain_config
122+ . get_general_config ( )
123+ . await ?
124+ . l2_http_url ( )
125+ . context ( "L2 RPC URL must be provided for cross checking" ) ?,
126+ gw_rpc_url. clone ( ) ,
127+ MigrationDirection :: FromGateway ,
128+ )
129+ . await ?;
130+
131+ if state != GatewayMigrationProgressState :: ServerReady {
132+ anyhow:: bail!(
133+ "Chain is not ready for starting the migration from Gateway. Current state: {:?}" ,
134+ state
135+ ) ;
136+ }
137+
104138 let start_migrate_from_gateway_call = start_migrate_chain_from_gateway (
105139 shell,
106140 & args. forge_args ,
@@ -124,13 +158,6 @@ pub async fn run(args: MigrateFromGatewayArgs, shell: &Shell) -> anyhow::Result<
124158 let ( calldata, value) =
125159 AdminCallBuilder :: new ( start_migrate_from_gateway_call. calls ) . compile_full_calldata ( ) ;
126160
127- let gw_rpc_url = match args. gateway_rpc_url {
128- Some ( url) => url,
129- None => {
130- let general_config = gateway_chain_config. get_general_config ( ) . await ?;
131- general_config. l2_http_url ( ) ?
132- }
133- } ;
134161 let gateway_provider = get_ethers_provider ( & gw_rpc_url) ?;
135162 let gateway_zk_client = get_zk_client ( & gw_rpc_url, chain_config. chain_id . as_u64 ( ) ) ?;
136163
0 commit comments