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
[BOUNTY-2] Explicit Configuration & General internal NAT API #190
Conversation
Signed-off-by: Karim TAAM <karim.t2am@gmail.com>
Signed-off-by: Karim TAAM <karim.t2am@gmail.com>
Signed-off-by: Karim TAAM <karim.t2am@gmail.com>
Signed-off-by: Karim TAAM <karim.t2am@gmail.com>
Signed-off-by: Karim TAAM <karim.t2am@gmail.com>
Signed-off-by: Karim TAAM <karim.t2am@gmail.com>
Signed-off-by: Karim TAAM <karim.t2am@gmail.com>
Signed-off-by: Karim TAAM <karim.t2am@gmail.com>
Signed-off-by: Karim TAAM <karim.t2am@gmail.com>
Signed-off-by: Karim TAAM <karim.t2am@gmail.com>
Signed-off-by: Karim TAAM <karim.t2am@gmail.com>
Signed-off-by: Karim TAAM <karim.t2am@gmail.com>
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.
It's hard for me to provide quality feedback because this PR is too large, 1,600 changed lines. I can't wrap my head around it in anything less than an hour. The few comments I left were before I realized that was why I was having a hard time thinking deeply about it. This needs to be split up into several smaller PRs. Here's some ideas on how
- A PR that just refactors the existing UPNP/None options into the NatManager
- A PR that renames and moves files with no other changes to the desired places and names.
- A PR to add network reporting files (besu.network)
- A PR to add reporting in the Admin Info
- A PR that adds manual NAT settings into the newly refactored NatManager
- A PR that adds docker support into the newly refactored NatManager
- A PR that adds K8s support into the newly refactoed NatManager.
It looks like docker, k8s, and manual are not in this PR, but there are some config options set up for them. Don't add these until the code adding them is brought in, it makes the PR look like it's doing more than it intends.
Also, minimize moving methods around if possible, it increases the diff count and makes it difficult to see if any changes were done in those methods. At least 200 of the diff lines are just moving within classes.
The refactoring may make for a somewhat large PR, but try and minimize what else is going on to keep it as slim as possible.
private final NATMethod natMethod = DEFAULT_NAT_METHOD; | ||
|
||
@Option( | ||
names = {"--nat-external-ip-usage-enabled"}, |
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.
This should be implicit by --nat-method=MANUAL
.
UPNP, | ||
DOCKER, | ||
KUBERNETES, | ||
NONE; |
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 also need a MANUAL value where the client just has the values plugged via configuration.
* <li><b>KUBERNETES:</b> Besu node is running inside a Kubernetes pod. | ||
* </ul> | ||
*/ | ||
public enum NATMethod { |
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.
Generally we treat initialism as words, so UpperCamelCase would be -> NatMethod
https://google.github.io/styleguide/javaguide.html#s5.3-camel-case
OK thanks for your answer. Indeed there is a lot of change in this PR. I start splitting my PR and I get back to you quickly with a smaller PR |
Hi @shemnon I just published a smaller PR in my private repo in order to simplify the review. I have also detailed as much as possible my modifications in the description. Hoping that it facilitates the review. it will make a merge to a branch that I would push to the master of the official repository at the end of the bounty Link to the PR : matkt#3 |
* refactor nat manager Signed-off-by: Karim TAAM <karim.t2am@gmail.com> Signed-off-by: Abdelhamid Bakhta <abdelhamid.bakhta@consensys.net> * restart tests Signed-off-by: Karim TAAM <karim.t2am@gmail.com> Signed-off-by: Abdelhamid Bakhta <abdelhamid.bakhta@consensys.net> * restart tests Signed-off-by: Karim TAAM <karim.t2am@gmail.com> Signed-off-by: Abdelhamid Bakhta <abdelhamid.bakhta@consensys.net> * Add Tuweni to Plugin-APIs (#295) Generally, byte[] -> Bytes of some form. Most of the changes are the side effect of the type changes or chaning to the names of Tuweni equivilant calls (getHexString->toHexString, etc). UnformattedData -> Bytes Log Topics went from Hash to Bytes32 Difficulty went to UInt256 to match core impl. Quantity lost BinaryData and is just getValue() and toHexString() Signed-off-by: Danno Ferrin <danno.ferrin@gmail.com> Signed-off-by: Abdelhamid Bakhta <abdelhamid.bakhta@consensys.net> * DSL precondition to avoid creating orphan processes (#291) Signed-off-by: Christopher Hare <chris.hare@consensys.net> Co-authored-by: Danno Ferrin <danno.ferrin@shemnon.com> Signed-off-by: Abdelhamid Bakhta <abdelhamid.bakhta@consensys.net> * Fix AT failure because of additional field sent by Orion (#299) Signed-off-by: Stefan Pingel <stefan.pingel@consensys.net> Signed-off-by: Abdelhamid Bakhta <abdelhamid.bakhta@consensys.net> * Update NatService.java Signed-off-by: Abdelhamid Bakhta <abdelhamid.bakhta@consensys.net> * Update NatServiceType.java Signed-off-by: Abdelhamid Bakhta <abdelhamid.bakhta@consensys.net> * Update NatServiceType.java Signed-off-by: Abdelhamid Bakhta <abdelhamid.bakhta@consensys.net> * Update NatServiceType.java Signed-off-by: Abdelhamid Bakhta <abdelhamid.bakhta@consensys.net> * Update NatServiceType.java Signed-off-by: Abdelhamid Bakhta <abdelhamid.bakhta@consensys.net> * remove method Signed-off-by: Abdelhamid Bakhta <abdelhamid.bakhta@consensys.net> * SPDX-License-Identifier: Apache-2.0 Signed-off-by: Abdelhamid Bakhta <abdelhamid.bakhta@consensys.net> * SPDX-License-Identifier: Apache-2.0 Signed-off-by: Abdelhamid Bakhta <abdelhamid.bakhta@consensys.net> * Comment waitForFile: "besu.networks" Signed-off-by: Abdelhamid Bakhta <abdelhamid.bakhta@consensys.net> * spotless apply Signed-off-by: Abdelhamid Bakhta <abdelhamid.bakhta@consensys.net> * test Signed-off-by: Abdelhamid Bakhta <abdelhamid.bakhta@consensys.net> * create file if not exist Signed-off-by: Abdelhamid Bakhta <abdelhamid.bakhta@consensys.net> * remove useless code Signed-off-by: Abdelhamid Bakhta <abdelhamid.bakhta@consensys.net> * fix waitForFile method Signed-off-by: Karim TAAM <karim.t2am@gmail.com> Co-authored-by: Danno Ferrin <danno.ferrin@shemnon.com> Co-authored-by: CJ Hare <CjHare@users.noreply.github.com> Co-authored-by: pinges <16143240+pinges@users.noreply.github.com> Co-authored-by: Abdelhamid Bakhta <45264458+abdelhamidbakhta@users.noreply.github.com>
…ger#190 (hyperledger#298) * refactor nat manager Signed-off-by: Karim TAAM <karim.t2am@gmail.com> Signed-off-by: Abdelhamid Bakhta <abdelhamid.bakhta@consensys.net> * restart tests Signed-off-by: Karim TAAM <karim.t2am@gmail.com> Signed-off-by: Abdelhamid Bakhta <abdelhamid.bakhta@consensys.net> * restart tests Signed-off-by: Karim TAAM <karim.t2am@gmail.com> Signed-off-by: Abdelhamid Bakhta <abdelhamid.bakhta@consensys.net> * Add Tuweni to Plugin-APIs (hyperledger#295) Generally, byte[] -> Bytes of some form. Most of the changes are the side effect of the type changes or chaning to the names of Tuweni equivilant calls (getHexString->toHexString, etc). UnformattedData -> Bytes Log Topics went from Hash to Bytes32 Difficulty went to UInt256 to match core impl. Quantity lost BinaryData and is just getValue() and toHexString() Signed-off-by: Danno Ferrin <danno.ferrin@gmail.com> Signed-off-by: Abdelhamid Bakhta <abdelhamid.bakhta@consensys.net> * DSL precondition to avoid creating orphan processes (hyperledger#291) Signed-off-by: Christopher Hare <chris.hare@consensys.net> Co-authored-by: Danno Ferrin <danno.ferrin@shemnon.com> Signed-off-by: Abdelhamid Bakhta <abdelhamid.bakhta@consensys.net> * Fix AT failure because of additional field sent by Orion (hyperledger#299) Signed-off-by: Stefan Pingel <stefan.pingel@consensys.net> Signed-off-by: Abdelhamid Bakhta <abdelhamid.bakhta@consensys.net> * Update NatService.java Signed-off-by: Abdelhamid Bakhta <abdelhamid.bakhta@consensys.net> * Update NatServiceType.java Signed-off-by: Abdelhamid Bakhta <abdelhamid.bakhta@consensys.net> * Update NatServiceType.java Signed-off-by: Abdelhamid Bakhta <abdelhamid.bakhta@consensys.net> * Update NatServiceType.java Signed-off-by: Abdelhamid Bakhta <abdelhamid.bakhta@consensys.net> * Update NatServiceType.java Signed-off-by: Abdelhamid Bakhta <abdelhamid.bakhta@consensys.net> * remove method Signed-off-by: Abdelhamid Bakhta <abdelhamid.bakhta@consensys.net> * SPDX-License-Identifier: Apache-2.0 Signed-off-by: Abdelhamid Bakhta <abdelhamid.bakhta@consensys.net> * SPDX-License-Identifier: Apache-2.0 Signed-off-by: Abdelhamid Bakhta <abdelhamid.bakhta@consensys.net> * Comment waitForFile: "besu.networks" Signed-off-by: Abdelhamid Bakhta <abdelhamid.bakhta@consensys.net> * spotless apply Signed-off-by: Abdelhamid Bakhta <abdelhamid.bakhta@consensys.net> * test Signed-off-by: Abdelhamid Bakhta <abdelhamid.bakhta@consensys.net> * create file if not exist Signed-off-by: Abdelhamid Bakhta <abdelhamid.bakhta@consensys.net> * remove useless code Signed-off-by: Abdelhamid Bakhta <abdelhamid.bakhta@consensys.net> * fix waitForFile method Signed-off-by: Karim TAAM <karim.t2am@gmail.com> Co-authored-by: Danno Ferrin <danno.ferrin@shemnon.com> Co-authored-by: CJ Hare <CjHare@users.noreply.github.com> Co-authored-by: pinges <16143240+pinges@users.noreply.github.com> Co-authored-by: Abdelhamid Bakhta <45264458+abdelhamidbakhta@users.noreply.github.com>
…ger#190 (hyperledger#298) * refactor nat manager Signed-off-by: Karim TAAM <karim.t2am@gmail.com> Signed-off-by: Abdelhamid Bakhta <abdelhamid.bakhta@consensys.net> * restart tests Signed-off-by: Karim TAAM <karim.t2am@gmail.com> Signed-off-by: Abdelhamid Bakhta <abdelhamid.bakhta@consensys.net> * restart tests Signed-off-by: Karim TAAM <karim.t2am@gmail.com> Signed-off-by: Abdelhamid Bakhta <abdelhamid.bakhta@consensys.net> * Add Tuweni to Plugin-APIs (hyperledger#295) Generally, byte[] -> Bytes of some form. Most of the changes are the side effect of the type changes or chaning to the names of Tuweni equivilant calls (getHexString->toHexString, etc). UnformattedData -> Bytes Log Topics went from Hash to Bytes32 Difficulty went to UInt256 to match core impl. Quantity lost BinaryData and is just getValue() and toHexString() Signed-off-by: Danno Ferrin <danno.ferrin@gmail.com> Signed-off-by: Abdelhamid Bakhta <abdelhamid.bakhta@consensys.net> * DSL precondition to avoid creating orphan processes (hyperledger#291) Signed-off-by: Christopher Hare <chris.hare@consensys.net> Co-authored-by: Danno Ferrin <danno.ferrin@shemnon.com> Signed-off-by: Abdelhamid Bakhta <abdelhamid.bakhta@consensys.net> * Fix AT failure because of additional field sent by Orion (hyperledger#299) Signed-off-by: Stefan Pingel <stefan.pingel@consensys.net> Signed-off-by: Abdelhamid Bakhta <abdelhamid.bakhta@consensys.net> * Update NatService.java Signed-off-by: Abdelhamid Bakhta <abdelhamid.bakhta@consensys.net> * Update NatServiceType.java Signed-off-by: Abdelhamid Bakhta <abdelhamid.bakhta@consensys.net> * Update NatServiceType.java Signed-off-by: Abdelhamid Bakhta <abdelhamid.bakhta@consensys.net> * Update NatServiceType.java Signed-off-by: Abdelhamid Bakhta <abdelhamid.bakhta@consensys.net> * Update NatServiceType.java Signed-off-by: Abdelhamid Bakhta <abdelhamid.bakhta@consensys.net> * remove method Signed-off-by: Abdelhamid Bakhta <abdelhamid.bakhta@consensys.net> * SPDX-License-Identifier: Apache-2.0 Signed-off-by: Abdelhamid Bakhta <abdelhamid.bakhta@consensys.net> * SPDX-License-Identifier: Apache-2.0 Signed-off-by: Abdelhamid Bakhta <abdelhamid.bakhta@consensys.net> * Comment waitForFile: "besu.networks" Signed-off-by: Abdelhamid Bakhta <abdelhamid.bakhta@consensys.net> * spotless apply Signed-off-by: Abdelhamid Bakhta <abdelhamid.bakhta@consensys.net> * test Signed-off-by: Abdelhamid Bakhta <abdelhamid.bakhta@consensys.net> * create file if not exist Signed-off-by: Abdelhamid Bakhta <abdelhamid.bakhta@consensys.net> * remove useless code Signed-off-by: Abdelhamid Bakhta <abdelhamid.bakhta@consensys.net> * fix waitForFile method Signed-off-by: Karim TAAM <karim.t2am@gmail.com> Co-authored-by: Danno Ferrin <danno.ferrin@shemnon.com> Co-authored-by: CJ Hare <CjHare@users.noreply.github.com> Co-authored-by: pinges <16143240+pinges@users.noreply.github.com> Co-authored-by: Abdelhamid Bakhta <45264458+abdelhamidbakhta@users.noreply.github.com>
…ger#190 (hyperledger#298) * refactor nat manager Signed-off-by: Karim TAAM <karim.t2am@gmail.com> Signed-off-by: Abdelhamid Bakhta <abdelhamid.bakhta@consensys.net> * restart tests Signed-off-by: Karim TAAM <karim.t2am@gmail.com> Signed-off-by: Abdelhamid Bakhta <abdelhamid.bakhta@consensys.net> * restart tests Signed-off-by: Karim TAAM <karim.t2am@gmail.com> Signed-off-by: Abdelhamid Bakhta <abdelhamid.bakhta@consensys.net> * Add Tuweni to Plugin-APIs (hyperledger#295) Generally, byte[] -> Bytes of some form. Most of the changes are the side effect of the type changes or chaning to the names of Tuweni equivilant calls (getHexString->toHexString, etc). UnformattedData -> Bytes Log Topics went from Hash to Bytes32 Difficulty went to UInt256 to match core impl. Quantity lost BinaryData and is just getValue() and toHexString() Signed-off-by: Danno Ferrin <danno.ferrin@gmail.com> Signed-off-by: Abdelhamid Bakhta <abdelhamid.bakhta@consensys.net> * DSL precondition to avoid creating orphan processes (hyperledger#291) Signed-off-by: Christopher Hare <chris.hare@consensys.net> Co-authored-by: Danno Ferrin <danno.ferrin@shemnon.com> Signed-off-by: Abdelhamid Bakhta <abdelhamid.bakhta@consensys.net> * Fix AT failure because of additional field sent by Orion (hyperledger#299) Signed-off-by: Stefan Pingel <stefan.pingel@consensys.net> Signed-off-by: Abdelhamid Bakhta <abdelhamid.bakhta@consensys.net> * Update NatService.java Signed-off-by: Abdelhamid Bakhta <abdelhamid.bakhta@consensys.net> * Update NatServiceType.java Signed-off-by: Abdelhamid Bakhta <abdelhamid.bakhta@consensys.net> * Update NatServiceType.java Signed-off-by: Abdelhamid Bakhta <abdelhamid.bakhta@consensys.net> * Update NatServiceType.java Signed-off-by: Abdelhamid Bakhta <abdelhamid.bakhta@consensys.net> * Update NatServiceType.java Signed-off-by: Abdelhamid Bakhta <abdelhamid.bakhta@consensys.net> * remove method Signed-off-by: Abdelhamid Bakhta <abdelhamid.bakhta@consensys.net> * SPDX-License-Identifier: Apache-2.0 Signed-off-by: Abdelhamid Bakhta <abdelhamid.bakhta@consensys.net> * SPDX-License-Identifier: Apache-2.0 Signed-off-by: Abdelhamid Bakhta <abdelhamid.bakhta@consensys.net> * Comment waitForFile: "besu.networks" Signed-off-by: Abdelhamid Bakhta <abdelhamid.bakhta@consensys.net> * spotless apply Signed-off-by: Abdelhamid Bakhta <abdelhamid.bakhta@consensys.net> * test Signed-off-by: Abdelhamid Bakhta <abdelhamid.bakhta@consensys.net> * create file if not exist Signed-off-by: Abdelhamid Bakhta <abdelhamid.bakhta@consensys.net> * remove useless code Signed-off-by: Abdelhamid Bakhta <abdelhamid.bakhta@consensys.net> * fix waitForFile method Signed-off-by: Karim TAAM <karim.t2am@gmail.com> Co-authored-by: Danno Ferrin <danno.ferrin@shemnon.com> Co-authored-by: CJ Hare <CjHare@users.noreply.github.com> Co-authored-by: pinges <16143240+pinges@users.noreply.github.com> Co-authored-by: Abdelhamid Bakhta <45264458+abdelhamidbakhta@users.noreply.github.com> Signed-off-by: edwardmack <ed@edwardmack.com>
Signed-off-by: Karim TAAM karim.t2am@gmail.com
PR description
Create a general internal API to support Network Address Translation (NAT) technologies in Besu. The goal of this work is to offer developers a consistent API for performing NAT tasks so that I can abstractly add support for new NAT systems (e.g. Docker, Kubernetes, etc.) with a minimum amount of code changes. As a second NAT style, explicit configuration for all ports and IP addresses would be available.
A few comments
Java APIs to determine if a node is in a NAT environment, and then identify the kind of NAT environment
Java APIs to enable/disable the NAT port forwarding if the environment requires it, as well as APIs to determine if such calls are needed or making the enable/disable calls a no-op when it is unneeded.
Ability to explicitly configure the external IP to broadcast without regards to NAT or other considerations.