-
Notifications
You must be signed in to change notification settings - Fork 266
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 new Federation and the complete process until it is confirmed and activated #2925
base: federation_change_federeration_integration
Are you sure you want to change the base?
Create new Federation and the complete process until it is confirmed and activated #2925
Conversation
…mitProposedFederation
…s named FederationChangeIT.java
…ed until activation phase
Dependency Review✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.OpenSSF Scorecard
Scanned Manifest Files |
case P2SH_ERP -> { | ||
originalFederation = FederationFactory.buildP2shErpFederation( | ||
originalFederationArgs, erpPubKeys, activationDelay); | ||
// TODO: CHECK REDEEMSCRIPT |
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.
Should this TODO
be here still?
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.
Removed, thanks
rskj-core/src/test/java/co/rsk/peg/federation/FederationChangeIT.java
Outdated
Show resolved
Hide resolved
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.
LGTM.
rskj-core/src/test/java/co/rsk/peg/federation/FederationChangeIT.java
Outdated
Show resolved
Hide resolved
rskj-core/src/test/java/co/rsk/peg/federation/FederationChangeIT.java
Outdated
Show resolved
Hide resolved
rskj-core/src/test/java/co/rsk/peg/federation/FederationChangeIT.java
Outdated
Show resolved
Hide resolved
rskj-core/src/test/java/co/rsk/peg/federation/FederationChangeIT.java
Outdated
Show resolved
Hide resolved
rskj-core/src/test/java/co/rsk/peg/federation/FederationChangeIT.java
Outdated
Show resolved
Hide resolved
rskj-core/src/test/java/co/rsk/peg/federation/FederationChangeIT.java
Outdated
Show resolved
Hide resolved
rskj-core/src/test/java/co/rsk/peg/federation/FederationChangeIT.java
Outdated
Show resolved
Hide resolved
rskj-core/src/test/java/co/rsk/peg/federation/FederationChangeIT.java
Outdated
Show resolved
Hide resolved
rskj-core/src/test/java/co/rsk/peg/federation/FederationChangeIT.java
Outdated
Show resolved
Hide resolved
rskj-core/src/test/java/co/rsk/peg/federation/FederationChangeIT.java
Outdated
Show resolved
Hide resolved
1ba5cc7
to
1191212
Compare
rskj-core/src/test/java/co/rsk/peg/federation/FederationChangeIT.java
Outdated
Show resolved
Hide resolved
rskj-core/src/test/java/co/rsk/peg/federation/FederationChangeIT.java
Outdated
Show resolved
Hide resolved
rskj-core/src/test/java/co/rsk/peg/federation/FederationChangeIT.java
Outdated
Show resolved
Hide resolved
rskj-core/src/test/java/co/rsk/peg/federation/FederationChangeIT.java
Outdated
Show resolved
Hide resolved
rskj-core/src/test/java/co/rsk/peg/federation/FederationChangeIT.java
Outdated
Show resolved
Hide resolved
rskj-core/src/test/java/co/rsk/peg/federation/FederationChangeIT.java
Outdated
Show resolved
Hide resolved
250c82b
to
0f5161b
Compare
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.
nice work
…hase of a federation change
…teps needed given all the activations
… agaisnt current block number to check migration has not started
class FederationChangeIT { | ||
|
||
private enum FederationType { | ||
NON_STANDARD_ERP, |
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.
Not sure we need this one, the goal is to have all RSKIPs active from the start right?
So we should have genesis federation that is of the standard multisig type, then immediately do a federation change. Now working with a p2sh erp fed. That's the only one we care about.
At least for now, then will come the segwit fed
@@ -656,7 +656,7 @@ private Integer addFederatorPublicKeyMultikey(boolean dryRun, BtcECKey btcKey, E | |||
* PENDING_FEDERATION_MISMATCHED_HASH if the given hash doesn't match the current pending federation's hash. | |||
* SUCCESSFUL upon success. | |||
*/ | |||
private FederationChangeResponseCode commitFederation(boolean dryRun, Keccak256 pendingFederationHash, BridgeEventLogger eventLogger) { | |||
FederationChangeResponseCode commitFederation(boolean dryRun, Keccak256 pendingFederationHash, BridgeEventLogger eventLogger) { |
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.
Can't we access this method by calling voteFederationChange
?
I think we should test this sending the required votes. Make it as realistic as possible. See VoteFederationChangeTest
class
var activations = ActivationConfigsForTest.all().forBlock(0); | ||
setUpFederationChange(activations); | ||
// Create a default original federation using the list of UTXOs | ||
var originalFederation = createOriginalFederation( |
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.
Can't we simply get the genesis federation here?
baf74f1
to
89d811f
Compare
89d811f
to
dcadcb4
Compare
22efa4a
to
dc6fb3f
Compare
Quality Gate passedIssues Measures |
var memberRskKey = member.getRskPublicKey(); | ||
var memberMstKey = member.getMstPublicKey(); | ||
|
||
voteToAddFederatorPublicKeysToPendingFederation(memberBtcKey, memberRskKey, memberMstKey); |
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.
Perhaps after voting each new member we could get the pending federation and assert that the new member has been added. Along with the previous members.
Something like
assert(pendingFederationSize++)
assert(pendingFederation.hasMember(member)
var pendingFederation = federationStorageProvider.getPendingFederation(); | ||
assertNotNull(pendingFederation); | ||
// We extract here because we will need for util methods | ||
var newFederation = pendingFederation.buildFederation( |
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.
Not sure about building it this way here.
I would build the expectedFederation
, similar to how we are bullding the originalFederation
. Take th public keys + erp constants and use FederationFactory
to build the expected federation. That way we don't use the same code we are testing to make the assertions.
Finally, get the active federation from FederationSupport after the commit and compare against expectedFederation. Makes sense?
voteToAddFederatorPublicKeysToPendingFederation(NEW_FEDERATION_MEMBERS); | ||
|
||
var pendingFederation = federationStorageProvider.getPendingFederation(); | ||
assertNotNull(pendingFederation); |
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.
assert size and members?
assertTrue(lastRetiredFederationP2SHScriptOptional.isPresent()); | ||
Script lastRetiredFederationP2SHScript = lastRetiredFederationP2SHScriptOptional.get(); | ||
|
||
if (ACTIVATIONS.isActive(ConsensusRule.RSKIP377)){ |
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 expect all RSKIPs to be active
|
||
private void assertMigrationHasStarted() throws Exception { | ||
// Pegouts waiting for confirmations should not be empty | ||
assertFalse(bridgeStorageProvider.getPegoutsWaitingForConfirmations().getEntries().isEmpty()); |
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.
Maybe we can check that there is only one element? Should be the case as long as there are less than 50 UTXOs to migrate
.map(Entry::getBtcTransaction) | ||
.toList(); | ||
|
||
if (ACTIVATIONS.isActive(ConsensusRule.RSKIP428)) { |
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.
should be active
newFederation.getAddress(), originalFederation.getAddress()); | ||
assertMigrationHasStarted(); | ||
verifySigHashes(); | ||
verifyPegoutTransactionCreatedEventWasEmitted(); |
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.
There are other events that should be emitted as well
Description
The idea is to provide building blocks that can be reused while creating new tests. This focuses on creating a new active and retiring federation.