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

Fix Issues After Remove createErpRedeemScript method from ErpFederationRedeemScriptParser in Bj-thin #2729

Conversation

wilmerrootstock
Copy link
Contributor

Description

After removing the createErpRedeemScript method from ErpFederationRedeemScriptParser in Bitcoinj-thin, please take a look at RSKj to see the impact this has on it.

Fix classes using the createErpRedeemScript method from ErpFederationRedeemScriptParser using the redeem script builder in RSKj.

Motivation and Context

This relates to the Refactors to add SegwitRedeemScriptParser.

How Has This Been Tested?

Unit Tests.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)

Checklist:

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • Tests for the changes have been added (for bug fixes / features)
  • Requires Activation Code (Hard Fork)
  • Other information:

julia-zack and others added 30 commits September 12, 2024 13:08
Add key to storage index

Remove declaration of svp fund tx hash since it is not being used yet. Remove _KEY suffix
Remove _KEY suffix. Save proposed federation the same way as pending one
Add proposedFederationIsSet logic

Getting rid of proposedFederationIsSet logic.

Add isProposedFederationSet logic.

Add rskip419 check in saveProposedFederation method

Save null version when proposed federation is null

Remove unnecessary private method

Refactor

Removes null activations from tests
Make variable final

Improve test name

Use all activations instead of lovell

Improve null handling
Add get proposed federation tests

Minor fix after rebase

Improve comment

Minor refactor

Minor refactor

Improve comment

Add test case

Throw exception when there is no storage version for non-null proposed federation

Add test cases

Add log. Add test case and refactor

Remove unused import
…sh methods and tests

Rebases

Reorders and renames tests
Rebases

Appends SVP prefix to FUND_TX_HASH_UNSIGNED and refactors tests
Rebases

Moves repeated arrange code to setup. Using Optional.
Rebases

Removes _ from the key

Using arrowhead631
Rebases

Rebases

Renames saveFundTransactionUnsignedHash to saveSvpFundTransactionUnsignedHash

Renames FundTransactionUnsignedHash instance fields
Remove unnecessary private method

Refactor
Add get proposed federation tests

Minor fix after rebase

Improve comment

Minor refactor

Add test case
…d federation

Add test cases

Add log. Add test case and refactor

Remove unused import
…sh methods and tests

Rebases

Moves repeated arrange code to setup. Using Optional.
Rebases
Adds test to assert empty is returned when hash hasn't been set or saved

Renames svp fields to match the RSKIP419 description. Adds more tests. Using standard.

Renames test
Improve variable name

Add comment

Minor refactors

Improve comments. Minor refactors

Improve comments

Refactor

Add tests for commitFederationAccordingToActivations

Remove unnecessary semicolon

Refactor to improve testing and readability

Add test cases

Remove some tests. Make bridge event logger not a mock. Make some methods private instead of protected. Fix log message

Improve test name

Change test name

Move reused method to utility class. Use real block instead of a mock

Make methods to be private instead of protected
Fix sonar complains

Add missing import

Move method to test class

Remove unused imports
… to bridge storage provider

Remove svp fund tx tests from federation storage provider tests, and adds them to bridge storage provider tests

Get rid of sonar complains

Add get methods to bridge

Put save, set and get tests in same nested class
Add tests. Add missing tests for minimum pegout tx value

Modify test
Remove unused import

Remove mistaken reason

Minor refactor

Make flyover rs builder receive a keccak256 hash instead of sha256 one

Refactors
Refactor and add test case

Add test case

Remove mistaken comment

Add comment

Modify comment
apancorb and others added 10 commits September 12, 2024 15:16
Rename variables

Modify method to just remove signatures from non-segwit transactions

Modify message from thrown exception to be more accurate

Add indentation to improve readability
Remove unnecessary import

resolve comments
… inputs or without inputs with p2sh multisig script sig. Rename.

Reorder blank lines

Rename scriptSig to inputScript

