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

Reused PlatformTxnAccessor with handleTransaction from expandSignatures #1474

Closed
wants to merge 8 commits into from

Conversation

abhishek-hedera
Copy link
Contributor

@abhishek-hedera abhishek-hedera commented May 25, 2021

Signed-off-by: abhishek-hedera [email protected]

Related issue(s):
Closes #1421

Summary of the change:
Modified ServicesState, ServicesStateTest, ProcessLogic, AwareProcessLogic to reuse PlatformTxnAccessor.
Removed unused imports.

External impacts:
None.

Applicable documentation

  • Javadoc
  • HAPI protobuf comments
  • README

@codecov
Copy link

codecov bot commented May 25, 2021

Codecov Report

Merging #1474 (4ce8c8a) into master (dca836f) will increase coverage by 0.02%.
The diff coverage is 100.00%.

Impacted file tree graph

@@             Coverage Diff              @@
##             master    #1474      +/-   ##
============================================
+ Coverage     91.39%   91.41%   +0.02%     
- Complexity     5899     5903       +4     
============================================
  Files           461      462       +1     
  Lines         16932    16954      +22     
  Branches       1783     1783              
============================================
+ Hits          15475    15499      +24     
+ Misses          991      990       -1     
+ Partials        466      465       -1     
Impacted Files Coverage Δ
...om/hedera/services/records/TxnIdRecentHistory.java 96.10% <ø> (ø)
...c/main/java/com/hedera/services/ServicesState.java 94.70% <100.00%> (+0.36%) ⬆️
...vices/legacy/services/state/AwareProcessLogic.java 30.90% <100.00%> (+0.55%) ⬆️
...a/com/hedera/services/utils/PlatformTxnRecord.java 100.00% <100.00%> (ø)
...a/com/hedera/services/utils/SignedTxnAccessor.java 97.36% <0.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update dca836f...4ce8c8a. Read the comment docs.

Comment on lines 323 to 324
} catch (InvalidProtocolBufferException exception) {
log.warn("Consensus platform txn was not gRPC!");
Copy link
Contributor

Choose a reason for hiding this comment

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

Need coverage for these two lines.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added more tests.

Comment on lines 331 to 332
setPlatformTxnAccessor(platformTxn);
expandIn(
accessor,
txnAccessor,
Copy link
Contributor

Choose a reason for hiding this comment

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

The change here slightly changes original logic. Now line 333 may have txnAccessor as null if line 331setPlatformTxnAccessor(platformTxn); throws exception. So it would be nice to add a test case for this scenario.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Modified logic to use a separate component that would handle the conversion from Transaction to PlatformTxnAccessor.

@anighanta
Copy link
Contributor

Description says that PR includes fixed failing test cases of ExpiryManagerTest. Cant find them in the changes

Comment on lines 90 to 91
PlatformTxnAccessor accessor,
Instant consensusTime, long submittingMember) throws InvalidProtocolBufferException{
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: the indentation seems to be way off here

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed

Copy link
Contributor

@qnswirlds qnswirlds left a comment

Choose a reason for hiding this comment

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

It seems to me that the PR is not ready for review. Will re-review when it is ready.

@abhishek-hedera abhishek-hedera marked this pull request as draft May 26, 2021 21:22
@abhishek-hedera
Copy link
Contributor Author

Description says that PR includes fixed failing test cases of ExpiryManagerTest. Cant find them in the changes

A few tests used observe() from TxnIdRecentHistory, which did not have the scope to be called from the ExpiryManagerTest. Modified it to be public instead.

liveTxnHistories.computeIfAbsent(newTxnId, ignore -> new TxnIdRecentHistory()).observe(firstRecord, OK);

liveTxnHistories.computeIfAbsent(newTxnId, ignore -> new TxnIdRecentHistory()).observe(secondRecord, OK);

liveTxnHistories.computeIfAbsent(newTxnId, ignore -> new TxnIdRecentHistory()).observe(firstRecord, OK);

@abhishek-hedera
Copy link
Contributor Author

It seems to me that the PR is not ready for review. Will re-review when it is ready.

After reviewing with @tinker-michaelj a few modifications needs to be added such as using Cache for PlatformTxnAccessor. Converting it to draft for now to be reopened later. Thanks for the review.

@abhishek-hedera abhishek-hedera force-pushed the 01421-M-ReusingSignedTxnAccessor branch from c56e488 to 2596ae3 Compare May 27, 2021 19:05
@abhishek-hedera abhishek-hedera force-pushed the 01421-M-ReusingSignedTxnAccessor branch from 467b037 to 314d040 Compare May 28, 2021 16:03
@abhishek-hedera abhishek-hedera marked this pull request as ready for review May 28, 2021 16:13
Signed-off-by: abhishek-hedera <[email protected]>
Signed-off-by: abhishek-hedera <[email protected]>

public class PlatformTxnRecord {

private Cache<Transaction, PlatformTxnAccessor> cache;
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you put some comments to explain what's the purpose of the PlatformTxnRecord? and also why a map of <Transaction, PlatformTxnAccessor> is needed here?

Comment on lines +102 to +103
if (!ctx.invariants().holdFor(accessor, effectiveConsensusTime, submittingMember)) {
return;
Copy link
Contributor

Choose a reason for hiding this comment

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

Seems like something unusual happened here, should we have a log message here before return?

effectiveConsensusTime = consensusTime.minusNanos(1);
}
public void incorporateConsensusTxn(
Transaction platformTxn,
Copy link
Contributor

Choose a reason for hiding this comment

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

Is the parameter platformTxn used anywhere in this method?

@abhishek-hedera
Copy link
Contributor Author

@tinker-michaelj tinker-michaelj deleted the 01421-M-ReusingSignedTxnAccessor branch August 30, 2021 22:36
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.

Reuse the SignedTxnAccessor from expandSignatures in handleTransaction
4 participants