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

Use FederationChangeFunctions enum when voting #2897

Conversation

julia-zack
Copy link
Contributor

No description provided.

Copy link

github-actions bot commented Dec 18, 2024

Dependency Review

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

OpenSSF Scorecard

PackageVersionScoreDetails

Scanned Manifest Files

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

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.

Should we update unit tests?

Comment on lines -547 to -550
default:
// Fail by default
logger.warn("[executeVoteFederationChangeFunction] Unrecognized called function.");
result = new ABICallVoteResult(false, FederationChangeResponseCode.GENERIC_ERROR.getCode());
Copy link
Contributor Author

@julia-zack julia-zack Dec 19, 2024

Choose a reason for hiding this comment

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

this is no needed since the method receives the FederationChangeFunction as an input

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.

Comment on lines 487 to 488
// Try to do a dry-run and only register the vote if the
// call would be successful
Copy link
Contributor

Choose a reason for hiding this comment

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

Not sure this comment belongs here, the dryRun is a parameter. It's on voteFederationChange function where the dryRun is first attempted

}

private ABICallVoteResult executeVoteFederationChangeFunction(boolean dryRun, ABICallSpec callSpec, BridgeEventLogger eventLogger) throws BridgeIllegalArgumentException {
private ABICallVoteResult executeVoteFederationChangeFunction(boolean dryRun, byte[][] callSpecArguments, FederationChangeFunction federationChangeFunction, BridgeEventLogger eventLogger) throws BridgeIllegalArgumentException {
Copy link
Contributor

Choose a reason for hiding this comment

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

Not a fan of receiving a byte[][] parameter. I think it let's you pass whatever. Wouldn't it be better to keep passing the ABICallSpec obejct

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yep, you right. I'll rollback the change

}

return result;
return new ABICallVoteResult(executionResult == 1, executionResult);
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
return new ABICallVoteResult(executionResult == 1, executionResult);
boolean executionWasSuccessful = executionResult == 1;
return new ABICallVoteResult(executionWasSuccessful, executionResult);

BtcECKey btcPublicKey;
ECKey rskPublicKey;
ECKey mstPublicKey;
try {
btcPublicKey = BtcECKey.fromPublicOnly(callSpec.getArguments()[0]);
btcPublicKey = BtcECKey.fromPublicOnly(callSpecArguments[0]);
Copy link
Contributor

Choose a reason for hiding this comment

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

Looks like callSpecArguments[] is read twice usually, inside the try and then inside the catch. Perhaps we should store in a variable to a avoid possible errors by mixing up the indexes?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

nice catch!

…able that can be reused. Modify method to not receive bytes as an argument
@julia-zack julia-zack force-pushed the use_enum_fed_change_functions_for_voting branch from 815d2c5 to 98a1d89 Compare January 6, 2025 18:38
@marcos-iov marcos-iov merged commit 8588748 into feature/powpeg_validation_protocol-phase4 Jan 6, 2025
9 checks passed
@marcos-iov marcos-iov deleted the use_enum_fed_change_functions_for_voting branch January 6, 2025 20:17
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.

5 participants