-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Add QUIC protocol implementation #1943
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
base: testnet
Are you sure you want to change the base?
Conversation
|
@codex review |
|
To use Codex here, create a Codex account and connect to github. |
| void start_up() override; | ||
| void tear_down() override; | ||
| void hangup() override; | ||
| void hangup_shared() override; | ||
| void wake_up() override; | ||
| void alarm() override; | ||
| void loop() override; |
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.
You don't have to implement these if you don't use them. The default implementation is reasonable enough.
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.
i'm not really familiar with td actor system, so i left them for debug logs in case of some unexpected signal from the scheduler
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.
I would define this in an anonymous namespace inside quic-connection.cpp unless there is a legitimate reason why we want to import the implementation from multiple places.
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.
that means you will need to declare all its ngtcp-insides in quic-connection.h, too
this is highly unwanted, as ngtcp exports some weird C symbols into global namespace -- they will contaminate the scope of every TU it's included into
see PImpl idiom
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.
Thanks, I know what pimpl is. I mostly don't like a separate header for implementation when this can be done in a single file, i. e. something resembling this: https://github.com/DanShaders/ton/blob/alpenglow/validator/consensus/block-producer.cpp#L11-L13.
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.
anyways, i plan to reuse this impl structure in server-side connections, so it will be useful to keep it in separate files
quic/quic-pimpl.cpp
Outdated
|
|
||
| std::string alpn_data(alpn.size() + 1, '\0'); | ||
| alpn_data[0] = static_cast<int8_t>(alpn.size()); | ||
| std::copy_n(alpn.c_str(), alpn.size(), alpn_data.begin()); |
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.
alpn_data.begin() + 1 as the last argument?
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.
fixed
| params.initial_max_stream_data_bidi_local = 1 << 20; | ||
| params.initial_max_stream_data_bidi_remote = 1 << 20; | ||
| params.initial_max_data = 1 << 20; |
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.
Where is this 1MB(?) coming from?
| path.local.addr = const_cast<ngtcp2_sockaddr*>(local_address.get_sockaddr()); | ||
| path.local.addrlen = static_cast<ngtcp2_socklen>(local_address.get_sockaddr_len()); | ||
| path.remote.addr = const_cast<ngtcp2_sockaddr*>(remote_address.get_sockaddr()); | ||
| path.remote.addrlen = static_cast<ngtcp2_socklen>(remote_address.get_sockaddr_len()); |
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.
I don't like const casts here, is ngtcp2 guaranteed not to change passed sockaddrs?
| }; | ||
|
|
||
| constexpr static size_t QUIC_MTU = 1350; | ||
| constexpr static size_t UDP_MTU = 2048; |
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.
Why not proper 65507 bytes if this is already larger than ethernet MTU?
| virtual ~Callback() = default; | ||
| }; | ||
|
|
||
| constexpr static size_t QUIC_MTU = 1350; |
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.
Where does this come from? I think ngtcp2 does some form of dynamic MTU discovery, so we should probably query the value from it or use true maximum
|
|
||
| option(USE_QUIC "use ngtcp2 QUIC library" OFF) | ||
| if (USE_QUIC) | ||
| find_package(OpenSSL 3.2 REQUIRED COMPONENTS SSL Crypto) |
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.
We build with OpenSSL 3.1.4 in CI. Not sure how this passed, I think this might just never execute as it sees previously set OpenSSL_FOUND (or something).
|
Findings:
|
No description provided.