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

Client NAT traversal 0.1 #494

Merged
merged 2 commits into from
Jun 30, 2018
Merged

Client NAT traversal 0.1 #494

merged 2 commits into from
Jun 30, 2018

Conversation

mvines
Copy link
Member

@mvines mvines commented Jun 29, 2018

UPnP is now used to request a port on the NAT be forwarded to the local machine.
This obviously only works for NATs that support UPnP, and thus is not a panacea
for all NAT-related connectivity issues.

Notable hacks in this patch include a transmit/receive UDP socket pair to work
around current protocol limitations whereby the full node assumes its peer can
receive on the same UDP port it transmitted from.

Fixes #458

@mvines
Copy link
Member Author

mvines commented Jun 29, 2018

Evidence of success:

$ ./multinode-demo/client.sh testnet.solana.com
+ mkdir -p config-client-demo
+ rsync -vPz rsync://testnet.solana.com/config/leader.json config-client-demo/
leader.json
         654 100%  638.67kB/s    0:00:00 (xfer#1, to-check=0/1)

sent 44 bytes  received 98 bytes  284.00 bytes/sec
total size is 654  speedup is 4.61
+ rsync -vPz rsync://testnet.solana.com/config/mint.json config-client-demo/
mint.json
         442 100%  431.64kB/s    0:00:00 (xfer#1, to-check=0/1)

sent 44 bytes  received 96 bytes  93.33 bytes/sec
total size is 442  speedup is 3.16
+ exec cargo run --bin solana-client-demo -- -n 1 -l config-client-demo/leader.json
   Compiling solana v0.7.0-alpha (file:///Users/mvines/ws/solana)
    Finished dev [unoptimized + debuginfo] target(s) in 15.57s
     Running `target/debug/solana-client-demo -n 1 -l config-client-demo/leader.json`
 INFO 2018-06-29T21:19:35Z: solana::nat: Using local address 0.0.0.0:52657 mapped to public address 76.167.194.243:59505 for gossip
CONVERGED!
Parsing stdin...
 INFO 2018-06-29T21:19:35Z: solana::nat: Using local address 0.0.0.0:57846 mapped to public address 76.167.194.243:47581 for transactions
 INFO 2018-06-29T21:19:35Z: solana::nat: Using local address 0.0.0.0:61049 mapped to public address 76.167.194.243:49060 for requests
Get last ID...
 INFO 2018-06-29T21:19:35Z: solana::thin_client: get_last_id
get_last_id send_to 35.230.65.68:8003
 INFO 2018-06-29T21:19:35Z: solana::thin_client: Response last_id [167, 141, 96, 4, 80, 190, 117, 216, 83, 180, 27, 50, 154, 239, 181, 222, 71, 252, 243, 173, 223, 21, 125, 251, 219, 122, 127, 109, 13, 182, 39, 89]
Got last ID [167, 141, 96, 4, 80, 190, 117, 216, 83, 180, 27, 50, 154, 239, 181, 222, 71, 252, 243, 173, 223, 21, 125, 251, 219, 122, 127, 109, 13, 182, 39, 89]
Creating keypairs...
 INFO 2018-06-29T21:19:37Z: solana::crdt: purge [142, 151, 75, 167] 1296
..
..
..

@mvines
Copy link
Member Author

mvines commented Jun 29, 2018

This doesn't work for GCP-based nodes yet since there's no NAT to talk to...

src/nat.rs Outdated
pub struct UdpSocketPair {
pub addr: SocketAddr, // Public address of the socket
pub rx: UdpSocket, // Locally bound socket that can receive from the public address
pub tx: UdpSocket, // Locally bound socket to send via public address
Copy link
Contributor

Choose a reason for hiding this comment

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

Since "tx" is so common in blockchain for "transaction", I think we should use "sender" (and "receiver" for "rx"), which is consistent with Rust's channel naming.

Copy link
Member Author

Choose a reason for hiding this comment

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

👍

@@ -15,7 +15,8 @@ use transaction::Transaction;
/// An object for querying and sending transactions to the network.
pub struct ThinClient {
requests_addr: SocketAddr,
requests_socket: UdpSocket,
requests_socket_tx: UdpSocket,
Copy link
Contributor

Choose a reason for hiding this comment

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

Likewise, drop "socket" here, to make it "requests_sender".

@garious
Copy link
Contributor

garious commented Jun 29, 2018

I can't help but notice this isn't written in bash. :)

@mvines
Copy link
Member Author

mvines commented Jun 29, 2018

Don't tempt me...

@mvines mvines force-pushed the nat branch 4 times, most recently from cc540ba to 863fd54 Compare June 29, 2018 22:07
@mvines
Copy link
Member Author

mvines commented Jun 29, 2018

@garious ready for another pass. I'm working on "This doesn't work for GCP-based nodes yet since there's no NAT to talk to..." now but that can easily be a follow-up PR

@mvines
Copy link
Member Author

mvines commented Jun 30, 2018

Coverage disabled for now (cc #443).

@mvines mvines added automerge Merge this Pull Request automatically once CI passes and removed automerge Merge this Pull Request automatically once CI passes labels Jun 30, 2018
UPnP is now used to request a port on the NAT be forwarded to the local machine.
This obviously only works for NATs that support UPnP, and thus is not a panacea
for all NAT-related connectivity issues.

Notable hacks in this patch include a transmit/receive UDP socket pair to work
around current protocol limitations whereby the full node assumes its peer can
receive on the same UDP port it transmitted from.
@mvines mvines added the automerge Merge this Pull Request automatically once CI passes label Jun 30, 2018
@solana-grimes solana-grimes merged commit 0b56d60 into solana-labs:master Jun 30, 2018
steviez pushed a commit to steviez/solana that referenced this pull request Apr 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
automerge Merge this Pull Request automatically once CI passes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants