Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: separate fedimint config info from gateway info endpoint #3880

Merged
merged 1 commit into from
Dec 20, 2023

Conversation

mayrf
Copy link
Contributor

@mayrf mayrf commented Dec 8, 2023

Fixes #3815. I am not sure it's completely done and would appreciate feedback.

@mayrf mayrf requested review from a team as code owners December 8, 2023 16:23
Copy link

codecov bot commented Dec 8, 2023

Codecov Report

Attention: 34 lines in your changes are missing coverage. Please review.

Comparison is base (b891544) 57.09% compared to head (dc7c1f9) 57.04%.
Report is 65 commits behind head on master.

Files Patch % Lines
gateway/ln-gateway/src/lib.rs 29.62% 19 Missing ⚠️
gateway/ln-gateway/src/rpc/rpc_server.rs 28.57% 5 Missing ⚠️
gateway/cli/src/main.rs 0.00% 4 Missing ⚠️
gateway/ln-gateway/src/rpc/rpc_client.rs 33.33% 4 Missing ⚠️
gateway/ln-gateway/src/rpc/mod.rs 33.33% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #3880      +/-   ##
==========================================
- Coverage   57.09%   57.04%   -0.06%     
==========================================
  Files         193      193              
  Lines       42649    43146     +497     
==========================================
+ Hits        24351    24613     +262     
- Misses      18298    18533     +235     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Contributor

@elsirion elsirion left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, but I think we can simplify it a bit more.

@@ -30,6 +30,8 @@ pub enum Commands {
VersionHash,
/// Display high-level information about the Gateway
Info,
/// Display config information about the Gateways federation
Config,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Imo this should be a per-federation command, i.e. takes the federation id as argument.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder which is better. This or --federation-id acting as a filter, and lack of it meaning "all".

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we need the "all" version of the command?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know. If you're in one federation only you can get the config without specifying the id. Or if you're writing a script you could loop over all in one go (one | jq ...). Not very strong reasons, but also doesn't change anything for someone that just wants one config.

client: &ClientArc,
federation_id: FederationId,
) -> FederationConfigInfo {
let balance_msat = client.get_balance().await;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need the balance here? We already have an API endpoint for that.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Balance doesn't seem like part of a "config".

Comment on lines 1244 to 1248
FederationConfigInfo {
federation_id,
balance_msat,
config,
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we allow config fetching per federation only then we don't need to include the federation id in the response.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we remove "balance", ... should it be just a map? id -> config ?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not just a config? Just call the command once for each federation you care about (likely only one at a time anyway)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess it's a follow up to do we allow listing all or not. If we do , will be easier to parse/filter, if not it's kind of needless.

@@ -8,4 +8,4 @@ ensure_in_dev_shell
build_workspace
add_target_dir_to_path

devimint --link-test-dir ./target/devimint "$@" dev-fed --exec bash -c 'mprocs -c misc/mprocs.yaml 2>$FM_LOGS_DIR/devimint-outer.log'
devimint --link-test-dir ./target/devimint "$@" dev-fed --exec bash -c 'mprocs -c misc/mprocs.yaml 2>$FM_LOGS_DIR/devimint-outer.high-levellog'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

question: ?

@mayrf mayrf force-pushed the split-gateway-info-endpoint branch 4 times, most recently from f3126d7 to 1bc5bfd Compare December 18, 2023 00:06
@mayrf
Copy link
Contributor Author

mayrf commented Dec 18, 2023

Sorry for the delay. I went for dpcs suggestion and implemented an --federation-id option, returning either the config of the federation specified or those of all federations, in case no federation-id is specified.

@mayrf mayrf requested review from elsirion and dpc December 18, 2023 11:16
elsirion
elsirion previously approved these changes Dec 18, 2023
@@ -94,7 +99,7 @@ impl GatewayRpcClient {
.base_url
.join("/set_configuration")
.expect("invalid base url");
self.call(Method::POST, url, Some(payload)).await
self.call_post(url, payload).await
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we want to have composite calls in fedimint-cli? Can be fixed in another PR.

let mut federations = BTreeMap::new();
if let Some(federation_id) = federation_id {
let client = self.select_client(federation_id).await?;
// federations.insert(federation_id, client.get_config().clone());
Copy link
Contributor

@okjodom okjodom Dec 18, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: let's clean up commented code

#[derive(Debug, Serialize, Deserialize, PartialEq)]
pub struct GatewayFedConfig {
pub federations: BTreeMap<FederationId, JsonClientConfig>,
// pub federations: BTreeMap<FederationId, ClientConfig>,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: let's clean up commented code

okjodom
okjodom previously approved these changes Dec 18, 2023
Copy link
Contributor

@okjodom okjodom left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

left nit comments, yet this looks and works great!

tACK 1bc5bfd

@elsirion elsirion added this pull request to the merge queue Dec 20, 2023
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Dec 20, 2023
@elsirion elsirion added this pull request to the merge queue Dec 20, 2023
Merged via the queue into fedimint:master with commit 251b16e Dec 20, 2023
20 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

gateway-cli info displays far too much information
4 participants