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: use commons module in server #272

Merged
merged 16 commits into from
Oct 31, 2024

Conversation

ata-nas
Copy link
Contributor

@ata-nas ata-nas commented Oct 17, 2024

Description:

  • refactor :server to start using logic from :common

Related issue(s):
Fixes #252

Notes for reviewer:

  • in the places where com.hedera.block.common.utils.FileUtilities#createPathIfNotExists is used, the previous alternative used Files#createDirectory, where the new version uses Files#createDirectories which acts quite differently, in fact, one unit test, namely testProvidesBlockWriter_IOException, which expects an exception to be thrown was not able to run successfully since it now creates the path using the new implementation with Files#createDirectories and previously it was not able to (the test is now modified). We should be careful about this since it is possible that the new usage could lead to silent bugs if unit tests do not already cover the needed edge cases.
  • have I missed any places to refactor?

Checklist

  • refactor com.hedera.block.server.Constants remove app.properties and logging.properties and use them from com.hedera.block.common.constants.StringsConstants;
  • remove com.hedera.block.server.persistence.storage.FileUtils and start using com.hedera.block.common.utils.FileUtilities instead;

  • Documented (Code comments, README, etc.)
  • Tested (unit, integration, etc.) - N/A

@ata-nas ata-nas added Improvement Code changes driven by non business requirements Common Issue/PR related to Common module labels Oct 17, 2024
@ata-nas ata-nas added this to the 0.2.0 milestone Oct 17, 2024
@ata-nas ata-nas self-assigned this Oct 17, 2024
@ata-nas ata-nas linked an issue Oct 17, 2024 that may be closed by this pull request
@ata-nas ata-nas marked this pull request as ready for review October 18, 2024 13:16
@ata-nas ata-nas requested a review from a team as a code owner October 18, 2024 13:16
@ata-nas ata-nas force-pushed the 252-refactor-use-commons-module-in-server branch 4 times, most recently from 40350e5 to b8092ec Compare October 23, 2024 07:57
@ata-nas ata-nas force-pushed the 252-refactor-use-commons-module-in-server branch 2 times, most recently from b58d804 to 7ead1c1 Compare October 24, 2024 12:59
AlfredoG87
AlfredoG87 previously approved these changes Oct 24, 2024
Copy link
Contributor

@AlfredoG87 AlfredoG87 left a comment

Choose a reason for hiding this comment

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

LGTM 👍

Copy link
Member

@jsync-swirlds jsync-swirlds left a comment

Choose a reason for hiding this comment

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

Still reviewing, but these changes are not correct.

Copy link
Member

@jsync-swirlds jsync-swirlds left a comment

Choose a reason for hiding this comment

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

That's the rest reviewed.
Let's chat about this code, as there are obviously some gaps in terms of understanding why some things are written the way they were.

@ata-nas
Copy link
Contributor Author

ata-nas commented Oct 25, 2024

@jsync-swirlds thanks for the reviews.

Keep in mind that when I was doing these changes (as well as the ones in the simulator in the other PR), my aim was to only kind of 'redirect' all current usages of the utilities and constants to the new common module that we introduced. That is why I have left everything as is and have not made any significant changes, but took the approach to modify a bit the common module in order to fit the 'redirection', which I do agree with you is not a good thing to do.

I have fixed the obvious and commented on the rest, but I agree, lets have a conversation in general about the topics here and others as well, since this would help me to gain more insight into the Hedera philosophy and the team's specific views on what we should aim for in terms of implementation and thought process. This will help avoid such big gaps and so many questions in the future. Thanks! :)

@jsync-swirlds
Copy link
Member

@jsync-swirlds thanks for the reviews.

Keep in mind that when I was doing these changes (as well as the ones in the simulator in the other PR), my aim was to only kind of 'redirect' all current usages of the utilities and constants to the new common module that we introduced. That is why I have left everything as is and have not made any significant changes, but took the approach to modify a bit the common module in order to fit the 'redirection', which I do agree with you is not a good thing to do.

