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

Feature/powpeg validation protocol phase4 #2917

Merged
Changes from 1 commit
Commits
Show all changes
101 commits
Select commit Hold shift + click to select a range
afb2a43
feat(peg): add function constants to Bridge for proposed federation
apancorb Oct 23, 2024
e87cc68
Make logs a global variable and remove it from methods arguments. Cre…
julia-zack Oct 21, 2024
aa31cb8
Add unit test for new clearProposedFederation method
julia-zack Oct 23, 2024
aeac614
Improve naming and logs. Create clearSvpValues method in provider to …
julia-zack Oct 29, 2024
bc4df1c
Create updateSvpState method and make all svp-related-methods private
julia-zack Oct 31, 2024
6eec5ca
Correct and make updateSvpState easier to follow
julia-zack Nov 13, 2024
aa33ed6
Do not set last retired fed p2sh script in new commitFederation impl
julia-zack Nov 7, 2024
6e12a55
fix(peg): svp spend tx waiting for signatures double serialization
apancorb Nov 15, 2024
89e43d0
Do not set active federation creation block height before validation
julia-zack Nov 19, 2024
72616eb
Modify public method to remove signatures for just returning the hash…
julia-zack Nov 19, 2024
38839b9
Register spend transaction
julia-zack Nov 19, 2024
06597ec
Create new registerSvpSpendTransaction method. Refactor to make code …
julia-zack Nov 20, 2024
be2a967
Add test for getTxHashWithoutSigs using a real pegout. Minor refactor
julia-zack Nov 21, 2024
87949c8
Create new public method in BridgeUtils to be reused
julia-zack Nov 20, 2024
e164d94
Create new commitProposedFederation public method in fed support to b…
julia-zack Nov 20, 2024
6c50cb3
Process svp success
julia-zack Nov 20, 2024
426b584
Refactor tests and improve comments
julia-zack Nov 21, 2024
1c8c63c
Reorder imports. Fix indentation
julia-zack Nov 22, 2024
5f09ae2
Improve comment
julia-zack Nov 22, 2024
e981cb9
Add test cases when registering spend tx. Rollback moving method to B…
julia-zack Nov 22, 2024
4dfc9e6
Fix Sonar issues
julia-zack Nov 22, 2024
bd9bd6e
Create FederationContext class to hold info avout the currently live …
marcos-iov Nov 21, 2024
a2c339a
Refactor logic in getRetiringFederation method to exit early
marcos-iov Nov 21, 2024
39ede54
Remove constructor from FederationContext only used in tests
marcos-iov Nov 21, 2024
d9b0085
Move javadoc from BridgeSupport to FederationSupport
marcos-iov Nov 21, 2024
1d35552
Update PegUtils.getTransactionType to also identify SVP related trans…
marcos-iov Nov 21, 2024
ea7cd47
Update registerBtcTransaction to consider SVP transaction types
marcos-iov Nov 21, 2024
0c8626e
Fix broken tests in BridgeSupportFlyoverTest class
julia-zack Nov 22, 2024
a21eecb
Add tests for FederationContext class
marcos-iov Nov 22, 2024
dc8c1a7
Refactor FederationContextTest
marcos-iov Nov 22, 2024
c72b5cd
Add tests for FederationSupport
marcos-iov Nov 22, 2024
228b41e
Refactor test setup to make tests independent
marcos-iov Nov 22, 2024
1b577d3
Fix tests. Add tests for fed context
julia-zack Nov 25, 2024
0322aa5
Fix svp tests that broke
julia-zack Nov 25, 2024
bac5bab
Minor refactor to make code cleaner
julia-zack Nov 28, 2024
bae46ff
Reduce switch complexity to avoid sonar complain
julia-zack Nov 28, 2024
4287aab
feat(peg): enhance logging for svp protocol
apancorb Dec 2, 2024
32ad5a1
feat(peg): save svp spend tx signature back to Bridge storage
apancorb Dec 2, 2024
6db74e4
feat(constants): increase svp validation period in regtest
apancorb Dec 2, 2024
cdf365a
refactor(peg): move comments
apancorb Dec 3, 2024
75392e4
refactor(peg): move comments
apancorb Dec 3, 2024
d4241b0
Implement builder pattern in fed context
julia-zack Nov 28, 2024
8c780d4
Rename to be consistent with other builders
julia-zack Dec 3, 2024
8915bfd
Simplify methods to register and process peg-in and peg-outs
marcos-iov Dec 4, 2024
b2fd04f
Rename processPegIn to registerPegIn
marcos-iov Dec 4, 2024
f9aa6f9
Rename processPegoutOrMigration to registerNewUtxos
marcos-iov Dec 4, 2024
4b935ee
Add explanatory comment in registerSvpFundTx
marcos-iov Dec 4, 2024
57bfe37
Refactor and simplify registerSvpSpendTx method
marcos-iov Dec 4, 2024
4241339
Call registerNewUtxos method from executePegIn to save UTXOs and mark…
marcos-iov Dec 4, 2024
a5ad276
Remove global variable svpSpendTransactionHashUnsigned from BridgeSup…
marcos-iov Dec 4, 2024
a274b80
Add new method to assert svp success
marcos-iov Dec 4, 2024
888e317
Remove global variable svpFundTxHashUnsigned from BridgeSupportSvpTest
marcos-iov Dec 4, 2024
4717b28
Mark tx as processed after refund in legacyRegisterPegin
marcos-iov Dec 4, 2024
8a5debf
Register UTXOs and mark tx as processed in the same method
marcos-iov Dec 4, 2024
2914ed6
Improve logging in registerBtcTransaction
marcos-iov Dec 5, 2024
f2da8f5
Mark tx as processed for peg-in v1 rejected if locking cap is exceeded
marcos-iov Dec 5, 2024
b5b6e75
Return active and retiring feds creation time in seconds after lovell
julia-zack Dec 5, 2024
2b0406e
Remove logs that are no longer necessary since the tx type is being l…
julia-zack Dec 5, 2024
9b182cc
Move tests to BridgeTest and use bridgeBuilder
julia-zack Dec 5, 2024
b0c014a
Fix test
julia-zack Dec 6, 2024
c3b2785
refactor(constants): make FederationConstants an abstract class
apancorb Dec 4, 2024
9d656b4
refactor(constants): make upper case for instance var
apancorb Dec 4, 2024
0617c06
feat(constants): make federation regtest constants use a lazy singlet…
apancorb Dec 4, 2024
50d7d86
refactor(constants): sort imports and upper case for static final var…
apancorb Dec 5, 2024
dd5fd63
refactor(constants): default federation public keys for bridge regtest
apancorb Dec 5, 2024
d248b17
feat(constants): add unit tests for lazy singleton pattern for federa…
apancorb Dec 5, 2024
deac9b9
feat(constants): add javadocs for lazy singletons in federation regte…
apancorb Dec 5, 2024
6a4d6b6
feat(constants): move to fed regtest constants unit tests class
apancorb Dec 6, 2024
1b3064f
Use clear methods instead of setting null values
julia-zack Dec 5, 2024
4433084
Add tests for clearSvpFundTxHashUnsigned
marcos-iov Dec 9, 2024
62e3948
Add tests for clearSvpSpendTxHashUnsigned
marcos-iov Dec 9, 2024
1a84264
Add tests for clearSvpSpendTxWaitingForSignatures
marcos-iov Dec 9, 2024
914a7ac
Add tests for clearSvpFundTxSigned
marcos-iov Dec 9, 2024
4bd6364
Use FederationChangeFunctions enum when voting
julia-zack Dec 18, 2024
d64bc12
Refactor to use new java17 switch
julia-zack Dec 19, 2024
b4a07e8
Remove wrong comment. Store call spec public keys arguments in a vari…
julia-zack Jan 6, 2025
0df06af
Remove validationPeriodIsOngoing method
julia-zack Dec 23, 2024
01a58fd
Make code more functional
julia-zack Jan 2, 2025
de24577
Create method to remove utxos used for a release transaction
julia-zack Jan 3, 2025
656908b
Fix the amount being send in svpSpendTx
julia-zack Jan 7, 2025
57d3582
Rename. Make log more accurate
julia-zack Jan 7, 2025
0e9324f
Remove unnecessary tests
julia-zack Jan 7, 2025
e772f46
Get active federation utxos directly
julia-zack Jan 7, 2025
151f415
Clean svp values not being get in execution time
julia-zack Jan 7, 2025
5e899ab
Reuse already declared global variable for spend tx creation hash
julia-zack Jan 8, 2025
351f431
Set info as logging level. Move svp cleaning logs to each specific me…
julia-zack Jan 8, 2025
e260062
Update testnet validation period duration and activation age
julia-zack Dec 23, 2024
d4da76e
Refactor activations name to use hf instead of rskip
julia-zack Jan 2, 2025
944b3f3
Refactor federation constants
marcos-iov Jan 8, 2025
4558f39
Add missing RSKIP419 to expected.conf file
marcos-iov Jan 8, 2025
68a38cf
Remove spendableValueFromProposedFed constant and use minPegoutTxValu…
julia-zack Jan 8, 2025
cefb90e
Add comment
julia-zack Jan 9, 2025
e4fb4c3
Do not shuffle fundTx outputs order
julia-zack Jan 8, 2025
ed6d032
Merge pull request #2918 from rsksmart/simplify_value_sent_in_fundTx
marcos-iov Jan 9, 2025
0f4a2a6
Merge pull request #2919 from rsksmart/fix_outputs_order_in_fundTx
marcos-iov Jan 9, 2025
4dd7d47
Rollback fundtx value change
julia-zack Jan 9, 2025
d1d3af9
Add missing blank line
julia-zack Jan 9, 2025
d8dd412
Fix test
julia-zack Jan 9, 2025
3c53d39
Merge pull request #2924 from rsksmart/rollback_change_in_fundTx_value
marcos-iov Jan 10, 2025
c0de479
Remove assert methods that do not return void
julia-zack Jan 9, 2025
89266ea
Merge pull request #2921 from rsksmart/refactor_svp_tests
marcos-iov Jan 10, 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
Reorder imports. Fix indentation
  • Loading branch information
