Skip to content

Commit 1bcabc8

Browse files
author
josecoll
authored
Merge pull request corda#49 from corda/boc-demo-integration
Bank of Corda integration with Trader Demo and Explorer
2 parents 924fb47 + eac2cb1 commit 1bcabc8

File tree

39 files changed

+497
-175
lines changed

39 files changed

+497
-175
lines changed

.idea/runConfigurations/Explorer___demo_nodes.xml

Lines changed: 15 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/runConfigurations/Explorer___demo_nodes__simulation_.xml

Lines changed: 15 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

client/src/main/kotlin/net/corda/client/mock/EventGenerator.kt

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,22 +6,23 @@ import net.corda.core.crypto.Party
66
import net.corda.core.serialization.OpaqueBytes
77
import net.corda.core.transactions.TransactionBuilder
88
import net.corda.flows.CashCommand
9+
import java.util.*
910

1011
/**
1112
* [Generator]s for incoming/outgoing events to/from the [WalletMonitorService]. Internally it keeps track of owned
1213
* state/ref pairs, but it doesn't necessarily generate "correct" events!
1314
*/
1415
class EventGenerator(
1516
val parties: List<Party>,
16-
val notary: Party
17+
val notary: Party,
18+
val currencies: List<Currency> = listOf(USD, GBP, CHF),
19+
val issuers: List<Party> = parties
1720
) {
18-
1921
private var vault = listOf<StateAndRef<Cash.State>>()
2022

2123
val issuerGenerator =
22-
Generator.pickOne(parties).combine(Generator.intRange(0, 1)) { party, ref -> party.ref(ref.toByte()) }
24+
Generator.pickOne(issuers).combine(Generator.intRange(0, 1)) { party, ref -> party.ref(ref.toByte()) }
2325

24-
val currencies = setOf(USD, GBP, CHF).toList() // + Currency.getAvailableCurrencies().toList().subList(0, 3).toSet()).toList()
2526
val currencyGenerator = Generator.pickOne(currencies)
2627

2728
val issuedGenerator = issuerGenerator.combine(currencyGenerator) { issuer, currency -> Issued(issuer, currency) }
@@ -93,8 +94,11 @@ class EventGenerator(
9394
1.0 to moveCashGenerator
9495
)
9596

96-
val bankOfCordaCommandGenerator = Generator.frequency(
97-
0.6 to issueCashGenerator,
97+
val bankOfCordaExitGenerator = Generator.frequency(
9898
0.4 to exitCashGenerator
9999
)
100+
101+
val bankOfCordaIssueGenerator = Generator.frequency(
102+
0.6 to issueCashGenerator
103+
)
100104
}

core/src/main/kotlin/net/corda/core/node/services/ServiceType.kt

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,7 @@ sealed class ServiceType(val id: String) {
1313
// * IDs can only contain alphanumeric, full stop and underscore ASCII characters
1414
require(id.matches(Regex("[a-z][a-zA-Z0-9._]+")))
1515
}
16-
17-
private class ServiceTypeImpl(baseId: String, subTypeId: String) : ServiceType("$baseId.$subTypeId") {
18-
init {
19-
// only allowed one level of subtype
20-
require(subTypeId.matches(Regex("[a-z]\\w+")))
21-
}
22-
}
16+
private class ServiceTypeImpl(baseId: String, subTypeId: String) : ServiceType("$baseId.$subTypeId")
2317

2418
private class ServiceTypeDirect(id: String) : ServiceType(id)
2519

docs/source/node-explorer.rst

Lines changed: 62 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
Node Explorer
22
=============
33

4-
The node explorer provide views to the node's vault and transaction data using Corda's RPC framework.
5-
The user can execute cash transaction commands to issue and move cash to other party on the network or exit cash using the user interface.
4+
The node explorer provides views into a node's vault and transaction data using Corda's RPC framework.
5+
The user can execute cash transaction commands to issue and move cash to other parties on the network or exit cash (eg. remove from the ledger)
66

77
Running the UI
88
--------------
@@ -17,6 +17,27 @@ Running the UI
1717

1818
Running demo nodes
1919
------------------
20+
21+
A demonstration Corda network topology is configured with 5 nodes playing the following roles:
22+
23+
1. Notary
24+
2. Issuer nodes, representing two fictional central banks (UK Bank Plc issuer of GBP and USA Bank Corp issuer of USD)
25+
3. Participant nodes, representing two users (Alice and Bob)
26+
27+
When connected to an *Issuer* node, a user can execute cash transaction commands to issue and move cash to itself or other
28+
parties on the network or to exit cash (for itself only).
29+
30+
When connected to a *Participant* node a user can only execute cash transaction commands to move cash to other parties on the network.
31+
32+
The Demo Nodes can be started in one of two modes:
33+
34+
1. Normal
35+
36+
Fresh clean environment empty of transactions.
37+
Firstly, launch an Explorer instance to login to one of the Issuer nodes and issue some cash to the other participants (Bob and Alice).
38+
Then launch another Explorer instance to login to a participant node and start making payments (eg. move cash).
39+
You will only be able to exit (eg. redeem from the ledger) cash as an issuer node.
40+
2041
**Windows**::
2142

2243
gradlew.bat tools:explorer:runDemoNodes
@@ -25,21 +46,45 @@ Running demo nodes
2546

2647
./gradlew tools:explorer:runDemoNodes
2748

28-
.. note:: 3 Corda nodes will be created on the following port on localhost by default.
49+
2. Simulation
50+
51+
In this mode Nodes will automatically commence executing commands as part of a random generation process.
52+
Issuer nodes will randomly issue, move and exit cash.
53+
Participant nodes will randomly generate spends (eg. move cash to other nodes, including issuers)
54+
55+
**Windows**::
56+
57+
gradlew.bat tools:explorer:runSimulationNodes
58+
59+
**Other**::
60+
61+
./gradlew tools:explorer:runSimulationNodes
62+
63+
64+
.. note:: 5 Corda nodes will be created on the following port on localhost by default.
2965

3066
* Notary -> 20002
3167
* Alice -> 20004
3268
* Bob -> 20006
69+
* UK Bank Plc -> 20008 (*Issuer node*)
70+
* USA Bank Corp -> 20010 (*Issuer node*)
71+
72+
Explorer login credentials to the Issuer nodes are defaulted to ``manager`` and ``test``.
73+
Explorer login credentials to the Participants nodes are defaulted to ``user1`` and ``test``.
74+
Please note you are not allowed to connect to the notary.
75+
76+
.. note:: Alternatively, you may start the demo nodes from within IntelliJ using either of the run configurations
77+
``Explorer - demo nodes`` or ``Explorer - demo nodes (simulation)``
78+
79+
.. note:: Use the Explorer in conjunction with the Trader Demo and Bank of Corda samples to use other *Issuer* nodes.
3380

3481
Interface
3582
---------
3683
Login
3784
User can login to any Corda node using the explorer. Alternatively, ``gradlew explorer:runDemoNodes`` can be used to start up demo nodes for testing.
3885
Corda node address, username and password are required for login, the address is defaulted to localhost:0 if leave blank.
39-
Username and password can be configured via the ``rpcUsers`` field in node's configuration file; for demo nodes, it is defaulted to ``user1`` and ``test``.
86+
Username and password can be configured via the ``rpcUsers`` field in node's configuration file.
4087

41-
.. note:: If you are connecting to the demo nodes, only Alice and Bob (20004, 20006) are accessible using user1 credential, you won't be able to connect to the notary.
42-
4388
.. image:: resources/explorer/login.png
4489
:scale: 50 %
4590
:align: center
@@ -57,12 +102,19 @@ Cash
57102

58103
.. image:: resources/explorer/vault.png
59104

60-
New cash transaction
61-
This is where you can create new cash transactions.
62-
The user can choose from three transaction types (issue, pay and exit) and any party visible on the network.
105+
New Transactions
106+
This is where you can create new cash transactions.
107+
The user can choose from three transaction types (issue, pay and exit) and any party visible on the network.
108+
109+
General nodes can only execute pay commands to any other party on the network.
110+
111+
.. image:: resources/explorer/newTransactionCash.png
112+
113+
Issuer Nodes
114+
Issuer nodes can execute issue (to itself or to any other party), pay and exit transactions.
63115
The result of the transaction will be visible in the transaction screen when executed.
64116

65-
.. image:: resources/explorer/newTransaction.png
117+
.. image:: resources/explorer/newTransactionIssuer.png
66118

67119
Transactions
68120
The transaction view contains all transactions handled by the node in a table view. It shows basic information on the table e.g. Transaction ID,
-133 KB
Loading
267 KB
Loading
261 KB
Loading
62.3 KB
Loading

docs/source/running-the-demos.rst

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,15 +31,15 @@ develop the demos themselves. For more details about running via the command lin
3131
Trader demo
3232
-----------
3333

34-
This demo brings up three nodes: Bank A, Bank B and a notary/network map node that they both use. Bank A will
35-
be the buyer, and self-issues some cash in order to acquire commercial paper from Bank B, the seller.
34+
This demo brings up four nodes: Bank A, Bank B, Bank Of Corda and a notary/network map node that they both use. Bank A will
35+
be the buyer, and requests some cash from the Bank of Corda in order to acquire commercial paper from Bank B, the seller.
3636

3737
To run from the command line:
3838

3939
1. Run ``./gradlew samples:trader-demo:deployNodes`` to create a set of configs and installs under ``samples/trader-demo/build/nodes``
40-
2. Run ``./samples/trader-demo/build/nodes/runnodes`` (or ``runnodes.bat`` on Windows) to open up three new terminals with the three nodes.
41-
3. Run ``./gradlew samples:trader-demo:runBuyer`` to set up the buyer node with some self-issued cash. This step
42-
is not expected to print much.
40+
2. Run ``./samples/trader-demo/build/nodes/runnodes`` (or ``runnodes.bat`` on Windows) to open up four new terminals with the four nodes.
41+
3. Run ``./gradlew samples:trader-demo:runBuyer`` to instruct the buyer node to request issuance of some cash from the Bank of Corda node.
42+
This step will display progress information related to the cash issuance process (in the bank of corda node log output).
4343
4. Run ``./gradlew samples:trader-demo:runSeller`` to trigger the transaction. You can see both sides of the
4444
trade print their progress and final transaction state in the bank node tabs/windows.
4545

@@ -177,6 +177,11 @@ To run from the command line (recommended for Mac/UNIX users!):
177177
.. note:: to verify the Bank of Corda node is alive and running navigate to the following URL
178178
http://localhost:10005/api/bank/date
179179

180+
.. note:: the Bank of Corda node explicitly advertises with a node service type as follows:
181+
``advertisedServices = setOf(ServiceInfo(ServiceType.corda.getSubType("issuer"))))``
182+
This allows for 3rd party applications to perform actions based on Node Type.
183+
For example, the Explorer tool only allows nodes of this type to issue and exit cash.
184+
180185
3. Run ``./gradlew samples:bank-of-corda-demo:runRPCCashIssue`` in another terminal window to trigger a cash issuance request
181186
4. Run ``./gradlew samples:bank-of-corda-demo:runWebCashIssue`` in another terminal window to trigger another cash issuance request
182187
Now look at the other windows to see the output of the demo.

0 commit comments

Comments
 (0)