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 processValidationFailure method #2817

Merged

Conversation

julia-zack
Copy link
Contributor

@julia-zack julia-zack commented Oct 21, 2024

After concluding the validation was a failure, we need to emit the commitFederationFailed event and reset all the values that are used in the process for the federation change to be allowed again.

In this pr, a new processValidationFailure method is created:

  • emit the new commitFederationFailed Bridge event

  • clear the proposedFederation storage entry

  • clear the svp fund tx storage entries

  • clear the expected svp spend tx storage entry/ies

@julia-zack julia-zack marked this pull request as ready for review October 22, 2024 12:58
@julia-zack julia-zack requested a review from a team as a code owner October 22, 2024 12:58
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.

Nice job, left some comments with a big focus on clearSvpValues

rskj-core/src/main/java/co/rsk/peg/BridgeSupport.java Outdated Show resolved Hide resolved
rskj-core/src/main/java/co/rsk/peg/BridgeSupport.java Outdated Show resolved Hide resolved
rskj-core/src/main/java/co/rsk/peg/BridgeSupport.java Outdated Show resolved Hide resolved
rskj-core/src/main/java/co/rsk/peg/BridgeSupport.java Outdated Show resolved Hide resolved
rskj-core/src/main/java/co/rsk/peg/BridgeSupport.java Outdated Show resolved Hide resolved
rskj-core/src/main/java/co/rsk/peg/BridgeSupport.java Outdated Show resolved Hide resolved
@marcos-iov marcos-iov force-pushed the feature/powpeg_validation_protocol-phase4 branch from e99b87a to 4e9f573 Compare October 24, 2024 22:27
@marcos-iov marcos-iov force-pushed the process_validation_failure branch from bc59eea to 085a14e Compare October 24, 2024 22:29
Copy link

github-actions bot commented Oct 24, 2024

Dependency Review

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

OpenSSF Scorecard

PackageVersionScoreDetails

Scanned Manifest Files

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.

Looking good, well done. Just a couple of style suggestions

@@ -1017,6 +1017,49 @@ private void logUpdateCollections(Transaction rskTx) {
eventLogger.logUpdateCollections(sender);
}

protected void processValidationFailure(Federation proposedFederation) {
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
protected void processValidationFailure(Federation proposedFederation) {
protected void processSVPFailure(Federation proposedFederation) {

What do you think? To give it context since it's part of BridgeSupport class and there's all of type of stuff in there

Copy link
Contributor Author

Choose a reason for hiding this comment

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

makes sense, thanks!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

updated

@@ -1017,6 +1017,49 @@ private void logUpdateCollections(Transaction rskTx) {
eventLogger.logUpdateCollections(sender);
}

protected void processValidationFailure(Federation proposedFederation) {
eventLogger.logCommitFederationFailure(rskExecutionBlock, proposedFederation);
logger.warn("[processValidationFailure] Proposed federation validation failed so svp values will be cleared.");
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we log something else? The block number where it failed maybe? We could then look for the event in that block

Copy link
Contributor Author

Choose a reason for hiding this comment

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

good idea yes

Copy link
Contributor Author

Choose a reason for hiding this comment

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

updated


provider.getSvpFundTxHashUnsigned().ifPresent(
svpFundTxHashUnsigned -> {
logger.warn("[clearSvpValues] Fund tx change {} was never registered.", svpFundTxHashUnsigned);
Copy link
Contributor

Choose a reason for hiding this comment

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

ouch

clearSvpValues();
}

private void clearSvpValues() {
Copy link
Contributor

Choose a reason for hiding this comment

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

Should this maybe be part of BridgeStorageProvider class? That would imply adding tests to it 😬

Copy link
Contributor Author

Choose a reason for hiding this comment

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

mmmjjjjjjj

Copy link
Contributor Author

Choose a reason for hiding this comment

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

you right, unfortunately for me

Copy link
Contributor Author

Choose a reason for hiding this comment

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

updated

// assert
assertLogCommitFederationFailed();
assertProposedFederationWasCleared();
assertFalse(bridgeStorageProvider.getSvpFundTxHashUnsigned().isPresent());
Copy link
Contributor

Choose a reason for hiding this comment

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

Perhaps have a method that checks that none of the SVP related values are present? fundTx, spendTx, tx wfs, etc

Copy link
Contributor Author

Choose a reason for hiding this comment

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

updated

bridgeStorageProvider.clearSvpValues();

// assert
assertFalse(bridgeStorageProvider.getSvpFundTxHashUnsigned().isPresent());
Copy link
Contributor

Choose a reason for hiding this comment

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

I would assert that no svp value is present, in all tests

Copy link
Contributor

Choose a reason for hiding this comment

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

Same as in BridgeSupportSvpTest

Copy link
Contributor Author

Choose a reason for hiding this comment

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

sure

Copy link
Contributor 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 1024 to 1034
clearProposedFederation();
clearSvpValues();
}

private void clearProposedFederation() {
federationSupport.clearProposedFederation();
}

private void clearSvpValues() {
provider.clearSvpValues();
}
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
clearProposedFederation();
clearSvpValues();
}
private void clearProposedFederation() {
federationSupport.clearProposedFederation();
}
private void clearSvpValues() {
provider.clearSvpValues();
}
federationSupport.clearProposedFederation();
provider.clearSvpValues();
}

Makes sense?

…r refactor for clearing svp values in support
Copy link

@marcos-iov marcos-iov merged commit 4697a0a into feature/powpeg_validation_protocol-phase4 Oct 30, 2024
8 checks passed
@marcos-iov marcos-iov deleted the process_validation_failure branch October 30, 2024 14:28
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