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

Save the entire svp fund tx instead of only its hash #2731

Conversation

julia-zack
Copy link
Contributor

Background
To create the svp spend transaction, we will need to have the entire svp fund transaction signed, and not only its hash.

Requirements
-Modify all the places where the svp fund transaction hash signed was being considered to now consider the entire svp fund transaction signed.
-Create new serialize/deserializeBtcTransaction methods in BridgeSerializationUtils to save the serialized tx.

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
Comment on lines -186 to -216
public static byte[] serializeSet(SortedSet<Sha256Hash> set) {
int nhashes = set.size();

byte[][] bytes = new byte[nhashes][];
int n = 0;

for (Sha256Hash hash : set) {
bytes[n++] = RLP.encodeElement(hash.getBytes());
}

return RLP.encodeList(bytes);
}

public static SortedSet<Sha256Hash> deserializeSet(byte[] data) {
SortedSet<Sha256Hash> set = new TreeSet<>();

if (data == null || data.length == 0) {
return set;
}

RLPList rlpList = (RLPList)RLP.decode2(data).get(0);

int nhashes = rlpList.size();

for (int k = 0; k < nhashes; k++) {
set.add(Sha256Hash.wrap(rlpList.get(k).getRLPData()));
}

return set;
}

Copy link
Contributor Author

@julia-zack julia-zack Sep 17, 2024

Choose a reason for hiding this comment

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

this has been removed since it is not being used anywhere

Comment on lines +401 to +404
BtcTransaction prevTx = new BtcTransaction(mainnetBtcParams);
Address address = BitcoinTestUtils.createP2PKHAddress(mainnetBtcParams, "address");
prevTx.addOutput(Coin.FIFTY_COINS, address);
svpFundTx.addInput(prevTx.getOutput(0));
Copy link
Contributor Author

@julia-zack julia-zack Sep 17, 2024

Choose a reason for hiding this comment

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

just to make the svpFundTx more complete, and different from the anotherSvpFundTx

@julia-zack julia-zack marked this pull request as ready for review September 17, 2024 12:24
@julia-zack julia-zack requested a review from a team as a code owner September 17, 2024 12:24
@julia-zack julia-zack force-pushed the save_fund_tx_signed_instead_of_hash branch from cc7bea6 to 45e7d97 Compare September 17, 2024 19:15
@julia-zack julia-zack changed the base branch from feature/powpeg_validation_protocol-phase2 to feat/refactor_bridge_serialization_utils September 17, 2024 19:15
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. minor comment

@julia-zack julia-zack changed the title When signed, save the svp fund tx instead of its hash Save the entire svp fund tx instead of only its hash Sep 18, 2024
@julia-zack julia-zack force-pushed the save_fund_tx_signed_instead_of_hash branch from 45e7d97 to 14712e3 Compare September 18, 2024 15:43
@julia-zack julia-zack force-pushed the save_fund_tx_signed_instead_of_hash branch from 14712e3 to 45b96c4 Compare September 18, 2024 18:22
Copy link

@marcos-iov marcos-iov force-pushed the feat/refactor_bridge_serialization_utils branch from 5a1e6c4 to 44c4644 Compare September 18, 2024 19:02
Base automatically changed from feat/refactor_bridge_serialization_utils to feature/powpeg_validation_protocol-phase2 September 18, 2024 19:29
@marcos-iov marcos-iov force-pushed the feature/powpeg_validation_protocol-phase2 branch from 98ed61b to 4835a42 Compare September 18, 2024 20:13
@julia-zack julia-zack changed the base branch from feature/powpeg_validation_protocol-phase2 to feat/refactor_bridge_serialization_utils_recovery September 19, 2024 00:31
@julia-zack julia-zack closed this Sep 19, 2024
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