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

[5.0 -> main] Support throttling block syncing to peers #1742

Merged
merged 56 commits into from
Oct 10, 2023

Conversation

heifner
Copy link
Member

@heifner heifner commented Oct 10, 2023

Peer to peer listen ports may now apply a block sync throttle. Each occurrence of p2p-listen-endpoint has an independent throttle specification. Here's the updated help text:

--p2p-listen-endpoint arg (=0.0.0.0:9876:0)
                                        The actual host:port[:<rate-cap>] used
                                        to listen for incoming p2p connections.
                                        May be used multiple times.   The
                                        optional rate cap will limit block sync
                                        bandwidth to the specified rate.  A
                                        number alone will be interpreted as
                                        bytes per second.  The number may be
                                        suffixed with units.  Supported units
                                        are:   'B/s', 'KB/s', 'MB/s, 'GB/s',
                                        'TB/s', 'KiB/s', 'MiB/s', 'GiB/s',
                                        'TiB/s'.  Transactions and blocks
                                        outside of sync mode are not throttled.
                                          Examples:
                                            192.168.0.100:9876:1MiB/s
                                            node.eos.io:9876:1512KB/s
                                            node.eos.io:9876:0.5GB/s
                                            [2001:db8:85a3:8d3:1319:8a2e:370:7348]:9876:250KB/s

Parsing of the rate cap accepts fractional numbers expressed as decimals. The throttle rate is in bytes per second. Per the help text, shorthand suffixes are supported, and transactions and blocks being propagated across the peer to peer network between synchronized nodes are not throttled. Only blocks transmitted to a syncing node are throttled. A throttle of 0 or 0B/s means unthrottled, and is the default.

The limit for specifying a rate cap is 30 characters, including the colon field separator. This is sufficient characters to specify any value in the 64 bit range of size_t with room left for a suffix. If the rate cap does not parse or the value multiplied by the suffix exceeds 18,446,744,073,709,551,615 an exception will be thrown and the node will not start.

IPv6 addresses are supported for listen endpoints. They must be in square bracket format: [<ipv6 address>]:port optionally followed by :<rate-cap>.

Note

Inbound connections from IPs which are configured p2p-peer-addresses are exempt from throttle rate caps. Care should be taken in NAT environments to avoid inadvertently exempting connections due to overlapping subnets.

Throttling is stable even at exceptionally low byterates, but of course on a busy network if the throttle is less than the average block size on the network, clients using that listen port will never catch up to the head block. Such configurations are allowed but not recommended.

Suggested network topology

Together with #1411 which allows multiple listen endpoints, an edge node for public peering might be configured as follows:
Leap Throttle Sample Network Diagram (truncated)

Merges release/5.0 into main including #1741

Resolves #1295.

jgiszczak and others added 30 commits August 22, 2023 03:16
Add necessary custom topology for p2p_sync_throttle_test.

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
Clarify variable names in p2p throttled sync test and tweak numbers.
Fix p2p throttled test to actually function (waitForBlock has a hidden
default timeout).
Bump up timeout in block_log_util_test.
Remove exponential backoff in throttle and utilize existing retry
mechanism.
Fix parsing and overflow problems and address peer review comments.
Extend throttle test to add another throttle prefix.
Added additional code comments.
Addressed peer review comment.

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
Update connections_manager::add method.
Clean up cruft and rename connection data structure back to
'connections'.
Address peer review comments.

Verified

This commit was signed with the committer’s verified signature.
heifner Kevin Heifner

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.

Verified

This commit was signed with the committer’s verified signature.
heifner Kevin Heifner
Add mock_connection constructor required by clang14.
jgiszczak and others added 22 commits September 27, 2023 16:00
Split prometheus statistics out of connection_monitor into
connection_statistics_monitor.

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.

Verified

This commit was signed with the committer’s verified signature.
heifner Kevin Heifner

Verified

This commit was signed with the committer’s verified signature.
oschwaldp-oci Peter Oschwald

Verified

This commit was signed with the committer’s verified signature.
oschwaldp-oci Peter Oschwald

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
Remove dependency on python requests package.
Remove locale-aware parsing of sync throttle rate.
Prevent transmitting peer from throttling while not in sync mode.
Add timeouts to throttle sync test.
This reverts commit caa703d.

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
[5.0] Support throttling block syncing to peers

Verified

This commit was signed with the committer’s verified signature.
heifner Kevin Heifner
…tle-main
@heifner heifner added the OCI Work exclusive to OCI team label Oct 10, 2023
@jgiszczak jgiszczak merged commit 1e020fe into main Oct 10, 2023
21 checks passed
@jgiszczak jgiszczak deleted the p2p-peer-throttle-main branch October 10, 2023 22:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
OCI Work exclusive to OCI team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

P2P: Ability to limit peer bandwidth consumption
4 participants