corda/docs/build/html/running-the-demos.html
Clinton Alexander 9a2963bca9 Docs regen.
2017-02-22 10:59:02 +00:00

646 lines
47 KiB
HTML

<!-- If you edit this, then please make the same changes to layout_for_doc_website.html, as that is used for the web
doc site generation which we put analytics tracking on to identify any potential problem pages -->
<!DOCTYPE html>
<!--[if IE 8]><html class="no-js lt-ie9" lang="en" > <![endif]-->
<!--[if gt IE 8]><!--> <html class="no-js" lang="en" > <!--<![endif]-->
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Running the demos &mdash; R3 Corda latest documentation</title>
<link rel="stylesheet" href="_static/css/custom.css" type="text/css" />
<link rel="top" title="R3 Corda latest documentation" href="index.html"/>
<link rel="next" title="CLI vs IDE" href="CLI-vs-IDE.html"/>
<link rel="prev" title="Troubleshooting" href="getting-set-up-fault-finding.html"/>
<script src="_static/js/modernizr.min.js"></script>
</head>
<body class="wy-body-for-nav" role="document">
<div class="wy-grid-for-nav">
<nav data-toggle="wy-nav-shift" class="wy-nav-side">
<div class="wy-side-scroll">
<div class="wy-side-nav-search">
<a href="index.html" class="icon icon-home"> R3 Corda
</a>
<div class="version">
latest
</div>
<div role="search">
<form id="rtd-search-form" class="wy-form" action="search.html" method="get">
<input type="text" name="q" placeholder="Search docs" />
<input type="hidden" name="check_keywords" value="yes" />
<input type="hidden" name="area" value="default" />
</form>
</div>
<br>
API reference: <a href="api/kotlin/corda/index.html">Kotlin</a>/ <a href="api/javadoc/index.html">JavaDoc</a>
<br>
<a href="https://discourse.corda.net">Discourse Forums</a>
<br>
<a href="http://slack.corda.net">Slack</a>
<br>
</div>
<div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation">
<p class="caption"><span class="caption-text">Getting started</span></p>
<ul class="current">
<li class="toctree-l1"><a class="reference internal" href="inthebox.html">What&#8217;s included?</a></li>
<li class="toctree-l1"><a class="reference internal" href="getting-set-up.html">Getting set up</a></li>
<li class="toctree-l1"><a class="reference internal" href="getting-set-up-fault-finding.html">Troubleshooting</a></li>
<li class="toctree-l1 current"><a class="current reference internal" href="#">Running the demos</a><ul>
<li class="toctree-l2"><a class="reference internal" href="#trader-demo">Trader demo</a></li>
<li class="toctree-l2"><a class="reference internal" href="#irs-demo">IRS demo</a></li>
<li class="toctree-l2"><a class="reference internal" href="#attachment-demo">Attachment demo</a></li>
<li class="toctree-l2"><a class="reference internal" href="#raft-notary-demo">Raft Notary demo</a></li>
<li class="toctree-l2"><a class="reference internal" href="#bank-of-corda-demo">Bank Of Corda demo</a></li>
<li class="toctree-l2"><a class="reference internal" href="#simm-and-portfolio-demo-aka-the-initial-margin-agreement-demo">SIMM and Portfolio Demo - aka the Initial Margin Agreement Demo</a><ul>
<li class="toctree-l3"><a class="reference internal" href="#background-and-simm-introduction">Background and SIMM Introduction</a></li>
<li class="toctree-l3"><a class="reference internal" href="#what-happens-in-the-demo-notionally">What happens in the demo (notionally)</a></li>
<li class="toctree-l3"><a class="reference internal" href="#demo-execution-step-by-step">Demo execution (step by step)</a></li>
</ul>
</li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="CLI-vs-IDE.html">CLI vs IDE</a></li>
</ul>
<p class="caption"><span class="caption-text">Key concepts</span></p>
<ul>
<li class="toctree-l1"><a class="reference internal" href="key-concepts.html">Overview</a></li>
<li class="toctree-l1"><a class="reference internal" href="key-concepts-ecosystem.html">Corda ecosystem</a></li>
<li class="toctree-l1"><a class="reference internal" href="key-concepts-data-model.html">Data model</a></li>
<li class="toctree-l1"><a class="reference internal" href="key-concepts-core-types.html">Core types</a></li>
<li class="toctree-l1"><a class="reference internal" href="key-concepts-financial-model.html">Financial model</a></li>
<li class="toctree-l1"><a class="reference internal" href="key-concepts-flow-framework.html">Flow framework</a></li>
<li class="toctree-l1"><a class="reference internal" href="key-concepts-consensus-notaries.html">Consensus and notaries</a></li>
<li class="toctree-l1"><a class="reference internal" href="key-concepts-vault.html">Vault</a></li>
<li class="toctree-l1"><a class="reference internal" href="key-concepts-security-model.html">Security model</a></li>
</ul>
<p class="caption"><span class="caption-text">CorDapps</span></p>
<ul>
<li class="toctree-l1"><a class="reference internal" href="creating-a-cordapp.html">CorDapp basics</a></li>
<li class="toctree-l1"><a class="reference internal" href="tutorial-cordapp.html">The example CorDapp</a></li>
</ul>
<p class="caption"><span class="caption-text">The Corda node</span></p>
<ul>
<li class="toctree-l1"><a class="reference internal" href="clientrpc.html">Client RPC</a></li>
<li class="toctree-l1"><a class="reference internal" href="messaging.html">Networking and messaging</a></li>
<li class="toctree-l1"><a class="reference internal" href="persistence.html">Persistence</a></li>
<li class="toctree-l1"><a class="reference internal" href="node-administration.html">Node administration</a></li>
<li class="toctree-l1"><a class="reference internal" href="corda-configuration-file.html">Node configuration</a></li>
<li class="toctree-l1"><a class="reference internal" href="corda-plugins.html">The Corda plugin framework</a></li>
<li class="toctree-l1"><a class="reference internal" href="node-services.html">Brief introduction to the node services</a></li>
<li class="toctree-l1"><a class="reference internal" href="node-explorer.html">Node Explorer</a></li>
<li class="toctree-l1"><a class="reference internal" href="permissioning.html">Network permissioning</a></li>
</ul>
<p class="caption"><span class="caption-text">Tutorials</span></p>
<ul>
<li class="toctree-l1"><a class="reference internal" href="tutorial-contract.html">Writing a contract</a></li>
<li class="toctree-l1"><a class="reference internal" href="tutorial-contract-clauses.html">Writing a contract using clauses</a></li>
<li class="toctree-l1"><a class="reference internal" href="tutorial-test-dsl.html">Writing a contract test</a></li>
<li class="toctree-l1"><a class="reference internal" href="contract-upgrade.html">Upgrading Contracts</a></li>
<li class="toctree-l1"><a class="reference internal" href="tutorial-integration-testing.html">Integration testing</a></li>
<li class="toctree-l1"><a class="reference internal" href="tutorial-clientrpc-api.html">Client RPC API tutorial</a></li>
<li class="toctree-l1"><a class="reference internal" href="tutorial-building-transactions.html">Building transactions</a></li>
<li class="toctree-l1"><a class="reference internal" href="flow-state-machines.html">Writing flows</a></li>
<li class="toctree-l1"><a class="reference internal" href="flow-testing.html">Writing flow tests</a></li>
<li class="toctree-l1"><a class="reference internal" href="running-a-notary.html">Running a notary service</a></li>
<li class="toctree-l1"><a class="reference internal" href="using-a-notary.html">Using a notary service</a></li>
<li class="toctree-l1"><a class="reference internal" href="oracles.html">Writing oracle services</a></li>
<li class="toctree-l1"><a class="reference internal" href="tutorial-attachments.html">Using attachments</a></li>
<li class="toctree-l1"><a class="reference internal" href="event-scheduling.html">Event scheduling</a></li>
</ul>
<p class="caption"><span class="caption-text">Other</span></p>
<ul>
<li class="toctree-l1"><a class="reference internal" href="network-simulator.html">Network Simulator</a></li>
<li class="toctree-l1"><a class="reference internal" href="clauses.html">Clauses</a></li>
<li class="toctree-l1"><a class="reference internal" href="merkle-trees.html">Transaction tear-offs</a></li>
</ul>
<p class="caption"><span class="caption-text">Component library</span></p>
<ul>
<li class="toctree-l1"><a class="reference internal" href="contract-catalogue.html">Contract catalogue</a></li>
<li class="toctree-l1"><a class="reference internal" href="contract-irs.html">Interest rate swaps</a></li>
</ul>
<p class="caption"><span class="caption-text">Appendix</span></p>
<ul>
<li class="toctree-l1"><a class="reference internal" href="loadtesting.html">Load testing</a></li>
<li class="toctree-l1"><a class="reference internal" href="setting-up-a-corda-network.html">What is a corda network?</a></li>
<li class="toctree-l1"><a class="reference internal" href="secure-coding-guidelines.html">Secure coding guidelines</a></li>
<li class="toctree-l1"><a class="reference internal" href="release-process.html">Release process</a></li>
<li class="toctree-l1"><a class="reference internal" href="release-notes.html">Release notes</a></li>
<li class="toctree-l1"><a class="reference internal" href="codestyle.html">Code style guide</a></li>
<li class="toctree-l1"><a class="reference internal" href="building-the-docs.html">Building the documentation</a></li>
<li class="toctree-l1"><a class="reference internal" href="further-notes-on-kotlin.html">Further notes on Kotlin</a></li>
<li class="toctree-l1"><a class="reference internal" href="publishing-corda.html">Publishing Corda</a></li>
<li class="toctree-l1"><a class="reference internal" href="azure-vm.html">Working with the Corda Demo on Azure Marketplace</a></li>
</ul>
<p class="caption"><span class="caption-text">Glossary</span></p>
<ul>
<li class="toctree-l1"><a class="reference internal" href="glossary.html">Glossary</a></li>
</ul>
</div>
</div>
</nav>
<section data-toggle="wy-nav-shift" class="wy-nav-content-wrap">
<nav class="wy-nav-top" role="navigation" aria-label="top navigation">
<i data-toggle="wy-nav-top" class="fa fa-bars"></i>
<a href="index.html">R3 Corda</a>
</nav>
<div class="wy-nav-content">
<div class="rst-content">
<div role="navigation" aria-label="breadcrumbs navigation">
<ul class="wy-breadcrumbs">
<li><a href="index.html">Docs</a> &raquo;</li>
<li>Running the demos</li>
<li class="wy-breadcrumbs-aside">
<a href="_sources/running-the-demos.txt" rel="nofollow"> View page source</a>
</li>
</ul>
<hr/>
</div>
<div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article">
<div itemprop="articleBody">
<div class="section" id="running-the-demos">
<h1>Running the demos<a class="headerlink" href="#running-the-demos" title="Permalink to this headline"></a></h1>
<p>The Corda repository contains a number of demo programs demonstrating the functionality developed so far:</p>
<ol class="arabic simple">
<li>The Trader Demo, which shows a delivery-vs-payment atomic swap of commercial paper for cash</li>
<li>The IRS Demo, which shows two nodes establishing an interest rate swap and performing fixings with a
rates oracle</li>
<li>The Attachment Demo, which demonstrates uploading attachments to nodes</li>
<li>The SIMM Valuation Demo, which shows two nodes agreeing on a portfolio and valuing the initial margin
using the Standard Initial Margin Model</li>
<li>The Distributed Notary Demo, which shows a single node getting multiple transactions notarised by a distributed (Raft-based) notary</li>
<li>The Bank of Corda Demo, which shows a node acting as an issuer of assets (the Bank of Corda) while remote client
applications request issuance of some cash on behalf of a node called Big Corporation</li>
</ol>
<p>The demos can be run either from the command line, or from inside IntelliJ. Running from the command line is
recommended if you just want to see the demos run, whereas using IntelliJ can be helpful if you want to debug or
extend the demos. For more details about running via the command line or from within IntelliJ, see <a class="reference internal" href="CLI-vs-IDE.html"><span class="doc">CLI vs IDE</span></a>.</p>
<div class="admonition note">
<p class="first admonition-title">Note</p>
<p class="last">If you are running the demos from the command line in Unix, you may have to install xterm.</p>
</div>
<div class="admonition note">
<p class="first admonition-title">Note</p>
<p class="last">If any of the demos don&#8217;t work, please raise an issue on GitHub.</p>
</div>
<div class="section" id="trader-demo">
<span id="id1"></span><h2>Trader demo<a class="headerlink" href="#trader-demo" title="Permalink to this headline"></a></h2>
<p>This demo brings up four nodes: Bank A, Bank B, Bank Of Corda, and a notary/network map node that they all use. Bank A will
be the buyer, and requests some cash from the Bank of Corda in order to acquire commercial paper from Bank B, the seller.</p>
<p>To run from the command line in Unix:</p>
<ol class="arabic simple">
<li>Run <code class="docutils literal"><span class="pre">./gradlew</span> <span class="pre">samples:trader-demo:deployNodes</span></code> to create a set of configs and installs under <code class="docutils literal"><span class="pre">samples/trader-demo/build/nodes</span></code></li>
<li>Run <code class="docutils literal"><span class="pre">./samples/trader-demo/build/nodes/runnodes</span></code> to open up four new terminals with the four nodes</li>
<li>Run <code class="docutils literal"><span class="pre">./gradlew</span> <span class="pre">samples:trader-demo:runBuyer</span></code> to instruct the buyer node to request issuance of some cash from the Bank of Corda node.
This step will display progress information related to the cash issuance process (in the bank of corda node log output)</li>
<li>Run <code class="docutils literal"><span class="pre">./gradlew</span> <span class="pre">samples:trader-demo:runSeller</span></code> to trigger the transaction. You can see both sides of the
trade print their progress and final transaction state in the bank node tabs/windows</li>
</ol>
<p>To run from the command line in Windows:</p>
<ol class="arabic simple">
<li>Run <code class="docutils literal"><span class="pre">gradlew</span> <span class="pre">samples:trader-demo:deployNodes</span></code> to create a set of configs and installs under <code class="docutils literal"><span class="pre">samples\trader-demo\build\nodes</span></code></li>
<li>Run <code class="docutils literal"><span class="pre">samples\trader-demo\build\nodes\runnodes</span></code> to open up four new terminals with the four nodes</li>
<li>Run <code class="docutils literal"><span class="pre">gradlew</span> <span class="pre">samples:trader-demo:runBuyer</span></code> to instruct the buyer node to request issuance of some cash from the Bank of Corda node.
This step will display progress information related to the cash issuance process (in the Bank of Corda node log output)</li>
<li>Run <code class="docutils literal"><span class="pre">gradlew</span> <span class="pre">samples:trader-demo:runSeller</span></code> to trigger the transaction. You can see both sides of the
trade print their progress and final transaction state in the bank node tabs/windows</li>
</ol>
<p>To run from IntelliJ:</p>
<ol class="arabic simple">
<li>Open the Corda project in IntelliJ and import the Gradle project</li>
<li>Run the <code class="docutils literal"><span class="pre">Trader</span> <span class="pre">Demo:</span> <span class="pre">Run</span> <span class="pre">Nodes</span></code> configuration, which will start four nodes. Once all nodes are started you will see several
&#8220;Node started up and registered in ...&#8221; messages</li>
<li>Run <code class="docutils literal"><span class="pre">Trader</span> <span class="pre">Demo:</span> <span class="pre">Run</span> <span class="pre">Buyer</span></code> to instruct the buyer node to request issuance of some cash from the Bank of Corda node</li>
<li>Run <code class="docutils literal"><span class="pre">Trader</span> <span class="pre">Demo:</span> <span class="pre">Run</span> <span class="pre">Seller</span></code> to trigger the transaction</li>
<li>In the &#8220;Trader Demo: Run Nodes&#8221; run configuration window, you should see some log lines scroll past. Within a few seconds, the message
&#8220;Purchase complete - we are a happy customer!&#8221; should be printed.</li>
</ol>
</div>
<div class="section" id="irs-demo">
<span id="id2"></span><h2>IRS demo<a class="headerlink" href="#irs-demo" title="Permalink to this headline"></a></h2>
<p>This demo brings up three nodes: Bank A, Bank B and a node that simultaneously runs a notary, a network map and an interest rates
oracle. The two banks agree on an interest rate swap, and then do regular fixings of the deal as the time
on a simulated clock passes.</p>
<p>To run from the command line in Unix:</p>
<ol class="arabic simple">
<li>Run <code class="docutils literal"><span class="pre">./gradlew</span> <span class="pre">samples:irs-demo:deployNodes</span></code> to install configs and a command line tool under <code class="docutils literal"><span class="pre">samples/irs-demo/build</span></code>.</li>
<li>Run <code class="docutils literal"><span class="pre">./gradlew</span> <span class="pre">samples:irs-demo:installDist</span></code></li>
<li>Move to the <code class="docutils literal"><span class="pre">samples/irs-demo/build</span></code> directory</li>
<li>Run <code class="docutils literal"><span class="pre">./nodes/runnodes</span></code> to open up three new terminals with the three nodes (you may have to install xterm).</li>
<li>Run <code class="docutils literal"><span class="pre">./install/irs-demo/bin/irs-demo</span> <span class="pre">--role</span> <span class="pre">UploadRates</span></code>. You should see a
message be printed to the first node (the notary/oracle/network map node) saying that it has accepted the new
interest rates</li>
<li>Now run <code class="docutils literal"><span class="pre">./install/irs-demo/bin/irs-demo</span> <span class="pre">--role</span> <span class="pre">Trade</span> <span class="pre">1</span></code>. The number is a trade ID. You should
see lots of activity as the nodes set up the deal, notarise it, get it signed by the oracle, and so on</li>
<li>Now run <code class="docutils literal"><span class="pre">./install/irs-demo/bin/irs-demo</span> <span class="pre">--role</span> <span class="pre">Date</span> <span class="pre">2017-12-12</span></code> to roll the simulated clock forward and see some fixings take place</li>
</ol>
<p>To run from the command line in Windows:</p>
<ol class="arabic simple">
<li>Run <code class="docutils literal"><span class="pre">gradlew</span> <span class="pre">samples:irs-demo:deployNodes</span></code> to install configs and a command line tool under <code class="docutils literal"><span class="pre">samples\irs-demo\build</span></code></li>
<li>Run <code class="docutils literal"><span class="pre">gradlew</span> <span class="pre">samples:irs-demo:installDist</span></code></li>
<li>Move to the <code class="docutils literal"><span class="pre">samples\irs-demo\build</span></code> directory</li>
<li>Run <code class="docutils literal"><span class="pre">nodes\runnodes</span></code> to open up three new terminals with the three nodes.</li>
<li>Run <code class="docutils literal"><span class="pre">install\irs-demo\bin\irs-demo</span> <span class="pre">--role</span> <span class="pre">UploadRates</span></code>. You should see a
message be printed to the first node (the notary/oracle/network map node) saying that it has accepted the new
interest rates</li>
<li>Now run <code class="docutils literal"><span class="pre">install\irs-demo\bin\irs-demo</span> <span class="pre">--role</span> <span class="pre">Trade</span> <span class="pre">1</span></code>. The number is a trade ID. You should
see lots of activity as the nodes set up the deal, notarise it, get it signed by the oracle, and so on</li>
<li>Now run <code class="docutils literal"><span class="pre">install\irs-demo\bin\irs-demo</span> <span class="pre">--role</span> <span class="pre">Date</span> <span class="pre">2017-12-12</span></code> to roll the simulated clock forward and see some fixings take place</li>
</ol>
<p>To run from IntelliJ:</p>
<ol class="arabic simple">
<li>Open the Corda project in IntelliJ and import the Gradle project</li>
<li>Run the <code class="docutils literal"><span class="pre">IRS</span> <span class="pre">Demo:</span> <span class="pre">Run</span> <span class="pre">Nodes</span></code> configuration to start three nodes. Once all nodes are started you will see several
&#8220;Node started up and registered in ...&#8221; messages</li>
<li>Run <code class="docutils literal"><span class="pre">IRS</span> <span class="pre">Demo:</span> <span class="pre">Run</span> <span class="pre">Upload</span> <span class="pre">Rates</span></code> to upload the new interest rates to the oracle</li>
<li>Run <code class="docutils literal"><span class="pre">IRS</span> <span class="pre">Demo:</span> <span class="pre">Run</span> <span class="pre">Trade</span></code> to have the nodes agree on a trade</li>
<li>Run <code class="docutils literal"><span class="pre">IRS</span> <span class="pre">Demo:</span> <span class="pre">Run</span> <span class="pre">Date</span> <span class="pre">Change</span></code> to roll the simulated clock forward and see some fixings take place</li>
<li>In the &#8220;IRS Demo: Run Nodes&#8221; window you&#8217;ll see a lot of activity when you run the trade and when you change the date.
The date change rolls the clock forwards and causes the nodes to agree on the fixings over a period.</li>
</ol>
<p>This demo also has a web app. To use this, run nodes and upload rates, then navigate to
<a class="reference external" href="http://localhost:10005/web/irsdemo">http://localhost:10005/web/irsdemo</a> and <a class="reference external" href="http://localhost:10007/web/irsdemo">http://localhost:10007/web/irsdemo</a> to see each node&#8217;s view of the ledger.</p>
<p>To use the web app, click the &#8220;Create Deal&#8221; button, fill in the form, then click the &#8220;Submit&#8221; button. You can then
use the time controls at the top left of the home page to run the fixings. Click any individual trade in the blotter to view it.</p>
</div>
<div class="section" id="attachment-demo">
<h2>Attachment demo<a class="headerlink" href="#attachment-demo" title="Permalink to this headline"></a></h2>
<p>This demo brings up three nodes, and sends a transaction containing an attachment from one to the other.</p>
<p>To run from the command line in Unix:</p>
<ol class="arabic simple">
<li>Run <code class="docutils literal"><span class="pre">./gradlew</span> <span class="pre">samples:attachment-demo:deployNodes</span></code> to create a set of configs and installs under <code class="docutils literal"><span class="pre">samples/attachment-demo/build/nodes</span></code></li>
<li>Run <code class="docutils literal"><span class="pre">./samples/attachment-demo/build/nodes/runnodes</span></code> to open up three new terminal tabs/windows with the three nodes</li>
<li>Run <code class="docutils literal"><span class="pre">./gradlew</span> <span class="pre">samples:attachment-demo:runRecipient</span></code>, which will block waiting for a trade to start</li>
<li>Run <code class="docutils literal"><span class="pre">./gradlew</span> <span class="pre">samples:attachment-demo:runSender</span></code> in another terminal window to send the attachment. Now look at the other windows to
see the output of the demo</li>
</ol>
<p>To run from the command line in Windows:</p>
<ol class="arabic simple">
<li>Run <code class="docutils literal"><span class="pre">gradlew</span> <span class="pre">samples:attachment-demo:deployNodes</span></code> to create a set of configs and installs under <code class="docutils literal"><span class="pre">samples\attachment-demo\build\nodes</span></code></li>
<li>Run <code class="docutils literal"><span class="pre">samples\attachment-demo\build\nodes\runnodes</span></code> to open up three new terminal tabs/windows with the three nodes</li>
<li>Run <code class="docutils literal"><span class="pre">gradlew</span> <span class="pre">samples:attachment-demo:runRecipient</span></code>, which will block waiting for a trade to start</li>
<li>Run <code class="docutils literal"><span class="pre">gradlew</span> <span class="pre">samples:attachment-demo:runSender</span></code> in another terminal window to send the attachment. Now look at the other windows to
see the output of the demo</li>
</ol>
<p>To run from IntelliJ:</p>
<ol class="arabic simple">
<li>Open the Corda project in IntelliJ and import the Gradle project</li>
<li>Run the <code class="docutils literal"><span class="pre">Attachment</span> <span class="pre">Demo:</span> <span class="pre">Run</span> <span class="pre">Nodes</span></code> configuration to start three nodes. Once all nodes are started you will see several
&#8220;Node started up and registered in ...&#8221; messages</li>
<li>Run <code class="docutils literal"><span class="pre">Attachment</span> <span class="pre">Demo:</span> <span class="pre">Run</span> <span class="pre">Recipient</span></code>, which will wait for a trade to start</li>
<li>Run <code class="docutils literal"><span class="pre">Attachment</span> <span class="pre">Demo:</span> <span class="pre">Run</span> <span class="pre">Sender</span></code> to send the attachment</li>
<li>In the &#8220;Attachment Demo: Run Nodes&#8221; window you should see some log lines scroll past. Within a few seconds, the
message &#8220;File received - we&#8217;re happy!&#8221; should be printed.</li>
</ol>
</div>
<div class="section" id="raft-notary-demo">
<h2>Raft Notary demo<a class="headerlink" href="#raft-notary-demo" title="Permalink to this headline"></a></h2>
<p>This demo shows a party getting transactions notarised by a distributed <a class="reference external" href="https://raft.github.io/">Raft</a>-based notary service.
The demo will start three distributed notary nodes, and two counterparty nodes. One of the counterparties will generate transactions
that transfer a self-issued asset to the other party and submit them for notarisation.</p>
<p>The output will display a list of notarised transaction IDs and corresponding signer public keys. In the Raft distributed notary,
every node in the cluster can service client requests, and one signature is sufficient to satisfy the notary composite key requirement.
You will notice that successive transactions get signed by different members of the cluster (usually allocated in a random order).</p>
<p>To run from the command line in Unix:</p>
<ol class="arabic simple">
<li>Run <code class="docutils literal"><span class="pre">./gradlew</span> <span class="pre">samples:raft-notary-demo:deployNodes</span></code>, which will create node directories with configs under <code class="docutils literal"><span class="pre">samples/raft-notary-demo/build/nodes</span></code>.</li>
<li>Run <code class="docutils literal"><span class="pre">./samples/raft-notary-demo/build/nodes/runnodes</span></code>, which will start the nodes in separate terminal windows/tabs.
Wait until a &#8220;Node started up and registered in ...&#8221; message appears on each of the terminals</li>
<li>Run <code class="docutils literal"><span class="pre">./gradlew</span> <span class="pre">samples:raft-notary-demo:notarise</span></code> to make a call to the &#8220;Party&#8221; node to initiate notarisation requests
In a few seconds you will see a message &#8220;Notarised 10 transactions&#8221; with a list of transaction ids and the signer public keys</li>
</ol>
<p>To run from the command line in Windows:</p>
<ol class="arabic simple">
<li>Run <code class="docutils literal"><span class="pre">gradlew</span> <span class="pre">samples:raft-notary-demo:deployNodes</span></code>, which will create node directories with configs under <code class="docutils literal"><span class="pre">samples\raft-notary-demo\build\nodes</span></code>.</li>
<li>Run <code class="docutils literal"><span class="pre">samples\raft-notary-demo\build\nodes\runnodes</span></code>, which will start the nodes in separate terminal windows/tabs.
Wait until a &#8220;Node started up and registered in ...&#8221; message appears on each of the terminals</li>
<li>Run <code class="docutils literal"><span class="pre">gradlew</span> <span class="pre">samples:raft-notary-demo:notarise</span></code> to make a call to the &#8220;Party&#8221; node to initiate notarisation requests
In a few seconds you will see a message &#8220;Notarised 10 transactions&#8221; with a list of transaction ids and the signer public keys</li>
</ol>
<p>To run from IntelliJ:</p>
<ol class="arabic simple">
<li>Open the Corda project in IntelliJ and import the Gradle project</li>
<li>Run the <code class="docutils literal"><span class="pre">Notary</span> <span class="pre">Demo:</span> <span class="pre">Run</span> <span class="pre">Nodes</span></code> configuration to start the nodes. Once all nodes are started you will see several
&#8220;Node started up and registered in ...&#8221; messages</li>
<li>Run the <code class="docutils literal"><span class="pre">Notary</span> <span class="pre">Demo:</span> <span class="pre">Run</span> <span class="pre">Notarisation</span></code> configuration to make a call to the &#8220;Party&#8221; node to initiate notarisation requests
In a few seconds you will see a message &#8220;Notarised 10 transactions&#8221; with a list of transaction ids and the signer public keys</li>
</ol>
<p>Notary nodes store consumed states in a replicated commit log, which is backed by a H2 database on each node.
You can ascertain that the commit log is synchronised across the cluster by accessing and comparing each of the nodes&#8217; backing stores
by using the H2 web console:</p>
<ul>
<li><p class="first">Firstly, download <a class="reference external" href="http://www.h2database.com/html/download.html">H2 web console</a> (download the &#8220;platform-independent zip&#8221;),
and start it using a script in the extracted folder: <code class="docutils literal"><span class="pre">h2/bin/h2.sh</span></code> (or <code class="docutils literal"><span class="pre">h2\bin\h2</span></code> for Windows)</p>
</li>
<li><p class="first">If you are uncertain as to which version of h2 to install or if you have connectivity issues, refer to <code class="docutils literal"><span class="pre">build.gradle</span></code>
located in the <code class="docutils literal"><span class="pre">node</span></code> directory and locate the compile step for <code class="docutils literal"><span class="pre">com.h2database</span></code>. Use a client of the same
major version - even if still in beta.</p>
</li>
<li><p class="first">The H2 web console should start up in a web browser tab. To connect we first need to obtain a JDBC connection string.
Each node outputs its connection string in the terminal window as it starts up. In a terminal window where a node is running,
look for the following string:</p>
<p><code class="docutils literal"><span class="pre">Database</span> <span class="pre">connection</span> <span class="pre">url</span> <span class="pre">is</span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span class="pre">:</span> <span class="pre">jdbc:h2:tcp://10.18.0.150:56736/node</span></code></p>
<p>You can use the string on the right to connect to the h2 database: just paste it into the <cite>JDBC URL</cite> field and click <em>Connect</em>.
You will be presented with a web application that enumerates all the available tables and provides an interface for you to query them using SQL</p>
</li>
<li><p class="first">The committed states are stored in the <code class="docutils literal"><span class="pre">NOTARY_COMMITTED_STATES</span></code> table. Note that the raw data is not human-readable,
but we&#8217;re only interested in the row count for this demo</p>
</li>
</ul>
</div>
<div class="section" id="bank-of-corda-demo">
<h2>Bank Of Corda demo<a class="headerlink" href="#bank-of-corda-demo" title="Permalink to this headline"></a></h2>
<p>This demo brings up three nodes: a notary, a node acting as the Bank of Corda that accepts requests for issuance of some asset
and a node acting as Big Corporation which requests issuance of an asset (cash in this example).</p>
<p>Upon receipt of a request the Bank of Corda node self-issues the asset and then transfers ownership to the requester
after successful notarisation and recording of the issue transaction on the ledger.</p>
<div class="admonition note">
<p class="first admonition-title">Note</p>
<p class="last">The Bank of Corda is somewhat like a &#8220;Bitcoin faucet&#8221; that dispenses free bitcoins to developers for
testing and experimentation purposes.</p>
</div>
<p>To run from the command line in Unix:</p>
<ol class="arabic simple">
<li>Run <code class="docutils literal"><span class="pre">./gradlew</span> <span class="pre">samples:bank-of-corda-demo:deployNodes</span></code> to create a set of configs and installs under <code class="docutils literal"><span class="pre">samples/bank-of-corda-demo/build/nodes</span></code></li>
<li>Run <code class="docutils literal"><span class="pre">./samples/bank-of-corda-demo/build/nodes/runnodes</span></code> to open up three new terminal tabs/windows with the three nodes</li>
<li>Run <code class="docutils literal"><span class="pre">./gradlew</span> <span class="pre">samples:bank-of-corda-demo:runRPCCashIssue</span></code> to trigger a cash issuance request</li>
<li>Run <code class="docutils literal"><span class="pre">./gradlew</span> <span class="pre">samples:bank-of-corda-demo:runWebCashIssue</span></code> to trigger another cash issuance request.
Now look at the Bank of Corda terminal tab/window to see the output of the demo</li>
</ol>
<p>To run from the command line in Windows:</p>
<ol class="arabic simple">
<li>Run <code class="docutils literal"><span class="pre">gradlew</span> <span class="pre">samples:bank-of-corda-demo:deployNodes</span></code> to create a set of configs and installs under <code class="docutils literal"><span class="pre">samples\bank-of-corda-demo\build\nodes</span></code></li>
<li>Run <code class="docutils literal"><span class="pre">samples\bank-of-corda-demo\build\nodes\runnodes</span></code> to open up three new terminal tabs/windows with the three nodes</li>
<li>Run <code class="docutils literal"><span class="pre">gradlew</span> <span class="pre">samples:bank-of-corda-demo:runRPCCashIssue</span></code> to trigger a cash issuance request</li>
<li>Run <code class="docutils literal"><span class="pre">gradlew</span> <span class="pre">samples:bank-of-corda-demo:runWebCashIssue</span></code> to trigger another cash issuance request.
Now look at the Bank of Corda terminal tab/window to see the output of the demo</li>
</ol>
<p>To run from IntelliJ:</p>
<ol class="arabic simple">
<li>Open the Corda project in IntelliJ and import the Gradle project</li>
<li>Run the <code class="docutils literal"><span class="pre">Bank</span> <span class="pre">Of</span> <span class="pre">Corda</span> <span class="pre">Demo:</span> <span class="pre">Run</span> <span class="pre">Issuer</span></code> configuration to start three nodes. Once all nodes are started you will see several
&#8220;Node started up and registered in ...&#8221; messages</li>
<li>Run <code class="docutils literal"><span class="pre">Bank</span> <span class="pre">Of</span> <span class="pre">Corda</span> <span class="pre">Demo:</span> <span class="pre">Run</span> <span class="pre">RPC</span> <span class="pre">Cash</span> <span class="pre">Issue</span></code> to request issuance of some cash on behalf of Big Corporation via RPC</li>
<li>Run <code class="docutils literal"><span class="pre">Bank</span> <span class="pre">Of</span> <span class="pre">Corda</span> <span class="pre">Demo:</span> <span class="pre">Run</span> <span class="pre">Web</span> <span class="pre">Cash</span> <span class="pre">Issue</span></code> to request issuance of some cash on behalf of Big Corporation via HTTP</li>
</ol>
<div class="admonition note">
<p class="first admonition-title">Note</p>
<p class="last">To verify that the Bank of Corda node is alive and running, navigate to the following URL:
<a class="reference external" href="http://localhost:10005/api/bank/date">http://localhost:10005/api/bank/date</a></p>
</div>
<div class="admonition note">
<p class="first admonition-title">Note</p>
<p class="last">The Bank of Corda node explicitly advertises with a node service type as follows:
<code class="docutils literal"><span class="pre">advertisedServices</span> <span class="pre">=</span> <span class="pre">setOf(ServiceInfo(ServiceType.corda.getSubType(&quot;issuer&quot;))))</span></code>
This allows for 3rd party applications to perform actions based on Node Type.
For example, the Explorer tool only allows nodes of this type to issue and exit cash.</p>
</div>
<p>In the &#8220;Bank Of Corda Demo: Run Issuer&#8221; window, you should see the following progress steps displayed:</p>
<ul class="simple">
<li>Awaiting issuance request</li>
<li>Self issuing asset</li>
<li>Transferring asset to issuance requester</li>
<li>Confirming asset issuance to requester</li>
</ul>
<p>In the client issue request window, you should see the following printed:</p>
<ul class="simple">
<li>Successfully processed Cash Issue request</li>
</ul>
<p>Launch the Explorer application to visualize the issuance and transfer of cash for each node:</p>
<blockquote>
<div><code class="docutils literal"><span class="pre">./gradlew</span> <span class="pre">tools:explorer:run</span></code> (on Unix) or <code class="docutils literal"><span class="pre">gradlew</span> <span class="pre">tools:explorer:run</span></code> (on Windows)</div></blockquote>
<p>Using the following login details:</p>
<ul class="simple">
<li>For the Bank of Corda node: localhost / port 10004 / username bankUser / password test</li>
<li>For the Big Corporation node: localhost / port 10006 / username bigCorpUser / password test</li>
</ul>
<p>See <a class="reference external" href="https://docs.corda.net/node-explorer.html">https://docs.corda.net/node-explorer.html</a> for further details on usage.</p>
</div>
<div class="section" id="simm-and-portfolio-demo-aka-the-initial-margin-agreement-demo">
<span id="simm-demo"></span><h2>SIMM and Portfolio Demo - aka the Initial Margin Agreement Demo<a class="headerlink" href="#simm-and-portfolio-demo-aka-the-initial-margin-agreement-demo" title="Permalink to this headline"></a></h2>
<div class="section" id="background-and-simm-introduction">
<h3>Background and SIMM Introduction<a class="headerlink" href="#background-and-simm-introduction" title="Permalink to this headline"></a></h3>
<p>This app is a demonstration of how Corda can be used for the real world requirement of initial margin calculation and
agreement; featuring the integration of complex and industry proven third party libraries into Corda nodes.</p>
<p>SIMM is an acronym for &#8220;Standard Initial Margin Model&#8221;. It is effectively the calculation of a &#8220;margin&#8221; that is paid
by one party to another when they agree a trade on certain types of transaction. This margin is
paid such that, in the event of one of the counterparties suffering a credit event
(a financial term and a polite way to say defaulting, not paying the debts that are due, or potentially even bankruptcy),
then the party that is owed any sum already has some of the amount that it should have been paid. This payment to the
receiving party is a preventative measure in order to reduce the risk of a potentially catastrophic default domino
effect that caused the <a class="reference external" href="https://en.wikipedia.org/wiki/Financial_crisis_of_2007%E2%80%932008">Great Financial Crisis</a>,
as it means that they can be assured that if they need to pay another party, they will have a proportion of the funds
that they have been relying on.</p>
<p>To enact this, in September 2016, the ISDA committee - with full backing from various governing bodies -
<a class="reference external" href="http://www2.isda.org/news/isda-simm-deployed-today-new-industry-standard-for-calculating-initial-margin-widely-adopted-by-market-participants">issued a ruling on what is known as the ISDA SIMM ™ model</a>,
a way of fairly and consistently calculating this margin. Any parties wishing to trade a financial product that is
covered under this ruling would, independently, use this model and calculate their margin payment requirement,
agree it with their trading counterparty and then pay (or receive, depending on the results of this calculation)
this amount. In the case of disagreement that is not resolved in a timely fashion, this payment would increase
and so therefore it is in the parties&#8217; interest to reach agreement in as short as time frame as possible.</p>
<p>To be more accurate, the SIMM calculation is not performed on just one trade - it is calculated on an aggregate of
intermediary values (which in this model are sensitivities to risk factors) from a portfolio of trades; therefore
the input to a SIMM is actually this data, not the individual trades themselves.</p>
<p>Also note that implementations of the SIMM are actually protected and subject to license restrictions by ISDA
(this is due to the model itself being protected). We were fortunate enough to technically partner with
<a class="reference external" href="http://www.opengamma.com">OpenGamma</a> who allowed us to demonstrate the SIMM process using their proprietary model.
In the source code released, we have replaced their analytics engine with very simple stub functions that allow
the process to run without actually calculating correct values, and can easily be swapped out in place for their real libraries.</p>
</div>
<div class="section" id="what-happens-in-the-demo-notionally">
<h3>What happens in the demo (notionally)<a class="headerlink" href="#what-happens-in-the-demo-notionally" title="Permalink to this headline"></a></h3>
<dl class="docutils">
<dt>Preliminaries</dt>
<dd><ul class="first last simple">
<li>Ensure that there are a number of live trades with another party financial products that are covered under the
ISDA SIMM agreement (if none, then use the demo to enter some simple trades as described below).</li>
</ul>
</dd>
<dt>Initial Margin Agreement Process</dt>
<dd><ul class="first last simple">
<li>Agree that one will be performing the margining calculation against a portfolio of trades with another party, and agree the trades in that portfolio. In practice, one node will start the flow but it does not matter which node does.</li>
<li>Individually (at the node level), identify the data (static, reference etc) one will need in order to be able to calculate the metrics on those trades</li>
<li>Confirm with the other counterparty the dataset from the above set</li>
<li>Calculate any intermediary steps and values needed for the margin calculation (ie sensitivities to risk factors)</li>
<li>Agree on the results of these steps</li>
<li>Calculate the initial margin</li>
<li>Agree on the calculation of the above with the other party</li>
<li>In practice, pay (or receive) this margin (omitted for the sake of complexity for this example)</li>
</ul>
</dd>
</dl>
</div>
<div class="section" id="demo-execution-step-by-step">
<h3>Demo execution (step by step)<a class="headerlink" href="#demo-execution-step-by-step" title="Permalink to this headline"></a></h3>
<p>To run from the command line in Unix:</p>
<ol class="arabic simple">
<li>Deploy the nodes using <code class="docutils literal"><span class="pre">./gradlew</span> <span class="pre">samples:simm-valuation-demo:deployNodes</span></code></li>
<li>Run the nodes using <code class="docutils literal"><span class="pre">./samples/simm-valuation-demo/build/nodes/runnodes</span></code></li>
</ol>
<p>To run from the command line in Windows:</p>
<ol class="arabic simple">
<li>Deploy the nodes using <code class="docutils literal"><span class="pre">gradlew</span> <span class="pre">samples:simm-valuation-demo:deployNodes</span></code></li>
<li>Run the nodes using <code class="docutils literal"><span class="pre">samples\simm-valuation-demo\build\nodes\runnodes</span></code></li>
</ol>
<p>To run from IntelliJ:</p>
<ol class="arabic simple">
<li>Open the Corda project in IntelliJ and import the Gradle project</li>
<li>Run the <code class="docutils literal"><span class="pre">SIMM</span> <span class="pre">Valuation</span> <span class="pre">Demo</span></code> configuration</li>
</ol>
<p>Then, for all three:</p>
<ol class="arabic simple" start="3">
<li>Browse to <a class="reference external" href="http://localhost:10005/web/simmvaluationdemo">http://localhost:10005/web/simmvaluationdemo</a></li>
<li>Select the counterparty (i.e. Bank B)</li>
<li>Enter at least 3 trades - via the &#8220;Create New Trade&#8221; tab</li>
<li>On the &#8220;Agree Valuations&#8221; tab, click the &#8220;Start Calculations&#8221; button</li>
</ol>
<p>Additionally, you can confirm that these trades are not visible from <a class="reference external" href="http://localhost:10009/web/simmvaluationdemo/">Bank C&#8217;s node</a>
and are visible to <a class="reference external" href="http://localhost:10007/web/simmvaluationdemo/">Bank B</a>.</p>
<p>Please note that any URL path information after <cite>simmvaluationdemo</cite> should not be bookmarked or navigated to directly, as it is only provided for aesthetic purposes.</p>
</div>
</div>
</div>
</div>
</div>
<footer>
<div class="rst-footer-buttons" role="navigation" aria-label="footer navigation">
<a href="CLI-vs-IDE.html" class="btn btn-neutral float-right" title="CLI vs IDE" accesskey="n">Next <span class="fa fa-arrow-circle-right"></span></a>
<a href="getting-set-up-fault-finding.html" class="btn btn-neutral" title="Troubleshooting" accesskey="p"><span class="fa fa-arrow-circle-left"></span> Previous</a>
</div>
<hr/>
<div role="contentinfo">
<p>
&copy; Copyright 2016, R3 Limited.
</p>
</div>
Built with <a href="http://sphinx-doc.org/">Sphinx</a> using a <a href="https://github.com/snide/sphinx_rtd_theme">theme</a> provided by <a href="https://readthedocs.org">Read the Docs</a>.
</footer>
</div>
</div>
</section>
</div>
<script type="text/javascript">
var DOCUMENTATION_OPTIONS = {
URL_ROOT:'./',
VERSION:'latest',
COLLAPSE_INDEX:false,
FILE_SUFFIX:'.html',
HAS_SOURCE: true
};
</script>
<script type="text/javascript" src="_static/jquery.js"></script>
<script type="text/javascript" src="_static/underscore.js"></script>
<script type="text/javascript" src="_static/doctools.js"></script>
<script type="text/javascript" src="_static/js/theme.js"></script>
<script type="text/javascript">
jQuery(function () {
SphinxRtdTheme.StickyNav.enable();
});
</script>
</body>
</html>