-
Notifications
You must be signed in to change notification settings - Fork 210
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
Conversation
Codecov ReportAttention:
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. |
There was a problem hiding this 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.
gateway/cli/src/main.rs
Outdated
@@ -30,6 +30,8 @@ pub enum Commands { | |||
VersionHash, | |||
/// Display high-level information about the Gateway | |||
Info, | |||
/// Display config information about the Gateways federation | |||
Config, |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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".
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
gateway/ln-gateway/src/lib.rs
Outdated
client: &ClientArc, | ||
federation_id: FederationId, | ||
) -> FederationConfigInfo { | ||
let balance_msat = client.get_balance().await; |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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".
gateway/ln-gateway/src/lib.rs
Outdated
FederationConfigInfo { | ||
federation_id, | ||
balance_msat, | ||
config, | ||
} |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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 ?
There was a problem hiding this comment.
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)
There was a problem hiding this comment.
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.
scripts/dev/mprocs/run.sh
Outdated
@@ -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' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
question: ?
f3126d7
to
1bc5bfd
Compare
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. |
@@ -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 |
There was a problem hiding this comment.
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.
gateway/ln-gateway/src/lib.rs
Outdated
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()); |
There was a problem hiding this comment.
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
gateway/ln-gateway/src/rpc/mod.rs
Outdated
#[derive(Debug, Serialize, Deserialize, PartialEq)] | ||
pub struct GatewayFedConfig { | ||
pub federations: BTreeMap<FederationId, JsonClientConfig>, | ||
// pub federations: BTreeMap<FederationId, ClientConfig>, |
There was a problem hiding this comment.
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
There was a problem hiding this 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
1bc5bfd
to
dc7c1f9
Compare
Fixes #3815. I am not sure it's completely done and would appreciate feedback.