Skip to content

Commit

Permalink
feat(peg): rollback to include current serialization logic for state …
Browse files Browse the repository at this point in the history
…federator

Fix failing test after rebase
  • Loading branch information
apancorb authored and marcos-iov committed Oct 18, 2024
1 parent 243beed commit b557817
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 8 deletions.
9 changes: 6 additions & 3 deletions rskj-core/src/main/java/co/rsk/peg/StateForFederator.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import java.util.Objects;
import java.util.SortedMap;
import org.ethereum.util.RLP;
import org.ethereum.util.RLPList;

public class StateForFederator {

Expand Down Expand Up @@ -52,13 +53,15 @@ public SortedMap<Keccak256, BtcTransaction> getRskTxsWaitingForSignatures() {
* @return The RLP-encoded byte array representing the current state.
*/
public byte[] encodeToRlp() {
return BridgeSerializationUtils.serializeRskTxsWaitingForSignatures(
rskTxsWaitingForSignatures);
byte[] serializedRskTxsWaitingForSignatures =
BridgeSerializationUtils.serializeRskTxsWaitingForSignatures(rskTxsWaitingForSignatures);
return RLP.encodeList(serializedRskTxsWaitingForSignatures);
}

private static byte[] decodeRlpToMap(byte[] rlpData) {
Objects.requireNonNull(rlpData);

return RLP.decode2(rlpData).get(0).getRLPData();
RLPList rlpList = (RLPList) RLP.decode2(rlpData).get(0);
return rlpList.get(0).getRLPData();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -54,13 +54,15 @@ public Map.Entry<Keccak256, BtcTransaction> getSvpSpendTxWaitingForSignatures()
* @return The RLP-encoded byte array representing the current state.
*/
public byte[] encodeToRlp() {
return BridgeSerializationUtils.serializeRskTxWaitingForSignatures(
svpSpendTxWaitingForSignatures);
byte[] serializedSvpSpendTxWaitingForSignatures =
BridgeSerializationUtils.serializeRskTxWaitingForSignatures(svpSpendTxWaitingForSignatures);
return RLP.encodeList(serializedSvpSpendTxWaitingForSignatures);
}

private static byte[] decodeRlpToEntry(byte[] rlpData) {
Objects.requireNonNull(rlpData);

return RLP.decode2(rlpData).get(0).getRLPData();
RLPList rlpList = (RLPList) RLP.decode2(rlpData).get(0);
return rlpList.get(0).getRLPData();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -381,10 +381,11 @@ void removeSignaturesFromTransaction_whenTransactionIsLegacyAndInputsHaveP2shMul
"member03",
"member04",
"member05"
}, true); // using private keys from federation declared above
}, true); // using private keys from federation declared above
List<TransactionInput> inputs = transaction.getInputs();
for (TransactionInput input : inputs) {
BitcoinTestUtils.signTransactionInputFromP2shMultiSig ansaction,
BitcoinTestUtils.signTransactionInputFromP2shMultiSig(
transaction,
inputs.indexOf(input),
keysToSign
);
Expand Down

0 comments on commit b557817

Please sign in to comment.