Skip to content
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

CORE-8856 Adding lambda to suspendible function to trigger bug #6149

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import net.corda.e2etest.utilities.startRestFlow
import net.corda.v5.crypto.SecureHash
import org.assertj.core.api.Assertions.assertThat
import org.junit.jupiter.api.BeforeAll
import org.junit.jupiter.api.RepeatedTest
import org.junit.jupiter.api.Test
import org.junit.jupiter.api.TestInfo
import org.junit.jupiter.api.TestInstance
Expand Down Expand Up @@ -109,7 +110,7 @@ class UtxoLedgerTests : ClusterReadiness by ClusterReadinessChecker() {
}


@Test
@RepeatedTest(100)
fun `Utxo Ledger - create a transaction containing states and finalize it then evolve it`(testInfo: TestInfo) {
val idGenerator = TestRequestIdGenerator(testInfo)
val input = "test input"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import net.corda.ledger.utxo.flow.impl.transaction.UtxoSignedTransactionInternal
import net.corda.ledger.utxo.flow.impl.transaction.UtxoSignedTransactionWithDependencies
import net.corda.sandbox.CordaSystemFlow
import net.corda.utilities.debug
import net.corda.utilities.trace
import net.corda.utilities.info
import net.corda.v5.application.crypto.DigitalSignatureAndMetadata
import net.corda.v5.application.flows.CordaInject
import net.corda.v5.application.messaging.FlowMessaging
Expand Down Expand Up @@ -86,7 +86,7 @@ class UtxoFinalityFlowV1(
val transferAdditionalSignatures = sessions.size > 1

addTransactionIdToFlowContext(flowEngine, transactionId)
log.trace("Starting finality flow for transaction: {}", transactionId)
log.info { "Starting finality flow for transaction: $transactionId" }
verifyExistingSignatures(initialTransaction)
verifyTransaction(initialTransaction)

Expand Down Expand Up @@ -115,14 +115,14 @@ class UtxoFinalityFlowV1(
val (notarizedTransaction, notarySignatures) = notarize(transaction, filteredTransactionsAndSignatures)
persistNotarizedTransaction(notarizedTransaction)
sendNotarySignaturesToCounterparties(notarySignatures)
log.trace("Finalisation of transaction {} has been finished.", transactionId)
log.info { "Finalisation of transaction $transactionId has been finished." }
return notarizedTransaction
}

@Suspendable
private fun persistUnverifiedTransaction() {
persistenceService.persist(initialTransaction, TransactionStatus.UNVERIFIED)
log.debug { "Recorded transaction with initial signatures $transactionId" }
log.info { "Recorded transaction with initial signatures $transactionId" }
}

// Send initialTransaction, transferAdditionalSignatures, and filteredTransactionsAndSignatures
Expand All @@ -144,7 +144,7 @@ class UtxoFinalityFlowV1(
if (initialTransaction.dependencies.isNotEmpty()) {
flowEngine.subFlow(TransactionBackchainSenderFlow(initialTransaction.id, it))
} else {
log.trace {
log.info {
"Transaction with id ${initialTransaction.id} has no dependencies so backchain resolution will not be performed."
}
}
Expand Down Expand Up @@ -190,17 +190,17 @@ class UtxoFinalityFlowV1(
is Payload.Failure<*> -> {
val message = "Failed to receive signatures from ${session.counterparty} for transaction " +
"$transactionId with message: ${signaturesPayload.message}"
log.warn(message)
log.info { message }
persistInvalidTransaction(initialTransaction)
throw CordaRuntimeException(message)
}
}

log.debug { "Received ${signatures.size} signature(s) from ${session.counterparty} for transaction $transactionId" }
log.info { "Received ${signatures.size} signature(s) from ${session.counterparty} for transaction $transactionId" }

signatures.forEach { signature ->
transaction = verifyAndAddSignature(transaction, signature)
log.debug {
log.info {
"Added signature $signature by (key id) ${signature.by} from ${session.counterparty} for transaction " +
transactionId
}
Expand All @@ -220,7 +220,7 @@ class UtxoFinalityFlowV1(
transaction: UtxoSignedTransactionInternal,
signaturesReceivedFromSessions: Map<FlowSession, List<DigitalSignatureAndMetadata>>
) {
log.debug { "Verifying all signatures for transaction $transactionId." }
log.info { "Verifying all signatures for transaction $transactionId." }

try {
transaction.verifySignatorySignatures()
Expand All @@ -237,7 +237,7 @@ class UtxoFinalityFlowV1(
val message = "Transaction $transactionId is missing signatures for signatories (key ids) " +
"${e.missingSignatories.map { it.fullId() }}. The following counterparties provided signatures while finalizing " +
"the transaction: $counterpartiesToSignatoriesMessage"
log.warn(message)
log.info { message }
persistInvalidTransaction(transaction)
throw TransactionMissingSignaturesException(transactionId, e.missingSignatories, message)
}
Expand All @@ -246,7 +246,7 @@ class UtxoFinalityFlowV1(
@Suspendable
private fun persistCounterpartySignatures(id: SecureHash, newSignatures: Set<DigitalSignatureAndMetadata>) {
persistenceService.persistTransactionSignatures(id, newSignatures)
log.debug { "Recorded transaction with all parties' signatures $transactionId" }
log.info { "Recorded transaction with all parties' signatures $transactionId" }
}

@Suspendable
Expand All @@ -260,9 +260,9 @@ class UtxoFinalityFlowV1(
it !in signatures // These came from that party
}
}.toMap()
log.trace { "Sending updated signatures to counterparties for transaction $transactionId" }
log.info { "Sending updated signatures to counterparties for transaction $transactionId" }
flowMessaging.sendAllMap(notSeenSignaturesBySessions)
log.debug { "Sent updated signatures to counterparties for transaction $transactionId" }
log.info { "Sent updated signatures to counterparties for transaction $transactionId" }
}

@Suppress("ThrowsCount")
Expand All @@ -283,10 +283,10 @@ class UtxoFinalityFlowV1(
)
// `log.trace {}` and `log.debug {}` are not used in this method due to a Quasar issue.
if (log.isTraceEnabled) {
log.trace(
log.info {
"Notarizing transaction $transactionId using pluggable notary client flow of " +
"${notarizationFlow::class.java.name} with notary $notary. Attempt number $attemptNumber"
)
}
}
flowEngine.subFlow(notarizationFlow)
}
Expand All @@ -299,16 +299,16 @@ class UtxoFinalityFlowV1(
notarySignatures = notarize(++attemptNumber)
break
} catch (e: NotaryExceptionGeneral) {
log.warn(
log.info {
"Received general error from notarization for transaction: ${transaction.id} on attempt: $attemptNumber. " +
"Error: ${e.message} Retrying notarisation."
)
}
continue
} catch (e: NotaryExceptionUnknown) {
log.warn(
log.info {
"Received unknown error from notarization for transaction: ${transaction.id} on attempt: $attemptNumber. " +
"Error: ${e.message} Retrying notarisation."
)
}
continue
} catch (e: CordaRuntimeException) {
val (message, failureReason) = if (e is NotaryExceptionFatal) {
Expand All @@ -322,22 +322,22 @@ class UtxoFinalityFlowV1(
Payload.Failure<List<DigitalSignatureAndMetadata>>(message, failureReason.value),
sessions.toSet()
)
log.warn(message)
log.info { message }
throw e
}
}

if (log.isTraceEnabled) {
log.trace(
log.info {
"Received ${notarySignatures.size} signature(s) from notary $notary after requesting notarization of transaction " +
transactionId
)
}
}

if (notarySignatures.isEmpty()) {
val message =
"Notary $notary did not return any signatures after requesting notarization of transaction $transactionId"
log.warn(message)
log.info { message }
persistInvalidTransaction(transaction)
flowMessaging.sendAll(
Payload.Failure<List<DigitalSignatureAndMetadata>>(
Expand Down Expand Up @@ -366,9 +366,9 @@ class UtxoFinalityFlowV1(
}

if (log.isDebugEnabled) {
log.debug(
log.debug {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You probably need to ensure that the tests are running at debug level, not sure if they do or not.

"Successfully notarized transaction $transactionId using notary $notary and received ${notarySignatures.size} signature(s)"
)
}
}

return notarizedTransaction to notarySignatures
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ inline fun Logger.debug(msg: () -> String) {
if (isDebugEnabled) debug(msg())
}

inline fun Logger.info(msg: () -> String) {
info(msg())
}

/**
* Extension method for easier construction of [Duration]s in terms of integer days: `val twoDays = 2.days`.
* @see Duration.ofDays
Expand Down