mirror of
https://github.com/corda/corda.git
synced 2025-01-06 05:04:20 +00:00
Demo bug fixes (#217)
* Add webAddress back to NMS as it shifts the port allocation for all subsequent nodes and causes all demos to break. * Attachment demo: fix node names * Notary demo: fix certificate paths & ports * IRS demo: role decider fixed to allocate roles properly. Previously it used to pick current node as the Fixer, causing both nodes to initiate the trade flow, resulting in double spend exceptions..
This commit is contained in:
parent
e4c2a34611
commit
e737fa5e9f
@ -3,7 +3,7 @@
|
|||||||
<extension name="coverage" enabled="false" merge="false" sample_coverage="true" runner="idea" />
|
<extension name="coverage" enabled="false" merge="false" sample_coverage="true" runner="idea" />
|
||||||
<option name="MAIN_CLASS_NAME" value="net.corda.notarydemo.NotaryDemoKt" />
|
<option name="MAIN_CLASS_NAME" value="net.corda.notarydemo.NotaryDemoKt" />
|
||||||
<option name="VM_PARAMETERS" value="-ea -javaagent:lib/quasar.jar " />
|
<option name="VM_PARAMETERS" value="-ea -javaagent:lib/quasar.jar " />
|
||||||
<option name="PROGRAM_PARAMETERS" value="" />
|
<option name="PROGRAM_PARAMETERS" value="--certificates="build/notary-demo-nodes/Party/certificates"" />
|
||||||
<option name="WORKING_DIRECTORY" value="" />
|
<option name="WORKING_DIRECTORY" value="" />
|
||||||
<option name="ALTERNATIVE_JRE_PATH_ENABLED" value="false" />
|
<option name="ALTERNATIVE_JRE_PATH_ENABLED" value="false" />
|
||||||
<option name="ALTERNATIVE_JRE_PATH" />
|
<option name="ALTERNATIVE_JRE_PATH" />
|
||||||
|
@ -452,13 +452,16 @@ open class DriverDSL(
|
|||||||
|
|
||||||
private fun startNetworkMapService(): ListenableFuture<Process> {
|
private fun startNetworkMapService(): ListenableFuture<Process> {
|
||||||
val debugPort = if (isDebug) debugPortAllocation.nextPort() else null
|
val debugPort = if (isDebug) debugPortAllocation.nextPort() else null
|
||||||
|
val apiAddress = portAllocation.nextHostAndPort().toString()
|
||||||
val baseDirectory = driverDirectory / networkMapLegalName
|
val baseDirectory = driverDirectory / networkMapLegalName
|
||||||
val config = ConfigHelper.loadConfig(
|
val config = ConfigHelper.loadConfig(
|
||||||
baseDirectory = baseDirectory,
|
baseDirectory = baseDirectory,
|
||||||
allowMissingConfig = true,
|
allowMissingConfig = true,
|
||||||
configOverrides = mapOf(
|
configOverrides = mapOf(
|
||||||
"myLegalName" to networkMapLegalName,
|
"myLegalName" to networkMapLegalName,
|
||||||
|
// TODO: remove the webAddress as NMS doesn't need to run a web server. This will cause all
|
||||||
|
// node port numbers to be shifted, so all demos and docs need to be updated accordingly.
|
||||||
|
"webAddress" to apiAddress,
|
||||||
"artemisAddress" to networkMapAddress.toString(),
|
"artemisAddress" to networkMapAddress.toString(),
|
||||||
"extraAdvertisedServiceIds" to "",
|
"extraAdvertisedServiceIds" to "",
|
||||||
"useTestClock" to useTestClock
|
"useTestClock" to useTestClock
|
||||||
|
@ -42,14 +42,14 @@ fun main(args: Array<String>) {
|
|||||||
Role.SENDER -> {
|
Role.SENDER -> {
|
||||||
val host = HostAndPort.fromString("localhost:10004")
|
val host = HostAndPort.fromString("localhost:10004")
|
||||||
println("Connecting to sender node ($host)")
|
println("Connecting to sender node ($host)")
|
||||||
CordaRPCClient(host, sslConfigFor("nodea", options.valueOf(certsPath))).use("demo", "demo") {
|
CordaRPCClient(host, sslConfigFor("BankA", options.valueOf(certsPath))).use("demo", "demo") {
|
||||||
sender(this)
|
sender(this)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Role.RECIPIENT -> {
|
Role.RECIPIENT -> {
|
||||||
val host = HostAndPort.fromString("localhost:10006")
|
val host = HostAndPort.fromString("localhost:10006")
|
||||||
println("Connecting to the recipient node ($host)")
|
println("Connecting to the recipient node ($host)")
|
||||||
CordaRPCClient(host, sslConfigFor("nodeb", options.valueOf(certsPath))).use("demo", "demo") {
|
CordaRPCClient(host, sslConfigFor("BankB", options.valueOf(certsPath))).use("demo", "demo") {
|
||||||
recipient(this)
|
recipient(this)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -147,11 +147,12 @@ object FixingFlow {
|
|||||||
progressTracker.nextStep()
|
progressTracker.nextStep()
|
||||||
val dealToFix = serviceHub.loadState(ref)
|
val dealToFix = serviceHub.loadState(ref)
|
||||||
val fixableDeal = (dealToFix.data as FixableDealState)
|
val fixableDeal = (dealToFix.data as FixableDealState)
|
||||||
val parties = fixableDeal.parties.filter { it.owningKey != serviceHub.myInfo.legalIdentity.owningKey }
|
val parties = fixableDeal.parties.sortedBy { it.owningKey.toBase58String() }
|
||||||
if (parties.isNotEmpty()) {
|
val myKey = serviceHub.myInfo.legalIdentity.owningKey
|
||||||
|
if (parties[0].owningKey == myKey) {
|
||||||
val fixing = FixingSession(ref, fixableDeal.oracleType)
|
val fixing = FixingSession(ref, fixableDeal.oracleType)
|
||||||
// Start the Floater which will then kick-off the Fixer
|
// Start the Floater which will then kick-off the Fixer
|
||||||
subFlow(Floater(parties.first(), fixing))
|
subFlow(Floater(parties[1], fixing))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -84,12 +84,32 @@ task generateNotaryIdentity(type: JavaExec) {
|
|||||||
task deployNodes(type: net.corda.plugins.Cordform, dependsOn: ['build', 'generateNotaryIdentity']) {
|
task deployNodes(type: net.corda.plugins.Cordform, dependsOn: ['build', 'generateNotaryIdentity']) {
|
||||||
directory deployTo
|
directory deployTo
|
||||||
networkMap "Notary 1"
|
networkMap "Notary 1"
|
||||||
|
node {
|
||||||
|
name "Party"
|
||||||
|
nearestCity "London"
|
||||||
|
advertisedServices = []
|
||||||
|
artemisPort 10002
|
||||||
|
webPort 10003
|
||||||
|
cordapps = []
|
||||||
|
rpcUsers = [['user': "demo", 'password': "demo", 'permissions': [
|
||||||
|
'StartFlow.net.corda.notarydemo.flows.DummyIssueAndMove',
|
||||||
|
'StartFlow.net.corda.flows.NotaryFlow$Client'
|
||||||
|
]]]
|
||||||
|
}
|
||||||
|
node {
|
||||||
|
name "Counterparty"
|
||||||
|
nearestCity "New York"
|
||||||
|
advertisedServices = []
|
||||||
|
artemisPort 10004
|
||||||
|
webPort 10005
|
||||||
|
cordapps = []
|
||||||
|
}
|
||||||
node {
|
node {
|
||||||
name "Notary 1"
|
name "Notary 1"
|
||||||
nearestCity "London"
|
nearestCity "London"
|
||||||
advertisedServices = [advertisedNotary]
|
advertisedServices = [advertisedNotary]
|
||||||
artemisPort 10002
|
artemisPort 10007
|
||||||
webPort 10009
|
webPort 10008
|
||||||
cordapps = []
|
cordapps = []
|
||||||
notaryNodePort 11002
|
notaryNodePort 11002
|
||||||
}
|
}
|
||||||
@ -97,8 +117,8 @@ task deployNodes(type: net.corda.plugins.Cordform, dependsOn: ['build', 'generat
|
|||||||
name "Notary 2"
|
name "Notary 2"
|
||||||
nearestCity "London"
|
nearestCity "London"
|
||||||
advertisedServices = [advertisedNotary]
|
advertisedServices = [advertisedNotary]
|
||||||
artemisPort 10004
|
artemisPort 10010
|
||||||
webPort 10005
|
webPort 10011
|
||||||
cordapps = []
|
cordapps = []
|
||||||
notaryNodePort 11004
|
notaryNodePort 11004
|
||||||
notaryClusterAddresses = ["localhost:11002"]
|
notaryClusterAddresses = ["localhost:11002"]
|
||||||
@ -107,28 +127,12 @@ task deployNodes(type: net.corda.plugins.Cordform, dependsOn: ['build', 'generat
|
|||||||
name "Notary 3"
|
name "Notary 3"
|
||||||
nearestCity "London"
|
nearestCity "London"
|
||||||
advertisedServices = [advertisedNotary]
|
advertisedServices = [advertisedNotary]
|
||||||
artemisPort 10006
|
artemisPort 10013
|
||||||
webPort 10007
|
webPort 10014
|
||||||
cordapps = []
|
cordapps = []
|
||||||
notaryNodePort 11006
|
notaryNodePort 11006
|
||||||
notaryClusterAddresses = ["localhost:11002"]
|
notaryClusterAddresses = ["localhost:11002"]
|
||||||
}
|
}
|
||||||
node {
|
|
||||||
name "Party"
|
|
||||||
nearestCity "London"
|
|
||||||
advertisedServices = []
|
|
||||||
artemisPort 10008
|
|
||||||
webPort 10003
|
|
||||||
cordapps = []
|
|
||||||
}
|
|
||||||
node {
|
|
||||||
name "Counterparty"
|
|
||||||
nearestCity "New York"
|
|
||||||
advertisedServices = []
|
|
||||||
artemisPort 10010
|
|
||||||
webPort 10011
|
|
||||||
cordapps = []
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
task notarise(type: JavaExec) {
|
task notarise(type: JavaExec) {
|
||||||
|
@ -2,6 +2,7 @@ package net.corda.notarydemo
|
|||||||
|
|
||||||
import com.google.common.net.HostAndPort
|
import com.google.common.net.HostAndPort
|
||||||
import com.google.common.util.concurrent.Futures
|
import com.google.common.util.concurrent.Futures
|
||||||
|
import joptsimple.OptionParser
|
||||||
import net.corda.core.crypto.toStringShort
|
import net.corda.core.crypto.toStringShort
|
||||||
import net.corda.core.div
|
import net.corda.core.div
|
||||||
import net.corda.core.getOrThrow
|
import net.corda.core.getOrThrow
|
||||||
@ -14,11 +15,13 @@ import net.corda.node.services.messaging.CordaRPCClient
|
|||||||
import net.corda.notarydemo.flows.DummyIssueAndMove
|
import net.corda.notarydemo.flows.DummyIssueAndMove
|
||||||
import java.nio.file.Path
|
import java.nio.file.Path
|
||||||
import java.nio.file.Paths
|
import java.nio.file.Paths
|
||||||
|
import kotlin.system.exitProcess
|
||||||
|
|
||||||
fun main(args: Array<String>) {
|
fun main(args: Array<String>) {
|
||||||
|
val certPath = getCertPath(args)
|
||||||
val host = HostAndPort.fromString("localhost:10002")
|
val host = HostAndPort.fromString("localhost:10002")
|
||||||
println("Connecting to the recipient node ($host)")
|
println("Connecting to the recipient node ($host)")
|
||||||
CordaRPCClient(host, sslConfigFor("nodeb", "build/notary-demo-nodes/Party/certificates")).use("demo", "demo") {
|
CordaRPCClient(host, sslConfigFor("Party", certPath)).use("demo", "demo") {
|
||||||
val api = NotaryDemoClientApi(this)
|
val api = NotaryDemoClientApi(this)
|
||||||
api.startNotarisation()
|
api.startNotarisation()
|
||||||
}
|
}
|
||||||
@ -79,6 +82,18 @@ private class NotaryDemoClientApi(val rpc: CordaRPCOps) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun getCertPath(args: Array<String>): String? {
|
||||||
|
val parser = OptionParser()
|
||||||
|
val certsPath = parser.accepts("certificates").withRequiredArg()
|
||||||
|
val options = try {
|
||||||
|
parser.parse(*args)
|
||||||
|
} catch (e: Exception) {
|
||||||
|
println(e.message)
|
||||||
|
exitProcess(1)
|
||||||
|
}
|
||||||
|
return options.valueOf(certsPath)
|
||||||
|
}
|
||||||
|
|
||||||
// TODO: Take this out once we have a dedicated RPC port and allow SSL on it to be optional.
|
// TODO: Take this out once we have a dedicated RPC port and allow SSL on it to be optional.
|
||||||
private fun sslConfigFor(nodename: String, certsPath: String?): SSLConfiguration {
|
private fun sslConfigFor(nodename: String, certsPath: String?): SSLConfiguration {
|
||||||
return object : SSLConfiguration {
|
return object : SSLConfiguration {
|
||||||
|
Loading…
Reference in New Issue
Block a user