2017-11-29 17:07:13 +00:00
|
|
|
Creating nodes locally
|
|
|
|
======================
|
|
|
|
|
|
|
|
Node structure
|
|
|
|
--------------
|
|
|
|
Each Corda node has the following structure:
|
|
|
|
|
|
|
|
.. sourcecode:: none
|
|
|
|
|
|
|
|
.
|
|
|
|
├── certificates // The node's certificates
|
|
|
|
├── corda-webserver.jar // The built-in node webserver
|
|
|
|
├── corda.jar // The core Corda libraries
|
|
|
|
├── logs // The node logs
|
|
|
|
├── node.conf // The node's configuration files
|
|
|
|
├── persistence.mv.db // The node's database
|
|
|
|
└── cordapps // The CorDapps jars installed on the node
|
|
|
|
|
|
|
|
The node is configured by editing its ``node.conf`` file. You install CorDapps on the node by dropping the CorDapp JARs
|
|
|
|
into the ``cordapps`` folder.
|
|
|
|
|
2018-02-28 18:04:08 +00:00
|
|
|
In development mode (i.e. when ``devMode = true``, see :doc:`corda-configuration-file` for more information), the ``certificates``
|
|
|
|
directory is filled with pre-configured keystores if the required keystores do not exist. This ensures that developers
|
|
|
|
can get the nodes working as quickly as possible. However, these pre-configured keystores are not secure, to learn more see :doc:`permissioning`.
|
|
|
|
|
2017-11-29 17:07:13 +00:00
|
|
|
Node naming
|
|
|
|
-----------
|
2017-12-08 17:00:08 +00:00
|
|
|
A node's name must be a valid X.500 distinguished name. In order to be compatible with other implementations
|
2018-02-28 18:04:08 +00:00
|
|
|
(particularly TLS implementations), we constrain the allowed X.500 name attribute types to a subset of the minimum
|
|
|
|
supported set for X.509 certificates (specified in RFC 3280), plus the locality attribute:
|
2017-12-08 17:00:08 +00:00
|
|
|
|
|
|
|
* Organization (O)
|
|
|
|
* State (ST)
|
|
|
|
* Locality (L)
|
|
|
|
* Country (C)
|
|
|
|
* Organizational-unit (OU)
|
2018-02-28 18:04:08 +00:00
|
|
|
* Common name (CN)
|
|
|
|
|
|
|
|
Note that the serial number is intentionally excluded in order to minimise scope for uncertainty in the distinguished name format.
|
|
|
|
The distinguished name qualifier has been removed due to technical issues; consideration was given to "Corda" as qualifier,
|
|
|
|
however the qualifier needs to reflect the compatibility zone, not the technology involved. There may be many Corda namespaces,
|
|
|
|
but only one R3 namespace on Corda. The ordering of attributes is important.
|
|
|
|
|
|
|
|
``State`` should be avoided unless required to differentiate from other ``localities`` with the same or similar names at the
|
|
|
|
country level. For example, London (GB) would not need a ``state``, but St Ives would (there are two, one in Cornwall, one
|
|
|
|
in Cambridgeshire). As legal entities in Corda are likely to be located in major cities, this attribute is not expected to be
|
|
|
|
present in the majority of names, but is an option for the cases which require it.
|
2017-12-08 17:00:08 +00:00
|
|
|
|
|
|
|
The name must also obey the following constraints:
|
|
|
|
|
2018-02-28 18:04:08 +00:00
|
|
|
* The ``organisation``, ``locality`` and ``country`` attributes are present
|
2017-12-08 17:00:08 +00:00
|
|
|
|
2018-02-28 18:04:08 +00:00
|
|
|
* The ``state``, ``organisational-unit`` and ``common name`` attributes are optional
|
2017-11-29 17:07:13 +00:00
|
|
|
|
|
|
|
* The fields of the name have the following maximum character lengths:
|
|
|
|
|
|
|
|
* Common name: 64
|
|
|
|
* Organisation: 128
|
|
|
|
* Organisation unit: 64
|
|
|
|
* Locality: 64
|
|
|
|
* State: 64
|
|
|
|
|
2018-02-28 18:04:08 +00:00
|
|
|
* The ``country`` attribute is a valid ISO 3166-1 two letter code in upper-case
|
2017-11-29 17:07:13 +00:00
|
|
|
|
2017-12-12 16:52:14 +00:00
|
|
|
* All attributes must obey the following constraints:
|
2017-11-29 17:07:13 +00:00
|
|
|
|
2017-12-08 17:00:08 +00:00
|
|
|
* Upper-case first letter
|
2017-11-29 17:07:13 +00:00
|
|
|
* Has at least two letters
|
|
|
|
* No leading or trailing whitespace
|
2017-12-08 17:00:08 +00:00
|
|
|
* Does not include the following characters: ``,`` , ``=`` , ``$`` , ``"`` , ``'`` , ``\``
|
2017-11-29 17:07:13 +00:00
|
|
|
* Is in NFKC normalization form
|
2017-12-12 16:52:14 +00:00
|
|
|
* Does not contain the null character
|
2017-11-29 17:07:13 +00:00
|
|
|
* Only the latin, common and inherited unicode scripts are supported
|
|
|
|
|
2018-02-28 18:04:08 +00:00
|
|
|
* The ``organisation`` field of the name also obeys the following constraints:
|
2017-12-12 16:52:14 +00:00
|
|
|
|
|
|
|
* No double-spacing
|
|
|
|
|
2017-12-08 17:00:08 +00:00
|
|
|
* This is to avoid right-to-left issues, debugging issues when we can't pronounce names over the phone, and
|
|
|
|
character confusability attacks
|
|
|
|
|
2018-02-28 18:04:08 +00:00
|
|
|
External identifiers
|
|
|
|
^^^^^^^^^^^^^^^^^^^^
|
|
|
|
Mappings to external identifiers such as Companies House nos., LEI, BIC, etc. should be stored in custom X.509
|
|
|
|
certificate extensions. These values may change for operational reasons, without the identity they're associated with
|
|
|
|
necessarily changing, and their inclusion in the distinguished name would cause significant logistical complications.
|
|
|
|
The OID and format for these extensions will be described in a further specification.
|
|
|
|
|
2017-11-29 17:07:13 +00:00
|
|
|
The Cordform task
|
|
|
|
-----------------
|
|
|
|
Corda provides a gradle plugin called ``Cordform`` that allows you to automatically generate and configure a set of
|
2018-03-01 21:24:10 +00:00
|
|
|
nodes for testing and demos. Here is an example ``Cordform`` task called ``deployNodes`` that creates three nodes, defined
|
|
|
|
in the `Kotlin CorDapp Template <https://github.com/corda/cordapp-template-kotlin/blob/release-V3/build.gradle#L100>`_:
|
2017-11-29 17:07:13 +00:00
|
|
|
|
|
|
|
.. sourcecode:: groovy
|
|
|
|
|
|
|
|
task deployNodes(type: net.corda.plugins.Cordform, dependsOn: ['jar']) {
|
|
|
|
directory "./build/nodes"
|
|
|
|
node {
|
2018-02-28 18:04:08 +00:00
|
|
|
name "O=Notary,L=London,C=GB"
|
2017-11-29 17:07:13 +00:00
|
|
|
// The notary will offer a validating notary service.
|
|
|
|
notary = [validating : true]
|
|
|
|
p2pPort 10002
|
|
|
|
rpcPort 10003
|
|
|
|
// No webport property, so no webserver will be created.
|
|
|
|
h2Port 10004
|
|
|
|
// Includes the corda-finance CorDapp on our node.
|
|
|
|
cordapps = ["net.corda:corda-finance:$corda_release_version"]
|
|
|
|
}
|
|
|
|
node {
|
|
|
|
name "O=PartyA,L=London,C=GB"
|
|
|
|
p2pPort 10005
|
|
|
|
rpcPort 10006
|
|
|
|
webPort 10007
|
|
|
|
h2Port 10008
|
|
|
|
cordapps = ["net.corda:corda-finance:$corda_release_version"]
|
|
|
|
// Grants user1 all RPC permissions.
|
|
|
|
rpcUsers = [[ user: "user1", "password": "test", "permissions": ["ALL"]]]
|
|
|
|
}
|
|
|
|
node {
|
|
|
|
name "O=PartyB,L=New York,C=US"
|
|
|
|
p2pPort 10009
|
|
|
|
rpcPort 10010
|
|
|
|
webPort 10011
|
|
|
|
h2Port 10012
|
|
|
|
cordapps = ["net.corda:corda-finance:$corda_release_version"]
|
|
|
|
// Grants user1 the ability to start the MyFlow flow.
|
|
|
|
rpcUsers = [[ user: "user1", "password": "test", "permissions": ["StartFlow.net.corda.flows.MyFlow"]]]
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Running this task will create three nodes in the ``build/nodes`` folder:
|
|
|
|
|
2018-02-28 18:04:08 +00:00
|
|
|
* A ``Notary`` node that:
|
2017-11-29 17:07:13 +00:00
|
|
|
|
|
|
|
* Offers a validating notary service
|
|
|
|
* Will not have a webserver (since ``webPort`` is not defined)
|
|
|
|
* Is running the ``corda-finance`` CorDapp
|
|
|
|
|
|
|
|
* ``PartyA`` and ``PartyB`` nodes that:
|
|
|
|
|
|
|
|
* Are not offering any services
|
|
|
|
* Will have a webserver (since ``webPort`` is defined)
|
|
|
|
* Are running the ``corda-finance`` CorDapp
|
|
|
|
* Have an RPC user, ``user1``, that can be used to log into the node via RPC
|
|
|
|
|
|
|
|
Additionally, all three nodes will include any CorDapps defined in the project's source folders, even though these
|
|
|
|
CorDapps are not listed in each node's ``cordapps`` entry. This means that running the ``deployNodes`` task from the
|
|
|
|
template CorDapp, for example, would automatically build and add the template CorDapp to each node.
|
|
|
|
|
2018-02-28 18:04:08 +00:00
|
|
|
You can extend ``deployNodes`` to generate additional nodes.
|
2017-11-29 17:07:13 +00:00
|
|
|
|
|
|
|
.. warning:: When adding nodes, make sure that there are no port clashes!
|
|
|
|
|
2018-02-12 14:00:25 +00:00
|
|
|
Specifying a custom webserver
|
2018-03-01 21:24:10 +00:00
|
|
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
2018-02-12 14:00:25 +00:00
|
|
|
By default, any node listing a webport will use the default development webserver, which is not production-ready. You
|
|
|
|
can use your own webserver JAR instead by using the ``webserverJar`` argument in a ``Cordform`` ``node`` configuration
|
|
|
|
block:
|
|
|
|
|
|
|
|
.. sourcecode:: groovy
|
|
|
|
|
|
|
|
node {
|
|
|
|
name "O=PartyA,L=New York,C=US"
|
|
|
|
webPort 10005
|
|
|
|
webserverJar "lib/my_webserver.jar"
|
|
|
|
}
|
|
|
|
|
|
|
|
The webserver JAR will be copied into the node's ``build`` folder with the name ``corda-webserver.jar``.
|
|
|
|
|
|
|
|
.. warning:: This is an experimental feature. There is currently no support for reading the webserver's port from the
|
|
|
|
node's ``node.conf`` file.
|
|
|
|
|
2017-11-29 17:07:13 +00:00
|
|
|
Running deployNodes
|
2018-03-01 21:24:10 +00:00
|
|
|
~~~~~~~~~~~~~~~~~~~
|
2017-11-29 17:07:13 +00:00
|
|
|
To create the nodes defined in our ``deployNodes`` task, run the following command in a terminal window from the root
|
|
|
|
of the project where the ``deployNodes`` task is defined:
|
|
|
|
|
|
|
|
* Linux/macOS: ``./gradlew deployNodes``
|
|
|
|
* Windows: ``gradlew.bat deployNodes``
|
|
|
|
|
|
|
|
This will create the nodes in the ``build/nodes`` folder. There will be a node folder generated for each node defined
|
|
|
|
in the ``deployNodes`` task, plus a ``runnodes`` shell script (or batch file on Windows) to run all the nodes at once
|
|
|
|
for testing and development purposes. If you make any changes to your CorDapp source or ``deployNodes`` task, you will
|
|
|
|
need to re-run the task to see the changes take effect.
|
|
|
|
|
2017-12-12 16:52:14 +00:00
|
|
|
You can now run the nodes by following the instructions in :doc:`Running a node <running-a-node>`.
|