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

Refactor Besu custom error prone dependency #6692

Merged
merged 41 commits into from
Mar 26, 2024

Conversation

usmansaleem
Copy link
Member

@usmansaleem usmansaleem commented Mar 7, 2024

PR description

Move Besu custom error-prone checks into its own repository. This allows to move to a newer version of Google errorprone checks as well while cleaning up build.gradle file.

Key changes:

  • String toLowerCase and toUpperCase to use Locale.ROOT as argument
  • Use interface such as List,Map or NavigatableMap instead of concrete class where appropriate.
  • Simplify StringBuilder to plain String
  • Supress warnings where appropriate.

Thanks for sending a pull request! Have you done the following?

  • Checked out our contribution guidelines?
  • Considered documentation and added the doc-change-required label to this PR if updates are required.
  • Considered the changelog and included an update if required.
  • For database changes (e.g. KeyValueSegmentIdentifier) considered compatibility and performed forwards and backwards compatibility tests

Most advanced CI tests are deferred until PR approval, but you could:

  • locally run all unit tests via: ./gradlew build
  • locally run all acceptance tests via: ./gradlew acceptanceTest
  • locally run all integration tests via: ./gradlew integrationTest
  • locally run all reference tests via: ./gradlew ethereum:referenceTests:referenceTests

Fixed Issue(s)

Signed-off-by: Usman Saleem <usman@usmans.info>
Signed-off-by: Usman Saleem <usman@usmans.info>
Signed-off-by: Usman Saleem <usman@usmans.info>
Signed-off-by: Usman Saleem <usman@usmans.info>
Signed-off-by: Usman Saleem <usman@usmans.info>
Signed-off-by: Usman Saleem <usman@usmans.info>
Signed-off-by: Usman Saleem <usman@usmans.info>

# Conflicts:
#	ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/sync/snapsync/request/StorageRangeDataRequest.java
Signed-off-by: Usman Saleem <usman@usmans.info>
Signed-off-by: Usman Saleem <usman@usmans.info>
Signed-off-by: Usman Saleem <usman@usmans.info>

# Conflicts:
#	ethereum/core/src/main/java/org/hyperledger/besu/ethereum/chain/BadBlockCause.java
#	ethereum/core/src/main/java/org/hyperledger/besu/ethereum/chain/BadBlockReason.java
Signed-off-by: Usman Saleem <usman@usmans.info>
Signed-off-by: Usman Saleem <usman@usmans.info>
Signed-off-by: Usman Saleem <usman@usmans.info>
Signed-off-by: Usman Saleem <usman@usmans.info>

# Conflicts:
#	ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/AbstractGasLimitSpecification.java
Signed-off-by: Usman Saleem <usman@usmans.info>
Signed-off-by: Usman Saleem <usman@usmans.info>
@usmansaleem usmansaleem marked this pull request as ready for review March 25, 2024 00:50
Signed-off-by: Usman Saleem <usman@usmans.info>
Signed-off-by: Usman Saleem <usman@usmans.info>
Signed-off-by: Usman Saleem <usman@usmans.info>
Signed-off-by: Usman Saleem <usman@usmans.info>
Signed-off-by: Usman Saleem <usman@usmans.info>
Signed-off-by: Usman Saleem <usman@usmans.info>
Signed-off-by: Usman Saleem <usman@usmans.info>
@usmansaleem usmansaleem changed the title Use external custom error prone dependency Refactor Besu custom error prone dependency Mar 25, 2024
Signed-off-by: Usman Saleem <usman@usmans.info>
Copy link
Contributor

@macfarla macfarla left a comment

Choose a reason for hiding this comment

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

couple of comments

Copy link
Contributor

Choose a reason for hiding this comment

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

are all these dependencies required? I thought we'd end up with fewer dependencies by moving error-prone out?

Copy link
Member Author

Choose a reason for hiding this comment

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

@macfarla This is gradle verification metadata. This is automagically updated by running command ./gradlew --write-verification-metadata sha256 help. This file simply records the sha256 signaturs of various jars that gradle resolves.

