-
Notifications
You must be signed in to change notification settings - Fork 26
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
Implement getProposedFederation in FederationProviderFromFederatorSupport #329
base: feat/powpeg_validation_protocol-phase4
Are you sure you want to change the base?
Implement getProposedFederation in FederationProviderFromFederatorSupport #329
Conversation
…tionProviderFromFederatorSupport
…nal check for building retiring federation
src/main/java/co/rsk/federate/FederationProviderFromFederatorSupport.java
Outdated
Show resolved
Hide resolved
src/main/java/co/rsk/federate/FederationProviderFromFederatorSupport.java
Outdated
Show resolved
Hide resolved
src/main/java/co/rsk/federate/FederationProviderFromFederatorSupport.java
Outdated
Show resolved
Hide resolved
src/main/java/co/rsk/federate/FederationProviderFromFederatorSupport.java
Outdated
Show resolved
Hide resolved
src/main/java/co/rsk/federate/FederationProviderFromFederatorSupport.java
Show resolved
Hide resolved
src/main/java/co/rsk/federate/FederationProviderFromFederatorSupport.java
Outdated
Show resolved
Hide resolved
); | ||
|
||
Federation initialFederation = FederationFactory.buildStandardMultiSigFederation(federationArgs); | ||
Federation expectedFederation = getExpectedFederation(initialFederation, proposedFederationAddress.get()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see how getExpectedFederation
builds the federation, and I think this method is unsuitable for this case. At the beginning, you have already checked if RSKIP419
is active, so we can be sure that the proposed federation will be a P2shFederation
. if not, I would like to understand why you would be a different type?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for pointing this out :) , I have made the changes. Let me know if this looks good now.
src/test/java/co/rsk/federate/FederationProviderFromFederatorSupportTest.java
Outdated
Show resolved
Hide resolved
src/test/java/co/rsk/federate/FederationProviderFromFederatorSupportTest.java
Outdated
Show resolved
Hide resolved
* and the retiring federation, if one exists. | ||
* | ||
* @return a {@link List} of live {@link Federation} instances | ||
*/ | ||
List<Federation> getLiveFederations(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can probably remove this method, is not being used anywhere at the moment. Maybe in another PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lets create a task for that
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agree
…deration exists any related data is missing
…s a P2shErpFederation
src/main/java/co/rsk/federate/FederationProviderFromFederatorSupport.java
Show resolved
Hide resolved
src/main/java/co/rsk/federate/FederationProviderFromFederatorSupport.java
Outdated
Show resolved
Hide resolved
…ate exisiting fed
…eing called to check if proposed fed exists
* and the retiring federation, if one exists. | ||
* | ||
* @return a {@link List} of live {@link Federation} instances | ||
*/ | ||
List<Federation> getLiveFederations(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agree
src/main/java/co/rsk/federate/FederationProviderFromFederatorSupport.java
Outdated
Show resolved
Hide resolved
src/test/java/co/rsk/federate/FederationProviderFromFederatorSupportTest.java
Show resolved
Hide resolved
…t because some data is missing from the Bridge
src/main/java/co/rsk/federate/FederationProviderFromFederatorSupport.java
Outdated
Show resolved
Hide resolved
Integer federationSize = federatorSupport.getProposedFederationSize() | ||
.orElse(FEDERATION_NON_EXISTENT.getCode()); | ||
if (federationSize == FEDERATION_NON_EXISTENT.getCode()) { | ||
return Optional.empty(); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Integer federationSize = federatorSupport.getProposedFederationSize() | |
.orElse(FEDERATION_NON_EXISTENT.getCode()); | |
if (federationSize == FEDERATION_NON_EXISTENT.getCode()) { | |
return Optional.empty(); | |
} | |
Optional<Integer> federationSize = federatorSupport.getProposedFederationSize(); | |
if (federationSize.isEmpty()) { | |
return Optional.empty(); | |
} |
wdyt?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This would work if the Bridge returned only a null value for the federation size if the proposed fed did not exist. But it can return FEDERATION_NON_EXISTENT which would be present in the optional. We would have to check this before continuing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pretty sure the FEDERATION_NON_EXISTENT
code is not being used for the proposed fed, but for the pending and retiring.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It was implemented here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
my bad, you right. But in that case it wont be necessary to have an optional right? Because you are always getting a value from the Bridge
…ception while building the proposed federation
Quality Gate passedIssues Measures |
@Test | ||
void getProposedFederation_whenRSKIP419IsNotActivated_shouldReturnEmptyOptional() { | ||
// Arrange | ||
ActivationConfig.ForBlock configMock = mock(ActivationConfig.ForBlock.class); | ||
when(federatorSupportMock.getConfigForBestBlock()).thenReturn(configMock); | ||
|
||
// Act & Assert | ||
assertEquals(Optional.empty(), federationProvider.getProposedFederation()); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
probably this test can be removed
Summary
This PR includes the implementation of
getProposedFederation
. As well as bridge RPC methods for specific proposed federation implementations forgetFederationSize
,getFederatorPublicKeyOfType
,getFederationCreationTime
, andgetFederationCreationBlockNumber
.Motivation and Context
https://github.com/rsksmart/RSKIPs/blob/master/IPs/RSKIP419.md