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

add dns support #1247

Merged
merged 17 commits into from
Aug 25, 2020
Merged

add dns support #1247

merged 17 commits into from
Aug 25, 2020

Conversation

matkt
Copy link
Contributor

@matkt matkt commented Jul 22, 2020

Signed-off-by: Karim TAAM karim.t2am@gmail.com

PR description

This PR add the support to DNS. By default Besu refuses the use of a DNS but it is possible to use it by adding the following flag --Xdns-enabled=true. Adding this flag will resolve the hostname when starting besu and then it won't change

If there is a need for a more dynamic update (eg for permissioning) add also this flag --Xdns-update-enabled = true ( this will query the DNS every time. So you must trust the DNS on which you are looking for the IP)

Test performed

  • Local Clique Permissioning network (valid/invalid hostname)
  • Azure IBT2 Permissioning network (init network, restart pod)
  • Sync Goerli with static-nodes and without permissioning (dns disabled)
  • Provide Static-nodes with or without hostname (dns enabled/disabled)
  • Provide bootnodes with or without hostname (dns enabled/disabled)

matkt added 3 commits July 22, 2020 17:41
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>
@sambacha
Copy link

Can this DNS option also check CAA policies down the line, or perhaps verify TLS certificate is authorized based on said CAA policy?
Obviously not now, but just trying to see if it's only for ennode usage, 👍

matkt added 2 commits August 17, 2020 18:31
Signed-off-by: Karim TAAM <karim.t2am@gmail.com>
Signed-off-by: Karim TAAM <karim.t2am@gmail.com>
matkt added 3 commits August 19, 2020 22:27
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>
@matkt
Copy link
Contributor Author

matkt commented Aug 21, 2020

Can this DNS option also check CAA policies down the line, or perhaps verify TLS certificate is authorized based on said CAA policy?
Obviously not now, but just trying to see if it's only for ennode usage, 👍

yes I think it might be interesting to explore this idea. this could be an additional parameter

matkt added 2 commits August 21, 2020 10:44
Signed-off-by: Karim TAAM <karim.t2am@gmail.com>
@matkt matkt marked this pull request as ready for review August 21, 2020 08:57
@@ -123,4 +136,89 @@ public void nodeAllowlistCheckShouldIgnoreDiscoveryPortParam() throws Exception
"Exception not expected. Validation of nodes in allowlist should ignore the optional discovery port param.");
}
}

@Test
public void nodeAllowlistCheckShouldWorkWithHostnameIfDndEnabled() throws Exception {
Copy link
Contributor

Choose a reason for hiding this comment

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

Is there a typo in this test name? (Dnd instead of Dns)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good catch . Changed

Copy link
Contributor

@CjHare CjHare left a comment

Choose a reason for hiding this comment

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

Code and test LGTM.

As it's been just over a month since this PR was raised, any reason for it not being reviewed or preventing merging?

@@ -209,12 +210,15 @@ private LocalPermissioningConfiguration localConfigPermissioningConfiguration()
localConfigNodesPermissioningFile = createTemporaryPermissionsFile();
}

List<String> nodesAsListOfStrings =
final List<String> nodesAsListOfStrings =
Copy link
Contributor

Choose a reason for hiding this comment

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

nit; these local variables could be have more succinct names (as we know they are list of strings from typing).

Maybe something like localPermittedNodes and localPermittedEnodeUrls?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

it's changed 👍

public void dnsEnabledOptionIsParsedCorrectly() {
TestBesuCommand besuCommand = parseCommand("--Xdns-enabled", "true");

assertThat(besuCommand.getEnodeDnsConfiguration().dnsEnabled()).isEqualTo(true);
Copy link
Contributor

Choose a reason for hiding this comment

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

nit; isTrue() and isFalse() can be nicer to read then isEqualTo(true) and isEqualTo(false)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

Signed-off-by: Karim TAAM <karim.t2am@gmail.com>
@matkt
Copy link
Contributor Author

matkt commented Aug 25, 2020

Code and test LGTM.

As it's been just over a month since this PR was raised, any reason for it not being reviewed or preventing merging?

No It's just that I was working on something else 😄 . I also wanted to take the time to validate my implementation on Azure etc. Thanks for your review

Copy link
Contributor

@CjHare CjHare left a comment

Choose a reason for hiding this comment

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

Looks good and once you've verified the Azure deployment you mention, feel free to merge 👍

}

private List<EnodeURL> bootNodes = null;
private final List<String> bootnodes = null;
Copy link
Contributor

Choose a reason for hiding this comment

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

Should this be camelCased? bootNodes? It was before and other places in the edited code retain the camel casing. Whatever it chosen it should be consistent.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

}

public InetAddress getIp() {
this.ip =
Copy link
Contributor

Choose a reason for hiding this comment

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

Is doing a DNS lookup every time the design intent? If not perhaps ip should be a supplier and this logic gets put in a Suppliers.memoize call? If it is the design intent it's work a comment so a later refactoring doesn't undo it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No it's a voluntary choice to DNS lookup every time. Because a cache could give a bad IP before it is invalidated again. If the "dns-update-enabled" flag is false it will do it only once.
we could add a cache but I'm afraid that this will prevent nodes from communicating each other while waiting for the next cache update

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I just added a comment 👍

matkt added 2 commits August 25, 2020 17:46
Signed-off-by: Karim TAAM <karim.t2am@gmail.com>
…pport

Signed-off-by: Karim TAAM <karim.t2am@gmail.com>
/**
* Get IP of the EnodeURL
*
* <p>If "dns" and "dns-update" are enabled -> DNS lookup every time to have the IP up to date and
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
* <p>If "dns" and "dns-update" are enabled -> DNS lookup every time to have the IP up to date and
* <p>If "dns" and "dns-update" are enabled -&gt; DNS lookup every time to have the IP up to date and

* <p>If "dns" and "dns-update" are enabled -> DNS lookup every time to have the IP up to date and
* not to rely on an invalid cache
*
* <p>If the "dns" is enabled but "dns-update" is disabled -> IP is retrieved only one time and
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
* <p>If the "dns" is enabled but "dns-update" is disabled -> IP is retrieved only one time and
* <p>If the "dns" is enabled but "dns-update" is disabled -&gt; IP is retrieved only one time and

matkt and others added 2 commits August 25, 2020 18:55
Signed-off-by: Karim TAAM <karim.t2am@gmail.com>
@matkt matkt merged commit 210c85c into hyperledger:master Aug 25, 2020
@matkt matkt deleted the add-dns-support branch September 8, 2020 13:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants