Skip to content

Commit

Permalink
Merge pull request #353 from rsksmart/fix/state_svp_client
Browse files Browse the repository at this point in the history
Some fixes with how the powpeg node interacts with the SVP protocol
  • Loading branch information
marcos-iov authored Dec 9, 2024
2 parents 3f2cf80 + ff50368 commit 5244d90
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -240,10 +240,12 @@ public void onBestBlock(org.ethereum.core.Block block, List<TransactionReceipt>

// Sign svp spend tx waiting for signatures, if it exists,
// before attempting to sign any pegouts.
federatorSupport.getStateForProposedFederator()
.map(StateForProposedFederator::getSvpSpendTxWaitingForSignatures)
.filter(svpSpendTxWaitingForSignatures -> isSVPSpendTxReadyToSign(block.getNumber(), svpSpendTxWaitingForSignatures))
.ifPresent(svpSpendTxReadyToBeSigned -> processReleases(Set.of(svpSpendTxReadyToBeSigned)));
if (activationConfig.isActive(ConsensusRule.RSKIP419, block.getNumber())) {
federatorSupport.getStateForProposedFederator()
.map(StateForProposedFederator::getSvpSpendTxWaitingForSignatures)
.filter(svpSpendTxWaitingForSignatures -> isSVPSpendTxReadyToSign(block.getNumber(), svpSpendTxWaitingForSignatures))
.ifPresent(svpSpendTxReadyToBeSigned -> processReleases(Set.of(svpSpendTxReadyToBeSigned)));
}

// Processing transactions waiting for signatures on best block only still "works",
// since it all lies within RSK's blockchain and normal rules apply. I.e., this
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ private void updateProposedFederation() {
boolean hasProposedFederationChanged = !currentlyProposedFederationAddress.equals(oldProposedFederationAddress);

if (hasProposedFederationChanged) {
logger.info("[updateRetiringFederation] Proposed federation changed from {} to {}",
logger.info("[updateProposedFederation] Proposed federation changed from {} to {}",
oldProposedFederationAddress.orElse(null),
currentlyProposedFederationAddress.orElse(null));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@
import java.util.concurrent.atomic.AtomicReference;
import java.util.stream.Collectors;
import java.util.stream.Stream;

import org.ethereum.config.blockchain.upgrades.ConsensusRule;
import org.ethereum.config.Constants;
import org.ethereum.config.blockchain.upgrades.ActivationConfig;
import org.ethereum.core.Block;
Expand Down Expand Up @@ -740,9 +740,12 @@ void onBestBlock_whenOnlySvpSpendTxWaitingForSignaturesIsAvailable_shouldAddSign
mock(NodeBlockProcessor.class)
);

ActivationConfig activationConfig = mock(ActivationConfig.class);
when(activationConfig.isActive(ConsensusRule.RSKIP419, bestBlock.getNumber())).thenReturn(true);

btcReleaseClient.setup(
signer,
mock(ActivationConfig.class),
activationConfig,
signerMessageBuilderFactory,
releaseCreationInformationGetter,
mock(ReleaseRequirementsEnforcer.class),
Expand Down Expand Up @@ -853,9 +856,12 @@ void onBestBlock_whenBothPegoutAndSvpSpendTxWaitingForSignaturesAreAvailableAndF
mock(NodeBlockProcessor.class)
);

ActivationConfig activationConfig = mock(ActivationConfig.class);
when(activationConfig.isActive(ConsensusRule.RSKIP419, bestBlock.getNumber())).thenReturn(true);

btcReleaseClient.setup(
signer,
mock(ActivationConfig.class),
activationConfig,
signerMessageBuilderFactory,
releaseCreationInformationGetter,
mock(ReleaseRequirementsEnforcer.class),
Expand Down Expand Up @@ -971,9 +977,12 @@ void onBestBlock_whenBothPegoutAndSvpSpendTxWaitingForSignaturesIsAvailable_shou
mock(NodeBlockProcessor.class)
);

ActivationConfig activationConfig = mock(ActivationConfig.class);
when(activationConfig.isActive(ConsensusRule.RSKIP419, bestBlock.getNumber())).thenReturn(true);

btcReleaseClient.setup(
signer,
mock(ActivationConfig.class),
activationConfig,
signerMessageBuilderFactory,
releaseCreationInformationGetter,
mock(ReleaseRequirementsEnforcer.class),
Expand Down

0 comments on commit 5244d90

Please sign in to comment.