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

feat: overhaul SignedState.getAddressBook() #16656

Merged
merged 22 commits into from
Dec 4, 2024

Conversation

anthony-swirldslabs
Copy link
Contributor

@anthony-swirldslabs anthony-swirldslabs commented Nov 18, 2024

Description:
This is the first step in a series of fixes to eventually remove AddressBook objects from the PlatformState. In this fix, the SignedState class now uses the RosterRetriever to fetch the active roster from the state. The latter automatically falls back to reading the AddressBook from the PlatformState if the RosterService data isn't populated.

Notable changes:

  1. The crux of the fix is the SignedState.getAddressBook() implementation and the supporting SignedStateFileReader.registerServiceStates() that allows the former to access states of the RosterService and the PlatformState via the States API.
  2. The SignedStateFileReader and the ReconnectLearner initialize these states to make the AddressBook/Roster accessible from the loaded/received SignedState.
  3. The FakeMerkleStateLifecycles is similarly extended to enable accessing these states in tests (both unit, and JRS.)
  4. The RandomSignedStateGenerator also enables the tests to uses these states, and it also registers all the generated states in ThreadLocal lists, allowing the tests to release them once the tests finish. This is now required to avoid producing OOMs due to a large number of VirtualMap instances created with each generated state.
  5. RosterSchema is moved back to the platform code, and the RosterStateId is resurrected, again, to be accessed from the platform code and eliminate circular dependencies between app and platform.
  6. Tests using VirtualMaps now have MerkleDb.resetDefaultInstancePath() calls to allow the VirtualMap implementation to create multiple instances of the same map on disk. W/o this call, the tests would clash because each of them would want to create the same ROSTERS map when a SignedState object is initialized in them.

Related issue(s):

Fixes #16541

Notes for reviewer:
Tests should pass.

Checklist

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

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

codecov bot commented Nov 18, 2024

Codecov Report

Attention: Patch coverage is 53.33333% with 21 lines in your changes missing coverage. Please review.

Project coverage is 63.73%. Comparing base (5e7562f) to head (4f9e245).
Report is 8 commits behind head on develop.

Files with missing lines Patch % Lines
...platform/state/snapshot/SignedStateFileReader.java 72.72% 4 Missing and 2 partials ⚠️
...s/demo/addressbook/AddressBookTestingToolMain.java 0.00% 2 Missing ⚠️
.../java/com/swirlds/demo/iss/ISSTestingToolMain.java 0.00% 2 Missing ⚠️
...irlds/demo/migration/MigrationTestingToolMain.java 0.00% 2 Missing ⚠️
...swirlds/demo/platform/PlatformTestingToolMain.java 0.00% 2 Missing ⚠️
...emo/stats/signing/StatsSigningTestingToolMain.java 0.00% 2 Missing ⚠️
...com/swirlds/demo/stress/StressTestingToolMain.java 0.00% 2 Missing ⚠️
...s/demo/consistency/ConsistencyTestingToolMain.java 0.00% 1 Missing ⚠️
.../demo/consistency/ConsistencyTestingToolState.java 0.00% 1 Missing ⚠️
...wirlds/demo/platform/PlatformTestingToolState.java 0.00% 1 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             develop   #16656   +/-   ##
==========================================
  Coverage      63.73%   63.73%           
- Complexity     20483    20494   +11     
==========================================
  Files           2538     2538           
  Lines          95008    95035   +27     
  Branches        9931     9932    +1     
==========================================
+ Hits           60549    60572   +23     
- Misses         30839    30848    +9     
+ Partials        3620     3615    -5     
Files with missing lines Coverage Δ
...java/com/hedera/node/app/roster/RosterService.java 100.00% <ø> (ø)
...va/com/hedera/node/app/tss/TssBaseServiceImpl.java 66.66% <ø> (ø)
...re/src/main/java/com/swirlds/platform/Browser.java 0.00% <ø> (ø)
...m/swirlds/platform/reconnect/ReconnectLearner.java 77.33% <100.00%> (+0.62%) ⬆️
...tform/state/service/schemas/V0540RosterSchema.java 92.30% <ø> (ø)
...com/swirlds/platform/state/signed/SignedState.java 85.13% <100.00%> (+0.10%) ⬆️
...java/com/swirlds/state/merkle/MerkleStateRoot.java 86.68% <100.00%> (+0.17%) ⬆️
...s/demo/consistency/ConsistencyTestingToolMain.java 0.00% <0.00%> (ø)
.../demo/consistency/ConsistencyTestingToolState.java 0.00% <0.00%> (ø)
...wirlds/demo/platform/PlatformTestingToolState.java 0.00% <0.00%> (ø)
... and 7 more

... and 17 files with indirect coverage changes

Impacted file tree graph

Copy link

codacy-production bot commented Nov 18, 2024

Coverage summary from Codacy

See diff coverage on Codacy

Coverage variation Diff coverage
+0.00% (target: -1.00%) 57.78%
Coverage variation details
Coverable lines Covered lines Coverage
Common ancestor commit (5e7562f) 97773 63979 65.44%
Head commit (4f9e245) 97800 (+27) 63997 (+18) 65.44% (+0.00%)

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 (#16656) 45 26 57.78%

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 November 18, 2024 23:57
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>
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>
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>
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>
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 3, 2024 22:11
@anthony-swirldslabs anthony-swirldslabs requested review from a team as code owners December 3, 2024 22:11
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.

Makes sense to me, tyvm @anthony-swirldslabs !

@anthony-swirldslabs anthony-swirldslabs merged commit 0f00ee2 into develop Dec 4, 2024
71 of 73 checks passed
@anthony-swirldslabs anthony-swirldslabs deleted the 16541-overhaulSignedStateGetAddressBook branch December 4, 2024 18:20
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.

Overhaul SignedState.getAddressBook()
3 participants