-
Notifications
You must be signed in to change notification settings - Fork 143
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
Avoid costly stream operations while iterating over SignaturePairs in the sigMap #1456
Avoid costly stream operations while iterating over SignaturePairs in the sigMap #1456
Conversation
Signed-off-by: Neeharika-Sompalli <[email protected]>
Signed-off-by: Neeharika-Sompalli <[email protected]>
hedera-node/src/main/java/com/hedera/services/sigs/sourcing/SigMapPubKeyToSigBytes.java
Show resolved
Hide resolved
Codecov Report
@@ Coverage Diff @@
## master #1456 +/- ##
============================================
+ Coverage 91.19% 91.21% +0.01%
- Complexity 5868 5870 +2
============================================
Files 459 459
Lines 16916 16919 +3
Branches 1771 1772 +1
============================================
+ Hits 15427 15432 +5
+ Misses 1020 1019 -1
+ Partials 469 468 -1
Continue to review full report at Codecov.
|
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.
Please see inline comments
hedera-node/src/main/java/com/hedera/services/sigs/sourcing/SigMapPubKeyToSigBytes.java
Outdated
Show resolved
Hide resolved
final int length = pubKeyPrefix.length; | ||
if (Arrays.equals(pubKeyPrefix, 0, length, pubKey, 0, length)) { | ||
if (sigBytes != EMPTY_SIG) { | ||
throw new KeyPrefixMismatchException("Source signature map is ambiguous for given public key!"); |
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.
For this throw
, also add the info of pubKeyPrefix
and pubKey
. Need a test to cover this throw with the expected info.
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.
There is at least one unit test where we create an intentionally ambiguous sigMap
and verify the KeyPrefixMismatchException
is thrown, here: SigVerifierRegressionTest.throwsOnInvalidSigMap().
Apparently it was unstable in CI because it has,
assumeFalse(isInCircleCi);
But @Neeharika-Sompalli you could try removing the assumeFalse(isInCircleCi)
from the SigVerifierRegressionTest
...at some point I could start running the SmartContract*Test
unit tests in CircleCI for no obvious reason, maybe this can too now! 😁
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.
@tinker-michaelj Sure, uncommented the line. SigMapPubKeyToSigBytesTest.rejectsNonUniqueSigBytes
also checks for the KeyPrefixMismatchException
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.
LGTM...I believe the semantics are unchanged, we can run the SigVerifierRegressionTest
mentioned below for extra test coverage if we want.
hedera-node/src/main/java/com/hedera/services/sigs/sourcing/SigMapPubKeyToSigBytes.java
Outdated
Show resolved
Hide resolved
final int length = pubKeyPrefix.length; | ||
if (Arrays.equals(pubKeyPrefix, 0, length, pubKey, 0, length)) { | ||
if (sigBytes != EMPTY_SIG) { | ||
throw new KeyPrefixMismatchException("Source signature map is ambiguous for given public key!"); |
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.
There is at least one unit test where we create an intentionally ambiguous sigMap
and verify the KeyPrefixMismatchException
is thrown, here: SigVerifierRegressionTest.throwsOnInvalidSigMap().
Apparently it was unstable in CI because it has,
assumeFalse(isInCircleCi);
But @Neeharika-Sompalli you could try removing the assumeFalse(isInCircleCi)
from the SigVerifierRegressionTest
...at some point I could start running the SmartContract*Test
unit tests in CircleCI for no obvious reason, maybe this can too now! 😁
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.
LGTM
Signed-off-by: Neeharika-Sompalli <[email protected]>
c8fa94f
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.
LGTM
Signed-off-by: Neeharika-Sompalli <[email protected]>
Signed-off-by: Neeharika-Sompalli <[email protected]>
Related issue(s):
Closes #1423
Summary of the change:
Removed
stream()
operation being used to iterate over theSignaturePairs
in thesigMap
. This is done because modifying this to use a simplefor
loop and usingArrays.equals()
improved performance