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 new Federation and the complete process until it is confirmed and activated #2925

Merged
Changes from 1 commit
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
2c9a630
feat(federation): setup new structure for PowpegMigrationTest
apancorb Jan 9, 2025
87741bf
feat(federation): add setup methods, commitPendingFederation, and com…
apancorb Jan 10, 2025
3d97aed
feat(federation): implement assertUTXOsMovedFromNewToOldFederation
apancorb Jan 10, 2025
a1d3c01
feat(federation): add locking cap constants to setup method for int test
apancorb Jan 10, 2025
ca26c8c
feat(federation): move to federation change testing logic to new clas…
apancorb Jan 10, 2025
2f726a7
feat(federation): add change of federation with all activations enabl…
apancorb Jan 10, 2025
1191212
feat(federation): refactor the entire class to accomdate new logic
apancorb Jan 14, 2025
355b873
feat(federation): change test name
apancorb Jan 14, 2025
0f5161b
feat(federation): improve existing tests structure for FederationChan…
apancorb Jan 15, 2025
fa32f4c
feat(federation): remove unused imports from FederationChangeIT
apancorb Jan 15, 2025
0813889
feat(federation): add integration test that completes the migration p…
apancorb Jan 16, 2025
690db38
feat(federation): add assert to check if utxos have moved from old to…
apancorb Jan 17, 2025
872aafe
refactor(federation): make one single integration test with all the s…
apancorb Jan 27, 2025
4257af5
refactor(federation): increase local variable scope
apancorb Jan 27, 2025
aea897a
refactor(federation): resolve minor comments
apancorb Jan 27, 2025
7a8541b
feat(federation): add fedActivationAge + fundsMigrationAgeBegin check…
apancorb Jan 27, 2025
63bc842
feat(federation): make update collections constant
apancorb Jan 28, 2025
e44fe2e
feat(federation): resolve comments
apancorb Jan 28, 2025
65cd052
feat(federation): make active federation have 9 members
apancorb Jan 30, 2025
dcadcb4
feat(federation): making the voting of the pending federation realistic
apancorb Jan 30, 2025
dc6fb3f
refactor(federation): many changes to FederationChangeIT class
apancorb Jan 31, 2025
3b207ac
feat(federation): have pending federation be verified after adding a …
apancorb Feb 3, 2025
c414e9f
feat(federation): build expected federation and compare against new f…
apancorb Feb 3, 2025
f5967c7
feat(federation): random UTXOs size to be always less than 50
apancorb Feb 3, 2025
3d6940f
feat(federation): add release requested log check
apancorb Feb 3, 2025
f0224a8
feat(federation): add verify for pegout confirmed event
apancorb Feb 4, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
feat(federation): implement assertUTXOsMovedFromNewToOldFederation
  • Loading branch information
apancorb committed Jan 10, 2025
commit 3d97aedc1f0950e92fad95ef2877487f6735e8d1
Original file line number Diff line number Diff line change
@@ -516,7 +516,7 @@ private void setUpPowpegChange(ActivationConfig.ForBlock activations) {
when(feePerKbSupport.getFeePerKb()).thenReturn(Coin.MILLICOIN);
}

private Federation createOriginalFederation(
private void createOriginalFederation(
FederationType federationType,
List<UTXO> federationAddress,
ActivationConfig.ForBlock activations) {
@@ -556,31 +556,21 @@ private Federation createOriginalFederation(
federationStorageProvider.setNewFederation(originalFederation);
federationStorageProvider.getNewFederationBtcUTXOs(
BRIDGE_MAINNET_CONSTANTS.getBtcParams(), activations).addAll(federationAddress);

return originalFederation;
}

private void commitPendingFederation(
FederationType federationType,
List<Triple<BtcECKey, ECKey, ECKey>> federationKeys,
Address newFederationAddress,
ActivationConfig.ForBlock activations) {
// Create Pending federation (doing this to avoid voting the pending Federation)
var newPowpegMembers = federationKeys.stream()
.map(newPowpegKey ->
var newFederationMembers = federationKeys.stream()
.map(newFederatorKey ->
new FederationMember(
newPowpegKey.getLeft(),
newPowpegKey.getMiddle(),
newPowpegKey.getRight()))
newFederatorKey.getLeft(),
newFederatorKey.getMiddle(),
newFederatorKey.getRight()))
.toList();
var pendingFederation = new PendingFederation(newPowpegMembers);

// Create the Federation just to provide it to utility methods
var newFederation = pendingFederation.buildFederation(
Instant.EPOCH,
0,
BRIDGE_MAINNET_CONSTANTS.getFederationConstants(),
activations);
var pendingFederation = new PendingFederation(newFederationMembers);

// Set pending federation
federationStorageProvider.setPendingFederation(pendingFederation);
@@ -608,6 +598,28 @@ private void commitProposedFederation(ActivationConfig.ForBlock activations) {
federationStorageProvider.getProposedFederation(
BRIDGE_MAINNET_CONSTANTS.getFederationConstants(), activations));
}

private void assertUTXOsMovedFromNewToOldFederation(
Federation oldFederation,
Federation newFederation,
List<UTXO> originalUTXOs,
ActivationConfig.ForBlock activations) {
// Assert old federation exists in storage and matches
assertEquals(
oldFederation,
federationStorageProvider.getOldFederation(BRIDGE_MAINNET_CONSTANTS.getFederationConstants(), activations));
// Assert new federation exists in storage and matches
assertEquals(
newFederation,
federationStorageProvider.getNewFederation(BRIDGE_MAINNET_CONSTANTS.getFederationConstants(), activations));
// Assert old federation holds the original utxos
List<UTXO> utxosToMigrate = federationStorageProvider.getOldFederationBtcUTXOs();
assertTrue(originalUTXOs.stream().allMatch(utxosToMigrate::contains));
// Assert the new federation does not have any utxos yet
assertTrue(federationStorageProvider
.getNewFederationBtcUTXOs(BRIDGE_MAINNET_CONSTANTS.getBtcParams(), activations)
.isEmpty());
}

private void executePowpegChange(
FederationType oldPowPegFederationType,
@@ -652,15 +664,6 @@ private void executePowpegChange(



SignatureCache signatureCache = new BlockTxSignatureCache(new ReceivedTxSignatureCache());
LockingCapStorageProvider lockingCapStorageProvider = new LockingCapStorageProviderImpl(new InMemoryStorage());
LockingCapSupport lockingCapSupport = new LockingCapSupportImpl(
lockingCapStorageProvider,
activations,
LockingCapMainNetConstants.getInstance(),
signatureCache
);

// Trying to create a new powpeg again should fail
// -2 corresponds to a new powpeg was elected and the Bridge is waiting for this new powpeg to activate
BridgeSupport bridgeSupport = BridgeSupportBuilder.builder()