-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Conversation
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
..
..
.. |
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 |
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.
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.
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.
👍
src/thin_client.rs
Outdated
@@ -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, |
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.
Likewise, drop "socket" here, to make it "requests_sender".
I can't help but notice this isn't written in bash. :) |
Don't tempt me... |
cc540ba
to
863fd54
Compare
@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 |
Coverage disabled for now (cc #443). |
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.
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