-
Notifications
You must be signed in to change notification settings - Fork 267
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
Svp success #2854
Svp success #2854
Conversation
Dependency Review✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.OpenSSF Scorecard
Scanned Manifest Files |
8c79e6e
to
41fccdc
Compare
if (activations.isActive(RSKIP186)) { | ||
// since we are creating the to-be-active-fed in this block, | ||
// its creation block height is this block number | ||
saveFederationChangeInfo(rskExecutionBlock.getNumber()); | ||
} |
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 is being done in handover
method now
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.
removing the re-declaration of activations since its being done in the setUp
|
||
public static Script getFederationMembersP2SHScript(ActivationConfig.ForBlock activations, Federation federation) { | ||
// when the federation is a standard multisig, | ||
// the members p2sh script is the p2sh script |
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.
nit: I think there's space for this to be in a single line with the above. It's a bit confusing I think.
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.
updated
} | ||
|
||
// when the federation also has erp keys, | ||
// the members p2sh script is the default p2sh script |
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.
The same 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.
updated!
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.
Looking good, just once thing we might what to make the base branch this one #2857
@@ -52,8 +53,7 @@ | |||
import java.util.List; | |||
import java.util.stream.Collectors; | |||
|
|||
import static org.ethereum.config.blockchain.upgrades.ConsensusRule.RSKIP284; | |||
import static org.ethereum.config.blockchain.upgrades.ConsensusRule.RSKIP293; | |||
import static org.ethereum.config.blockchain.upgrades.ConsensusRule.*; |
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.
nit: move the static imports to top file
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.
updated
if (!(federation instanceof ErpFederation)) { | ||
return federation.getP2SHScript(); | ||
} | ||
|
||
// when the federation also has erp keys, | ||
// the members p2sh script is the default p2sh script | ||
return ((ErpFederation) federation).getDefaultP2SHScript(); |
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.
Is there a way we can avoid doing explicit casting?
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 right now
Federation currentOldFederation = provider.getOldFederation(constants, activations); | ||
Federation currentNewFederation = provider.getNewFederation(constants, activations); | ||
logCommitmentWithVotedFederation(eventLogger, currentOldFederation, currentNewFederation); | ||
|
||
return FederationChangeResponseCode.SUCCESSFUL; | ||
} | ||
|
||
public void commitProposedFederation() { | ||
Federation proposedFederation = provider.getProposedFederation(constants, activations) | ||
.orElseThrow(IllegalStateException::new); |
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.
nit: big identation, only four spaces
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!
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.
updated
List<UTXO> utxosToMove = new ArrayList<>(provider.getNewFederationBtcUTXOs(constants.getBtcParams(), activations)); | ||
// since the current active fed reference will change from being 'new' to 'old', | ||
// we have to change the UTXOs reference to match it | ||
List<UTXO> activeFederationUTXOs = new ArrayList<>(provider.getNewFederationBtcUTXOs(constants.getBtcParams(), activations)); |
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.
why pass the list to the constructor of another list?
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 think is to create a shallow copy of the list before clear the original one. Btw, you can do this instead:
List<UTXO> activeFederationUTXOs = new ArrayList<>(provider.getNewFederationBtcUTXOs(constants.getBtcParams(), activations)); | |
List<UTXO> activeFederationUTXOs = provider.getNewFederationBtcUTXOs(constants.getBtcParams(), activations).stream().toList(); |
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.
Or simply use List.copyOf
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.
updated
import co.rsk.peg.utils.BridgeEventLogger; | ||
import co.rsk.peg.utils.BridgeEventLoggerImpl; | ||
import co.rsk.test.builders.BridgeSupportBuilder; | ||
import java.io.IOException; | ||
import java.util.*; | ||
import java.util.stream.IntStream; | ||
|
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.
nit: remove blank line
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.
updated
import static co.rsk.peg.BridgeUtils.getFederationMembersP2SHScript; | ||
import static co.rsk.peg.bitcoin.BitcoinTestUtils.flatKeysAsByteArray; | ||
import static org.ethereum.config.blockchain.upgrades.ConsensusRule.RSKIP377; | ||
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; |
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.
nit: I would move the static imports to the top for consistency
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.
updated
20afc09
to
1d0aabe
Compare
rskj-core/src/main/java/co/rsk/peg/federation/FederationSupportImpl.java
Show resolved
Hide resolved
rskj-core/src/test/java/co/rsk/peg/federation/VoteFederationChangeTest.java
Outdated
Show resolved
Hide resolved
} | ||
|
||
@Test | ||
void registerBtcTransaction_whenIsTheSpendTransaction_shouldProcessSpendTx() throws BlockStoreException, BridgeIllegalArgumentException, IOException { | ||
void registerBtcTransaction_whenIsNotTheSpendTransaction_shouldNotProcessSpendTx() throws BlockStoreException, BridgeIllegalArgumentException, IOException { |
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 we add the test cases when tx is a PEGIN or UNKNOWN also?
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.
the pegin case could be, the unknown i dont think is necessary.
but we definitely should be testing that the spend tx is being processed even when it does not have the minimum pegin value! So thanks
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 is interesting, if the spend tx is below the min peg-in value I don't think the powpeg will inform it to the Bridge
} | ||
|
||
@Test | ||
void registerBtcTransaction_whenSpendTransactionHashIsNotSaved_shouldNotProcessSpendTx() throws BlockStoreException, BridgeIllegalArgumentException, IOException { | ||
void registerBtcTransaction_whenIsTheSpendTransaction_shouldProcessSpendTxAndSvpSuccess() throws BlockStoreException, BridgeIllegalArgumentException, IOException { |
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 think we are missing some border cases:
- Trying to register the spend transaction for a second time. What is the expected result?
- Trying to register the spend transaction spent by the ERP Flow. I guess it should be registered if the transaction arrives on time.
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.
- Trying to register the spend transaction for a second time. What is the expected result?
the tx is being marked as processed when registered, same as any other tx. So it won't be registered again. I will add a test for that case
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.
- Trying to register the spend transaction spent by the ERP Flow. I guess it should be registered if the transaction arrives on time.
Well, no. We specifically wanna test that the proposed federators can spend.
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 I followed the second part, you need a year to sign ith the ERP flow
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.
True, the value set is 1 year. But shouldn't we also check that we can spend using the ERP Flow? Just an idea that came to my mind.
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.
@@ -619,4 +619,17 @@ public static int calculatePegoutTxSize(ActivationConfig.ForBlock activations, F | |||
|
|||
return baseSize + signingSize; | |||
} | |||
|
|||
public static Script getFederationMembersP2SHScript(ActivationConfig.ForBlock activations, Federation federation) { |
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 is quite confusing, really hard to understand what's going on.
What's the idea? Get the default p2sh script or the full p2sh script? Seems like any of those can be achieved through Federation class methods
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.
updated
List<UTXO> utxosToMove = new ArrayList<>(provider.getNewFederationBtcUTXOs(constants.getBtcParams(), activations)); | ||
// since the current active fed reference will change from being 'new' to 'old', | ||
// we have to change the UTXOs reference to match it | ||
List<UTXO> activeFederationUTXOs = new ArrayList<>(provider.getNewFederationBtcUTXOs(constants.getBtcParams(), activations)); |
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.
Or simply use List.copyOf
} | ||
|
||
@Test | ||
void registerBtcTransaction_whenSpendTransactionHashIsNotSaved_shouldNotProcessSpendTx() throws BlockStoreException, BridgeIllegalArgumentException, IOException { | ||
void registerBtcTransaction_whenIsTheSpendTransaction_shouldProcessSpendTxAndSvpSuccess() throws BlockStoreException, BridgeIllegalArgumentException, IOException { |
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 I followed the second part, you need a year to sign ith the ERP flow
…e called from bridge
9628200
to
f1dad07
Compare
Quality Gate passedIssues Measures |
2ae9834
into
feature/powpeg_validation_protocol-phase4
No description provided.