I have fixed the obvious and commented on the rest, but I agree, lets have a conversation in general about the topics here and others as well, since this would help me to gain more insight into the Hedera philosophy and the team's specific views on what we should aim for in terms of implementation and thought process. This will help avoid such big gaps and so many questions in the future. Thanks! :)

I understand the intent. I think (as we discussed) that you would be better off (and the result will be better designed) to keep the shared library as clean as practical, and make whatever changes are needed in the server to correctly use that library.

@ata-nas ata-nas force-pushed the 252-refactor-use-commons-module-in-server branch from 4d4f691 to c611732 Compare October 28, 2024 10:58
@ata-nas ata-nas marked this pull request as draft October 28, 2024 12:07
@ata-nas ata-nas requested review from jsync-swirlds and a team and removed request for georgi-l95 and mattp-swirldslabs October 28, 2024 14:36
@ata-nas ata-nas marked this pull request as ready for review October 28, 2024 18:03
Copy link
Member

@jsync-swirlds jsync-swirlds left a comment

Choose a reason for hiding this comment

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

Just one nitpick, which could be addressed later.

@ata-nas
Copy link
Contributor Author

ata-nas commented Oct 28, 2024

address this comment as well

jsync-swirlds
jsync-swirlds previously approved these changes Oct 28, 2024
Copy link
Member

@jsync-swirlds jsync-swirlds left a comment

Choose a reason for hiding this comment

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

There are a couple items noted that should be addressed as a separate issue.
Please file issues for those prior to merging this PR.

Signed-off-by: Atanas Atanasov <[email protected]>
Signed-off-by: Atanas Atanasov <[email protected]>
Signed-off-by: Atanas Atanasov <[email protected]>
…with pr comments about test format

Signed-off-by: Atanas Atanasov <[email protected]>
@ata-nas ata-nas force-pushed the 252-refactor-use-commons-module-in-server branch from 5241854 to 1cc7962 Compare October 29, 2024 15:50
Copy link
Contributor

@mattp-swirldslabs mattp-swirldslabs 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

@ata-nas ata-nas merged commit 791af49 into main Oct 31, 2024
13 checks passed
@ata-nas ata-nas deleted the 252-refactor-use-commons-module-in-server branch October 31, 2024 08:11
Copy link

codecov bot commented Oct 31, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 98.88%. Comparing base (b6c93e6) to head (1cc7962).
Report is 4 commits behind head on main.

Additional details and impacted files
@@             Coverage Diff              @@
##               main     #272      +/-   ##
============================================
- Coverage     99.35%   98.88%   -0.48%     
+ Complexity      295      288       -7     
============================================
  Files            60       59       -1     
  Lines          1092     1077      -15     
  Branches         78       76       -2     
============================================
- Hits           1085     1065      -20     
- Misses            5        8       +3     
- Partials          2        4       +2     
Files with missing lines Coverage Δ
...a/com/hedera/block/common/utils/FileUtilities.java 100.00% <100.00%> (ø)
.../persistence/storage/PersistenceStorageConfig.java 100.00% <100.00%> (ø)
...ver/persistence/storage/read/BlockAsDirReader.java 100.00% <100.00%> (ø)
...sistence/storage/read/BlockAsDirReaderBuilder.java 100.00% <100.00%> (ø)
.../persistence/storage/remove/BlockAsDirRemover.java 82.35% <100.00%> (-17.65%) ⬇️
...er/persistence/storage/write/BlockAsDirWriter.java 100.00% <100.00%> (ø)
...istence/storage/write/BlockAsDirWriterBuilder.java 100.00% <100.00%> (ø)
...ator/exception/BlockSimulatorParsingException.java 50.00% <100.00%> (-50.00%) ⬇️
.../simulator/generator/BlockAsFileLargeDataSets.java 90.62% <100.00%> (ø)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Common Issue/PR related to Common module Improvement Code changes driven by non business requirements
Projects
None yet
Development

Successfully merging this pull request may close these issues.

refactor: use commons module in server
4 participants