Copy link
Member Author

Choose a reason for hiding this comment

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

I think its a good idea to re-generate the whole file (by deleting it first and rerunning above command), otherwise it will keep updating it rather than removing older entries.

build.gradle Outdated
@@ -226,8 +229,9 @@ allprojects {
]

options.errorprone {
excludedPaths = '.*/(generated/*.*|.*ReferenceTest_.*|build/.*/annotation-output/.*)'

//excludedPaths = '.*/(generated/*.*|.*ReferenceTest_.*|build/.*/annotation-output/.*)'
Copy link
Contributor

Choose a reason for hiding this comment

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

what's the consequence of this change - do we end up flagging issues within ref tests?

Copy link
Member Author

Choose a reason for hiding this comment

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

@macfarla Should have removed the commented line. I think the option disableWarningsInGeneratedCode = true has started ignoring quite a bit of files. Also, the ReferenceTest_ tests are generated in the generated sub-folder. In summary, we are still good by updating the excludedPath to only ignore generated subfolders.

Signed-off-by: Usman Saleem <usman@usmans.info>
Signed-off-by: Usman Saleem <usman@usmans.info>
Signed-off-by: Usman Saleem <usman@usmans.info>
Signed-off-by: Usman Saleem <usman@usmans.info>
Signed-off-by: Usman Saleem <usman@usmans.info>
Signed-off-by: Usman Saleem <usman@usmans.info>
Signed-off-by: Usman Saleem <usman@usmans.info>
Signed-off-by: Usman Saleem <usman@usmans.info>
Signed-off-by: Usman Saleem <usman@usmans.info>
Signed-off-by: Usman Saleem <usman@usmans.info>
Signed-off-by: Usman Saleem <usman@usmans.info>
allowlistEntry.toLowerCase().equals(header.toLowerCase())))
allowlistEntry
.toLowerCase(Locale.ROOT)
.equals(header.toLowerCase(Locale.ROOT))))
Copy link
Contributor

Choose a reason for hiding this comment

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

Better to replace it with equalsIgnoreCase

Copy link
Member Author

Choose a reason for hiding this comment

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

done.

