async fn recover_tokens(&self) -> Result<(), SnapshotsApplierError> {
        // Check whether tokens are already recovered.
        let mut storage = self
            .connection_pool
            .connection_tagged("snapshots_applier")
            .await?;
        let all_token_addresses = storage.tokens_dal().get_all_l2_token_addresses().await?;
        if !all_token_addresses.is_empty() {
            tracing::info!(
                "{} tokens are already present in DB; skipping token recovery",
                all_token_addresses.len()
            );
            return Ok(());
        }
        drop(storage);

        let snapshot_l2_block_number = self.applied_snapshot_status.l2_block_number;
        let tokens = self
            .main_node_client
            .fetch_tokens(snapshot_l2_block_number)
            .await?;
        tracing::info!("Retrieved {} tokens from main node", tokens.len());

        // Check that all tokens returned by the main node were indeed successfully deployed.
        let l2_addresses = tokens.iter().map(|token| token.l2_address);
        let mut storage = self
            .connection_pool
            .connection_tagged("snapshots_applier")
            .await?;
        let filtered_addresses = storage
            .storage_logs_dal()
            .filter_deployed_contracts(l2_addresses, Some(snapshot_l2_block_number))
            .await?;

        let bogus_tokens = tokens.iter().filter(|token| {
            // We need special handling for L2 ether; its `l2_address` doesn't have a deployed contract
            !token.l2_address.is_zero() && !filtered_addresses.contains_key(&token.l2_address)
        });
        let bogus_tokens: Vec<_> = bogus_tokens.collect();
        if !bogus_tokens.is_empty() {
            let err = anyhow::anyhow!(
                "Main node returned bogus tokens that are not deployed on L2: {bogus_tokens:?}"
            );
            return Err(SnapshotsApplierError::Retryable(err));
        }

        tracing::info!(
            "Checked {} tokens deployment on L2; persisting tokens into DB",
            tokens.len()
        );
        storage.tokens_dal().add_tokens(&tokens).await?;
        Ok(())
    }
Needs to run after recovering storage logs.
core/lib/snapshots_applier/src/lib.rs