async fn validate_portal_config(
    portal_config: &mut PortalConfig,
    ecosystem_config: &EcosystemConfig,
) -> anyhow::Result<()> {
    let chain_names = ecosystem_config.list_of_chains();
    for chain_name in &chain_names {
        if portal_config.contains(chain_name) {
            continue;
        }
        // Append missing chain, chain might not be initialized, so ignoring errors
        if let Ok(chain_config) = ecosystem_config.load_chain(Some(chain_name.clone())) {
            if let Ok(portal_chain_config) = build_portal_chain_config(&chain_config).await {
                portal_config.add_chain_config(&portal_chain_config);
            }
        }
    }
    portal_config.filter(&chain_names);
    Ok(())
}
Validates portal config - appends missing chains and removes unknown chains
zkstack_cli/crates/zkstack/src/commands/portal.rs