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

Update Ethereum Node Record When We Pass Network Upgrade Blocks #1998

Merged
merged 22 commits into from Mar 16, 2021

Conversation

RatanRSur
Copy link
Contributor

@RatanRSur RatanRSur commented Mar 10, 2021

Fixed Issue(s)

#1998

Changelog

Signed-off-by: Ratan Rai Sur <ratan.r.sur@gmail.com>
Signed-off-by: Ratan Rai Sur <ratan.r.sur@gmail.com>
Signed-off-by: Ratan Rai Sur <ratan.r.sur@gmail.com>
Signed-off-by: Ratan Rai Sur <ratan.r.sur@gmail.com>
Signed-off-by: Ratan Rai Sur <ratan.r.sur@gmail.com>
Signed-off-by: Ratan Rai Sur <ratan.r.sur@gmail.com>
Signed-off-by: Ratan Rai Sur <ratan.r.sur@gmail.com>
Signed-off-by: Ratan Rai Sur <ratan.r.sur@gmail.com>
Signed-off-by: Ratan Rai Sur <ratan.r.sur@gmail.com>
Signed-off-by: Ratan Rai Sur <ratan.r.sur@gmail.com>
Signed-off-by: Ratan Rai Sur <ratan.r.sur@gmail.com>
@RatanRSur RatanRSur changed the title enr dynamic update Update Ethereum Node Record When We Pass Network Upgrade Blocks Mar 10, 2021
Signed-off-by: Ratan Rai Sur <ratan.r.sur@gmail.com>
@RatanRSur RatanRSur marked this pull request as ready for review March 10, 2021 22:57
&& addressBytes.equals(nodeRecord.get(EnrField.IP_V4))
&& discoveryPort.equals(nodeRecord.get(EnrField.UDP))
&& listeningPort.equals(nodeRecord.get(EnrField.TCP))
&& forkIdSupplier.get().equals(nodeRecord.get("eth")))
Copy link
Contributor

Choose a reason for hiding this comment

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

non-blocking feedback: would be nice to have an enum rather than "eth" magic string. I see that it is an existing practice from 1893 though. Any reason not to add this to EnrField?

Copy link
Contributor

@garyschulte garyschulte left a comment

Choose a reason for hiding this comment

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

LGTM, non-blocking feedback

Comment on lines 190 to 191
final Integer discoveryPort = localNode.get().getEnodeURL().getDiscoveryPortOrZero();
final Integer listeningPort = localNode.get().getEnodeURL().getListeningPortOrZero();
Copy link
Contributor

Choose a reason for hiding this comment

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

since this is public now and could theoretically be called before start(), perhaps it would be safer to:

Optional<EnodeURL> enodeUrl = localNode.flatMap(DiscoveryPeer::getEnodeURL)
final Integer discoveryPort = enodeURL.flatMap(EnodeURL::getDiscoveryPort).orElse(0);
final Integer listeningPort = enodeURL.flatMap(EnodeURL::getListeningPort).orElse(0);

it would avoid the potential for NoSuchElementException

Comment on lines 190 to 195
assertThat(
storageProvider
.getStorageBySegmentIdentifier(BLOCKCHAIN)
.get("local-enr-seqno".getBytes(StandardCharsets.UTF_8)))
.isNotNull();
}
Copy link
Contributor

Choose a reason for hiding this comment

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

is this actually checking that the sequence has incremented or just that it isn't null? could we assert that it has gone from 0 -> 1 ? (or rather null -> 1)

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'm really glad you mentioned this because in looking at it I actually found out I had an unrelated test bug (nulls vs optionals). I also expanded it a bit to update multiple times.

Signed-off-by: Ratan Rai Sur <ratan.r.sur@gmail.com>
Signed-off-by: Ratan Rai Sur <ratan.r.sur@gmail.com>
Signed-off-by: Ratan Rai Sur <ratan.r.sur@gmail.com>
Signed-off-by: Ratan Rai Sur <ratan.r.sur@gmail.com>
Signed-off-by: Ratan Rai Sur <ratan.r.sur@gmail.com>
Copy link
Contributor

@garyschulte garyschulte left a comment

Choose a reason for hiding this comment

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

👍

Copy link
Contributor

@matkt matkt left a comment

Choose a reason for hiding this comment

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

Looking at the code this seems good to me. I wonder if it is possible to take advantage of the next goerli fork to verify that this feature works as we want?

@RatanRSur
Copy link
Contributor Author

Good idea, I should add a log line anyways.

Signed-off-by: Ratan Rai Sur <ratan.r.sur@gmail.com>
@RatanRSur RatanRSur enabled auto-merge (squash) March 16, 2021 16:07
@RatanRSur RatanRSur merged commit 30ef443 into hyperledger:master Mar 16, 2021
@RatanRSur RatanRSur deleted the enr-dynamic-update branch March 16, 2021 16:22
RichardH92 pushed a commit to RichardH92/besu that referenced this pull request Mar 29, 2021
…rledger#1998)


Signed-off-by: Ratan Rai Sur <ratan.r.sur@gmail.com>
Signed-off-by: Richard Hart <richardhart92@gmail.com>
eum602 pushed a commit to lacchain/besu that referenced this pull request Nov 3, 2023
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.

None yet

3 participants