@@ -41,25 +40,25 @@ public void lastSeenAndFirstDiscoveredTimestampsUpdatedOnMessage() {
final Packet pong = helper.createPongPacket(agent, Hash.hash(agentPing.getHash()));
helper.sendMessageBetweenAgents(testAgent, agent, pong);

final AtomicLong lastSeen = new AtomicLong();
final AtomicLong firstDiscovered = new AtomicLong();
long lastSeen;
Copy link
Contributor

Choose a reason for hiding this comment

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

Can't see why an AtomicLong was ever needed, but it's normally a very deliberate choice. Is there some concurrency happening in this test?

Copy link
Member Author

Choose a reason for hiding this comment

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

@jframe I checked the git history. It used to have code similar to:

await()
        .atMost(1, TimeUnit.SECONDS)
        .untilAsserted(
            () -> {
              assertThat(controller.getPeers()).hasSize(1);

which since has been removed. Now there is no need to have AtomicLong anymore (and errorprone reported it as UnnecessaryAsync warning).

@@ -141,6 +141,7 @@ protected boolean hasExpectedNonce(
}

@Override
@SuppressWarnings("NonApiType")
protected void internalConsistencyCheck(
final Map<Address, TreeMap<Long, PendingTransaction>> prevLayerTxsBySender) {
Copy link
Contributor

Choose a reason for hiding this comment

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

I think the TreeMap can be changed to a NavigableMap. I think the method we use on the Map is computeIfPresent which is also present on the NavigableMap. I changed this locally and for types that inherit this method and seemed to compile for me.

@@ -568,6 +568,7 @@ public String logSender(final Address sender) {

protected abstract String internalLogStats();

@SuppressWarnings("NonApiType")
boolean consistencyCheck(
final Map<Address, TreeMap<Long, PendingTransaction>> prevLayerTxsBySender) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Can this also be changed to use a NavigableMap?

@@ -130,6 +130,7 @@ public boolean isResponseReceived() {
return true;
}

@SuppressWarnings("NonApiType")
public void addLocalData(
final WorldStateProofProvider worldStateProofProvider,
final TreeMap<Bytes32, Bytes> accounts,
Copy link
Contributor

Choose a reason for hiding this comment

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

Can this be a NavigableMap?

@@ -203,6 +204,7 @@ public Bytes32 getStorageRoot() {
return storageRoot;
}

@SuppressWarnings("NonApiType")
public TreeMap<Bytes32, Bytes> getSlots() {
Copy link
Contributor

Choose a reason for hiding this comment

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

NavigableMap?

@@ -126,6 +126,7 @@ protected int doPersist(
return nbNodesSaved.get();
}

@SuppressWarnings("NonApiType")
public void addResponse(
final SnapWorldDownloadState downloadState,
Copy link
Contributor

Choose a reason for hiding this comment

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

Is is the TreeMap is doesn't like here?

@@ -129,12 +129,12 @@ allprojects {
}

task sourcesJar(type: Jar, dependsOn: classes) {
classifier = 'sources'
archiveClassifier = 'sources'
Copy link
Contributor

Choose a reason for hiding this comment

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

Why did this need to change?

Copy link
Member Author

Choose a reason for hiding this comment

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

These were warnings in build.gradle file that will be an issue in future release of gradle. Although they should not be technically part of this PR, I fixed them originally while researching this problem and were using debug flags to the build.

Signed-off-by: Usman Saleem <usman@usmans.info>
Signed-off-by: Usman Saleem <usman@usmans.info>
Signed-off-by: Usman Saleem <usman@usmans.info>
Signed-off-by: Usman Saleem <usman@usmans.info>
Signed-off-by: Usman Saleem <usman@usmans.info>
Signed-off-by: Usman Saleem <usman@usmans.info>
@usmansaleem usmansaleem merged commit e954537 into hyperledger:main Mar 26, 2024
42 checks passed
@usmansaleem usmansaleem deleted the werror_issue branch March 26, 2024 20:17
amsmota pushed a commit to Citi/besu that referenced this pull request Apr 16, 2024
Move Besu custom error-prone checks into its own repository and use it as an external dependency. This allows to move to a newer version of Google errorprone checks as well while cleaning up build.gradle file.

Key changes resulted due to this change:

* String toLowerCase and toUpperCase to use Locale.ROOT as argument
* Use interface such as List,Map or NavigatableMap instead of concrete class where appropriate.
* Simplify StringBuilder to plain String
* Suppress warnings where appropriate.
-----
Signed-off-by: Usman Saleem <usman@usmans.info>

Signed-off-by: amsmota <antonio.mota@citi.com>
amsmota pushed a commit to Citi/besu that referenced this pull request Apr 16, 2024
Move Besu custom error-prone checks into its own repository and use it as an external dependency. This allows to move to a newer version of Google errorprone checks as well while cleaning up build.gradle file.

Key changes resulted due to this change:

* String toLowerCase and toUpperCase to use Locale.ROOT as argument
* Use interface such as List,Map or NavigatableMap instead of concrete class where appropriate.
* Simplify StringBuilder to plain String
* Suppress warnings where appropriate.
-----
Signed-off-by: Usman Saleem <usman@usmans.info>

Signed-off-by: amsmota <antonio.mota@citi.com>
matthew1001 pushed a commit to kaleido-io/besu that referenced this pull request Jun 7, 2024
Move Besu custom error-prone checks into its own repository and use it as an external dependency. This allows to move to a newer version of Google errorprone checks as well while cleaning up build.gradle file.

Key changes resulted due to this change:

* String toLowerCase and toUpperCase to use Locale.ROOT as argument
* Use interface such as List,Map or NavigatableMap instead of concrete class where appropriate.
* Simplify StringBuilder to plain String
* Suppress warnings where appropriate.
-----
Signed-off-by: Usman Saleem <usman@usmans.info>
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.

3 participants