-
Notifications
You must be signed in to change notification settings - Fork 185
feat: Highest node id in state #21861
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
base: main
Are you sure you want to change the base?
Conversation
Signed-off-by: Derek Riley <[email protected]>
Signed-off-by: Derek Riley <[email protected]>
✅ Snyk checks have passed. No issues have been found so far.
💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse. |
Signed-off-by: Derek Riley <[email protected]>
Signed-off-by: Derek Riley <[email protected]>
Codecov Report❌ Patch coverage is @@ Coverage Diff @@
## main #21861 +/- ##
============================================
- Coverage 74.18% 74.17% -0.02%
- Complexity 23572 23584 +12
============================================
Files 2551 2553 +2
Lines 96367 96412 +45
Branches 10209 10212 +3
============================================
+ Hits 71488 71510 +22
- Misses 21084 21107 +23
Partials 3795 3795 ... and 11 files with indirect coverage changes 🚀 New features to boost your workflow:
|
Coverage summary from CodacySee diff coverage on Codacy
Coverage variation details
Coverage variation is the difference between the coverage for the head and common ancestor commits of the pull request branch: Diff coverage details
Diff coverage is the percentage of lines that are covered by tests out of the coverable lines that the pull request added or modified: See your quality gate settings Change summary preferences |
Signed-off-by: Derek Riley <[email protected]>
Signed-off-by: Derek Riley <[email protected]>
Signed-off-by: Derek Riley <[email protected]>
# Conflicts: # hedera-node/hedera-addressbook-service-impl/src/test/java/com/hedera/node/app/service/addressbook/impl/test/handlers/AddressBookTestBase.java # hedera-node/hedera-addressbook-service-impl/src/test/java/com/hedera/node/app/service/addressbook/impl/test/handlers/NodeCreateHandlerTest.java # hedera-node/hedera-addressbook-service-impl/src/test/java/com/hedera/node/app/service/addressbook/impl/test/handlers/NodeDeleteHandlerTest.java
Signed-off-by: Zhivko Kelchev <[email protected]>
Signed-off-by: Zhivko Kelchev <[email protected]>
…tion. Signed-off-by: Zhivko Kelchev <[email protected]>
Signed-off-by: Zhivko Kelchev <[email protected]>
Signed-off-by: Zhivko Kelchev <[email protected]>
Signed-off-by: Zhivko Kelchev <[email protected]>
Signed-off-by: Zhivko Kelchev <[email protected]>
Signed-off-by: Zhivko Kelchev <[email protected]>
Signed-off-by: Zhivko Kelchev <[email protected]>
Signed-off-by: Zhivko Kelchev <[email protected]>
hapi/hedera-protobuf-java-api/src/main/proto/block/stream/output/state_changes.proto
Outdated
Show resolved
Hide resolved
Neeharika-Sompalli
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall Looks great! Thanks @JivkoKelchev @derektriley . Had a few minor comments
hapi/hedera-protobuf-java-api/src/main/proto/platform/state/virtual_map_state.proto
Outdated
Show resolved
Hide resolved
| final var size = sizeOfState(); | ||
| final var keys = new ArrayList<EntityNumber>(); | ||
| for (int i = 0; i < size; i++) { | ||
| final long highestExclusive = entityIdStore.peekAtNextNodeId(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: Is there a reason to not have a method, getHighestNodeId, instead of looking at next node id?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess to be consistent with peekAtNextNumber(). But we can introduce getHighestNodeId() too.
hedera-node/hedera-app-spi/src/main/java/com/hedera/node/app/spi/workflows/HandleContext.java
Show resolved
Hide resolved
| if (storeInterface == WritableEntityIdStore.class) { | ||
| return storeInterface.cast(writableEntityIdStore); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm I don't understand why we need this
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't know. I guess since this store is already a private field of the class, we can return it directly and skip the checks below.
@derektriley ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't recall why I added this originally, go ahead and remove it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed
| if (dispatch.txnInfo().functionality() == NODE_CREATE) { | ||
| WritableSingletonState<EntityCounts> countsBefore = | ||
| dispatch.stack().getWritableStates(EntityIdService.NAME).getSingleton(ENTITY_COUNTS_STATE_ID); | ||
| countsBefore.put(requireNonNull(countsBefore.get()) | ||
| .copyBuilder() | ||
| .numNodes(isSuccess ? Math.max(nextEntityNum + 1, prevEntityNum) : prevEntityNum) | ||
| .build()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we not need this case anymore? Don't we need to look at the new state now instead of entity counts?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here we were restoring the EntityCounts state, because before the dispatch we were updating it.
See here,
This code was preparing/updating the state so that when a NODE_CREATE transaction is dispatched, the new node will receive a specific, desired ID (nextEntityNum).
The both updating and restoring the EntityCounts are not needed anymore, because now we are passing the nextEntityNum to the handler by dispatch metadata.
...-impl/src/main/java/com/hedera/node/app/service/entityid/impl/WritableEntityIdStoreImpl.java
Outdated
Show resolved
Hide resolved
Signed-off-by: Zhivko Kelchev <[email protected]>
Signed-off-by: Zhivko Kelchev <[email protected]>
Signed-off-by: Zhivko Kelchev <[email protected]>
# Conflicts: # hedera-node/hedera-app/src/main/java/com/hedera/node/app/workflows/handle/HandleWorkflow.java # hedera-node/test-clients/src/main/java/com/hedera/services/bdd/suites/hip869/NodeUpdateTest.java # hedera-node/test-clients/src/main/java/com/hedera/services/bdd/suites/hip869/batch/AtomicNodeUpdateTest.java
Signed-off-by: Zhivko Kelchev <[email protected]>
# Conflicts: # hapi/hedera-protobuf-java-api/src/main/proto/block/stream/output/state_changes.proto # hapi/hedera-protobuf-java-api/src/main/proto/platform/state/virtual_map_state.proto
Signed-off-by: Zhivko Kelchev <[email protected]>
Signed-off-by: Zhivko Kelchev <[email protected]>
# Conflicts: # hedera-node/test-clients/src/main/java/com/hedera/services/bdd/suites/regression/system/DabEnabledUpgradeTest.java
Signed-off-by: Zhivko Kelchev <[email protected]>
Signed-off-by: Zhivko Kelchev <[email protected]>
Signed-off-by: Zhivko Kelchev <[email protected]>
# Conflicts: # hedera-node/hedera-app/src/main/java/com/hedera/node/app/workflows/handle/record/SystemTransactions.java
Signed-off-by: Zhivko Kelchev <[email protected]>
Description:
This PR introduces a new singleton state to track the highest node ID ever used. The change includes:
Related issue(s):
Fixes #18855
Notes for reviewer:
Since the new singleton state is part of
EntityIdStore, a big part of the changes are just mocking or initializing the new singleton for many unit tests.Checklist