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

chore: replace PlatformStateAccessor.getAddressBook() with calls to R… #17047

Merged

Conversation

anthony-swirldslabs
Copy link
Contributor

@anthony-swirldslabs anthony-swirldslabs commented Dec 12, 2024

…osterRetriever

Description:
This fix replaces meaningful usages of the PlatformStateAccessor.getAddressBook() with calls to the RosterRetriever in order to fetch the current Roster/AddressBook in the app, platform, and test code.

The RosterRetriever implementation would first check the RosterService state, and only if it's not populated with data yet, then it will fall back to reading the AddressBook from the PlatformState. In other words, the new code path will automatically activate the moment we start writing to the RosterService states. Please note that all the tests code has been updated to go through this new code path already thanks to the newly introduced RosterServiceStateMock utility class, as well as the most crucial call to the RosterUtils.setActiveRoster() in the RandomSignedStateGenerator.build().

The remaining usages of this method support the PlatformState.addressBook field directly and shouldn't be removed until we actually deprecate this field physically, or at least stop populating it altogether, which is going to be a part of a follow-up ticket/PR.

Related issue(s):

Fixes #16904

Notes for reviewer:
All tests should pass.

Checklist

  • Documented (Code comments, README, etc.)
  • Tested (unit, integration, etc.)

…osterRetriever

Signed-off-by: Anthony Petrov <anthony@swirldslabs.com>
Copy link

codacy-production bot commented Dec 12, 2024

Coverage summary from Codacy

See diff coverage on Codacy

Coverage variation Diff coverage
+0.01% (target: -1.00%) 78.57%
Coverage variation details
Coverable lines Covered lines Coverage
Common ancestor commit (720d1e0) 98488 64924 65.92%
Head commit (58fd82b) 98486 (-2) 64931 (+7) 65.93% (+0.01%)

Coverage variation is the difference between the coverage for the head and common ancestor commits of the pull request branch: <coverage of head commit> - <coverage of common ancestor commit>

Diff coverage details
Coverable lines Covered lines Diff coverage
Pull request (#17047) 28 22 78.57%

Diff coverage is the percentage of lines that are covered by tests out of the coverable lines that the pull request added or modified: <covered lines added or modified>/<coverable lines added or modified> * 100%

See your quality gate settings    Change summary preferences

Codacy stopped sending the deprecated coverage status on June 5th, 2024. Learn more

@anthony-swirldslabs anthony-swirldslabs marked this pull request as draft December 12, 2024 22:29
Copy link

codecov bot commented Dec 12, 2024

Codecov Report

Attention: Patch coverage is 75.00000% with 7 lines in your changes missing coverage. Please review.

Project coverage is 64.25%. Comparing base (720d1e0) to head (58fd82b).
Report is 1 commits behind head on develop.

Files with missing lines Patch % Lines
.../platform/cli/ValidateAddressBookStateCommand.java 0.00% 2 Missing ⚠️
...rlds/platform/system/address/AddressBookUtils.java 0.00% 2 Missing ⚠️
...-app/src/main/java/com/hedera/node/app/Hedera.java 0.00% 1 Missing ⚠️
...lds/platform/builder/PlatformComponentBuilder.java 0.00% 1 Missing ⚠️
...ds/platform/state/snapshot/SavedStateMetadata.java 66.66% 0 Missing and 1 partial ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             develop   #17047   +/-   ##
==========================================
  Coverage      64.25%   64.25%           
- Complexity     20824    20827    +3     
==========================================
  Files           2547     2547           
  Lines          95723    95721    -2     
  Branches       10018    10018           
==========================================
+ Hits           61503    61510    +7     
+ Misses         30608    30599    -9     
  Partials        3612     3612           
Files with missing lines Coverage Δ
.../com/hedera/node/app/info/DiskStartupNetworks.java 89.41% <100.00%> (-0.13%) ⬇️
...java/com/hedera/node/app/roster/RosterService.java 100.00% <100.00%> (ø)
...era/node/app/roster/schemas/V0540RosterSchema.java 100.00% <100.00%> (ø)
...a/com/swirlds/platform/roster/RosterRetriever.java 79.26% <100.00%> (ø)
.../java/com/swirlds/platform/roster/RosterUtils.java 67.02% <100.00%> (+2.65%) ⬆️
...platform/state/address/AddressBookInitializer.java 79.20% <100.00%> (ø)
...ds/platform/state/service/WritableRosterStore.java 95.91% <100.00%> (+0.08%) ⬆️
...-app/src/main/java/com/hedera/node/app/Hedera.java 57.37% <0.00%> (+0.31%) ⬆️
...lds/platform/builder/PlatformComponentBuilder.java 36.13% <0.00%> (+0.40%) ⬆️
...ds/platform/state/snapshot/SavedStateMetadata.java 73.54% <66.66%> (+1.05%) ⬆️
... and 2 more

... and 11 files with indirect coverage changes

Impacted file tree graph

Signed-off-by: Anthony Petrov <anthony@swirldslabs.com>
Signed-off-by: Anthony Petrov <anthony@swirldslabs.com>
Signed-off-by: Anthony Petrov <anthony@swirldslabs.com>
Signed-off-by: Anthony Petrov <anthony@swirldslabs.com>
@anthony-swirldslabs anthony-swirldslabs marked this pull request as ready for review December 14, 2024 00:08
Copy link
Member

@Neeharika-Sompalli Neeharika-Sompalli left a comment

Choose a reason for hiding this comment

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

LGTM from hedera-services file changes. Thanks @anthony-swirldslabs

Signed-off-by: Anthony Petrov <anthony@swirldslabs.com>
timfn-hg
timfn-hg previously approved these changes Dec 16, 2024
Signed-off-by: Anthony Petrov <anthony@swirldslabs.com>
imalygin
imalygin previously approved these changes Dec 17, 2024
Copy link
Collaborator

@tinker-michaelj tinker-michaelj left a comment

Choose a reason for hiding this comment

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

LGTM, tyvm @anthony-swirldslabs !

Signed-off-by: Anthony Petrov <anthony@swirldslabs.com>
Signed-off-by: Anthony Petrov <anthony@swirldslabs.com>
…stream

Signed-off-by: Anthony Petrov <anthony@swirldslabs.com>
Copy link
Collaborator

@tinker-michaelj tinker-michaelj left a comment

Choose a reason for hiding this comment

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

LGTM, tyvm @anthony-swirldslabs !

@anthony-swirldslabs anthony-swirldslabs merged commit 13bd3a9 into develop Dec 17, 2024
45 checks passed
@anthony-swirldslabs anthony-swirldslabs deleted the 16904-stopUsingPlatformStateAccessorGetAddressBook branch December 17, 2024 20:54
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.

Replace all PlatformStateAccessor.get[Previous]AddressBook() usages with calls to RosterRetriever
6 participants