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: adapt StatsSigningTestingTool to work with Bytes wrapper for transactions #17144

Open
wants to merge 10 commits into
base: main
Choose a base branch
from

Conversation

IvanKavaldzhiev
Copy link
Collaborator

Description:
This PR updates StatsSigningTestingTool to work with the new Bytes format of system transactions.

Related issue(s):

Fixes #16871

Notes for reviewer:

Checklist

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

mustafauzunn and others added 7 commits December 19, 2024 20:52
Signed-off-by: Ivan Kavaldzhiev <[email protected]>
…ransactions' into 16871-adapt-StatsSigningTestingTool-to-work-with-Bytes

# Conflicts:
#	platform-sdk/platform-apps/tests/StatsSigningTestingTool/src/main/java/com/swirlds/demo/stats/signing/StatsSigningTestingToolState.java

Signed-off-by: Ivan Kavaldzhiev <[email protected]>
…ransactions' into 16871-adapt-StatsSigningTestingTool-to-work-with-Bytes
@IvanKavaldzhiev IvanKavaldzhiev added the Platform Tickets pertaining to the platform label Dec 20, 2024
@IvanKavaldzhiev IvanKavaldzhiev added this to the v0.58 milestone Dec 20, 2024
@IvanKavaldzhiev IvanKavaldzhiev self-assigned this Dec 20, 2024
@IvanKavaldzhiev IvanKavaldzhiev requested review from a team as code owners December 20, 2024 11:30
Copy link

codecov bot commented Dec 20, 2024

Codecov Report

Attention: Patch coverage is 84.21053% with 3 lines in your changes missing coverage. Please review.

Project coverage is 64.40%. Comparing base (ca2e9a8) to head (2c6d151).
Report is 1 commits behind head on develop.

Files with missing lines Patch % Lines
...emo/stats/signing/StatsSigningTestingToolMain.java 0.00% 1 Missing ⚠️
...n/java/com/swirlds/platform/system/SwirldMain.java 0.00% 1 Missing ⚠️
.../java/com/swirlds/platform/system/SwirldState.java 0.00% 1 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@              Coverage Diff              @@
##             develop   #17144      +/-   ##
=============================================
+ Coverage      64.28%   64.40%   +0.11%     
- Complexity     20886    20921      +35     
=============================================
  Files           2549     2549              
  Lines          95969    95983      +14     
  Branches       10041    10045       +4     
=============================================
+ Hits           61690    61814     +124     
+ Misses         30653    30532     -121     
- Partials        3626     3637      +11     
Files with missing lines Coverage Δ
.../demo/addressbook/AddressBookTestingToolState.java 0.00% <ø> (ø)
.../demo/consistency/ConsistencyTestingToolState.java 0.00% <ø> (ø)
...java/com/swirlds/demo/iss/ISSTestingToolState.java 0.00% <ø> (ø)
...rlds/demo/migration/MigrationTestingToolState.java 0.00% <ø> (ø)
...wirlds/demo/platform/PlatformTestingToolState.java 0.00% <ø> (ø)
...mo/stats/signing/StatsSigningTestingToolState.java 44.87% <100.00%> (+44.87%) ⬆️
...om/swirlds/demo/stress/StressTestingToolState.java 0.00% <ø> (ø)
...rm/eventhandling/DefaultTransactionPrehandler.java 86.36% <100.00%> (ø)
...wirlds/platform/state/PlatformMerkleStateRoot.java 73.46% <ø> (ø)
...com/swirlds/platform/state/SwirldStateManager.java 96.55% <ø> (ø)
... and 3 more

... and 16 files with indirect coverage changes

Impacted file tree graph

Copy link

codacy-production bot commented Dec 20, 2024

Coverage summary from Codacy

See diff coverage on Codacy