julia-zack authored and marcos-iov committed Jan 8, 2025

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
commit 1c8c63caf1afb99b771da156dadd33055fc55a49
10 changes: 4 additions & 6 deletions rskj-core/src/main/java/co/rsk/peg/BridgeUtils.java
Original file line number Diff line number Diff line change
@@ -17,6 +17,8 @@
*/
package co.rsk.peg;

import static org.ethereum.config.blockchain.upgrades.ConsensusRule.*;

import co.rsk.bitcoinj.core.*;
import co.rsk.bitcoinj.crypto.TransactionSignature;
import co.rsk.bitcoinj.script.*;
@@ -50,8 +52,6 @@
import java.util.*;
import java.util.stream.Collectors;

import static org.ethereum.config.blockchain.upgrades.ConsensusRule.*;

/**
* @author Oscar Guindzberg
*/
@@ -618,17 +618,15 @@ public static int calculatePegoutTxSize(ActivationConfig.ForBlock activations, F
}

public static Script getFederationMembersP2SHScript(ActivationConfig.ForBlock activations, Federation federation) {
// when the federation is a standard multisig,
// the members p2sh script is the p2sh script
// when the federation is a standard multisig, the members p2sh script is the p2sh script
if (!activations.isActive(RSKIP377)) {
return federation.getP2SHScript();
}
if (!(federation instanceof ErpFederation)) {
return federation.getP2SHScript();
}

// when the federation also has erp keys,
// the members p2sh script is the default p2sh script
// when the federation also has erp keys, the members p2sh script is the default p2sh script
return ((ErpFederation) federation).getDefaultP2SHScript();
}
}
Original file line number Diff line number Diff line change
@@ -706,7 +706,7 @@ private FederationChangeResponseCode legacyCommitPendingFederation(PendingFedera

public void commitProposedFederation() {
Federation proposedFederation = provider.getProposedFederation(constants, activations)
.orElseThrow(IllegalStateException::new);
.orElseThrow(IllegalStateException::new);

handoverToNewFederation(proposedFederation);
clearProposedFederation();
Original file line number Diff line number Diff line change
@@ -35,7 +35,6 @@
import java.io.IOException;
import java.util.*;
import java.util.stream.IntStream;

import co.rsk.test.builders.FederationSupportBuilder;
import org.ethereum.config.blockchain.upgrades.ActivationConfig;
import org.ethereum.config.blockchain.upgrades.ActivationConfigsForTest;
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
package co.rsk.peg.federation;

import static co.rsk.peg.BridgeUtils.getFederationMembersP2SHScript;
import static co.rsk.peg.bitcoin.BitcoinTestUtils.flatKeysAsByteArray;
import static co.rsk.peg.federation.FederationStorageIndexKey.NEW_FEDERATION_BTC_UTXOS_KEY;
import static org.junit.jupiter.api.Assertions.*;
import static org.mockito.Mockito.mock;

import co.rsk.bitcoinj.core.BtcECKey;
import co.rsk.bitcoinj.core.UTXO;
import co.rsk.bitcoinj.script.Script;
@@ -29,18 +35,11 @@
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.Arguments;
import org.junit.jupiter.params.provider.MethodSource;

import java.math.BigInteger;
import java.time.Instant;
import java.util.*;
import java.util.stream.Stream;

import static co.rsk.peg.BridgeUtils.getFederationMembersP2SHScript;
import static co.rsk.peg.bitcoin.BitcoinTestUtils.flatKeysAsByteArray;
import static co.rsk.peg.federation.FederationStorageIndexKey.NEW_FEDERATION_BTC_UTXOS_KEY;
import static org.junit.jupiter.api.Assertions.*;
import static org.mockito.Mockito.mock;

class VoteFederationChangeTest {
private static final FederationConstants federationMainnetConstants = FederationMainNetConstants.getInstance();
private static final BtcECKey federatorBtcKey = BtcECKey.fromPrivate(BigInteger.valueOf(100));