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: get rid of WsAdminClient #4520

Merged
merged 2 commits into from
Mar 15, 2024

Conversation

dpc
Copy link
Contributor

@dpc dpc commented Mar 10, 2024

Re #4519

I wrote it just to see if it's possible and everything still works.

Now I think we might tweak IRawFederationApi a bit and retain ability to do both. I.e. split IRawFederationApi::all_peers into all_peers + admin_peer, so that FederationApiExt::request_admin can call only the admin, while other requests - all guardians.

But one way or another I think getting rid of WsAdminClient is easy and the right thing to do.

@dpc dpc requested review from a team as code owners March 10, 2024 08:55
@dpc dpc force-pushed the getting-rid-of-ws-admin-client branch from 88ec9a7 to 289a955 Compare March 10, 2024 22:41
@dpc dpc enabled auto-merge March 11, 2024 03:09
elsirion
elsirion previously approved these changes Mar 14, 2024
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.

I think this makes sense, having two clients annoyed me too.

As a next step towards the goal of a "guardian client" I could imagine being able to save our_id and the password to the client DB, which would lead to guardian functionality becoming available. To allow modules to access guardian APIs we should add something like ClientContext::guardian_auth(&self) -> Option<(PeerId, ApiAuth)> that can be used to determine if the user is a guardian and if so what the authentication token is.

Comment on lines +471 to +480
pub fn from_pre_peer_id_endpoint(url: SafeUrl) -> Self {
// PeerIds are used only for informational purposes, but just in case, make a
// big number so it stands out
GlobalFederationApiWithCache::new(WsFederationApi::new(vec![(PeerId::from(1024), url)]))
.into()
}

pub fn from_single_endpoint(peer: PeerId, url: SafeUrl) -> Self {
GlobalFederationApiWithCache::new(WsFederationApi::new(vec![(peer, url)])).into()
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Is it really worth having two of these functions?

Copy link
Contributor Author

@dpc dpc Mar 14, 2024

Choose a reason for hiding this comment

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

Doesn't matter too much, just wanted a simplest patch possible, to unblock meta module. We'll clean up with time.

Comment on lines +561 to +564
/// Sets the password used to decrypt the configs and authenticate
///
/// Must be called first before any other calls to the API
async fn set_password(&self, auth: ApiAuth) -> FederationResult<()>;
Copy link
Contributor

Choose a reason for hiding this comment

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

Must be called first before any other calls to the API

This doesn't make a lot of sense if read in the context of the normal client API. Maybe the admin API should be defined as an extension trait just like module APIs are? I think that would make it easier to understand the separate concepts of "normal API" and "admin API"

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I just moved it.

@elsirion
Copy link
Contributor

Needs rebase :(

@dpc
Copy link
Contributor Author

dpc commented Mar 14, 2024

As a next step towards the goal of a "guardian client" I could imagine being able to save our_id and the password to the client DB,

Meta module PR already does something like that, thought it does not store it in the DB.

@dpc
Copy link
Contributor Author

dpc commented Mar 14, 2024

Rebased.

1,
"attempted to broadcast admin password?!"
);
self.request_current_consensus(method.into(), params.with_auth(auth))
Copy link
Contributor

Choose a reason for hiding this comment

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

Could we use request_single_peer here instead of request_current_consensus?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It makes sense, but it changes the type of the result, which will lead further changes, and I have other PRs on top of this one, and just wanted to move these methods 1:1 to a new place to keep it small. We'll follow up with improvements. Added a TODO to #4519 4519

Copy link
Contributor

Choose a reason for hiding this comment

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

Works for me

@dpc dpc mentioned this pull request Mar 15, 2024
2 tasks
@dpc dpc requested a review from m1sterc001guy March 15, 2024 02:12
@dpc dpc added this pull request to the merge queue Mar 15, 2024
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Mar 15, 2024
@dpc dpc added this pull request to the merge queue Mar 15, 2024
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Mar 15, 2024
@elsirion elsirion added this pull request to the merge queue Mar 15, 2024
Merged via the queue into fedimint:master with commit 868cf90 Mar 15, 2024
20 checks passed
@okjodom
Copy link
Contributor

okjodom commented Mar 27, 2024

As a next step towards the goal of a "guardian client"

Could you elaborate more on this goal. What functionalities would this guardian client have, differentiated from the current Federation/User client, and from the direct API calls to a Guardian app makes to ConfigGen / Consensus APIs

@dpc
Copy link
Contributor Author

dpc commented Mar 27, 2024

Could you elaborate more on this goal. What functionalities would this guardian client have, differentiated from the current Federation/User client, and from the direct API calls to a Guardian app makes to ConfigGen / Consensus APIs

I'm not sure about the original meaning but, the AFAICT next goals are:

  • Turn IRawFederationApi::all_peers into two calls: all_peers and our_id() -> Option<PeerdID>
  • Make unauth calls use one, the admin calls the others
  • Make the client initializing implementations of IRawFederationApi with correct settings so they can return them from the DB
  • Maybe make the Client remember peer_id + auth in the database.

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.

None yet

4 participants