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

Use cached topology for clients #674

Merged
merged 21 commits into from
Jul 9, 2021
Merged

Use cached topology for clients #674

merged 21 commits into from
Jul 9, 2021

Conversation

neacsu
Copy link
Contributor

@neacsu neacsu commented Jul 5, 2021

No description provided.

@neacsu neacsu changed the title Use cached topology for Rust clients Use cached topology for clients Jul 6, 2021
/// Makes requests to assemble a full list of gateways from validator-api
async refreshValidatorAPIGateways(url: string): Promise<GatewayBond[]> {
const validator_api_url = url.split(":", 2);
validator_api_url.push("8080");
Copy link
Contributor

Choose a reason for hiding this comment

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

Shouldn't port be part of the URL? What if it's not 8080?

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 is part of the URL, but it's constructed here instead of passed directly by the user, as is the case with the validator url. Ideally, the user should only pass the host address, and not the port, but some refactoring needs to be done in order to split those. That way, we can attach the necessary port, when needed (1317 for contract calls, 8080 or whatever for validator-api).
As for the port changing, I'll have to look into linking the value from the validator-api crate here. I will however put a global variable in index.ts, as it would be easier to maintain.

Copy link
Contributor

Choose a reason for hiding this comment

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

Correct me if I'm wrong, isn't it the case that in theory each validator is going to be able to configure to use a different port hence the user would need to pass one themselves rather than use the hardcoded one?

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 don't have a problem with asking the user to provide the port, but I'm not sure how the user would come to (reliably) know what port to mention for the validator-api. Having it as a hardcoded value seems like the good old way of doing things -> having one hardcoded port per service e.g. 80 for HTTP, 22 for SSH etc. Of course we can make it configurable on both ends (which at this moment is not, even in the validator-api), but imho it should have a value to default to, in case the user doesn't know what to provide.
If we go with a configurable port here, that change should be made in a future PR, which also makes the validator-api configurable as well.

clients/validator/src/caches/mixnodes.ts Outdated Show resolved Hide resolved
common/client-libs/validator-client/src/lib.rs Outdated Show resolved Hide resolved
common/client-libs/validator-client/src/lib.rs Outdated Show resolved Hide resolved
@neacsu neacsu requested a review from jstuczyn July 6, 2021 10:53
async refreshValidatorAPIGateways(urls: string[]): Promise<GatewayBond[]> {
for (const url of urls) {
const validator_api_url = new URL(url);
validator_api_url.port = VALIDATOR_API_PORT;
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not entirely sure what to feel about ignoring user-provided port and using the hardcoded one, but if somebody else takes a look at it and is fine with that, I'll also feel good about it

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The user-provided port is not ignored, but it just isn't usable for the validator-api. In the future, my thoughts are that the user shouldn't have to provide even the validator port or the http scheme. An IP or DNS address should be everything that's needed.

clients/validator/src/index.ts Outdated Show resolved Hide resolved
neacsu added 21 commits July 9, 2021 12:56
... to make sure the validator URLs are in the correct format.
... until we find a way to link to the values from the validator-api
crate.
... as they were working correctly before.
@futurechimp futurechimp merged commit 973c305 into develop Jul 9, 2021
@futurechimp futurechimp deleted the use_cached_topology branch July 9, 2021 10:50
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

3 participants