Set network parameters at bridge support class level to avoid duplication code
…of updateScriptWithSignature

Add [methodName] when logging. Use getSigInsertionIndex to make method more realistic. Remove error being thrown when tx has no inputs.

Remove unused import
…action

Improve comments

Improve method name. Add transactionsInBlock argument for creating a pmt.

Improve method to create a valid pmt for transactions following class implementation
Once the method signature on RedeemScriptParser#extractStandardRedeemScript is changed, we need to apply this to RSKj to modify how the method is used from it.

Old method signature: Script extractStandardRedeemScript();

New method signature: List<ScriptChunk> extractStandardRedeemScriptChunks();
@wilmerrootstock wilmerrootstock requested a review from a team as a code owner September 16, 2024 00:26
…hod inside the parsers

- Fix MultiSigType.ERP_FED reference to MultiSigType.NON_STANDARD_ERP_FED after refactor.
- Update isPegOutTx and isValidPegInTx instead of passing script sig, pass redeem script chunks to RedeemScriptParserFactory.get.
Copy link
Contributor

@jeremy-then jeremy-then left a comment

Choose a reason for hiding this comment

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

LGTM.

@@ -155,4 +157,23 @@ private static void signLegacyTransactionInputFromP2shMultiSig(BtcTransaction tr
input.setScriptSig(inputScriptSig);
}
}

public static List<BtcECKey> getDefaultPublicKeys() {
Copy link
Contributor

Choose a reason for hiding this comment

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

What's the use for this? Seems to be very specific

Copy link
Contributor Author

@wilmerrootstock wilmerrootstock Sep 17, 2024

Choose a reason for hiding this comment

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

This method gets the default public keys. It'll be use only for tests. Should it be in a different Utils Class?

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! Started using the getBtcPublicKeys method from the active federation. Reversed the changes on BitcoinTestUtils.

Copy link
Contributor

@apancorb apancorb left a comment

Choose a reason for hiding this comment

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

LGTM

marcos-iov and others added 5 commits September 17, 2024 14:35
…eem-script-class

Update ErpRedeemScriptParser reference to new name and fix tests failing after RedeemScriptParserFactory refactor
…onRedeemScriptParser in Bj-thin

After removing the createErpRedeemScript method from ErpFederationRedeemScriptParser in Bitcoinj-thin, please take a look at RSKj to see the impact this has on it.

Fix classes using the createErpRedeemScript method from ErpFederationRedeemScriptParser using the redeem script builder in RSKj.
@wilmerrootstock wilmerrootstock force-pushed the feature/remove-createerpredeemscript-from-bjthin branch from c9f1e9c to 0ee2d22 Compare September 17, 2024 17:58
Federation activeFederation = FederationTestUtils.getGenesisFederation(federationConstantsMainnet);
int defaultThreshold = activeFederation.getBtcPublicKeys().size() / 2 + 1;
int emergencyThreshold = federationConstantsMainnet.getErpFedPubKeysList().size() / 2 + 1;
ErpRedeemScriptBuilder nonStandardErpRedeemScriptBuilder = new NonStandardErpRedeemScriptBuilder();
Copy link
Contributor

Choose a reason for hiding this comment

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

Please use NonStandardErpRedeemScriptBuilderFactory instead.

@nathanieliov
Copy link
Contributor

@wilmerrootstock, these tests failing were already fixed in this PR: #2730 by me

@nathanieliov nathanieliov force-pushed the wip/fed-scripts-refactors-integration branch from 38cdfcd to 4b55c0d Compare September 18, 2024 02:14
@wilmerrootstock
Copy link
Contributor Author

wilmerrootstock commented Sep 18, 2024

The task was addressed by @nathanieliov when he was fixing some issues on RSKj in this PR

@marcos-iov marcos-iov deleted the feature/remove-createerpredeemscript-from-bjthin branch September 19, 2024 13:29
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.

6 participants