-
Notifications
You must be signed in to change notification settings - Fork 25
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
Remove signatures from svp spend tx before searching it while running HSM #390
base: LOVELL-7.0.0-rc
Are you sure you want to change the base?
Conversation
src/main/java/co/rsk/federate/btcreleaseclient/BtcReleaseClient.java
Outdated
Show resolved
Hide resolved
src/main/java/co/rsk/federate/btcreleaseclient/BtcReleaseClient.java
Outdated
Show resolved
Hide resolved
src/main/java/co/rsk/federate/btcreleaseclient/BtcReleaseClient.java
Outdated
Show resolved
Hide resolved
Dependency Review✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.OpenSSF Scorecard
Scanned Manifest Files |
731329b
to
a368f73
Compare
* @return {@code true} if the transaction has the required number of confirmations and is ready to be signed; | ||
* {@code false} otherwise | ||
*/ | ||
private boolean isSVPSpendTxReadyToSign(long currentBlockNumber, Map.Entry<Keccak256, BtcTransaction> svpSpendTx) { | ||
try { | ||
|
||
BtcTransaction svpSpendTxWithoutSignatures = svpSpendTx.getValue(); |
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 wouldn't call it that way here, it still has the signatures
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 renamed it back to btcTx
.
Federation spendingFed = getSpendingFederation(svpSpendTxWithoutSignatures); | ||
|
||
logger.debug("[isSvpSpendTxReadyToSign] SVP spend tx before removing signatures [{}]", svpSpendTxWithoutSignatures); | ||
removeSignaturesFromTransaction(svpSpendTxWithoutSignatures, spendingFed); |
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.
Could make use of BitcoinUtils:: removeSignaturesFromTransactionWithP2shMultiSigInputs
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.
Agree. Maybe we should deprecate co.rsk.federate.btcreleaseclient.BtcReleaseClient#removeSignaturesFromTransaction
and suggest use removeSignaturesFromTransactionWithP2shMultiSigInputs
in the comment.
Btw, removeSignaturesFromTransactionWithP2shMultiSigInputs
throws RuntimeExceptions
. Should we catch them if so? I think we should, if not, it could result in pegouts not being able to be signed.
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.
Let's not change more than we need right now, just fix the problem and move on with Lovell. Future refactors can come later.
By the way, instead of removeSignaturesFromTransactionWithP2shMultiSigInputs
we should actually use getMultiSigTransactionHashWithoutSignatures
that makes a copy of the transaction and returns it without signatures. That makes it a lot clearer
BtcTransaction svpSpendTxWithoutSignatures = svpSpendTx.getValue(); | ||
Federation spendingFed = getSpendingFederation(svpSpendTxWithoutSignatures); | ||
|
||
logger.debug("[isSvpSpendTxReadyToSign] SVP spend tx before removing signatures [{}]", svpSpendTxWithoutSignatures); |
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.
Probably want to log just the hash of the transaction
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.
Check:
powpeg-node/src/main/java/co/rsk/federate/btcreleaseclient/BtcReleaseClient.java
Line 390 in a368f73
logger.trace("[tryGetReleaseInformation] Removing possible signatures from pegout btcTxHash {}", pegoutBtcTx.getHash()); |
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.
Updated
|
||
logger.debug("[isSvpSpendTxReadyToSign] SVP spend tx before removing signatures [{}]", svpSpendTxWithoutSignatures); | ||
removeSignaturesFromTransaction(svpSpendTxWithoutSignatures, spendingFed); | ||
logger.debug("[isSvpSpendTxReadyToSign] SVP spend tx after removing signatures [{}]", svpSpendTxWithoutSignatures); |
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.
same here
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.
Updated
src/main/java/co/rsk/federate/btcreleaseclient/BtcReleaseClient.java
Outdated
Show resolved
Hide resolved
src/test/java/co/rsk/federate/btcreleaseclient/BtcReleaseClientTest.java
Outdated
Show resolved
Hide resolved
src/test/java/co/rsk/federate/btcreleaseclient/BtcReleaseClientTest.java
Outdated
Show resolved
Hide resolved
Quality Gate passedIssues Measures |
Description
When running with an HSM, the node is unable to find the related event since it is taking account the hash of the transaction with the singnatures on it. It must remove the signatures from the bitcoin transaction before comparing with the tx hash of the event.
Motivation and Context
How Has This Been Tested?
Types of changes
Checklist:
rskj:fix/remove-sigs-svp-spend
fed:fix/remove-sigs-svp-spend