fedimint / ui

https://ui-umber-ten.vercel.app
MIT License
26 stars 39 forks source link

Fedimint does not return federationId in the config #390

Closed Kodylow closed 5 months ago

Kodylow commented 5 months ago

Found some discrepancies between our typescript API and the rust code.

We expect a federationId and other keys from the client config which are not returned by the rust code. I'm putting up a PR to add it fedimint side since it's useful and I want to use it for guardian auth

typescript:

interface ClientConfig {
    consensus_version: CoreConsensusVersion;
    epoch_pk: string;
    federation_id: string;
    api_endpoints: Record<number, ApiEndpoint>;
    modules: Record<number, FedimintModule>;
    meta: MetaConfig;
}

rust:

/// Total client config
///
/// This includes global settings and client-side module configs.
#[derive(Debug, Clone, Eq, PartialEq, Serialize, Deserialize, Encodable, Decodable)]
pub struct ClientConfig {
    #[serde(flatten)]
    pub global: GlobalClientConfig,
    #[serde(deserialize_with = "de_int_key")]
    pub modules: BTreeMap<ModuleInstanceId, ClientModuleConfig>,
}

pub struct GlobalClientConfig {
    /// API endpoints for each federation member
    #[serde(deserialize_with = "de_int_key")]
    pub api_endpoints: BTreeMap<PeerId, PeerUrl>,
    /// Core consensus version
    pub consensus_version: CoreConsensusVersion,
    // TODO: make it a String -> serde_json::Value map?
    /// Additional config the federation wants to transmit to the clients
    pub meta: BTreeMap<String, String>,
}
okjodom commented 5 months ago

Latest ClientConfig returned by the API includes these fields Image

making an update to remove epoch_pk which I think lingered since the days of HBBFT

elsirion commented 5 months ago

The problem was solved differently on the Fedimint side: https://github.com/fedimint/fedimint/pull/4576, is this issue still relevant @Kodylow?

okjodom commented 5 months ago

The problem was solved differently on the Fedimint side: fedimint/fedimint#4576, is this issue still relevant?

After the upstream fix, we can now add a new rpc call to Typescript api to get the federation id. The part about typescritpt types being stale is still relevant. Fixed by https://github.com/fedimint/ui/pull/400