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

Pegin it register btc tx negative height #2888

Open
wants to merge 6 commits into
base: pegin-it-repeatedTx
Choose a base branch
from

Conversation

julianlen
Copy link
Contributor

No description provided.

Copy link

github-actions bot commented Dec 10, 2024

Dependency Review

✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.

OpenSSF Scorecard

PackageVersionScoreDetails

Scanned Manifest Files

@julianlen julianlen force-pushed the pegin-it-registerBtcTx-negativeHeight branch 2 times, most recently from de4c30f to b699b73 Compare December 13, 2024 16:45
@julianlen julianlen changed the base branch from master to pegin-it-repeatedTx December 13, 2024 16:45
@julianlen julianlen closed this Dec 13, 2024
@julianlen julianlen force-pushed the pegin-it-registerBtcTx-negativeHeight branch from b699b73 to 171c569 Compare December 13, 2024 21:33
@julianlen julianlen reopened this Dec 13, 2024
@julianlen julianlen force-pushed the pegin-it-registerBtcTx-negativeHeight branch 3 times, most recently from fac66b3 to 25c1834 Compare December 17, 2024 13:23
@julianlen julianlen force-pushed the pegin-it-registerBtcTx-negativeHeight branch 3 times, most recently from a4aee36 to be35cf6 Compare December 18, 2024 15:09
@julianlen julianlen force-pushed the pegin-it-registerBtcTx-negativeHeight branch from be35cf6 to bc71e17 Compare December 18, 2024 15:34
@julianlen julianlen marked this pull request as ready for review December 18, 2024 19:34
@julianlen julianlen requested a review from a team as a code owner December 18, 2024 19:34
List<UTXO> expectedFederationUTXOs = federationSupport.getActiveFederationBtcUTXOs();

// Act
bridgeSupport.registerBtcTransaction(rskTx, bitcoinTransaction.bitcoinSerialize(), -1, pmtWithTransactions.bitcoinSerialize());
Copy link
Contributor

Choose a reason for hiding this comment

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

Based on the logic internal logic, this should throw a new RegisterBtcTransactionException("Could not validate transaction").

Copy link
Contributor

Choose a reason for hiding this comment

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

Interesting, this test should be failing then. Maybe we are missing something 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.

No exception is thrown because of negative height or repeated btc transactions. The exception is caught within the BridgeSupport::registerBtcTransaction method and it prints a log. I'll add this as a future issue to review.

Comment on lines 150 to 151
@Test
void registerBtcTransaction_forALegacyBtcTransactionWithNegativeHeight_shouldNotPerformAnyChange() throws Exception {
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
@Test
void registerBtcTransaction_forALegacyBtcTransactionWithNegativeHeight_shouldNotPerformAnyChange() throws Exception {
@Test
void registerBtcTransaction_whenLegacyBtcTransactionWithNegativeHeight_shouldNotPerformAnyChange() throws Exception {

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done!

List<UTXO> expectedFederationUTXOs = federationSupport.getActiveFederationBtcUTXOs();

// Act
bridgeSupport.registerBtcTransaction(rskTx, bitcoinTransaction.bitcoinSerialize(), -1, pmtWithTransactions.bitcoinSerialize());
Copy link
Contributor

Choose a reason for hiding this comment

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

Interesting, this test should be failing then. Maybe we are missing something here?

@@ -169,7 +188,8 @@ private BtcTransaction createPegInTransaction(Address federationAddress, Coin co
private void assertLogPegInBtc() {
Sha256Hash peginTransactionHash = bitcoinTransaction.getHash();
List<DataWord> encodedTopics = getEncodedTopics(BridgeEvents.PEGIN_BTC.getEvent(), rskReceiver.toString(), peginTransactionHash.getBytes());
byte[] encodedData = getEncodedData(BridgeEvents.PEGIN_BTC.getEvent(), minimumPeginValue.getValue(), 0);
int protocolVersion = 0;
Copy link
Contributor

Choose a reason for hiding this comment

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

nice

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.

4 participants