CORDA-3060: Notary logging improvements

Add more detailed logging to the notary service flow.
This commit is contained in:
Andrius Dagys 2019-09-12 14:20:46 +01:00
parent 16e4650d8d
commit c7cd947c32
3 changed files with 9 additions and 7 deletions

View File

@ -61,7 +61,7 @@ class NotaryFlow {
logger.info("Sending transaction to notary: ${notaryParty.name}.") logger.info("Sending transaction to notary: ${notaryParty.name}.")
progressTracker.currentStep = REQUESTING progressTracker.currentStep = REQUESTING
val response = notarise(notaryParty) val response = notarise(notaryParty)
logger.info("Notary responded.") logger.info("Notary responded (${notaryParty.name}).")
progressTracker.currentStep = VALIDATING progressTracker.currentStep = VALIDATING
return validateResponse(response, notaryParty) return validateResponse(response, notaryParty)
} }

View File

@ -81,6 +81,7 @@ abstract class NotaryServiceFlow(val otherSideSession: FlowSession, val service:
try { try {
val transaction = extractParts(requestPayload) val transaction = extractParts(requestPayload)
transactionId = transaction.id transactionId = transaction.id
logger.info("Received a notarisation request for Tx [$transactionId] from [${otherSideSession.counterparty.name}]")
checkNotary(transaction.notary) checkNotary(transaction.notary)
checkParameterHash(transaction.networkParametersHash) checkParameterHash(transaction.networkParametersHash)
checkInputs(transaction.inputs + transaction.references) checkInputs(transaction.inputs + transaction.references)
@ -125,6 +126,7 @@ abstract class NotaryServiceFlow(val otherSideSession: FlowSession, val service:
@Suspendable @Suspendable
private fun signTransactionAndSendResponse(txId: SecureHash) { private fun signTransactionAndSendResponse(txId: SecureHash) {
val signature = service.signTransaction(txId) val signature = service.signTransaction(txId)
logger.info("Transaction [$txId] successfully notarised, sending signature back to [${otherSideSession.counterparty.name}]")
otherSideSession.send(NotarisationResponse(listOf(signature))) otherSideSession.send(NotarisationResponse(listOf(signature)))
} }

View File

@ -181,7 +181,7 @@ class PersistentUniquenessProvider(val clock: Clock, val database: CordaPersiste
val future = openFuture<UniquenessProvider.Result>() val future = openFuture<UniquenessProvider.Result>()
val request = CommitRequest(states, txId, callerIdentity, requestSignature, timeWindow, references, future) val request = CommitRequest(states, txId, callerIdentity, requestSignature, timeWindow, references, future)
requestQueue.put(request) requestQueue.put(request)
log.debug { "Request added to queue. txId: $txId" } log.debug { "Request added to queue. TxId: $txId" }
return future return future
} }
@ -247,18 +247,18 @@ class PersistentUniquenessProvider(val clock: Clock, val database: CordaPersiste
private fun handleReferenceConflicts(txId: SecureHash, conflictingStates: LinkedHashMap<StateRef, StateConsumptionDetails>) { private fun handleReferenceConflicts(txId: SecureHash, conflictingStates: LinkedHashMap<StateRef, StateConsumptionDetails>) {
if (!previouslyCommitted(txId)) { if (!previouslyCommitted(txId)) {
val conflictError = NotaryError.Conflict(txId, conflictingStates) val conflictError = NotaryError.Conflict(txId, conflictingStates)
log.info("Failure, input states already committed: ${conflictingStates.keys}. txId: $txId") log.info("Failure, input states already committed: ${conflictingStates.keys}. TxId: $txId")
throw NotaryInternalException(conflictError) throw NotaryInternalException(conflictError)
} }
log.info("Transaction $txId already notarised. txId: $txId") log.info("Transaction $txId already notarised. TxId: $txId")
} }
private fun handleConflicts(txId: SecureHash, conflictingStates: LinkedHashMap<StateRef, StateConsumptionDetails>) { private fun handleConflicts(txId: SecureHash, conflictingStates: LinkedHashMap<StateRef, StateConsumptionDetails>) {
if (isConsumedByTheSameTx(txId.sha256(), conflictingStates)) { if (isConsumedByTheSameTx(txId.sha256(), conflictingStates)) {
log.info("Transaction $txId already notarised. txId: $txId") log.info("Transaction $txId already notarised. TxId: $txId")
return return
} else { } else {
log.info("Failure, input states already committed: ${conflictingStates.keys}. txId: $txId") log.info("Failure, input states already committed: ${conflictingStates.keys}. TxId: $txId")
val conflictError = NotaryError.Conflict(txId, conflictingStates) val conflictError = NotaryError.Conflict(txId, conflictingStates)
throw NotaryInternalException(conflictError) throw NotaryInternalException(conflictError)
} }
@ -277,7 +277,7 @@ class PersistentUniquenessProvider(val clock: Clock, val database: CordaPersiste
} }
val session = currentDBSession() val session = currentDBSession()
session.persist(CommittedTransaction(txId.toString())) session.persist(CommittedTransaction(txId.toString()))
log.info("Successfully committed all input states: $states. txId: $txId") log.info("Successfully committed all input states: $states. TxId: $txId")
} else { } else {
throw NotaryInternalException(outsideTimeWindowError) throw NotaryInternalException(outsideTimeWindowError)
} }