Skip to content

Commit

Permalink
Add missing logs and method name to logs.
Browse files Browse the repository at this point in the history
  • Loading branch information
julia-zack committed Oct 16, 2024
1 parent 0bc0589 commit 2352597
Showing 1 changed file with 15 additions and 13 deletions.
28 changes: 15 additions & 13 deletions rskj-core/src/main/java/co/rsk/peg/BridgeSupport.java
Original file line number Diff line number Diff line change
Expand Up @@ -1579,10 +1579,12 @@ public void addSignature(BtcECKey federatorBtcPublicKey, List<byte[]> signatures
Context.propagate(btcContext);

if (svpIsOngoing() && isSvpSpendTx(releaseCreationRskTxHash)) {
logger.trace("[addSignature] Going to sign svp spend transaction with federator public key {}", federatorBtcPublicKey);
addSvpSpendTxSignatures(federatorBtcPublicKey, signatures);
return;
}

logger.trace("[addSignature] Going to sign release transaction with federator public key {}", federatorBtcPublicKey);
addReleaseSignatures(federatorBtcPublicKey, signatures, releaseCreationRskTxHash);
}

Expand All @@ -1594,7 +1596,7 @@ private void addReleaseSignatures(

BtcTransaction releaseTx = provider.getPegoutsWaitingForSignatures().get(releaseCreationRskTxHash);
if (releaseTx == null) {
logger.warn("No tx waiting for signature for hash {}. Probably fully signed already.", releaseCreationRskTxHash);
logger.warn("[addReleaseSignatures] No tx waiting for signature for hash {}. Probably fully signed already.", releaseCreationRskTxHash);
return;
}
if (!areSignaturesEnoughToSignAllTxInputs(releaseTx, signatures)) {
Expand All @@ -1604,7 +1606,7 @@ private void addReleaseSignatures(
Optional<Federation> optionalFederation = getFederationFromPublicKey(federatorPublicKey);
if (optionalFederation.isEmpty()) {
logger.warn(
"[addSignature] Supplied federator btc public key {} does not belong to any of the federators.",
"[addReleaseSignatures] Supplied federator btc public key {} does not belong to any of the federators.",
federatorPublicKey
);
return;
Expand All @@ -1614,7 +1616,7 @@ private void addReleaseSignatures(
Optional<FederationMember> federationMember = federation.getMemberByBtcPublicKey(federatorPublicKey);
if (federationMember.isEmpty()){
logger.warn(
"[addSignature] Supplied federator btc public key {} doest not match any of the federator member btc public keys {}.",
"[addReleaseSignatures] Supplied federator btc public key {} doest not match any of the federator member btc public keys {}.",
federatorPublicKey, federation.getBtcPublicKeys()
);
return;
Expand Down Expand Up @@ -1696,7 +1698,7 @@ private boolean areSignaturesEnoughToSignAllTxInputs(BtcTransaction releaseTx, L
int signaturesSize = signatures.size();

if (inputsSize != signaturesSize) {
logger.warn("Expected {} signatures but received {}.", inputsSize, signaturesSize);
logger.warn("[areSignaturesEnoughToSignAllTxInputs] Expected {} signatures but received {}.", inputsSize, signaturesSize);
return false;
}
return true;
Expand All @@ -1707,12 +1709,12 @@ private void logMissingSignatures(BtcTransaction btcTx, Keccak256 releaseCreatio
int neededSignatures = federation.getNumberOfSignaturesRequired();
int signaturesCount = neededSignatures - missingSignatures;

logger.debug("Tx {} not yet fully signed. Requires {}/{} signatures but has {}",
logger.debug("[logMissingSignatures] Tx {} not yet fully signed. Requires {}/{} signatures but has {}",
releaseCreationRskTxHash, neededSignatures, federation.getSize(), signaturesCount);
}

private void logReleaseBtc(BtcTransaction btcTx, byte[] releaseCreationRskTxHashSerialized) {
logger.info("Tx fully signed {}. Hex: {}", btcTx, Bytes.of(btcTx.bitcoinSerialize()));
logger.info("[logReleaseBtc] Tx fully signed {}. Hex: {}", btcTx, Bytes.of(btcTx.bitcoinSerialize()));
eventLogger.logReleaseBtc(btcTx, releaseCreationRskTxHashSerialized);
}

Expand Down Expand Up @@ -1757,7 +1759,7 @@ private List<TransactionSignature> getTransactionSignatures(BtcECKey federatorBt

if (!federatorBtcPublicKey.verify(sigHash, decodedSignature)) {
logger.warn(
"Signature {} {} is not valid for hash {} and public key {}",
"[getTransactionSignatures] Signature {} {} is not valid for hash {} and public key {}",
i,
Bytes.of(decodedSignature.encodeToDER()),
sigHash,
Expand All @@ -1768,7 +1770,7 @@ private List<TransactionSignature> getTransactionSignatures(BtcECKey federatorBt

TransactionSignature txSig = new TransactionSignature(decodedSignature, BtcTransaction.SigHash.ALL, false);
if (!txSig.isCanonical()) {
logger.warn("Signature {} {} is not canonical.", i, Bytes.of(decodedSignature.encodeToDER()));
logger.warn("[getTransactionSignatures] Signature {} {} is not canonical.", i, Bytes.of(decodedSignature.encodeToDER()));
throw new SignatureException();
}
txSigs.add(txSig);
Expand All @@ -1783,7 +1785,7 @@ private List<BtcECKey.ECDSASignature> getDecodedSignatures(List<byte[]> signatur
decodedSignatures.add(BtcECKey.ECDSASignature.decodeFromDER(signature));
} catch (RuntimeException e) {
int index = signatures.indexOf(signature);
logger.warn("Malformed signature for input {} : {}", index, Bytes.of(signature));
logger.warn("[getDecodedSignatures] Malformed signature for input {} : {}", index, Bytes.of(signature));
throw new SignatureException();
}
}
Expand All @@ -1807,7 +1809,7 @@ private boolean sign(
BridgeUtils.isInputSignedByThisFederator(federatorBtcPublicKey, sigHash, input);

if (alreadySignedByThisFederator) {
logger.warn("Input {} of tx {} already signed by this federator.", i, releaseCreationRskTxHash);
logger.warn("[sign] Input {} of tx {} already signed by this federator.", i, releaseCreationRskTxHash);
break;
}

Expand All @@ -1823,14 +1825,14 @@ private boolean sign(

Script inputScriptWithSignature = outputScript.getScriptSigWithSignature(inputScript, txSigs.get(i).encodeToBitcoin(), sigIndex);
input.setScriptSig(inputScriptWithSignature);
logger.debug("Tx input {} for tx {} signed.", i, releaseCreationRskTxHash);
logger.debug("[sign] Tx input {} for tx {} signed.", i, releaseCreationRskTxHash);
signed = true;
} catch (IllegalStateException e) {
Federation retiringFederation = getRetiringFederation();
if (getActiveFederation().hasBtcPublicKey(federatorBtcPublicKey)) {
logger.debug("A member of the active federation is trying to sign a tx of the retiring one");
logger.debug("[sign] A member of the active federation is trying to sign a tx of the retiring one");
} else if (retiringFederation != null && retiringFederation.hasBtcPublicKey(federatorBtcPublicKey)) {
logger.debug("A member of the retiring federation is trying to sign a tx of the active one");
logger.debug("[sign] A member of the retiring federation is trying to sign a tx of the active one");
}
return false;
}
Expand Down

0 comments on commit 2352597

Please sign in to comment.