Coverage variation Diff coverage
+0.12% (target: -1.00%) 85.71%
Coverage variation details
Coverable lines Covered lines Coverage
Common ancestor commit (89e2f35) 95732 65134 68.04%
Head commit (9315b1c) 95745 (+13) 65259 (+125) 68.16% (+0.12%)

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 (#17144) 14 12 85.71%

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

Base automatically changed from 16703-refactor-consumer-system-transactions to develop December 20, 2024 12:58
@@ -313,4 +315,9 @@ public PlatformMerkleStateRoot newMerkleStateRoot() {
public BasicSoftwareVersion getSoftwareVersion() {
return softwareVersion;
}

@Override
public Bytes encodeSystemTransaction(@NonNull StateSignatureTransaction transaction) {
Copy link
Member

Choose a reason for hiding this comment

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

add final

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Fixed


if (areTransactionBytesSystemOnes((ConsensusTransaction) transaction)) {
stateSignatureTransactions.accept(
new ScopedSystemTransaction(event.getCreatorId(), event.getSoftwareVersion(), transaction));
Copy link
Member

Choose a reason for hiding this comment

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

You can return after this, since the application should not do anything with the system transactions other than invoke the callback.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Good idea. Fixed

round.forEachTransaction(this::handleTransaction);

round.forEachEventTransaction((event, transaction) -> {
final var transactionWithSystemBytes = handleTransaction(transaction);
Copy link
Member

Choose a reason for hiding this comment

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

Why not check if it is a system transaction here in the lambda before invoking handleTransaction?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Updated

…igningTestingTool-to-work-with-Bytes

# Conflicts:
#	platform-sdk/platform-apps/demos/CryptocurrencyDemo/src/main/java/com/swirlds/demo/crypto/CryptocurrencyDemoState.java
#	platform-sdk/platform-apps/demos/HelloSwirldDemo/src/main/java/com/swirlds/demo/hello/HelloSwirldDemoState.java
#	platform-sdk/platform-apps/demos/StatsDemo/src/main/java/com/swirlds/demo/stats/StatsDemoState.java
#	platform-sdk/platform-apps/tests/AddressBookTestingTool/src/main/java/com/swirlds/demo/addressbook/AddressBookTestingToolState.java
#	platform-sdk/platform-apps/tests/ConsistencyTestingTool/src/main/java/com/swirlds/demo/consistency/ConsistencyTestingToolState.java
#	platform-sdk/platform-apps/tests/ISSTestingTool/src/main/java/com/swirlds/demo/iss/ISSTestingToolState.java
#	platform-sdk/platform-apps/tests/MigrationTestingTool/src/main/java/com/swirlds/demo/migration/MigrationTestingToolState.java
#	platform-sdk/platform-apps/tests/PlatformTestingTool/src/main/java/com/swirlds/demo/platform/PlatformTestingToolState.java
#	platform-sdk/platform-apps/tests/StatsSigningTestingTool/src/main/java/com/swirlds/demo/stats/signing/StatsSigningTestingToolState.java
#	platform-sdk/platform-apps/tests/StressTestingTool/src/main/java/com/swirlds/demo/stress/StressTestingToolState.java
#	platform-sdk/swirlds-platform-core/src/main/java/com/swirlds/platform/state/PlatformMerkleStateRoot.java
#	platform-sdk/swirlds-platform-core/src/main/java/com/swirlds/platform/system/SwirldState.java
#	platform-sdk/swirlds-platform-core/src/test/java/com/swirlds/platform/turtle/runner/TurtleTestingToolState.java
#	platform-sdk/swirlds-platform-core/src/testFixtures/java/com/swirlds/platform/test/fixtures/state/BlockingSwirldState.java

Signed-off-by: Ivan Kavaldzhiev <[email protected]>
Signed-off-by: Ivan Kavaldzhiev <[email protected]>
Signed-off-by: Ivan Kavaldzhiev <[email protected]>
Comment on lines +200 to +208
private boolean areTransactionBytesSystemOnes(final ConsensusTransaction transaction) {
// We have maximum allocation of 100 bytes for the transaction + 10 bytes for the preamble size in
// TransactionCodec
// + 64 bytes for the maximum public key size + 64 bytes for the maximum signature size + 12 bytes for 3
// integers
final var maximumSignedEncodedTransactionSize = 100 + 10 + 64 + 64 + 12;
return transaction.getApplicationTransaction().length() > maximumSignedEncodedTransactionSize;
}

Copy link
Member

Choose a reason for hiding this comment

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

this app has a configurable transaction size, so size cannot be used to differentiate between system and app

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Platform Tickets pertaining to the platform
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Adapt StatsSigningTestingTool to work with the new Bytes transaction type and add README.md
4 participants