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

Create StateForProposedFederator and Refactor StateForFederator #2738

Merged

Conversation

apancorb
Copy link

Description

New DTO class called StateForProposedFederator, which would act similar to existingStateForFederator. It will receive the svpSpendTxWaitingForSignatures to notify the pegnatories.

Also includes a refactor of StateForFederator.

Motivation and Context

https://github.com/rsksmart/RSKIPs/blob/master/IPs/RSKIP419.md

@apancorb apancorb marked this pull request as ready for review September 19, 2024 10:34
@apancorb apancorb requested a review from a team as a code owner September 19, 2024 10:34
@apancorb apancorb self-assigned this Sep 19, 2024
Copy link
Contributor

@marcos-iov marcos-iov left a comment

Choose a reason for hiding this comment

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

Nice refactor! Very well done


public class StateForProposedFederator {

private final Map.Entry<Keccak256, BtcTransaction> rskTxWaitingForSignatures;
Copy link
Contributor

Choose a reason for hiding this comment

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

Since this will be for a very specific use case, what do you think about calling it svpSpendTxWaitingForSignatures

Copy link
Author

Choose a reason for hiding this comment

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

Should we also change the other one to pegoutsWaitingForSignatures? Or too specific?

Copy link
Contributor

Choose a reason for hiding this comment

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

That one can be pegouts, migrations, fund tx. This one is very specific

Copy link
Author

Choose a reason for hiding this comment

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

Updated

Comment on lines 44 to 45
Keccak256 rskTxHash1 = createHash3(1);
Keccak256 rskTxHash2 = createHash3(2);
Copy link
Contributor

Choose a reason for hiding this comment

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

Let's use the new method that's in RskTestUtils in favor of this one that is deprecated.

No need to change it everywhere, but at least in the new places and lines we refactor

Copy link
Author

Choose a reason for hiding this comment

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

Updated


package co.rsk.peg;

import static co.rsk.peg.PegTestUtils.createHash3;
Copy link
Contributor

Choose a reason for hiding this comment

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

same here

Copy link
Author

Choose a reason for hiding this comment

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

Updated

private static final NetworkParameters NETWORK_PARAMETERS = NetworkParameters.fromID(NetworkParameters.ID_MAINNET);

@Test
void stateForProposedFederator_whenSerializeAndDeserialize_shouldHaveEqualState() {
Copy link
Contributor

Choose a reason for hiding this comment

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

a test when there's no tx waiting for signatures?

Copy link
Author

Choose a reason for hiding this comment

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

Updated


public StateForFederator(byte[] rlpData, NetworkParameters parameters) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Careful careful, I believe this is used from the powpeg-node

Copy link
Author

Choose a reason for hiding this comment

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

Okay it makes sense now, will update :) Thanks for the heads up

@apancorb apancorb force-pushed the feat/state_for_federator branch 2 times, most recently from 64d8dae to 9aff079 Compare September 20, 2024 08:48
Copy link

sonarcloud bot commented Sep 20, 2024

@@ -1657,7 +1657,7 @@ private void processSigning(
*/
public byte[] getStateForBtcReleaseClient() throws IOException {
Copy link
Contributor

Choose a reason for hiding this comment

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

Not related to this PR, but looks like we are going to need some tests for this method

@marcos-iov marcos-iov merged commit 24f3a93 into feature/powpeg_validation_protocol-phase2 Sep 20, 2024
6 checks passed
@marcos-iov marcos-iov deleted the feat/state_for_federator branch September 20, 2024 19:02
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.

2 participants