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

[Cli] Retrieve a waypoint value from a given url #2446

Closed
wants to merge 1 commit into from
Closed

[Cli] Retrieve a waypoint value from a given url #2446

wants to merge 1 commit into from

Conversation

dmitri-perelman
Copy link
Contributor

Summary:
Added a waypoint-url cmd line argument to download the waypoint value from.
These are still optional but we might consider making it a non-optional value with a default pointing to https://developers.libra.org/testnet_waypoint.txt.

Testing:

./scripts/cli/start_cli_testnet.sh -- --waypoint-url https://developers.libra.org/testnet_waypoint.txt
./scripts/cli/start_cli_testnet.sh
./scripts/cli/start_cli_testnet.sh -- --waypoint 0:997acd1b112a19eb1d2d3dff78677a0009343727926071c3858aeff2ea3499bf

Issues: ref #2425

@cargo-dep-bot
Copy link

cargo-dep-bot bot commented Feb 5, 2020

This PR made the following dependency changes:

Added Packages (Duplicate versions in '()'):
	autocfg 1.0.0 (0.1.6)
	curl 0.4.25
	curl-sys 0.4.25
	openssl-sys 0.9.54


// If waypoint is given explicitly, use its value, otherwise try to retrieve it from a given
// URL.
let waypoint = args.waypoint.or_else(|| {
Copy link
Contributor

Choose a reason for hiding this comment

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

so this can still be None right? probably worth a comment

Copy link
Contributor

Choose a reason for hiding this comment

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

If I specify both, should we check for the latest?

/// Retrieve a waypoint given the URL.
fn retrieve_waypoint(url_str: &str) -> anyhow::Result<Waypoint> {
let mut data = Vec::new(); // waypoint bytes downloaded from the given URL
let mut handle = Easy::new();
Copy link
Contributor

Choose a reason for hiding this comment

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

@davidiw did you evaluate this client library? 😆

Copy link
Contributor

Choose a reason for hiding this comment

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

I would recommend we just use ureq throughout our codebase unless there's a need for an async web client.

Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Contributor

Choose a reason for hiding this comment

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

ureq doesn't support system-wide proxy , and some client needs to run on tupperware and devserver with fwdproxy configured.

Copy link
Contributor

Choose a reason for hiding this comment

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

I think we could work with them to add that feature. HTTP Proxy is pretty trivial: https://en.wikipedia.org/wiki/Proxy_server#Implementations_of_proxies

Copy link
Contributor

Choose a reason for hiding this comment

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

The actual proxy protocol support is relatively easy. But handle all corner cases where http_proxy https_proxy and no_proxy are defined are not. Which is also why most implementation doesn’t work out of the box . I am not saying it is impossible to do, but it is well beyond the scope of this change.

After all, reqwest has already been added to CLI dependency tree to solve this exact issue, so there are no new additional deps to be add.

Copy link
Contributor

Choose a reason for hiding this comment

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

reqwest pulls in so many dependencies into the client code base. I would prefer we challenge ourselves a little bit and ask the community for help rather than bloating the dependency tree. If, when closer to launch, we this hasn't been resolved, I am happy to support changing to a different library that supports our needs.

Copy link
Contributor

Choose a reason for hiding this comment

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

@@ -14,6 +14,7 @@ anyhow = "1.0"
chrono = "0.4.7"
tonic = "0.1"
hex = "0.3.2"
curl = "0.4.25"
Copy link
Contributor

Choose a reason for hiding this comment

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

can we use https://docs.rs/reqwest/0.10.1/reqwest/ instead? Mint code is already using it (due to its support on system proxies), it is best if we don't introduce new libraries.

Copy link
Contributor

@davidiw davidiw left a comment

Choose a reason for hiding this comment

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

nice!!

@@ -14,6 +14,7 @@ anyhow = "1.0"
chrono = "0.4.7"
tonic = "0.1"
hex = "0.3.2"
ureq = { version = "0.11.3"}
Copy link
Contributor

Choose a reason for hiding this comment

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

maybe we should order these alphabetically?

Comment on lines 17 to 19
use std::num::NonZeroU16;
use std::str::FromStr;
use std::time::{Duration, UNIX_EPOCH};
Copy link
Contributor

Choose a reason for hiding this comment

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

merge these into std::{...
?


// If waypoint is given explicitly, use its value, otherwise try to retrieve it from a given
// URL.
let waypoint = args.waypoint.or_else(|| {
Copy link
Contributor

Choose a reason for hiding this comment

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

If I specify both, should we check for the latest?

_ => Err(anyhow::format_err!(
"URL {} returned {}",
url_str,
response.status()
Copy link
Contributor

Choose a reason for hiding this comment

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

status_line

Summary:
Added a waypoint-url cmd line argument to download the waypoint value from.
These are still optional but we might consider making it a non-optional value with a default pointing to https://developers.libra.org/testnet_waypoint.txt.

Testing:
```
./scripts/cli/start_cli_testnet.sh -- --waypoint-url https://developers.libra.org/testnet_waypoint.txt
./scripts/cli/start_cli_testnet.sh
./scripts/cli/start_cli_testnet.sh -- --waypoint 0:997acd1b112a19eb1d2d3dff78677a0009343727926071c3858aeff2ea3499bf
```

Issues: ref #2425
@dmitri-perelman
Copy link
Contributor Author

Thanks a lot for the constructive comments! :)

@dmitri-perelman
Copy link
Contributor Author

@bors-libra r+

@bors-libra
Copy link
Contributor

📌 Commit 09b19e5 has been approved by dmitri-perelman

@bors-libra
Copy link
Contributor

⌛ Testing commit 09b19e5 with merge 126c729...

@bors-libra
Copy link
Contributor

☀️ Test successful - checks-circle_commit_workflow
Approved by: dmitri-perelman
Pushing 126c729 to master...

@bors-libra bors-libra closed this in 126c729 Feb 6, 2020
@thefallentree
Copy link
Contributor

Who is following up on the issue of proxy support in ureq? Why was my concern dismissed without merit? @dmitri-perelman @davidiw

@thefallentree thefallentree reopened this Feb 6, 2020
@zekun000 zekun000 closed this Feb 7, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants