Skip to content

Commit

Permalink
fix(weaver-corda): throw error correctly in responder flows
Browse files Browse the repository at this point in the history
    docs(weaver-rfcs): remove master from github link and fix to tag

Signed-off-by: Sandeep Nishad <sandeep.nishad1@ibm.com>
  • Loading branch information
sandeepnRES authored and petermetz committed Jul 10, 2023
1 parent 6d012c7 commit b888a5e
Show file tree
Hide file tree
Showing 8 changed files with 61 additions and 41 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,9 @@ class CreateAccessControlPolicyResponder(val session: FlowSession) : FlowLogic<S
println("${ourIdentity} signed transaction.")
return subFlow(ReceiveFinalityFlow(session, expectedTxId = txId))
} catch (e: Exception) {
println("Error during transaction by ${ourIdentity}: ${e.message}\n")
return subFlow(ReceiveFinalityFlow(session))
val errorMsg = "Error during transaction by ${ourIdentity}: ${e.message}\n"
println(errorMsg)
throw Error(errorMsg)
}
}
}
Expand Down Expand Up @@ -207,8 +208,9 @@ class UpdateAccessControlPolicyStateResponder(val session: FlowSession) : FlowLo
println("${ourIdentity} signed transaction.")
return subFlow(ReceiveFinalityFlow(session, expectedTxId = txId))
} catch (e: Exception) {
println("Error during transaction by ${ourIdentity}: ${e.message}\n")
return subFlow(ReceiveFinalityFlow(session))
val errorMsg = "Error during transaction by ${ourIdentity}: ${e.message}\n"
println(errorMsg)
throw Error(errorMsg)
}
}
}
Expand Down Expand Up @@ -285,8 +287,9 @@ class DeleteAccessControlPolicyStateResponder(val session: FlowSession) : FlowLo
println("${ourIdentity} signed transaction.")
return subFlow(ReceiveFinalityFlow(session, expectedTxId = txId))
} catch (e: Exception) {
println("Error during transaction by ${ourIdentity}: ${e.message}\n")
return subFlow(ReceiveFinalityFlow(session))
val errorMsg = "Error during transaction by ${ourIdentity}: ${e.message}\n"
println(errorMsg)
throw Error(errorMsg)
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -160,8 +160,9 @@ object LockAssetHTLC {
println("Issuer signed transaction.")
return subFlow(ReceiveFinalityFlow(session, expectedTxId = txId))
} catch (e: Exception) {
println("Error signing unlock asset transaction by Issuer: ${e.message}\n")
return subFlow(ReceiveFinalityFlow(session))
val errorMsg = "Error signing lock asset transaction: ${e.message}\n"
println(errorMsg)
throw Error(errorMsg)
}
} else if (role == ResponderRole.RECIPIENT) {
val signTransactionFlow = object : SignTransactionFlow(session) {
Expand All @@ -176,8 +177,9 @@ object LockAssetHTLC {
println("Recipient signed transaction.")
return subFlow(ReceiveFinalityFlow(session, expectedTxId = txId))
} catch (e: Exception) {
println("Error signing unlock asset transaction by Recipient: ${e.message}\n")
return subFlow(ReceiveFinalityFlow(session))
val errorMsg = "Error signing lock asset transaction by Recipient: ${e.message}\n"
println(errorMsg)
throw Error(errorMsg)
}
} else if (role == ResponderRole.OBSERVER) {
val sTx = subFlow(ReceiveFinalityFlow(session, statesToRecord = StatesToRecord.ALL_VISIBLE))
Expand Down Expand Up @@ -447,8 +449,9 @@ object ClaimAssetHTLC {
println("Issuer signed transaction.")
return subFlow(ReceiveFinalityFlow(session, expectedTxId = txId))
} catch (e: Exception) {
println("Error signing claim asset transaction by issuer: ${e.message}\n")
return subFlow(ReceiveFinalityFlow(session))
val errorMsg = "Error signing claim asset transaction: ${e.message}\n"
println(errorMsg)
throw Error(errorMsg)
}
} else if (role == ResponderRole.LOCKER) {
val sTx = subFlow(ReceiveFinalityFlow(session))
Expand Down Expand Up @@ -586,8 +589,9 @@ object UnlockAssetHTLC {
println("Issuer signed transaction.")
return subFlow(ReceiveFinalityFlow(session, expectedTxId = txId))
} catch (e: Exception) {
println("Error signing unlock asset transaction by Issuer: ${e.message}\n")
return subFlow(ReceiveFinalityFlow(session))
val errorMsg = "Error signing unlock asset transaction: ${e.message}\n"
println(errorMsg)
throw Error(errorMsg)
}
} else if (role == ResponderRole.LOCKER) {
val signTransactionFlow = object : SignTransactionFlow(session) {
Expand All @@ -603,8 +607,9 @@ object UnlockAssetHTLC {
println("Locker signed transaction.")
return subFlow(ReceiveFinalityFlow(session, expectedTxId = txId))
} catch (e: Exception) {
println("Error signing unlock asset transaction by Locker: ${e.message}\n")
return subFlow(ReceiveFinalityFlow(session))
val errorMsg = "Error signing unlock asset transaction by Locker: ${e.message}\n"
println(errorMsg)
throw Error(errorMsg)
}
} else if (role == ResponderRole.RECIPIENT) {
val sTx = subFlow(ReceiveFinalityFlow(session))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -188,8 +188,9 @@ object PledgeAsset {
println("Issuer signed transaction.")
return subFlow(ReceiveFinalityFlow(session, expectedTxId = txId))
} catch (e: Exception) {
println("Error signing unlock asset transaction by Issuer: ${e.message}\n")
return subFlow(ReceiveFinalityFlow(session))
val errorMsg = "Error signing unlock asset transaction: ${e.message}\n"
println(errorMsg)
throw Error(errorMsg)
}
} else if (role == AssetTransferResponderRole.OBSERVER) {
val sTx = subFlow(ReceiveFinalityFlow(session, statesToRecord = StatesToRecord.ALL_VISIBLE))
Expand Down Expand Up @@ -607,8 +608,9 @@ object ReclaimPledgedAsset {
println("Issuer signed transaction.")
return subFlow(ReceiveFinalityFlow(session, expectedTxId = txId))
} catch (e: Exception) {
println("Error signing reclaim asset transaction by Issuer: ${e.message}\n")
return subFlow(ReceiveFinalityFlow(session))
val errorMsg = "Error signing reclaim asset transaction: ${e.message}\n"
println(errorMsg)
throw Error(errorMsg)
}
} else if (role == AssetTransferResponderRole.PLEDGER) {
val signTransactionFlow = object : SignTransactionFlow(session) {
Expand All @@ -624,8 +626,9 @@ object ReclaimPledgedAsset {
println("Locker signed transaction.")
return subFlow(ReceiveFinalityFlow(session, expectedTxId = txId))
} catch (e: Exception) {
println("Error signing reclaim asset transaction by Locker: ${e.message}\n")
return subFlow(ReceiveFinalityFlow(session))
val errorMsg = "Error signing reclaim asset transaction by Locker: ${e.message}\n"
println(errorMsg)
throw Error(errorMsg)
}
} else if (role == AssetTransferResponderRole.OBSERVER) {
val sTx = subFlow(ReceiveFinalityFlow(session, statesToRecord = StatesToRecord.ALL_VISIBLE))
Expand Down Expand Up @@ -862,8 +865,9 @@ object ClaimRemoteAsset {
println("Party: ${ourIdentity} signed transaction.")
return subFlow(ReceiveFinalityFlow(session, expectedTxId = txId))
} catch (e: Exception) {
println("Error signing claim asset transaction by issuer: ${e.message}\n")
return subFlow(ReceiveFinalityFlow(session))
val errorMsg = "Error signing claim asset transaction: ${e.message}\n"
println(errorMsg)
throw Error(errorMsg)
}
} else if (role == AssetTransferResponderRole.OBSERVER) {
val sTx = subFlow(ReceiveFinalityFlow(session, statesToRecord = StatesToRecord.ALL_VISIBLE))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,9 @@ class CreateMembershipStateResponder(val session: FlowSession) : FlowLogic<Signe
println("${ourIdentity} signed transaction.")
return subFlow(ReceiveFinalityFlow(session, expectedTxId = txId))
} catch (e: Exception) {
println("Error during transaction by ${ourIdentity}: ${e.message}\n")
return subFlow(ReceiveFinalityFlow(session))
val errorMsg = "Error during transaction by ${ourIdentity}: ${e.message}\n"
println(errorMsg)
throw Error(errorMsg)
}
}
}
Expand Down Expand Up @@ -188,8 +189,9 @@ class UpdateMembershipStateResponder(val session: FlowSession) : FlowLogic<Signe
println("${ourIdentity} signed transaction.")
return subFlow(ReceiveFinalityFlow(session, expectedTxId = txId))
} catch (e: Exception) {
println("Error during transaction by ${ourIdentity}: ${e.message}\n")
return subFlow(ReceiveFinalityFlow(session))
val errorMsg = "Error during transaction by ${ourIdentity}: ${e.message}\n"
println(errorMsg)
throw Error(errorMsg)
}
}
}
Expand Down Expand Up @@ -265,8 +267,9 @@ class DeleteMembershipStateResponder(val session: FlowSession) : FlowLogic<Signe
println("${ourIdentity} signed transaction.")
return subFlow(ReceiveFinalityFlow(session, expectedTxId = txId))
} catch (e: Exception) {
println("Error during transaction by ${ourIdentity}: ${e.message}\n")
return subFlow(ReceiveFinalityFlow(session))
val errorMsg = "Error during transaction by ${ourIdentity}: ${e.message}\n"
println(errorMsg)
throw Error(errorMsg)
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,8 +138,9 @@ class Acceptor(val session: FlowSession) : FlowLogic<SignedTransaction>() {
println("Network member signed transaction.")
return subFlow(ReceiveFinalityFlow(session, expectedTxId = txId))
} catch (e: Exception) {
println("Error signing create network id transaction by network member: ${e.message}\n")
return subFlow(ReceiveFinalityFlow(session))
val errorMsg = "Error signing create network id transaction by network member: ${e.message}\n"
println(errorMsg)
throw Error(errorMsg)
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,9 @@ class CreateVerificationPolicyStateResponder(val session: FlowSession) : FlowLog
println("${ourIdentity} signed transaction.")
return subFlow(ReceiveFinalityFlow(session, expectedTxId = txId))
} catch (e: Exception) {
println("Error during transaction by ${ourIdentity}: ${e.message}\n")
return subFlow(ReceiveFinalityFlow(session))
val errorMsg = "Error during transaction by ${ourIdentity}: ${e.message}\n"
println(errorMsg)
throw Error(errorMsg)
}
}
}
Expand Down Expand Up @@ -192,8 +193,9 @@ class UpdateVerificationPolicyStateResponder(val session: FlowSession) : FlowLog
println("${ourIdentity} signed transaction.")
return subFlow(ReceiveFinalityFlow(session, expectedTxId = txId))
} catch (e: Exception) {
println("Error during transaction by ${ourIdentity}: ${e.message}\n")
return subFlow(ReceiveFinalityFlow(session))
val errorMsg = "Error during transaction by ${ourIdentity}: ${e.message}\n"
println(errorMsg)
throw Error(errorMsg)
}
}
}
Expand Down Expand Up @@ -270,8 +272,9 @@ class DeleteVerificationPolicyStateResponder(val session: FlowSession) : FlowLog
println("${ourIdentity} signed transaction.")
return subFlow(ReceiveFinalityFlow(session, expectedTxId = txId))
} catch (e: Exception) {
println("Error during transaction by ${ourIdentity}: ${e.message}\n")
return subFlow(ReceiveFinalityFlow(session))
val errorMsg = "Error during transaction by ${ourIdentity}: ${e.message}\n"
println(errorMsg)
throw Error(errorMsg)
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,8 +132,9 @@ class WriteExternalStateAcceptor(val session: FlowSession) : FlowLogic<SignedTra
println("Issuer signed transaction.")
return subFlow(ReceiveFinalityFlow(session, expectedTxId = txId))
} catch (e: Exception) {
println("Error signing write external state transaction: ${e.message}\n")
return subFlow(ReceiveFinalityFlow(session))
val errorMsg = "Error signing write external state transaction: ${e.message}\n"
println(errorMsg)
throw Error(errorMsg)
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion weaver/rfcs/models/security/confidentiality.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,5 +46,5 @@ This protocol ensures confidentiality against potentially malicious relays and a
There are different ways in which the above protocol can be realized, and these are listed and discussed in the [appendix](confidentiality-design-choices.md). We use [Protocol #5](./confidentiality-design-choices.md#protocol-5) in the above model, as it is the most secure and usable option, and this is implemented in Weaver as a reference.

Additional notes:
- Initially, Weaver will support encryption and decryption using [ECIES](https://github.com/ethereum/go-ethereum/tree/master/crypto/ecies) but other asymmetric key algorithms may be supported in the future, including with Ed25519 keys.
- Initially, Weaver will support encryption and decryption using [ECIES](https://github.com/ethereum/go-ethereum/tree/v1.11.5/crypto/ecies) but other asymmetric key algorithms may be supported in the future, including with Ed25519 keys.
- We can consider an alternative solution whereby even the applicaton client does not possess the private key, which instead is maintained by the interoperation module in the destination network. But this requires a private key to be disseminated to, and maintained in secondary storage by, multiple nodes. This is both logistically challenging and insecure; hence, we recommend the procedure describes above.

0 comments on commit b888a5e

Please sign in to comment.