<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Sneha Damle on Medium]]></title>
        <description><![CDATA[Stories by Sneha Damle on Medium]]></description>
        <link>https://medium.com/@sne.damle?source=rss-3ca8a436b4e5------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*dJ_s8Y4T2TaKprrKTJpYlQ.jpeg</url>
            <title>Stories by Sneha Damle on Medium</title>
            <link>https://medium.com/@sne.damle?source=rss-3ca8a436b4e5------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 04 Dec 2026 07:52:02 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@sne.damle/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Announcing Corda 4.14: Unlocking Interoperability with the Solana Notary]]></title>
            <link>https://medium.com/corda/announcing-corda-4-14-unlocking-interoperability-with-the-solana-notary-591f23c56554?source=rss-3ca8a436b4e5------2</link>
            <guid isPermaLink="false">https://medium.com/p/591f23c56554</guid>
            <category><![CDATA[solana-blockchain]]></category>
            <category><![CDATA[interoperability]]></category>
            <category><![CDATA[defi]]></category>
            <category><![CDATA[corda]]></category>
            <dc:creator><![CDATA[Sneha Damle]]></dc:creator>
            <pubDate>Wed, 01 Apr 2026 13:04:23 GMT</pubDate>
            <atom:updated>2026-04-01T13:04:23.747Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xIcAAe6u0b8iorTBaQMsSQ.jpeg" /><figcaption>Announcing the release of Corda 4.14 — Corda Solana Notary</figcaption></figure><p>We’re excited to announce the release of <a href="https://docs.r3.com/en/platform/corda/4.14/enterprise.html"><strong>Corda 4.14</strong></a>, the latest update in the Corda 4 line. This release reflects our continued commitment to supporting and evolving the platform that many of you rely on for mission-critical applications.</p><p>A key highlight of this release is the introduction of the <strong>Corda Solana Notary</strong>, bringing new capabilities that connect the reliability of Corda networks with the performance of the Solana ecosystem.</p><h3>Opportunities Enabled by the Corda Solana Notary</h3><p>For existing Corda 4 network deployments, the Solana Notary opens several potential avenues:</p><p><strong>Enhanced verifiability</strong>: Notarization events from Corda networks can be anchored to Solana, enabling additional independent verification without exposing private business data.</p><p><strong>Access to high-performance public infrastructure</strong>: Leveraging Solana’s scalable infrastructure enables Corda networks to support growing transaction volumes and larger multi-party ecosystems.</p><p><strong>Interoperability potential:</strong> Integration with Solana creates opportunities for Corda networks to engage with the growing digital asset infrastructure ecosystem when required.</p><p><strong>Asset bridging and cross‑chain DvP:</strong> Enable tokenized assets on Corda to be represented on Solana, allowing for the atomic exchange of assets for payments such as stablecoins. The Corda notary coordinates settlement and anchors proof on Solana, preventing double spending while allowing institutions to retain their existing infrastructure and unlocking access to digital asset investors and DeFi liquidity.</p><p><strong>Future ready architecture:</strong> This approach prepares Corda networks for hybrid enterprise public blockchain workflows as the market evolves.</p><p>These capabilities are optional and additive, meaning existing Corda networks can explore them where relevant without disrupting current deployments.</p><h3><strong>Benefits for existing Corda 4 networks</strong></h3><p>Our foremost commitment is to support, optimize, and evolve the Corda 4 platform for our client’s long-term success. Corda 4.14 delivers new capabilities that extend your network’s functionality while enhancements that ensure your deployments continue to benefit from ongoing innovation while maintaining the stability and enterprise grade features you expect.</p><p>The introduction of the Corda Solana Notary expands the options available for transaction finality by leveraging Solana’s high performance blockchain infrastructure. For Corda networks, this creates new opportunities to anchor transaction uniqueness and provide additional transparency and verifiability through public infrastructure, while maintaining Corda’s privacy model.</p><h3><strong>Continued Innovation and Why Upgrading Matters</strong></h3><p>Our recent releases demonstrate a consistent pattern of incremental innovation and platform strengthening:</p><p>Corda 4.12 introduced support for <a href="https://docs.r3.com/en/platform/corda/4.12/enterprise/release-notes-enterprise.html#java-and-kotlin-upgrade">Java 17 and Kotlin 1.9</a>.</p><p>Corda 4.13 built on this with enhanced operational capabilities, including <a href="https://docs.r3.com/en/platform/corda/4.13/enterprise/release-notes-enterprise.html#segregated-thread-pools">segregated thread pools</a>, <a href="https://docs.r3.com/en/platform/corda/4.13/enterprise/release-notes-enterprise.html#automatic-ledger-recovery">automatic ledger recovery</a>, and <a href="https://docs.r3.com/en/platform/corda/4.13/enterprise/release-notes-enterprise.html#read-only-nodes">read-only node</a> support, as well as <a href="https://docs.r3.com/en/platform/corda/4.13/enterprise/release-notes-enterprise.html#additional-monitoring-metrics">improvements to monitoring</a>, <a href="https://docs.r3.com/en/platform/corda/4.13/enterprise/release-notes-enterprise.html#rpc-thread-pool">RPC performance</a>, and security controls.</p><p>Corda 4.14 continues this trajectory with the <a href="https://docs.r3.com/en/platform/corda/4.14/enterprise/release-notes-enterprise.html#solana-notary">Corda Solana Notary</a>, enabling new options for interoperability, and hybrid blockchain architectures.</p><p>Staying up to date with these releases ensures you benefit from the latest capabilities, improved performance and security, and alignment with our actively evolving roadmap.</p><h3><strong>Strengthening the Corda Roadmap</strong></h3><p>The Corda 4.14 release is also an important step in our broader roadmap. It demonstrates our commitment to:</p><ol><li>Continuing to deliver incremental innovation for our Corda 4 clients.</li><li>Introducing new interoperability capabilities with external blockchain networks.</li><li>Enabling new enterprise use cases while preserving Corda’s privacy and security model.</li></ol><h3><strong>The Corda&lt;&gt;Solana Collaboration</strong></h3><p>Our collaboration with the Solana ecosystem represents a strategic effort to bridge enterprise DLT with high performance public blockchain infrastructure. By combining Corda’s privacy focused architecture with Solana’s scalability and global developer ecosystem, we are creating new possibilities for enterprise networks looking to extend their reach and functionality.</p><h3><strong>Our Commitment to You</strong></h3><p>Most importantly, we want to reaffirm that our primary focus remains supporting our existing Corda 4 clients. Releases like Corda 4.14 ensure that your platforms continue to benefit from innovation, expanded capabilities, and a clear product roadmap.</p><p>The Corda 4.14 release packs are available for download on the Customer Hub <a href="https://jor3cev.sharepoint.com/sites/CustomerHub/Shared%20Documents/Forms/AllItems.aspx?csf=1&amp;web=1&amp;e=nzkM3J&amp;CID=de987c37%2D1ef4%2D4879%2D978f%2D35d96df00ba4&amp;FolderCTID=0x012000E8B3ECE554289E48A89EC477C7BA800B&amp;id=%2Fsites%2FCustomerHub%2FShared%20Documents%2FCorda%5FEnterprise%2FCorda%20Enterprise%204%2E14%20%2B%20Notary">here</a>.</p><p>The documentation for Corda 4.14 is also available <a href="https://docs.r3.com/en/platform/corda/4.14/enterprise/notary/solana-notary.html">here</a> for reference.</p><p>If you would like to learn more about Corda 4.14 or the Corda Solana Notary, please reach out to your Corda representative.</p><p>Best regards,<br>The Corda Team</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=591f23c56554" width="1" height="1" alt=""><hr><p><a href="https://medium.com/corda/announcing-corda-4-14-unlocking-interoperability-with-the-solana-notary-591f23c56554">Announcing Corda 4.14: Unlocking Interoperability with the Solana Notary</a> was originally published in <a href="https://medium.com/corda">Corda</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Corda Payments SDK Developer preview: Announcement Letter]]></title>
            <link>https://medium.com/corda/corda-payments-sdk-developer-preview-announcement-letter-99034ffab4a3?source=rss-3ca8a436b4e5------2</link>
            <guid isPermaLink="false">https://medium.com/p/99034ffab4a3</guid>
            <category><![CDATA[payment-service-provider]]></category>
            <category><![CDATA[sdk]]></category>
            <category><![CDATA[corda]]></category>
            <category><![CDATA[blockchain]]></category>
            <category><![CDATA[payments]]></category>
            <dc:creator><![CDATA[Sneha Damle]]></dc:creator>
            <pubDate>Thu, 13 Jan 2022 15:26:07 GMT</pubDate>
            <atom:updated>2022-01-13T15:28:32.382Z</atom:updated>
            <content:encoded><![CDATA[<h3><strong>The Technical Preview of Corda Payments is Here!</strong></h3><p>R3 has launched the Technical Preview of Corda Payments, a new payment initiation and processing module for CorDapps. Corda Payments enables developers to quickly connect to traditional off-ledger payment rails and payment service providers with minimal coding. Corda Payments includes out-of-the-box integration with <a href="https://www.modulrfinance.com/">Modulr</a> — a banking as a service provider for UK and EU real-time payments that can initiate a payment on behalf of the customer. With minimal code, developers can initiate a payment instruction, check balances, review transaction history and view the payment status. The agent application then orchestrates the payment by taking the instructions from the payment flow and routes the transaction to Modulr.</p><p>Sign up for your Corda Payments trial today on <a href="https://customerhub.r3.com/s/sign-up">Customer Hub</a>.</p><h3>How It Works</h3><p>Corda Payments Technical Preview comprises of two core components:</p><p><strong>1) Agent CorDapp: </strong>a closed source JAR operated by a Business Network Operator. It can use an existing Corda network or establish a new permissioned Corda Payments Network. The operator needs to own a node and install the Corda Payments Agent CorDapp.</p><ul><li><strong>Gateway Service: </strong>this collects payment requests from the vault within the Agent Cordapp and makes a call to the REST API endpoints of the PSP to try and process the payment.</li></ul><p><strong>2) Corda Payments SDK: </strong>a library that integrates with user’s CorDapp allowing the end user to initiate a payment. You can use it to send payment instructions on the Corda Payments Network to the Agent.</p><p>Additionally, we are providing :</p><ul><li><strong>Sample Agent UI </strong>— This is a sample React front end which can be used with the Agent to provide an enhanced user experience for testing and using the Corda Payments system</li><li><strong>Sample Client UI </strong>— This is a sample React front end which connects to one of the nodes on the network and can carry out limited functionality using the SDK. This front is an easy way to view the capabilities of the SDK without having to write code.</li><li><strong>Sample CorDapp</strong> — This is a sample CorDapp template which includes SDK configuration instructions and sample code to showcase how to integrate the SDK into a new or an existing CorDapp. This is not a CorDapp in the traditional sense but a template to allow one to easily setup a CorDapp.</li></ul><p>This diagram shows high-level components included in the preview, and an example of a simple payment flow.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*NRXUVmzMHlhXUSuIOb09Sw.png" /><figcaption>Diagram 1. High-level payment workflow and components</figcaption></figure><h3>FEATURES:</h3><p>The main features are the:</p><p><strong>Client CorDapp. </strong>The end-user writes business logic and creates payment instructions.</p><p><strong>Agent. </strong>Trusted party on the network — usually the Business Network Operator. As the agent, you will facilitate payments through to the integration with the PSP: Modulr. The agent is responsible for</p><ul><li><strong>Setting up the customer account</strong> on Modulr on behalf of the customer and removing the pain of KYB and compliance checks.</li><li><strong>Payment facilitator</strong> Since it sits in the middle of the business network, the agent facilitates payment instructions. An agent can’t make payment on the user’s behalf but can review any errors that may occur when processing the transaction.</li></ul><p><strong>PSP</strong>. An external payment service provider (PSP). Our current integration is with Modulr who provides us with direct access to UK Faster Payments and SEPA. We are working with Modulr to establish other alternative payment routes on behalf of the Agent. The workflow is:</p><ol><li>An end-user initiates payment instructions to make a payment.</li><li>The agent sends the payments to the PSP.</li><li>The PSP responds to say that the payment has been successfully received and accepted</li><li>The PSP will then sends a second payment status to confirm settlement success</li><li>The agent receives the payment status from the PSP and in turns updates the payment status through to the Cordapp for end user visibility.</li></ol><p>We have designed the technical preview to provide the core payment capabilities our Corda customers require, whilst delivering a seamless digital experience as the user remains within the Corda environment. Payments will be processed off ledger using traditional payments rails. Payments rails are optimised to offer the fastest settlement service and status is tracked and updated on the ledger and held within the vault.</p><h4>Low-level Components of Corda Payments</h4><p>This diagram shows the end-user infrastructure and the agent infrastructure in more details.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*MsEO_qZhqQBZsGTJvDy7wA.png" /><figcaption>Diagram 2. Low-level Components of Corda Payments</figcaption></figure><p>R3 provides fully prewritten end user and agent infrastructure. It contains the:</p><ul><li><strong>Agent CorDapp</strong>, the network operator, installs this on the agent node.</li><li><strong>Key storage,</strong> for storing agent’s credentials.</li></ul><p>The agent exposes the agent REST API for agent operations staff to interact with the agent infrastructure. There will also be a sample Agent GUI provided as part of the release</p><p>The above diagram shows the components of a Business CorDapp:</p><p><strong>User-written components</strong>:</p><ul><li>Business CorDapp flows</li><li>Web server</li><li>Business CorDapp UI</li></ul><p><strong>The Payments SDK:</strong></p><ul><li>Payment Flows APIs</li><li>The State Machine, which is shared with the agent CorDapp, and the vault listener.</li></ul><p>The end-user interacts with the Payments CorDapp. Business CorDapp flows use Payments SDK calls and interact with the payments infrastructure. The end-user needs to write business logic to drive Payments SDK calls. The payments SDK provides an easy way to integrate a set of generic Payments Service APIs, which trigger the State Machine to execute payments and return a status update to the Vault Listener.</p><p>Here’s an example of a payment execution from the user’s perspective, simplified to one line. Consider the following example of establishing connection (line 1), getting a list of nodes on the network (line 3), and making payment (line 20):</p><p>Code snippet: <a href="https://gist.github.com/iryna-09/b91709491e5f950d43ea250618ce03ce">https://gist.github.com/iryna-09/b91709491e5f950d43ea250618ce03ce</a></p><p>Payment can be achieved through a simple one-line payment instruction with only three parameters (amount, debtor, and creditor).</p><p>We are keen to get feedback and comments on Corda Payments to make improvements and meet your needs. For this and together with any questions please use our Slack payments <a href="https://cordaledger.slack.com/archives/C02KT1A3CGM">channel</a>.</p><p>Sign up for your trial on <a href="https://customerhub.r3.com/s/sign-up">Customer Hub</a> to start using Corda Payments today!</p><p><em>This blog has been written by Dr. Iryna Tsimashenka</em></p><p><em>Developer Evangelist at R3 | PhD in Computing | DLT | Performance Optimisation | Emerging Technologies</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=99034ffab4a3" width="1" height="1" alt=""><hr><p><a href="https://medium.com/corda/corda-payments-sdk-developer-preview-announcement-letter-99034ffab4a3">Corda Payments SDK Developer preview: Announcement Letter</a> was originally published in <a href="https://medium.com/corda">Corda</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[R3 APAC Developer Week Opening Day]]></title>
            <link>https://medium.com/@sne.damle/r3-apac-developer-week-opening-day-ea508f3858af?source=rss-3ca8a436b4e5------2</link>
            <guid isPermaLink="false">https://medium.com/p/ea508f3858af</guid>
            <category><![CDATA[corda]]></category>
            <category><![CDATA[conclave]]></category>
            <category><![CDATA[blockchain]]></category>
            <category><![CDATA[startup]]></category>
            <dc:creator><![CDATA[Sneha Damle]]></dc:creator>
            <pubDate>Mon, 25 Oct 2021 12:29:08 GMT</pubDate>
            <atom:updated>2021-10-25T12:29:08.772Z</atom:updated>
            <content:encoded><![CDATA[<p>Today we kicked off our <a href="https://events.hubilo.com/r3APAC/home">APAC Developer Week</a>. The first day of the R3 APAC developer week was eventful and full of superb talks and conversations that set the tone for the entire event.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*-rPVET0W1--1H-Yx" /></figure><p>The event was kicked off by Jeanine Ju, Head of Dev Rels @ R3.</p><p>Day 1 witnessed almost <a href="https://events.hubilo.com/r3APAC/people">150 attendees</a>, most of them seasoned and high technical developers. There were developers representing various technical communities, who attended in good numbers to set the tone for our developer week with a successful and collaborative Day 1.</p><p>Peter Li kicked off by talking about some of our live-in production applications like Contour. Following 14 public live pilots in 14 countries, <a href="https://www.r3.com/case-studies/contour-case-study/">Contour</a> has proven to reduce end-to-end processing time for LCs by 90% or more, simplifying the process for all participants and enabling new business opportunities for banks, corporates and trade ecosystem players.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*vNFwio1xjIbBdjVY" /></figure><p>Developers were enlightened with a talk on the potential of <a href="https://youtu.be/0_JPj0N0xWM">Corda</a> by Ashutosh as he explained the power of Corda.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*GUtUsT8sS9PVwckO" /></figure><p>The quiz in round 1 was won by Andre Chan who bagged $200 USD.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*JlSWzSHkIc4mc2YJ" /></figure><p>Of course, we would be wrong not to mention the Bollywood quizzes and the Magic show that kept us entertained throughout the session.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*tOldg4c9iSGWxEWv" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*AzLEgoBxr7Eyf8tU" /></figure><p>Developers were super interested in <a href="https://www.youtube.com/watch?v=DzF0Q2amiN4">Conclave’s business session</a> led by Ashutosh Meher. Then, R3’s Sneha Damle took the developers into the <a href="https://www.youtube.com/watch?v=tfRYKshX7RU&amp;t=2s">technical</a> and exciting features of Conclave with a talk on confidential computing, trusted execution environments, and data privacy.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*yKBG9pV2qtASIYrL" /></figure><p>Next up was the startup showcase. It was amazing to listen to Andre Chan, Innovation Lead at SCB Tech X, (the technology startup under Siam Commercial Bank group) speak about how they leverage DLT to solve their problems.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*1a10uT5WRbu-yQqU" /></figure><p>It was also great to listen to Mark Macduffie, Managing Director of Downsizer, speak about their transformative real estate platform that connects property developers and purchasers. There are two key features: firstly, NO cash deposit required and second, developers NEVER lose money on sales.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*sIbfOdnQHRoa2Or3" /></figure><p>Apart from above, the day was eventful and full of magic shows, questions, debates, sharing of information, and overall super interactive.</p><p>The biggest highlight of Day 1 — and certainly the part everyone was looking forward to — was the Code Challenge kickstart. Over the course of the week k, a prize of $1000 USD is being offered to the best designed Corda or Conclave application.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*p0StD23WqlMG2Zcx" /></figure><p>On Day 1 prizes worth more than $500 USD were distributed.</p><p>Finally, it’s important not to forget Adam kicked off the daily job fair, where attendees were given the chance to meet a whole bunch of employers one-on-one by scheduling time with them.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*sDgeIu5MHjS41Mj7" /></figure><p>These were the brief highlights from day one — I hope to see you all on day two of <a href="https://events.hubilo.com/r3APAC/home">APAC Developer Week</a> tomorrow.</p><p><em>— Sneha Damle is a Developer Evangelist at </em><a href="https://www.r3.com/"><em>R3</em></a><em>, an enterprise blockchain software firm working with a global ecosystem of more than 350 participants across multiple industries from both the private and public sectors to develop on Corda, its open-source blockchain platform, Corda Enterprise, a commercial version of Corda for enterprise usage, and Conclave, a confidential computing platform.</em></p><p><em>Follow Sneha on LinkedIn </em><a href="https://www.linkedin.com/in/sneha-damle-26919355/"><em>here</em></a><em>.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ea508f3858af" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[To mock or not to mock an enclave]]></title>
            <link>https://medium.com/@sne.damle/to-mock-or-not-to-mock-an-enclave-28a0649988cd?source=rss-3ca8a436b4e5------2</link>
            <guid isPermaLink="false">https://medium.com/p/28a0649988cd</guid>
            <category><![CDATA[confidential-computing]]></category>
            <category><![CDATA[r3]]></category>
            <category><![CDATA[developer]]></category>
            <category><![CDATA[conclave]]></category>
            <category><![CDATA[enclave]]></category>
            <dc:creator><![CDATA[Sneha Damle]]></dc:creator>
            <pubDate>Tue, 29 Jun 2021 17:30:44 GMT</pubDate>
            <atom:updated>2021-07-01T05:41:35.130Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/600/1*0nEfe-N5Msu6Uj128jgj2w.jpeg" /></figure><p>It is an exciting time: Conclave 1.1 is out and loaded with a bunch of new features and enhancements. In this blog I am going to talk about when you should compile and load an enclave in mock mode and how to do it, thus simplifying the development and testing when writing enclaves. Let’s start by <a href="https://www.conclave.net/downloads/conclave-sdk.html"><strong>downloading the SDK</strong></a><strong>.</strong></p><blockquote>Pretty good testing is easy to do. Excellent testing is quite hard to do. <em><br></em><strong> — James Bach, founder, Satisfice</strong></blockquote><p>Now, let’s talk about what an enclave is and how we use Conclave to build enclave applications. Then, we can explore the different modes you can use when building and running an enclave using Conclave. Finally, we’ll talk about ‘mock’ enclaves.</p><h4><strong>What is an enclave?</strong></h4><p>An Intel SGX enclave is a protected region of memory where the code executed and the data accessed is isolated in terms of</p><ul><li>Confidentiality: no one has access to the data</li><li>Integrity: no one can change the code and its behavior</li></ul><p>No one can access this memory; not even the processes running at higher levels, the operating system, or even the user himself/herself.</p><h4><strong>What is the role of Conclave when writing an SGX enclave?</strong></h4><p>Conclave builds on top of Intel’s SGX SDK, making it easier to develop enclaves in high-level languages, like Java or Kotlin.</p><p>An enclave can be built and loaded as a shared object on Linux OS. When using Conclave, this is managed automatically for you. You develop your application in two parts: the ‘host’ and the ‘enclave.’</p><p>The host runs outside the enclave and is responsible for loading the enclave and connecting it with the outside world. The enclave is where you put your code that handles data, keeping it locked away and safe in a small, controlled environment.</p><p>The command below is an example of how to load and start a Conclave application on a Linux machine.</p><pre>./gradlew host:run</pre><p>But what if you’re using a Mac or Windows platform?</p><h4><strong>How to load an enclave on Mac or Windows</strong></h4><p>Conclave provides you with a <em>container-gradle</em> script, which essentially provides a Linux environment to build your enclave using a docker container. You can compile, load, start, and then run a host and enclave using the container-gradle command.</p><pre>./container-gradle host:run</pre><p>When building an enclave for Intel SGX, Conclave compiles the code down to a native binary using the native-image capability in GraalVM. The resulting enclave benefits from a faster startup time and lower runtime memory overhead than if we had embedded an alternative JVM inside the enclave.</p><p>You might be wondering how to run an enclave if you don’t have an SGX-enabled CPU. This takes us to our next point.</p><h4><strong>Running an enclave in simulation mode</strong></h4><p>Conclave provides a ‘simulation’ mode for running enclaves on systems that don’t have an Intel SGX capability. Building and running Conclave applications in simulation mode uses the same process as production enclaves, it’s still compiled down to a native image, except that you can run your application on a system that does not support SGX. However, simulation mode still needs to run on a Linux platform.</p><p>Again, the container-gradle script comes to our rescue on non-Linux platforms, allowing us to load our simulation enclave using a Linux docker container. If you build the ‘hello-world’ sample provided with the Conclave SDK, then by default when you run the container-gradle script, Conclave loads the enclave in simulation mode.</p><p>This mode is useful when you do not have an SGX-enabled CPU but still want to use a mode that is as similar to a real SGX environment as possible.</p><p>This mode still compiles your code down to a native binary, which can result in fairly lengthy build times. You might be wondering — are there any other modes in which you can develop your enclave which makes build times as short as possible and debugging your enclave as easy as possible?</p><h4><strong>Running an enclave in modes other than simulation</strong></h4><p>Enclaves can also be built and run in debug and release modes. Both require SGX-enabled CPU.</p><p>Debug mode lets you run your enclave code in a real SGX environment but with certain debugging features enabled. For instance, if you write to the console inside an enclave in debug mode, it will be shown in the console output. It is also possible to connect a debugger to a debug mode enclave, however, at present it is not easy to step through Java code using this mode. Although debug enclaves run in a real SGX environment, the debug capability opens the door to accessing data inside the enclave so <strong>debug mode enclaves should never be used in production!</strong></p><p>Use release mode enclaves when you want to deploy your enclave to production. Release mode enclaves give you the full protection provided by Intel SGX. Unlike with a debug mode enclave, any writes to the console inside the enclave <strong>never leave the enclave</strong>, which prevents you from accidentally leaking data via the console.</p><p>To build an enclave in debug or release mode, specify the mode in container-gradle command for non-Linux systems.</p><pre>./container-gradle -PenclaveMode=debug host:build</pre><p>For Linux systems, use the below command:</p><pre>./gradlew -PenclaveMode=debug host:build</pre><p>We spoke about building an enclave in release, debug and simulation mode.</p><p>Now what if you want to test your enclave logic quickly, without the need to convert the enclave code to a native image? This is where <strong><em>mock</em></strong> mode comes into the picture.</p><h4><strong>How to run an enclave in mock mode</strong></h4><p>With the Conclave 1.1 release you can now load your enclave in mock mode. This means the enclave is loaded in the same JVM as that of the host, but no native image is created, no SGX-enabled CPU is required, and the build time is also reduced drastically. In mock mode, calling an enclave function is similar to calling a plain Java function. This is useful when you are continuously changing the enclave logic in the development phase and want to quickly test it. To run your enclave in mock mode, use the same script and provide “mock” as a parameter.</p><p>Unlike when using simulation, debug or release modes, the below command will work on macOS and Windows, as well as Linux. You do not need to use the container-gradle script for running mock mode enclaves on non-Linux platforms.</p><pre>./gradlew -PenclaveMode=mock host:run</pre><h4><strong>Unit Testing your Enclave Module using Mock Enclave</strong></h4><p>To test the enclave logic you can write unit tests in the enclave module. You need to add the host dependency to your enclave build.gradle, as the enclave instance is loaded by the EnclaveHost class present in the host module.</p><pre>testImplementation <strong>&quot;com.r3.conclave:conclave-host&quot;</strong></pre><p>You can then create an instance of the enclave by calling EnclaveHost.load.</p><pre>EnclaveHost mockHost = EnclaveHost.load(&quot;com.r3.conclave.sample.enclave.ReverseEnclave&quot;);<br>mockHost.start(null, null);</pre><p>Conclave automatically loads the enclave in mock mode by internally checking if the enclave class file is available on classpath. You can obtain the enclave instance using the EnclaveHost.mockEnclave property and then access the mock enclave’s internals.</p><pre>ReverseEnclave reverseEnclave = (ReverseEnclave)mockHost.getMockEnclave();</pre><p>Once you have the enclave handle, you can unit test the business logic in the enclave just as you would test any simple Java function. All the business logic written in your enclave class should ideally be unit tested in the enclave module using the mock enclave mode.</p><p>If you run the below command, by default the enclave is loaded in mock mode.</p><pre>./gradlew enclave:test</pre><h4><strong>Unit Testing your Host Module using Mock Enclave</strong></h4><p>When you want to test your enclave in simulation or on real SGX hardware (debug or release mode), it would make sense to write an integration test in the host module. Use the below command to run the host tests. By default, an enclave is loaded in simulation mode in the host.</p><p>You can now take advantage of the fact that an enclave can also be loaded in mock mode from the host test class as shown by the below command. Though I would say, when writing integration tests from the host, you would usually want to load your enclave in simulation mode or on real SGX hardware.</p><pre>./gradlew -PenclaveMode=mock host:test</pre><p><strong>MockConfiguration</strong></p><p>Sealing is the ability to encrypt and save data outside the enclave and make sure that only the appropriate enclave can decrypt it. When you build an enclave, the resulting enclave can be identified by two ‘measurements:’</p><ul><li>MRENCLAVE is a hash of the code, static data and layout of the enclave binary and ensures the enclave cannot be modified before it has been loaded.</li><li>MRSIGNER is a hash of the public part of the key used to sign the enclave.</li></ul><p>To encrypt the data, a key is used which is derived either from MRENCLAVE or MRSIGNER, and also version numbers for the software revocation level and the SGX TCB level. When data is sealed using MRENCLAVE, only that enclave can decrypt the data, hence updates to the enclave will leave the data useless. Sealing data to MRSIGNER allows different enclaves to access the data and also allows for enclave upgrades. Enclaves with higher revocation levels or TCB levels can read data sealed to lower levels, but enclaves with lower revocation or TCB levels cannot read data sealed by higher levels. You can test this behavior by passing in the different levels to a mock configuration as shown below.</p><h4><strong>Note</strong>:</h4><p><em>Revocation level</em> is the mock revocation level of the enclave, and gets incremented if a bug in the enclave/Conclave code is fixed.</p><p><em>TCB level</em> is the current security state of the CPU platform identified by Intel. This also includes the CPU SGX microcode version.</p><pre>MockConfiguration mockConfiguration = <strong>new </strong>MockConfiguration();<br>mockConfiguration.setRevocationLevel(1);<br>mockConfiguration.setTcbLevel(2);<br>mockConfiguration.setProductID(1);<br>EnclaveHost mockHost = EnclaveHost.load(&quot;com.r3.conclave.sample.enclave.ReverseEnclave&quot;, mockConfiguration);</pre><p>The Hello-World Sample used for this blog can be found in the Conclave SDK which you downloaded in the first section.</p><p><em>Thanks to Roy, Rusheb and the Conclave Team</em></p><p>To learn more, make sure to visit <a href="http://conclave.net/"><strong>conclave.net</strong></a> or join <a href="https://groups.io/g/conclave-discuss"><strong>the conclave-discuss mailing list</strong></a>, where you’ll have a direct line to the Conclave development team.</p><p><em>— Sneha Damle is a Developer Evangelist at </em><a href="https://www.r3.com/"><em>R3</em></a><em>, an enterprise blockchain software firm working with a global ecosystem of more than 350 participants across multiple industries from both the private and public sectors to develop on Corda, its open-source blockchain platform, Corda Enterprise, a commercial version of Corda for enterprise usage, and Conclave, a confidential computing platform.</em></p><p><em>Follow Sneha on LinkedIn </em><a href="https://www.linkedin.com/in/sneha-damle-26919355/"><em>here</em></a><em>.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=28a0649988cd" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Continuing Database Harmonization Between Corda and Corda Enterprise]]></title>
            <link>https://medium.com/corda/continuing-database-harmonization-between-corda-and-corda-enterprise-9d2a8ac12516?source=rss-3ca8a436b4e5------2</link>
            <guid isPermaLink="false">https://medium.com/p/9d2a8ac12516</guid>
            <category><![CDATA[dlt]]></category>
            <category><![CDATA[corda]]></category>
            <category><![CDATA[database]]></category>
            <category><![CDATA[upgrade]]></category>
            <category><![CDATA[blockchain]]></category>
            <dc:creator><![CDATA[Sneha Damle]]></dc:creator>
            <pubDate>Thu, 01 Oct 2020 01:24:28 GMT</pubDate>
            <atom:updated>2020-11-13T16:13:19.956Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*QDrEvEhRJ0-_pFrZ-6f1HA.png" /></figure><p>Since our Corda Enterprise launch in July of 2018, it&#39;s been our goal that CorDapps written and tested on Corda should work<em> </em>seamlessly<em> </em>when migrated to Corda Enterprise, without additional effort needed. With the release of <strong>Corda 4.6</strong>, we’ve added new enhancements to database harmonization to instill confidence in CorDapp developers that their CorDapps will work, no matter which flavor of Corda they choose.</p><p>In this blog, we will cover the database improvements included in the latest release to achieve easier harmonization and what steps should be taken by CorDapp developers interested in migrating to Corda 4.6.</p><h3><strong>First, a bit on Liquibase</strong></h3><p>Both the internals of the Corda and external enterprise CorDapps use <a href="https://www.liquibase.org/">Liquibase</a> for database schema versioning. CorDapp custom tables are created or upgraded automatically using <a href="https://docs.corda.r3.com/head/node-database.html#liquibase-ref">Liquibase</a>. Liquibase supports writing DDL/DML statements in many formats (XML, JSON, SQL, YAML).</p><h3>How does Liquibase work?</h3><blockquote>Liquibase uses a table called as DATABASECHANGELOG. This table maintains all the executed/applied DDL/DML scripts till date. Liquibase uses something called changeset to save executed scripts in DATABASECHANGELOG table. Each changeset is a collection of DDL/DML scripts. Essentially, DATABASECHANGELOG stores each executed changeset. This changelog table will be read every time a migration command is run to determine what changesets need to be executed. The node by default uses Liquibase internally which can be verified by looking at node-specific changesets in the DATABASECHANGELOG table. Liquibase will also be used by the CorDapp developer for CorDapp custom schemas. So each time a new schema is introduced, a new liquibase script should be added to the CorDapp.</blockquote><h3>Changes introduced in Corda 4.6</h3><p>In Corda, Liquibase was not supported/needed till now, and custom schemas/tables were created using Hibernate JPA. The idea is to harmonize database schema creation using Liquibase across Corda and Corda Enterprise. With this approach, migration scripts will now be needed for Corda as well. Migrating from Corda to Corda Enterprise will now be easy and will increase the possibility of discovering bugs/ testing migration scripts at a very early stage. Before Corda 4.6, nodes were setting up their schemas at runtime, whereas now, schema management is a deliberate step that has to be taken before running.</p><p>1. <strong>run-migration-scripts</strong></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/e2b1457ea6377c66cb0c89c6bdc18a32/href">https://medium.com/media/e2b1457ea6377c66cb0c89c6bdc18a32/href</a></iframe><p>2. <strong>— allow-hibernate-to-manage-app-schemas</strong></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/945b5530fb7d7eae717f6c6eb0b14e0a/href">https://medium.com/media/945b5530fb7d7eae717f6c6eb0b14e0a/href</a></iframe><p>3. <strong>runSchemaMigration = true</strong></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/fb79686fa254f40bebded999867d8451/href">https://medium.com/media/fb79686fa254f40bebded999867d8451/href</a></iframe><p>4. <strong>transactionIsolationLevel , initialiseSchema, initialiseAppSchema</strong> — These flags have now been removed and can no longer be used.</p><h3><strong>Upgrade from lower versions to Corda 4.6</strong></h3><h4>CorDapp Upgrade</h4><p>As mentioned above, until now, migration scripts/Liquibase were not required in open source. Hence any custom tables present in your CorDapp were created by Hibernate. Since Liquibase was not used to create these tables, there won&#39;t be any entries in the databasechangelog table. So, we will have to add these entries to the databasechangelog retrospectively. Follow the below steps to upgrade your CorDapp.</p><p><em>Assumption: The CorDapp is using a version of Corda less than 4.6.</em></p><p>Custom schemas/tables have been created in the database using Hibernate. There are no databasechangelog entries corresponding to this schema. I will be using the <a href="https://github.com/corda/samples-java/tree/master/Basic/cordapp-example">cordapp-example</a> to perform a CorDapp upgrade to 4.6.</p><p><strong>Step 1. Define Liquibase Scripts</strong></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/7c72436013f150806462ade8ceddfa67/href">https://medium.com/media/7c72436013f150806462ade8ceddfa67/href</a></iframe><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/be5447c628aa55410eef1cf4e09bfc26/href">https://medium.com/media/be5447c628aa55410eef1cf4e09bfc26/href</a></iframe><p><strong>Step 2. Override Migration resource by specifying the migration script name</strong></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/e69de73014b5b94958d86dcafbdd1ca8/href">https://medium.com/media/e69de73014b5b94958d86dcafbdd1ca8/href</a></iframe><p><strong>Step 3. Place the migration scripts in resources/migration folder in workflow</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/858/1*vxc3nxEJZ2nitnWwsCRSsg.png" /></figure><p><strong>Step 4. Build workflow and contract jar.</strong></p><p>Command: “./gradlew jar” to be run from project root. The cordapp jars can be found in build/libs directory of workflow and contract respectively.</p><p><strong>Step 5. Replace old workflow and contract jar with new one.</strong></p><p><strong>Step 6. Start the node by running java -jar corda.jar sync-app-schemas.</strong></p><p>If you do not run the sync-app-schemas and instead directly run <strong>run-migration-scripts — app-schemas</strong> command, it will complain with below error.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*bGyWvcuzNJr_8ZS-3txRxQ.png" /></figure><p>This is because we already have a table created by Hibernate in the database. To sync migration entry to databasechangelog use <strong>sync-app-schemas </strong>command.<strong> </strong>This will sync the table created by Hibernate and an entry will be made in the databasechangelog using the migration scripts.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*dKvmHm9YemMEr6zAPuqOmg.png" /></figure><p><strong>Step 7. Start the node</strong></p><h4>Node Upgrade</h4><p>By default, the node uses Liquibase scripts internally for its tables. Assuming all the required tables before 4.6 must be present in the database; we only need to worry about adding the new core schema tables part of 4.6.</p><p><strong>Step 1. Stop the node. Replace corda.jar with new 4.6 corda.jar</strong></p><p><strong>Step 2. Run the command run-migration-scripts — core-schemas</strong> to run new schemas part of 4.6. Running this command will automatically apply the new Liquibase scripts onto the database.</p><p><strong>Step 3. Start the node.</strong></p><h3>Upgrade from versions Corda &gt;= 4.6 to Corda Enterprise &gt;= 4.6</h3><p>CorDapp developers upgrading from an older version of Corda or Corda Enterprise to 4.6 will only need to run one command to upgrade the node.</p><p><strong>CorDapp Upgrade</strong></p><p><em>Note: If switching from H2 to any other database, users are required to retrospectively add entries to databasechangelog table for the custom tables created by Hibernate in Open Source.</em></p><p>As explained above, when upgrading from Corda to Corda Enterprise, developers are required to add Liquibase scripts for their CorDapps. Now developers won’t be required to add any Liquibase script for Enterprise, as they would already have a Liquibase script for our CorDapp in Corda. In addition, syncing changelogs will not be required.</p><p>Hence from an Corda to Corda Enterprise upgrade perspective, users don’t have to do anything beyond replacing the Corda jar with a Corda Enterprise jar!</p><p><strong>Node Upgrade</strong></p><p>Node upgrade will require adding extra tables/schemas of Corda Enterprise by running the below command.</p><p><strong><em>java -jar corda.jar run-migration-scripts -core-schemas</em></strong></p><p><em>Note: All the above migration paths apply to Corda 4.x nodes only and not to any of 3.x Corda nodes.</em></p><h3>Summary</h3><p>With the 4.6 release, database schemas are harmonized across Corda and Corda Enterprise by removing all schema management options from node configuration files and added start-up sub-commands. This would help reduce error-prone node configs. Liquibase support has now been added to Corda, making the upgrade from Corda to Corda Enterprise that much easier for CorDapp developers.</p><p>Thank you to Christian Sailer, Valerio Campanella, and the Corda Team.</p><p><em>Thanks for reading — </em><a href="https://www.linkedin.com/in/sneha-damle-26919355/"><em>Sneha Damle</em></a><em>, Developer Evangelist (R3)</em></p><p><em>Want to learn more about building excellent blockchain applications on Corda? Be sure to visit </em><a href="http://corda.net/"><em>corda.net</em></a><em>, check out our </em><a href="https://www.corda.net/community/"><em>community page</em></a><em> to learn how to connect with other Corda developers, and </em><a href="https://info.r3.com/email-preferences"><em>sign up</em></a><em> for one of our newsletters for the latest updates.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9d2a8ac12516" width="1" height="1" alt=""><hr><p><a href="https://medium.com/corda/continuing-database-harmonization-between-corda-and-corda-enterprise-9d2a8ac12516">Continuing Database Harmonization Between Corda and Corda Enterprise</a> was originally published in <a href="https://medium.com/corda">Corda</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Corda’s Accounts+Tokens-making blockchain more inclusive for everyone.]]></title>
            <link>https://medium.com/corda/cordas-accounts-tokens-making-blockchain-more-inclusive-for-everyone-3bf0c3993d41?source=rss-3ca8a436b4e5------2</link>
            <guid isPermaLink="false">https://medium.com/p/3bf0c3993d41</guid>
            <category><![CDATA[cordapp]]></category>
            <category><![CDATA[token]]></category>
            <category><![CDATA[blockchain]]></category>
            <category><![CDATA[corda]]></category>
            <category><![CDATA[account]]></category>
            <dc:creator><![CDATA[Sneha Damle]]></dc:creator>
            <pubDate>Mon, 15 Jun 2020 12:44:49 GMT</pubDate>
            <atom:updated>2020-06-15T12:51:52.095Z</atom:updated>
            <content:encoded><![CDATA[<h3>Corda’s Accounts + Tokens: making blockchain more inclusive</h3><p><em>After working with partners and developers, it is interesting to see how the trade finance, supply chain applications and many more are migrating to using an account-based model from the node-based model.</em></p><p><em>By integrating accounts and tokens as the solution these developers and partners are taking their very first step and answering the important questions such as how can you achieve more in a node-based model, how can you get more people on-boarded and make the blockchain platform inclusive in a more cost-efficient manner and how can you have people building token-based applications to take the advantage of the same.</em></p><p><em>Let us dive into the world of accounts and tokens by looking at a world cup ticket booking system as explained below and see how easy it is to integrate both.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/972/1*oMPRsyJKW145Np6fIHkRVQ.png" /><figcaption>Accounts and Tokens World Cup Ticket Booking CorDapp</figcaption></figure><p>This sample talks about a scenario where typically when the Cricket season starts, BCCI (Board of Control for Cricket) starts selling tickets.<br>There are multiple dealers whom the BCCI issues tickets and further these dealers sell tickets to their client. Dealer’s will represent their clients as accounts on their nodes. The tickets will be represented as tokens. Buyers (accounts) will be issued cash (tokens). Seller’s(accounts) will be issued a ticket(token). Buyers will then buy the ticket from the seller by giving him cash in the return. Below are the nodes used for this CorDapp.</p><p><strong>BCCI Node</strong>-Board of Control For Cricket node. This node is the primary legal authority for all cricket matches. This node will issue Non-Fungible tokens representing tickets to dealer accounts.</p><p><strong>Multiple Dealer Nodes</strong>-These are legal dealers verified by BCCI. They will set up accounts for all their customers on their nodes. They will be issued tickets by BCCI, which they can further sell to their customers.</p><p><strong>Bank Node-</strong>Issue’s cash to different accounts.</p><p><strong>Customer Accounts</strong>-Buyer who wish to buy a ticket from the dealer.</p><p><strong>Step 1: Create and Share Account Info</strong></p><p>To build a CorDapp which uses accounts, we need to create these accounts first. Accounts do not have legal identities like nodes but have an identity within the context of a node. So an account is always linked to a host node which will host this account. To have a transaction between accounts hosted on different nodes, both the nodes should be aware of the existence of the account. Hence the hosting node will share the account details with counterparties. Basic info like account name, hostname, account id is shared.</p><p>Let&#39;s start with two dealer nodes: DealerNode1 and DealerNode2. Let’s create agent accounts on respective dealer nodes. Let’s also create a buyer accounts on respective nodes.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/15f5cda79b396204a78817f65a9ee52f/href">https://medium.com/media/15f5cda79b396204a78817f65a9ee52f/href</a></iframe><p><strong>Step 2: Create the base token type</strong></p><p>Create the base token type for the ticket by calling the built inflow. We will create an evolvable type for the ticket instead of fixed, with issuer being the only participant. This makes it easy to update the ticket holders in case of any changes to the ticket; let&#39;s say the match is rescheduled because of adverse weather conditions.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/51d413abe57c876e2d244897101a401b/href">https://medium.com/media/51d413abe57c876e2d244897101a401b/href</a></iframe><p><strong>Step 3: Issue Non-Fungible Token To Dealer Account</strong></p><p>Once we have created a base ticket type, the dealer will issue non-fungible tokens representing the match tickets to dealers. It is advisable not to mix transactions involving participants as accounts and nodes. Either you use entirely accounts based model or node-based model. Hence in Step 1, we have created an account for the dealer as well. A default account is not created automatically for the node.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/9f890423cf28fa6060a8b377b0a7fa1c/href">https://medium.com/media/9f890423cf28fa6060a8b377b0a7fa1c/href</a></iframe><p><strong>Step 4: Issue cash(Fungible Tokens) to accounts</strong></p><p>Before the buyers can buy tickets, the bank will issue some cash to the buyers. To issue cash to the buyer, we will generate an anonymous key linked to this buyers account, assign this key as the holder of fungible token and issue cash. Notice the holder in class FungibleToken is of type AbstractParty, which implies the holder can either be a node or an account. In our case, it will be the buyer’s account.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/d77d3f546303bcc466dcbc874dd9572c/href">https://medium.com/media/d77d3f546303bcc466dcbc874dd9572c/href</a></iframe><p><strong>Step 5: Perform DVP between buyer and seller’s account on the same node</strong></p><p>To perform a DVP between two accounts, the buyer account will transfer cash to the seller account, and the seller account will transfer the ticket to the buyer account. This will be executed within one transaction. Part one of the DVP transaction is about moving the ticket from seller to buyer account by specifying the buyer account parameter.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/4820065da221b6e11b94d043685d3c22/href">https://medium.com/media/4820065da221b6e11b94d043685d3c22/href</a></iframe><p>The second part is about moving fungible tokens from buyer to seller account by specifying the seller account as the third param and specifying the buyer account as a change holder. When mixing accounts and tokens, do not forget to mention the query criteria by specifying account id using <strong>withExternalIds </strong>as specified on line 6 below. If you do not specify these criteria, all the unconsumed tokens will be available for transfer. To have tokens linked only to the account, specify the account id in the criteria.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/bd017fbfe2ce0b38bec72ded24a68d11/href">https://medium.com/media/bd017fbfe2ce0b38bec72ded24a68d11/href</a></iframe><p>To get signatures from both the buyer’s and seller’s account, we initiate the sessions with the accounts and call the CollectSignaturesFlow.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/889d8232f3feb4b25ab03a9a86f5a94c/href">https://medium.com/media/889d8232f3feb4b25ab03a9a86f5a94c/href</a></iframe><p><strong>Step 6: Perform DVP between buyer and seller’s account on different nodes</strong></p><p>This is an interesting flow where we will perform the DVP between accounts held on different nodes. Few important points to note are as below.</p><p>1.Since buyer’s and seller’s account want to transact with each other, buyers should be aware of the seller’s account and vice-versa. To do this, the node hosts will share the account info’s with each other. A node can share the account details created on its node with a counterparty by calling <strong><em>ShareAccountInfo</em></strong>. A node can also request for account info by calling <strong><em>RequestAccountInfo</em></strong>.</p><p>2.Since accounts do not have a true identity, we use Confidential Identities to generate a public-private key pair and assign it to an account. These keys can be used to transact with the accounts. These keys can be generated by calling <strong><em>RequestKeyForAccount</em></strong>. One account can be mapped to multiple keys. For the node to know which key belongs to which account, this mapping of keys to accounts must be present in the database. These keys are also used for signing the transaction. When we call CollectSignaturesFlow, the counterparty must know account&lt;-&gt;key mapping, otherwise, it complains when it tries to resolve the transaction since this key is unknown to the node. To avoid such scenarios, it is good to call <strong><em>SyncKeyMappingFlow</em></strong> in advance which syncs all the account&lt;-&gt;key mapping with the specified counterparty.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/ec6e2d55602dc1601a5f871471992e7c/href">https://medium.com/media/ec6e2d55602dc1601a5f871471992e7c/href</a></iframe><p>We will sync buyer’s and seller’s keys with the counterparty. However, when you will call the <strong><em>generateMove</em></strong> method of tokens to add inputs and outputs to a transaction, you will notice that it&#39;s not only the buyer’s and seller’s accounts represented as anonymous keys but there is one more unknown anonymous party present in the transaction. The token’s flow internally uses CI to generate a new anonymous party for the token holder. Make sure to sync the key corresponding to this anonymous party as well.</p><p>3. Now a bit on a signing. Sometimes since with accounts, we are using Confidential Identities, it becomes pretty confusing to get hold of the actual keys used for signing. This might happen when you have multiple inputs/outputs/commands each having multiple signers. I used a simple approach for this as below.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/ae4c5ea339ecbcdffc25ca3fcd9125a4/href">https://medium.com/media/ae4c5ea339ecbcdffc25ca3fcd9125a4/href</a></iframe><p>I used the <strong><em>filterMyKeys</em></strong> method from the <strong><em>KeyManagementService</em></strong>, which gives me the keys used for signing given a transaction. These keys will have the exact set of anonymous keys used as signers in the command. Once we get hold of these signers, we can sign the transaction using these keys. We can then specify these signers as a third param to CollectSignaturesFlow telling CollectSignaturesFlow to ignore collecting signatures from these given keys as they have already signed the transaction.</p><p><strong>Step 7: Confirm successful DVP</strong></p><p>We can query the vault to confirm the DVP transfer by specifying the account id in the query criteria.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/37953714c12c5d270b242adc5584528b/href">https://medium.com/media/37953714c12c5d270b242adc5584528b/href</a></iframe><h4>Database View</h4><p>Looking at the database, the following tables are predominately used for accounts and tokens.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Sx0B-r1-r5EEyAei4imSYQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vRxv5VzCJ3LTWlPFEE5jsA.png" /></figure><p>You can use below SQL query to get the token balance specific to an account by specifying the account name.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/e964c6928bb9bbdcd9a3c8c1a28c3eb4/href">https://medium.com/media/e964c6928bb9bbdcd9a3c8c1a28c3eb4/href</a></iframe><h4>Points to Note:</h4><ol><li>While integrating accounts and tokens, keep in mind that the new token holders are also added as anonymous parties. So make sure to sync their keys with appropriate counterparties.</li><li>When using tokens, the holder of the token will now be an account instead of the node.</li></ol><p>Sample code showing how to use Accounts and Tokens can be found <a href="https://github.com/corda/accounts-demo-supplychain">here</a>.</p><p>Accounts blog explaining a sample on Accounts can be found <a href="https://www.google.com/url?sa=t&amp;rct=j&amp;q=&amp;esrc=s&amp;source=web&amp;cd=2&amp;cad=rja&amp;uact=8&amp;ved=2ahUKEwipkrTfzL3pAhV0zjgGHZC_Ck8QFjABegQIBRAB&amp;url=https%3A%2F%2Fwww.corda.net%2Fblog%2Funlocking-new-opportunities-with-accounts-on-corda-2%2F&amp;usg=AOvVaw2K280toMk7mto-Gi3te3FP">here</a>.</p><p>Thanks to Roger, Will, Kasia, Stefano, Nitesh and The Corda Team</p><p><strong>Want to learn more about building excellent blockchain applications on Corda? Be sure to visit </strong><a href="http://corda.net/"><strong>corda.net</strong></a><strong>, check out our </strong><a href="https://www.corda.net/community/"><strong>community page</strong></a><strong> to learn how to connect with other Corda developers, and </strong><a href="https://info.r3.com/email-preferences"><strong>sign up</strong></a><strong> for one of our newsletters for the latest updates.</strong></p><p>— Sneha Damle is a Developer Evangelist at <a href="https://www.r3.com/">R3</a>, an enterprise blockchain software firm working with a global ecosystem of more than 350 participants across multiple industries from both the private and public sectors to develop on Corda, its open-source blockchain platform, and Corda Enterprise, a commercial version of Corda for enterprise usage.</p><p>Follow Sneha on <a href="https://www.linkedin.com/in/sneha-damle-26919355/">Linkedin</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3bf0c3993d41" width="1" height="1" alt=""><hr><p><a href="https://medium.com/corda/cordas-accounts-tokens-making-blockchain-more-inclusive-for-everyone-3bf0c3993d41">Corda’s Accounts+Tokens-making blockchain more inclusive for everyone.</a> was originally published in <a href="https://medium.com/corda">Corda</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Scale Your CorDapp with Corda’s Account Library]]></title>
            <link>https://medium.com/corda/scale-your-cordapp-with-cordas-account-library-2430960a5a58?source=rss-3ca8a436b4e5------2</link>
            <guid isPermaLink="false">https://medium.com/p/2430960a5a58</guid>
            <category><![CDATA[corda]]></category>
            <category><![CDATA[dlt]]></category>
            <category><![CDATA[blockchain]]></category>
            <category><![CDATA[r3]]></category>
            <category><![CDATA[developer]]></category>
            <dc:creator><![CDATA[Sneha Damle]]></dc:creator>
            <pubDate>Fri, 05 Jun 2020 20:45:24 GMT</pubDate>
            <atom:updated>2020-06-08T05:12:24.920Z</atom:updated>
            <content:encoded><![CDATA[<h3>Scale Your CorDapp with Corda’s Accounts Library</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0_VLm8h1OdOn3JquH2CxyQ.png" /></figure><p><em>An application underpinned by blockchain technology can be complex to deploy and operate. Blockchain applications — and their networks — need a way to represent their customers, be it a brokerage firm, a bank or a custodial account. The Accounts SDK is designed to satisfy these customer needs.</em></p><p><strong><em>What are Accounts</em></strong></p><blockquote>The accounts library allows a Corda node operator to split the vault into multiple “<strong>logical</strong>” sub-partitions. That’s it.</blockquote><blockquote><strong>An account is NOT a true identity. There is no physical vault isolation between accounts, and all accounts share the same vault. Accounts do not have a Doorman provisioned identity; instead, they only have an identity in the context of a host node.</strong></blockquote><p>Let’s take a look at a typical account flow.</p><h4>Step 1 : Import accounts</h4><p>The very first step after making the decision to use accounts in your CorDapp is to import the needed dependencies. The Accounts SDK operates on the application layer and so the following entries in your build.gradle (as shown below) will make Accounts accessible within your project. The entries include versioning info, addition of the corda-lib repository, and accounts and confidential identity. You can utilize accounts with new applications, or migrate an existing application from a node based model to accounts based (<em>in the latter scenario, you will also need to adjust your state definitions to handle AnonymousParty as described in step 4).</em></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/2cb2dd9633277b2dd217da8d567a113d/href">https://medium.com/media/2cb2dd9633277b2dd217da8d567a113d/href</a></iframe><h4>Before you move to Step 2….. a bit on AccountInfo</h4><p>An account is represented using an AccountInfo state which is a Linear State.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/844e11f57a4b4b83881c1b450690dffe/href">https://medium.com/media/844e11f57a4b4b83881c1b450690dffe/href</a></iframe><p>Each account has a name, host and unique id (linear id of linear state) associated with it. Account id can be assumed to be unique at a network level. AccountInfo is similar to NodeInfo but is <strong>not auto discoverable</strong> via Network Map Service. It is expected that the node which creates the account will share this account info with the peers as stated below.</p><h4>Step 2: Create Accounts</h4><p>To use accounts, the node needs to create accounts. The node vault is logically subdivided into multiple sub vaults each corresponding to an account. To create an account, you can use the inbuilt flow <em>CreateAccount</em> as below.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/433dcc8d10f9680560f34b8f3f57015d/href">https://medium.com/media/433dcc8d10f9680560f34b8f3f57015d/href</a></iframe><p>This flow creates an AccountInfo object and specifies the node name as the hostname on the node which runs this flow. Note: hostname is a Party object; hence an account is always associated with a particular node. This party object is the single participant of AccountInfo Linear state and will get notified of any state changes.</p><h4>Step 3 : Share Account</h4><p>If account on NodeB wants to interact with this account created on NodeA, NodeA should either share this account with NodeB by calling <em>ShareAccountInfo…</em></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/6344c8f2f37389eeae987e56a735ab53/href">https://medium.com/media/6344c8f2f37389eeae987e56a735ab53/href</a></iframe><p>or, NodeB can request this account from NodeA by calling <em>RequestAccountInfo.</em></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/5082639d7445e06851866d23e554d4aa/href">https://medium.com/media/5082639d7445e06851866d23e554d4aa/href</a></iframe><p>Once both the nodes are aware of the account info, they can transact with each other.</p><h4>Step 4: State Share with accounts</h4><p>We use Corda to make sure “What you see is what I see”, where <em>you</em> and <em>I </em>were nodes until now. With accounts, we aim to achieve “What you see is what I see” where <em>you</em> and <em>I</em> are accounts hosted on individual nodes.</p><p>As we know, states have a participant field which is of type AbstractParty.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/f19b1f79a2702ea191f0569f86bd57d5/href">https://medium.com/media/f19b1f79a2702ea191f0569f86bd57d5/href</a></iframe><p>Instead of adding Party class which implements AbstractParty, we will add AnonymousParty (which takes in a Public Key as a parameter) representing an account to participants. Hence each account must be associated with a Public Key. Just as a node is associated with a CordaX500 name and a public key, an account is not associated with any legal CordaX500 and is not a true identity, but is only associated with a public key (We rely on Confidential Identities to generate these public keys). To create a public key and associate it with an account, you can use the below flow.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/8605d129fa6fbed468d3c98664a15c18/href">https://medium.com/media/8605d129fa6fbed468d3c98664a15c18/href</a></iframe><p>This creates a public key saves the public key to account id mapping in the database and returns an AnonymousParty object.</p><p><strong>Note: One account has more than 1 public keys associated with it. 1 public key belongs to only 1 account.</strong></p><p>Generate a new key pair, map it to an account and use this public key to participate in a state. These public keys are based on <a href="https://www.google.com/url?sa=t&amp;rct=j&amp;q=&amp;esrc=s&amp;source=web&amp;cd=&amp;cad=rja&amp;uact=8&amp;ved=2ahUKEwj4lYyFpsfpAhWljuYKHRjKDrAQFjACegQIBBAB&amp;url=https%3A%2F%2Fgithub.com%2Fcorda%2Fconfidential-identities&amp;usg=AOvVaw3xuWeFW2-U6vV76G1nTDC5"><em>confidential identities</em></a>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*UnQJzFS5w_FarGaRA6w2Gg.png" /></figure><p>This state is now mapped to account using the above generated public keys.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*OsMU5WqAdhSvvfSVNWqnqA.png" /></figure><blockquote>An account is<strong> a collection of Public Keys</strong>. These PublicKeys are used to participate in (or own) ContractStates. Then we’d say <strong>ContractState is owned by the account</strong> that the Public Key is allocated to.</blockquote><p><strong>Step 5 : Signing the transaction</strong></p><p>These bunch of public-private key pairs created for accounts are actually owned by the host node, and when it comes to account signing, it’s actually the host node who signs the transaction using these keys on behalf of the account.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/aa101d7b9faab2c8f938fa3b4f8d6f2c/href">https://medium.com/media/aa101d7b9faab2c8f938fa3b4f8d6f2c/href</a></iframe><p>Buyer first signs the transaction by passing in its key to signInitialTransaction. Here the node actually signs using this key on behalf of the buyer. We then call CollectSignaturesFlow to get the seller’s signature on the transaction by specifying the buyer’s key as the last parameter which tells CollectSignaturesFlow that buyer has already signed the transaction.</p><h4><strong>Some important flows to know</strong></h4><h4>1. ShareStateWithAccountFlow</h4><p>We usually use SendStateAndRefFlow for sharing states between nodes. For accounts, you can use, <strong>ShareStateWithAccountFlow </strong>flow<strong> </strong>which wraps SendStateAndRefFlow and makes sure that the shared state is visible only to the specified account and not to other accounts hosted on the node. This is how states are shared to accounts only on a need to know basis.</p><h4>2. SyncKeyMappingFlow</h4><p>As we know there can be multiple keys mapped to a single account. Also in each transaction we could potentially request for new keys and use new keys each time. The counterparty must be aware about the keys used for signing the transaction. So it makes sense to share account&lt;-&gt;public key mappings to the counterparty. This can be done by calling <strong>SyncKeyMappingFlow.</strong></p><h4>3. ShareStateAndSyncAccounts</h4><p>This flow is a combination of above two which can be used to sync states as well as sync keys.It shares a StateRef with another node, sends all the confidential identities participating in the state and also sends all the AccountInfos associated with the participation keys.</p><h4>Querying Accounts</h4><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/697df6f13bc55066f79dd0ca3af916b8/href">https://medium.com/media/697df6f13bc55066f79dd0ca3af916b8/href</a></iframe><p>To query states which belong to this account make sure you specify the account id. Not specifying this account id will return you states not belonging to this account but other accounts as well.</p><h4>Migrating from One Host to other</h4><p>Can we in any way change the host “ownership” of the account from one node to another?</p><p>There will be work done on this in the future, but as of now, there are two options which could help you resolve your issue.</p><ol><li>Set up a new account on the new node. Generate new key(s) for the new account. Spend all the states from the old account to this new account. (This is the recommended one)</li><li>If you control the all the keys used to participate in your states and can migrate them to the new node, then you need to import the key pairs somehow and then copy all the states across from the old node to the new node.</li></ol><h4>Holistic Account View</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*s_WWrYQMLEXAgOXCwvzjQA.png" /><figcaption>Holistic View of Accounts-SDK</figcaption></figure><p>Looking at accounts from a holistic view, we can see that the above diagram is divided into 3 parts — the nodes which are first-class identities and have their certificates signed by the Doorman.</p><p>The second part shows how a node hosts accounts. 1 account belongs(hosted on) to only 1 node but can be shared with other nodes as well.</p><p>The third layer talks about identities. These are not true identities like node but are identifiable only in the context of the node. They do not have certificates signed by Doorman but instead have self-signed certificates. These identities represent application-level identities which can be mapped to accounts. Hence off ledger identities can be easily mapped to accounts on Corda. Account-level / ACL should be handled by the Cordapp developer at the application level. Identities can be used to handle permissioning at the application level.</p><h4><strong>Points to Note:</strong></h4><ol><li>By default, an account is not created for the node.</li><li>Do not mix accounts with non-accounts, its highly recommended that if you wish to use accounts, then use accounts in all your flows.</li><li>Accounts can be thought of as the very first step towards handling key pairs outside the node.</li><li>Use cases like building custody accounts/brokerage accounts/bank accounts/company employee account etc. can make good use of accounts-sdk.</li><li>All nodes need not support accounts. The accounts sdk is a JAR which can be dropped into the CorDapps folder. Use of it is optional.</li><li>Accounts-sdk was introduced in Corda 4.3, available to CE and OS. It integrates well with tokens-sdk.</li></ol><p><strong>Links</strong></p><p>Sample code showing how to use Accounts can be found <a href="https://github.com/corda/accounts-demo-supplychain">here</a>.</p><p>Accounts blog explaining a sample on Accounts can be found <a href="https://www.corda.net/blog/unlocking-new-opportunities-with-accounts-on-corda-2/">here</a>.</p><p>Thanks to Roger, Will, Kasia, Stefano and The Corda Team</p><p>Thanks for reading — <em>Sneha Damle</em>, Developer Evangelist (R3)</p><p><strong>Want to learn more about building awesome blockchain applications on Corda? Be sure to visit </strong><a href="http://corda.net/"><strong>corda.net</strong></a><strong>, check out our </strong><a href="https://www.corda.net/community/"><strong>community page</strong></a><strong> to learn how to connect with other Corda developers, and </strong><a href="https://info.r3.com/email-preferences"><strong>sign up</strong></a><strong> for one of our newsletters for the latest updates.</strong></p><p>— Sneha Damle is a Developer Evangelist at <a href="https://www.r3.com/">R3</a>, an enterprise blockchain software firm working with a global ecosystem of more than 350 participants across multiple industries from both the private and public sectors to develop on Corda, its open-source blockchain platform, and Corda Enterprise, a commercial version of Corda for enterprise usage.</p><p>Follow Sneha on <a href="https://www.linkedin.com/in/sneha-damle-26919355/">Linkedin</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2430960a5a58" width="1" height="1" alt=""><hr><p><a href="https://medium.com/corda/scale-your-cordapp-with-cordas-account-library-2430960a5a58">Scale Your CorDapp with Corda’s Account Library</a> was originally published in <a href="https://medium.com/corda">Corda</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Corda Firewall — Components, PKI, Deployment]]></title>
            <link>https://medium.com/corda/corda-firewall-components-pki-deployment-d255c940c10a?source=rss-3ca8a436b4e5------2</link>
            <guid isPermaLink="false">https://medium.com/p/d255c940c10a</guid>
            <category><![CDATA[artemis]]></category>
            <category><![CDATA[firewall]]></category>
            <category><![CDATA[security]]></category>
            <category><![CDATA[corda]]></category>
            <category><![CDATA[blockchain]]></category>
            <dc:creator><![CDATA[Sneha Damle]]></dc:creator>
            <pubDate>Fri, 10 Jan 2020 19:26:55 GMT</pubDate>
            <atom:updated>2020-01-10T19:26:55.402Z</atom:updated>
            <content:encoded><![CDATA[<h3>Corda Firewall — Components, PKI, Deployment</h3><p><em>As compared to traditional client-server applications, distributed blockchain applications like Corda interact directly with each other by establishing a P2P connection. Corda nodes connect to the database, which has sensitive information. In enterprise production deployments, it’s a considerable risk to establish a P2P connection with the counter-party directly. One option is to place the Corda node in a DMZ. P2P connection is also a threat to the node’s sensitive information. Corda Firewall addresses these concerns.</em></p><p>Corda Firewall is an application-level firewall that acts like a proxy(Bridge) and a reverse proxy(Float) server. Corda Firewall is a piece of software that provides an additional layer of security. Corda Firewall consists of two components — Bridge (takes care of outbound messages) and Float (takes care of inbound messages).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*fviQX2jvlwXB7v_AXd2vIg.png" /><figcaption>Simple Node, Single Bridge outbound via SOCKS Proxy and DMZ Float</figcaption></figure><h4><strong>Component 1: Bridge</strong></h4><p>The bridge component of the Corda Firewall takes care of the outbound messages. It can be configured to run within the node, or it can run outside the node. If the node wants to send a message to a peer sitting in a different organization, instead of connecting directly to the peer, the node can be configured to send messages to a bridge, which in turn forwards it to the peer. A durable outbound queue is created within the Artemis server for each peer. The Bridge establishes a secured TLS encrypted connection with the remote peer (direct or via a SOCKS proxy), acts as a consumer, consumes the message from the out queue, and sends the message to the remote peer sitting outside the nodes network. The peer consumes this Artemis message, checkpoints it and sends an acknowledgement to the source. The source node permanently consumes the message from the out queue after it receives the acknowledgement. The connection from Bridge to the outside world is AMQP 1.0/TLS 1.2.</p><h4><strong>Component 2: Float</strong></h4><p>Float acts as a listener for the incoming AMQP packets from its peers. It forwards these to the Bridge over TLS/AMQP and is responsible for sending acknowledgments back to the peers. Instead of directly receiving the messages from the outside world, the Float acts as a shield to the node for inbound traffic. The Float should be placed in the DMZ. It performs the initial handshake with the peer by exchanging the certificates, validates each message/packet before sending it to the node. It performs validations like it checks if the message size is higher than that defined by the current node and drop the packet without forwarding it to the node. This way only the genuine messages reach the node. Float can eventually be made more secure by adding more specific packet drop logic if required. The firewall component also performs auditing of every message received on the Float and the Bridge.</p><h4><strong>Component 3: Socks Proxy</strong></h4><p>In production systems, the node sits behind the firewall and is not allowed to connect to the outside world directly, or the firewall blocks the AMQP port. In blockchain systems, where a node has to establish a P2P connection with the peer, the Bridge can be connected to a SOCKS proxy, which in turn connects to the peer. SOCKS 5 provides additional support for security.</p><h4><strong>Component 4: Http Proxy</strong></h4><p>Http Proxy connects to Doorman and Network Map via HTTPS get requests.</p><h4><strong>Component 5: Artemis Broker</strong></h4><p>Artemis Broker is used to creating inbound and peer specific multiple outbound queues. The Bridge establishes a TLS link with the peer, consumes a message from this outbound queue, sends it to the peer, and removes it from the queue when it gets an acknowledgment from the peer. The inbound queue is used to store the inbound messages from the peers. Artemis broker, by default, is embedded within the node. It can be configured to set up Artemis out of the process as well.</p><h4><strong>Benefits of Corda Firewall</strong></h4><ol><li>Acts as a shield/proxy for the node, providing protocol break and can be placed in the DMZ. The Float prevents the Node and Artemis server from being exposed to the peer nodes.</li><li>Peer node to float, float-bridge tunnel, internal node to bridge connection is TLS encrypted. Float bridge tunnel uses a different set of TLS certificates and does not use the node’s certificates. Since the data passing through the DMZ device is sent over encrypted TLS channels, this data is not leaked if ever the Float is compromised.</li><li>Corda Firewall supports CRL, and if configured, each certificate in the certificate path is checked against a CRL.</li><li>From an audit perspective business critical events at the Bridge and the Float are logged to a file. Future implementations will be enhanced to post data to an enterprise service.</li><li>Messages are dropped at the Float and logged if they do not satisfy the validations; hence only valid messages pass to the internal network.</li><li>Corda Firewall bridge can connect to the outer world via a SOCKS 4/5 proxy server. SOCKS 5 supports additional security. Also, having Bridge lets the node not have a public IP address.</li><li>A connection is initiated by the bridge control to the external Float, establishing a bi-directional connection. The connection is never initiated by the DMZ device to the internal network, but is initiated by the Bridge.</li><li>Float and Bridge are stateless and do not save any information.</li><li>Artemis Broker can be taken out of the node. Thus one Artemis can be used by multiple nodes.</li><li>Corda Firewall has a facility to enable TLS signing using HSM.</li></ol><h4><strong>Corda Firewall PKI</strong></h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/936/1*cxfD8z2SiJQ_6kPqoTe11A.png" /></figure><p>TLS authenticated channel is set up at three places</p><p><strong><em>truststore.jks</em></strong> contains the Corda network root ca certificate used at the time of node registration. truststore.jks is dynamically transferred to the float by the bridge and is stored only in memory. truststore.jks is used for mutual authentication between nodes and bridge/float.</p><p><strong><em>sslkeystore.jks</em></strong> contains node’s TLS certificate, and is used by the establishing a secured TLS connection between nodes and bridge(and float).</p><p><strong><em>bridge.jks </em></strong>and <strong><em>float.jks</em></strong> contains a new set of TLS certificates used to set up a TLS tunnel between bridge and float and <strong><em>trust.jks</em></strong> contains a root certificate.</p><h4><strong>Corda Firewall Configurations</strong></h4><p>The Corda node can be run as a simple single process that is compatible with peers running the Corda firewall. There are multiple ways in which you can configure Corda Firewall depending on your requirements. You have to consider various factors like security requirements, network infrastructure requirements, on-premise, or cloud deployments for deploying Corda into production. I have listed down a few of the possible deployment options.</p><p><strong>Option 1 : Simple Self-Contained Node, No Firewall</strong></p><p>For development purposes, you can quickly get started with this approach which has an embedded bridge. There is no explicit configuration required for this approach and is suitable for development purposes only.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0RrWdUxLt9OPo7Y4D96Q1A.png" /></figure><p><strong>Option 2 : Hot-Cold HA Nodes with Embedded Artemis, Hot-Warm HA Bridge and Hot-Warm HA DMZ Float</strong></p><p>In this type of deployment, you can configure a hot-warm HA bridge and float along with a hot-cold HA node. In this type of deployment, Artemis sits inside the node.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*oIjXzjOpBT-Kf2PLKHF5XQ.png" /></figure><p><strong>Option 3 : Hot-Cold HA Nodes with External Artemis, Hot-Warm HA Bridge and Hot-Warm HA DMZ Float</strong></p><p>In this type of deployment, you can configure a hot-warm HA bridge and float along with a hot-cold HA node. In this type of deployment, the Artemis sits outside the node which allows multiple nodes to share one Artemis.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*seNMMX_F15SV88RpZSqWOg.png" /></figure><h4><strong>Final Thoughts</strong></h4><p>Enterprise P2P blockchain deployments can pose serious threats to internal assets when adequate measures are not taken. It is important to understand the ultimate goal of your deployment and take into account all the factors related to network infrastructure, security requirements by the organisation, HA requirements, on premise or cloud deployment etc. Corda takes critical steps and has designed Corda Firewall to ensure underlying assets are protected from protocol level attacks, network attacks, DOS like attacks etc.</p><p>You can read more about Corda Firewall <a href="https://docs.corda.r3.com/releases/4.2/corda-firewall.html">here</a>.</p><p><em>Thanks to Matthew Nesbit and The Corda Team</em></p><p><em>Thanks for reading — Sneha Damle, Developer Evangelist (R3).</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d255c940c10a" width="1" height="1" alt=""><hr><p><a href="https://medium.com/corda/corda-firewall-components-pki-deployment-d255c940c10a">Corda Firewall — Components, PKI, Deployment</a> was originally published in <a href="https://medium.com/corda">Corda</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[CorDapp Database Setup-Development Perspective]]></title>
            <link>https://medium.com/corda/cordapp-database-setup-development-perspective-1c572adf5957?source=rss-3ca8a436b4e5------2</link>
            <guid isPermaLink="false">https://medium.com/p/1c572adf5957</guid>
            <category><![CDATA[upgrade]]></category>
            <category><![CDATA[migration]]></category>
            <category><![CDATA[database]]></category>
            <category><![CDATA[corda]]></category>
            <category><![CDATA[docker]]></category>
            <dc:creator><![CDATA[Sneha Damle]]></dc:creator>
            <pubDate>Wed, 08 Jan 2020 17:00:24 GMT</pubDate>
            <atom:updated>2020-01-08T17:00:24.987Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*j_r_RWgNZxH-gFD9m5Qdbw.png" /><figcaption>Connect node to PostgreSQL using admin access in development mode</figcaption></figure><p><em>This blog post shows you how to configure your node to connect to a Postgres database in </em><strong><em>development</em></strong><em> mode, instead of H2 which is used by default.</em></p><p>Generally, when connecting to a database we consider two perspectives-development and production. From a development perspective, Corda lets the node connect to the database using admin permissions, which lets the node create the database schemas automatically. Automatically running schemas against a database is controlled by the runMigration flag, which we will set to true in dev mode. So, from a development perspective, developers can quickly get started with connecting to a non H2 database.</p><p>But from a production perspective, we don’t want the node to perform any schema creation automatically on the database. This can be controlled by setting the runMigration flag to false. We use the database management tool for generating the database-specific scripts. We will talk more about this in the <a href="https://medium.com/p/2c400e60fae5/edit">next blog</a>.</p><p>In this post, we will look at how to set up a PostgreSQL database for an IOU application. To do this, we will start a PostgreSQL container using docker and PSQL to connect to the database.</p><p>Corda Enterprise supports four commercial databases: PostgreSQL (also supported in Corda Open Source), SQL Server, Oracle, Azure SQL. For this blog, we will be connecting to PostgreSQL.</p><p><strong>Prerequisites</strong></p><ol><li>We will use the IOU application from the sample directory. We will configure 3 nodes — Notary, PartyA, PartyB. The Notary will connect to a H2 database (by default), hence no explicit database configuration is required. PartyA and PartyB will connect to the PostgreSQL database, which will require configuring the steps mentioned below.</li><li>The latest version of PostgreSQL and JDBC PostgreSQL driver can be used. PostgreSQL 9.6 is the lowest acceptable version. For this demo, I used PostgreSQL 11 and docker to quickly create a database.</li></ol><p><strong>There are 3 steps to connect to a PostgreSQL database.</strong></p><ol><li>Creating a database user with administrative schema permissions.</li><li>Node Configuration (set runMigration = true).</li><li>Start the node.</li></ol><p><strong>Step 1: Creating a database user with schema permissions, start docker</strong></p><p>1. Create file<em> party_a.sql</em> for PartyA node containing scripts to create a user, schema, and assign administrative access for the schema to user party_a. The PartyA node will connect to the database using user party_a.</p><pre><strong>CREATE USER &quot;party_a&quot; WITH </strong>LOGIN PASSWORD <strong>&#39;my_password&#39;</strong>;<br><strong>CREATE SCHEMA &quot;party_a_schema&quot;</strong>;<br><strong>GRANT USAGE</strong>, <strong>CREATE ON SCHEMA &quot;party_a_schema&quot; TO &quot;party_a&quot;</strong>;<br><strong>GRANT SELECT</strong>, <strong>INSERT</strong>, <strong>UPDATE</strong>, <strong>DELETE</strong>, <strong>REFERENCES ON ALL </strong>tables <strong>IN SCHEMA &quot;party_a_schema&quot; TO &quot;party_a&quot;</strong>;<br><strong>ALTER DEFAULT privileges IN SCHEMA &quot;party_a_schema&quot; GRANT SELECT</strong>, <strong>INSERT</strong>, <strong>UPDATE</strong>, <strong>DELETE</strong>, <strong>REFERENCES ON </strong>tables <strong>TO &quot;party_a&quot;</strong>;<br><strong>GRANT USAGE</strong>, <strong>SELECT ON ALL </strong>sequences <strong>IN SCHEMA &quot;party_a_schema&quot; TO &quot;party_a&quot;</strong>;<br><strong>ALTER DEFAULT privileges IN SCHEMA &quot;party_a_schema&quot; GRANT USAGE</strong>, <strong>SELECT ON </strong>sequences <strong>TO &quot;party_a&quot;</strong>;<br><strong>ALTER </strong>ROLE <strong>&quot;party_a&quot; SET </strong>search_path = <strong>&quot;party_a_schema&quot;</strong>;</pre><p><em>Lines 1/2 We create party_a user and schema party_a_schema.</em></p><p><em>Line 3 allows the user to access the schema and create objects in that schema.</em></p><p><em>Line 4/5/6/7 is about adding permissions for current tables in that schema and the tables created in the future.</em></p><p><em>By default, in postgresql the default schema resolves to the user name. But, since our schema name is diff than the user name, Corda adds schema namespace prefix to most of the SQL queries but not all. So we can use </em><strong><em>set search_path</em></strong><em> to set the default schema name.</em></p><p>2. The same should be done for PartyB, below is what that configuration would look like.</p><pre><strong>CREATE USER &quot;party_b&quot; WITH </strong>LOGIN PASSWORD <strong>&#39;my_password&#39;</strong>;<br><strong>CREATE SCHEMA &quot;party_b_schema&quot;</strong>;<br><strong>GRANT USAGE</strong>, <strong>CREATE ON SCHEMA &quot;party_b_schema&quot; TO &quot;party_b&quot;</strong>;<br><strong>GRANT SELECT</strong>, <strong>INSERT</strong>, <strong>UPDATE</strong>, <strong>DELETE</strong>, <strong>REFERENCES ON ALL </strong>tables <strong>IN SCHEMA &quot;party_b_schema&quot; TO &quot;party_b&quot;</strong>;<br><strong>ALTER DEFAULT privileges IN SCHEMA &quot;party_b_schema&quot; GRANT SELECT</strong>, <strong>INSERT</strong>, <strong>UPDATE</strong>, <strong>DELETE</strong>, <strong>REFERENCES ON </strong>tables <strong>TO &quot;party_b&quot;</strong>;<br><strong>GRANT USAGE</strong>, <strong>SELECT ON ALL </strong>sequences <strong>IN SCHEMA &quot;party_b_schema&quot; TO &quot;party_b&quot;</strong>;<br><strong>ALTER DEFAULT privileges IN SCHEMA &quot;party_b_schema&quot; GRANT USAGE</strong>, <strong>SELECT ON </strong>sequences <strong>TO &quot;party_b&quot;</strong>;<br><strong>ALTER </strong>ROLE <strong>&quot;party_b&quot; SET </strong>search_path = <strong>&quot;party_b_schema&quot;</strong>;</pre><p>3. Start a <em>docker</em> Postgres container by running the below command. The container is named postgres_for_corda.</p><pre>docker run --name postgres_for_corda -e POSTGRES_PASSWORD=my_password -d -p 5432:5432 postgres:11</pre><p>4. Connect to the database using admin access and execute above created scripts to create users, schema’s and assign permissions. Use the docker exec command to execute party_a.sql.</p><pre>cat party_a.sql | docker exec -i postgres_for_corda psql -h localhost -p 5432 -U postgres</pre><pre><em>cat party_b.sql | docker exec -i postgres_for_corda psql -h localhost -p 5432 -U postgres</em></pre><p>In the last section below, I have mentioned queries to list the users and schemas created. Run these queries to ensure the users and schemas have been created successfully.</p><p><strong>Step 2: Node Configuration</strong></p><p>1. Create <em>party_a_database.conf</em> for PartyA specifying the database connection properties to connect to the database.</p><pre>dataSourceProperties {<br>    dataSource {<br>        password=<strong>&quot;my_password&quot;<br>        </strong>url=<strong>&quot;jdbc:postgresql://localhost:5432/postgres&quot;<br>        </strong>user=<strong>&quot;party_a&quot;<br>    </strong>}<br>    dataSourceClassName=<strong>&quot;org.postgresql.ds.PGSimpleDataSource&quot;<br></strong>}<br>database {<br>   transactionIsolationLevel=READ_COMMITTED<br>   schema=<strong>&quot;party_a_schema&quot; <br>   </strong>runMigration=<strong>true<br></strong>}<br><em># When JDBC driver is not placed into node&#39;s &#39;drivers&#39; directory then add absolute path:<br># jarDirs = [&#39;absolute_path_to_directory_with_jdbc_driver&#39;]</em></pre><p>2. The same should be done for PartyB, below is what that configuration would look like.</p><pre>dataSourceProperties {<br>    dataSource {<br>        password=<strong>&quot;my_password&quot;<br>        </strong>url=<strong>&quot;jdbc:postgresql://localhost:5432/postgres&quot;<br>        </strong>user=<strong>&quot;party_b&quot;<br>    </strong>}<br>    dataSourceClassName=<strong>&quot;org.postgresql.ds.PGSimpleDataSource&quot;<br></strong>}<br>database {<br>   transactionIsolationLevel=READ_COMMITTED<br>   schema=<strong>&quot;party_b_schema&quot;<br>   </strong>runMigration=<strong>true<br></strong>}<br><em># When JDBC driver is not placed into node&#39;s &#39;drivers&#39; directory then add absolute path:<br># jarDirs = [&#39;absolute_path_to_directory_with_jdbc_driver&#39;]</em></pre><p>Since we are running this in development mode, we are setting runMigration to true.</p><p>The Corda documentation talks more about <a href="https://docs.corda.r3.com/node-database-developer.html#db-setup-developer-step-1-ref">writing scripts for Azure, Oracle and Sql Server</a> as well.</p><p>3. Deploy your IOU CorDapp and run the command below to update each node’s node.conf. This will append the database connection properties to node.conf.</p><pre>cat party_a_database.conf &gt;&gt; ../../build/nodes/PartyA/node.conf</pre><pre>cat party_b_database.conf &gt;&gt; ../../build/nodes/PartyB/node.conf</pre><p>You can even add the database configuration to node attribute in deployNodes task.</p><pre>node {<br>  ……………<br> <strong>extraConfig</strong> = [<br>&#39;dataSourceProperties.dataSourceClassName&#39;:&#39;org.postgresql.ds.PGSimpleDataSource&#39;,<br>&#39;dataSourceProperties.dataSource.url&#39;:&#39;jdbc:postgresql://localhost:5432/postgres&#39;,<br>&#39;dataSourceProperties.dataSource.password&#39; : &#39;my_password&#39;,<br>&#39;dataSourceProperties.dataSource.user&#39; : &#39;party_a&#39;,<br>&#39;database.transactionIsolationLevel&#39; : &#39;READ_COMMITTED&#39;,<br>&#39;database.schema&#39; : &#39;party_a_schema&#39;,<br>&#39;database.runMigration&#39; : &#39;false&#39;<strong> </strong>]<br> <strong>drivers</strong> = [&#39;<em>absolute_path_to_directory_with_jdbc_driver</em>&#39;]<br>}</pre><p>4. Copy the PostgreSQL jdbc driver to node’s driver directory. You could also specify the driver&#39;s absolute path in <em>jarDirs </em>property in node.conf.</p><pre>cp postgresql-42.1.4.jar nodes/PartyA/drivers/<br>cp postgresql-42.1.4.jar nodes/PartyB/drivers/</pre><p><strong>Step 3 : Run the node</strong></p><p>1. The node connects to the database using administrative access, and automatically creates the required tables.</p><pre>./runnodes</pre><p>2. Verify if the tables are created using</p><pre>docker exec -i postgres_for_corda psql -U postgres -p 5432 -h localhost postgres -c &quot;<strong>\dt party_a_schema.</strong>&quot;</pre><p><strong>Node Upgrade</strong></p><p>If you want to perform node upgrade from version x to y follow below steps.</p><ol><li>Stop the node</li><li>Replace the current corda.jar with the upgraded corda.jar.</li><li>Start the node. The node connects to the database, automatically detects schema changes in the new version and applies them automatically on the database.</li></ol><p><strong>Points to Note:</strong></p><ol><li>To download the IOU application used in this post you can the clone url below, switch to database-migration-tutorial branch and use the <a href="https://github.com/corda/samples/tree/database_migration_tutorial/database-migration-tutorial">database-migration-tutorial </a>project.</li></ol><pre>git clone https://github.com/corda/samples.git</pre><p>2. To connect to databases other than PostgreSQL visit <a href="https://docs.corda.r3.com/node-database-developer.html#db-setup-developer-step-1-ref">documentation</a> which provides scripts for each.</p><p>3. <em>runMigration</em> flag is only used in Corda Enterprise. For Corda Open Source you could use initialiseSchema to control the automatic schema creation. The runMigration flag only enables the automatic application of schemas onto the database. At the end of the day, which scripts get executed depends on the way the node is connected to the database, and if it’s connected using admin or restrictive access.</p><p><strong>Some useful docker commands to use</strong></p><p><strong>LIST ALL ROLES</strong></p><pre>docker exec -i postgres_for_corda psql -U postgres -p 5432 -h localhost postgres -c “\dg”</pre><p><strong>LIST ALL SCHEMAS</strong></p><pre>docker exec -i postgres_for_corda psql -U postgres -p 5432 -h localhost postgres -c “\dn”</pre><p><strong>ALL TABLES IN A SCHEMA</strong></p><pre>docker exec -i postgres_for_corda psql -U postgres -p 5432 -h localhost postgres -c “\dt party_a_schema.*”</pre><p><strong>SELECT CUSTOM TABLE ROWS</strong></p><pre>docker exec -i postgres_for_corda psql -U postgres -p 5432 -h localhost postgres -c “select * from party_a_schema.iou_states”</pre><p><strong>DROP SCHEMA</strong></p><pre>docker exec -i postgres_for_corda psql -U postgres -p 5432 -h localhost postgres -c “drop schema party_a_schema cascade”</pre><p><strong>DROP USER</strong></p><pre>docker exec -i postgres_for_corda psql -U postgres -p 5432 -h localhost postgres -c “REASSIGN OWNED BY party_a TO my_user”</pre><pre>docker exec -i postgres_for_corda psql -U postgres -p 5432 -h localhost postgres -c “DROP role party_a”</pre><p><strong>SHOW SEARCH PATH</strong></p><pre>docker exec -i postgres_for_corda psql -U postgres -p 5432 -h localhost postgres -c “show search_path”</pre><p><strong>Next Steps</strong></p><p><a href="https://medium.com/p/2c400e60fae5/edit"><strong><em>Tutorial 2 : Connect to PostgreSQL from production perspective</em></strong></a></p><p><em>Thanks to Szymon Sztuka and The Corda Team</em></p><p><em>Thanks for reading — Sneha Damle, Developer Evangelist (R3).</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1c572adf5957" width="1" height="1" alt=""><hr><p><a href="https://medium.com/corda/cordapp-database-setup-development-perspective-1c572adf5957">CorDapp Database Setup-Development Perspective</a> was originally published in <a href="https://medium.com/corda">Corda</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[CorDapp Database Upgrade/ Migration-Development Perspective]]></title>
            <link>https://medium.com/corda/cordapp-database-upgrade-migration-development-perspective-c2931e28b9b4?source=rss-3ca8a436b4e5------2</link>
            <guid isPermaLink="false">https://medium.com/p/c2931e28b9b4</guid>
            <category><![CDATA[migration]]></category>
            <category><![CDATA[corda]]></category>
            <category><![CDATA[database]]></category>
            <category><![CDATA[upgrade]]></category>
            <category><![CDATA[docker]]></category>
            <dc:creator><![CDATA[Sneha Damle]]></dc:creator>
            <pubDate>Wed, 08 Jan 2020 17:00:10 GMT</pubDate>
            <atom:updated>2020-01-08T17:00:10.218Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*j_r_RWgNZxH-gFD9m5Qdbw.png" /><figcaption>Node applies the schemas automatically onto the database</figcaption></figure><p>We have seen how to set up and connect to a PostgreSQL database in the <a href="https://medium.com/p/1c572adf5957/edit">previous blog post</a>. In this blog, we will see how we can upgrade custom CorDapp database tables using Liquibase scripts in development mode.</p><p>Both the internals of the Corda and external CorDapps use <a href="https://www.liquibase.org/"><strong>Liquibase</strong></a> for database schema versioning. This makes Corda database agnostic. CorDapp custom tables are created or upgraded automatically using <a href="https://docs.corda.r3.com/head/node-database.html#liquibase-ref">Liquibase</a>. Liquibase supports writing ddl/dml statements in many formats (XML, JSON, SQL, YAML).</p><p>In development mode, we will connect the node to the database using admin access. When the node is started, the database<strong> </strong>agnostic scripts are automatically converted to database specific scripts and are applied automatically onto the database.</p><p><strong>Broadly there are 6 steps to perform a CorDapp database upgrade/migration.</strong></p><ol><li>Define the Liquibase script.</li><li>Define a custom schema.</li><li>Define IOUState by extending with QueryableState and override IOUState’s supported Schemas, generateMappedSchema, migrationResource.</li><li>Setup users, schema permissions, update node.conf and start the node as described in the <a href="https://medium.com/p/1c572adf5957/edit">previous blog</a>. Database tables are created automatically.</li><li>Stop the node. Update the schema by adding a new column. Create a new Liquibase script and update the master-changelog to include the script. Replace old jars with new jars.</li><li>Start the node. The new script automatically applies to the database.</li></ol><p><strong>Step 1: Define the Liquibase script.</strong></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/978e0ed793e463604823f522a36d9d1f/href">https://medium.com/media/978e0ed793e463604823f522a36d9d1f/href</a></iframe><ol><li>Add the Liquibase script to create the IOU table.</li><li>Line 6 defines a new changeset. Line 7 defines a create table command by specifying table name. We specify all the columns of the table with datatype, default values on the remaining lines.</li><li>Create a migration folder in workflow-java/src/main/resources/migration.</li><li>Add this script to the migration folder. This is the default place where Corda tries to find the Liquibase scripts.</li><li>Create a parent <strong>iou.changelog-master </strong>containing reference to <strong>iou.changelog-v1.xml </strong>as below. It’s a good practice to define a master changelog, which includes all the versions of a particular schema. To update the schema, create a new Liquibase script and include the script in this file.</li></ol><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/7c72436013f150806462ade8ceddfa67/href">https://medium.com/media/7c72436013f150806462ade8ceddfa67/href</a></iframe><p><strong>Step 2: Define a custom schema</strong></p><ol><li>To define a schema, extend the class via MappedSchema and define a JPA entity within this class. By default, if you do not override the migrationResource then a Hibernate entity gets created. To use Liquibase, override the migrationResource specifying the Liquibase script name.</li><li>Extend the JPA entity via PersistentIOU, which has the stateRef pointer to the ledger state. This pointer joins the table to the ledger states table, which allows you to query the table using a vault query.</li></ol><pre><strong>public class </strong>IOUSchemaV1 <strong>extends </strong>MappedSchema {<br>    <strong>public </strong>IOUSchemaV1() {<br>        <strong>super</strong>(IOUSchema.<strong>class</strong>, 1, ImmutableList.<em>of</em>(PersistentIOU.<strong>class</strong>));<br>    }<br><br>    @Nullable<br>    @Override<br>    <strong>public </strong>String getMigrationResource() {<br>        <strong>return &quot;iou.changelog-master&quot;</strong>;<br>    }<br><br>    @Entity<br>    @Table(name = <strong>&quot;iou_states&quot;</strong>)<br>    <strong>public static class </strong>PersistentIOU <strong>extends </strong>PersistentState {<br>        @Column(name = <strong>&quot;lender&quot;</strong>) <strong>private final </strong>String <strong>lender</strong>;<br>        @Column(name = <strong>&quot;borrower&quot;</strong>) <strong>private final </strong>String <strong>borrower</strong>;<br>        @Column(name = <strong>&quot;value&quot;</strong>) <strong>private final int value</strong>;<br>        @Column(name = <strong>&quot;linear_id&quot;</strong>) <strong>private final </strong>UUID <strong>linearId</strong>;<br><br><br>        <strong>public </strong>PersistentIOU(String lender, String borrower, <strong>int </strong>value, UUID linearId) {<br>            <strong>this</strong>.<strong>lender </strong>= lender;<br>            <strong>this</strong>.<strong>borrower </strong>= borrower;<br>            <strong>this</strong>.<strong>value </strong>= value;<br>            <strong>this</strong>.<strong>linearId </strong>= linearId;<br>        }<br><br>        <em>// Default constructor required by hibernate.<br>        </em><strong>public </strong>PersistentIOU() {<br>            <strong>this</strong>.<strong>lender </strong>= <strong>null</strong>;<br>            <strong>this</strong>.<strong>borrower </strong>= <strong>null</strong>;<br>            <strong>this</strong>.<strong>value </strong>= 0;<br>            <strong>this</strong>.<strong>linearId </strong>= <strong>null</strong>;<br>        }<br><br>        <strong>public </strong>String getLender() {<br>            <strong>return lender</strong>;<br>        }<br><br>        <strong>public </strong>String getBorrower() {<br>            <strong>return borrower</strong>;<br>        }<br><br>        <strong>public int </strong>getValue() {<br>            <strong>return value</strong>;<br>        }<br><br>        <strong>public </strong>UUID getId() {<br>            <strong>return linearId</strong>;<br>        }<br>    }<br>}</pre><p><strong>Step 3: Define IOUState by extending via QueryableState</strong></p><ol><li>Every contract state should implement QueryableState if they need to be inserted as a custom table. Doing so will add two new functions to the class that must be implemented. supportedSchemas which should list the supported schemas and generateMappedObject to provide a mapping of the ledger state to the custom state.</li></ol><pre>@Override <strong>public </strong>PersistentState generateMappedObject(MappedSchema schema) {<br>    <strong>if </strong>(schema <strong>instanceof </strong>IOUSchemaV1) {<br>        <strong>return new </strong>IOUSchemaV1.PersistentIOU(<br>                <strong>this</strong>.<strong>lender</strong>.getName().toString(),<br>                <strong>this</strong>.<strong>borrower</strong>.getName().toString(),<br>                <strong>this</strong>.<strong>value</strong>,<br>                <strong>this</strong>.<strong>linearId</strong>.getId());<br>    } <strong>else </strong>{<br>        <strong>throw new </strong>IllegalArgumentException(<strong>&quot;Unrecognised schema $schema&quot;</strong>);<br>    }<br>}</pre><pre>@Override <strong>public </strong>Iterable&lt;MappedSchema&gt; supportedSchemas() {<br>    <strong>return </strong>ImmutableList.<em>of</em>(<strong>new </strong>IOUSchemaV1());<br>}</pre><p><strong>Step 4 : Setup users, schema permissions, update node.conf and start the node as described briefly in </strong><a href="https://medium.com/p/1c572adf5957/edit"><strong>previous blog</strong></a><strong>.</strong></p><p><strong>Step 5: Stop the node. Update the schema by adding a new column. Create a new Liquibase script and update the master-changelog to include this.</strong></p><ol><li>Stop the node, and then update IOUSchemaV1 by adding a new column.</li></ol><pre><strong>public class </strong>IOUSchemaV1 <strong>extends </strong>MappedSchema {<br>    <strong>public </strong>IOUSchemaV1() {<br>        <strong>super</strong>(IOUSchema.<strong>class</strong>, 1, ImmutableList.<em>of</em>(PersistentIOU.<strong>class</strong>));<br>    }<br><br>    @Nullable<br>    @Override<br>    <strong>public </strong>String getMigrationResource() {<br>        <strong>return &quot;iou.changelog-master&quot;</strong>;<br>    }<br><br>    @Entity<br>    @Table(name = <strong>&quot;iou_states&quot;</strong>)<br>    <strong>public static class </strong>PersistentIOU <strong>extends </strong>PersistentState {<br>        @Column(name = <strong>&quot;lender&quot;</strong>) <strong>private final </strong>String <strong>lender</strong>;<br>        @Column(name = <strong>&quot;borrower&quot;</strong>) <strong>private final </strong>String <strong>borrower</strong>;<br>        @Column(name = <strong>&quot;value&quot;</strong>) <strong>private final int value</strong>;<br>        @Column(name = <strong>&quot;linear_id&quot;</strong>) <strong>private final </strong>UUID <strong>linearId</strong>;<br>        @Column(name = <strong>&quot;constraint_type&quot;</strong>) <strong>private final </strong>Integer <strong>constraint_type</strong>;<br><br><br>        <strong>public </strong>PersistentIOU(String lender, String borrower, <strong>int </strong>value, UUID linearId, Integer constraint_type) {<br>            <strong>this</strong>.<strong>lender </strong>= lender;<br>            <strong>this</strong>.<strong>borrower </strong>= borrower;<br>            <strong>this</strong>.<strong>value </strong>= value;<br>            <strong>this</strong>.<strong>linearId </strong>= linearId;<br>            <strong>this</strong>.<strong>constraint_type </strong>= constraint_type;<br>        }<br><br>        <em>// Default constructor required by hibernate.<br>        </em><strong>public </strong>PersistentIOU() {<br>            <strong>this</strong>.<strong>lender </strong>= <strong>null</strong>;<br>            <strong>this</strong>.<strong>borrower </strong>= <strong>null</strong>;<br>            <strong>this</strong>.<strong>value </strong>= 0;<br>            <strong>this</strong>.<strong>linearId </strong>= <strong>null</strong>;<br>            <strong>constraint_type </strong>= 0;<br>        }<br><br>        <strong>public </strong>String getLender() {<br>            <strong>return lender</strong>;<br>        }<br><br>        <strong>public </strong>String getBorrower() {<br>            <strong>return borrower</strong>;<br>        }<br><br>        <strong>public int </strong>getValue() {<br>            <strong>return value</strong>;<br>        }<br><br>        <strong>public </strong>UUID getId() {<br>            <strong>return linearId</strong>;<br>        }<br><br>        <strong>public </strong>Integer getConstraint_type() {<br>            <strong>return constraint_type</strong>;<br>        }<br>    }<br>}</pre><p>2. Update IOUState by adding an extra column, updating mapping in generateMappedObject.</p><pre>@BelongsToContract(IOUContract.<strong>class</strong>)<br><strong>public class </strong>IOUState <strong>implements </strong>LinearState, QueryableState {<br>    <strong>private final </strong>Integer <strong>value</strong>;<br>    <strong>private final </strong>Party <strong>lender</strong>;<br>    <strong>private final </strong>Party <strong>borrower</strong>;<br>    <strong>private final </strong>UniqueIdentifier <strong>linearId</strong>;<br>    <strong>private final </strong>Integer <strong>constraint_type</strong>;<br><br>    <em>/**<br>     * </em><strong><em>@param value </em></strong><em>the value of the IOU.<br>     * </em><strong><em>@param lender </em></strong><em>the party issuing the IOU.<br>     * </em><strong><em>@param borrower </em></strong><em>the party receiving and approving the IOU.<br>     */<br>    </em><strong>public </strong>IOUState(Integer value,<br>                    Party lender,<br>                    Party borrower,<br>                    UniqueIdentifier linearId,<br>                    Integer constraint_type)<br>    {<br>        <strong>this</strong>.<strong>value </strong>= value;<br>        <strong>this</strong>.<strong>lender </strong>= lender;<br>        <strong>this</strong>.<strong>borrower </strong>= borrower;<br>        <strong>this</strong>.<strong>linearId </strong>= linearId;<br>        <strong>this</strong>.<strong>constraint_type </strong>= constraint_type;<br>    }<br><br>    <strong>public </strong>Integer getValue() { <strong>return value</strong>; }<br>    <strong>public </strong>Party getLender() { <strong>return lender</strong>; }<br>    <strong>public </strong>Party getBorrower() { <strong>return borrower</strong>; }<br>    @Override <strong>public </strong>UniqueIdentifier getLinearId() { <strong>return linearId</strong>; }<br>    @Override <strong>public </strong>List&lt;AbstractParty&gt; getParticipants() {<br>        <strong>return </strong>Arrays.<em>asList</em>(<strong>lender</strong>, <strong>borrower</strong>);<br>    }<br><br>    @Override <strong>public </strong>PersistentState generateMappedObject(MappedSchema schema) {<br>        <strong>if </strong>(schema <strong>instanceof </strong>IOUSchemaV1) {<br>            <strong>return new </strong>IOUSchemaV1.PersistentIOU(<br>                    <strong>this</strong>.<strong>lender</strong>.getName().toString(),<br>                    <strong>this</strong>.<strong>borrower</strong>.getName().toString(),<br>                    <strong>this</strong>.<strong>value</strong>,<br>                    <strong>this</strong>.<strong>linearId</strong>.getId(),<br>                    <strong>this</strong>.<strong>constraint_type</strong>);<br>        } <strong>else </strong>{<br>            <strong>throw new </strong>IllegalArgumentException(<strong>&quot;Unrecognised schema $schema&quot;</strong>);<br>        }<br>    }<br><br>    @Override <strong>public </strong>Iterable&lt;MappedSchema&gt; supportedSchemas() {<br>        <strong>return </strong>ImmutableList.<em>of</em>(<strong>new </strong>IOUSchemaV1());<br>    }<br><br>    @Override<br>    <strong>public </strong>String toString() {<br>        <strong>return </strong>String.<em>format</em>(<strong>&quot;IOUState(value=%s, lender=%s, borrower=%s, linearId=%s)&quot;</strong>, <strong>value</strong>, <strong>lender</strong>, <strong>borrower</strong>, <strong>linearId</strong>);<br>    }<br>}</pre><p>3. Create a new Liquibase script as below for this new column.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/29040c2329f695df9aa9df71922d63a8/href">https://medium.com/media/29040c2329f695df9aa9df71922d63a8/href</a></iframe><p>4. Add a reference to this script to iou-changelog-master.xml.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/faa53b05e4eb5265d47747842a981385/href">https://medium.com/media/faa53b05e4eb5265d47747842a981385/href</a></iframe><p>4. Run the gradle <em>jar</em> task.</p><p>5. Replace the old jar in the project with this new jar.</p><p><strong>Step 6: Start the node.</strong></p><p>When the node starts, Liquibase looks at the databasechangelog table. As of now, there is only an iou-changelog-v1.xml entry in the table. Hence it knows that only iou-changelog-v1.xml has been executed. Hence it now picks up the new script, which is iou-changelog-v2.xml, converts it to database-specific scripts, and executes it on the database. An entry of iou-changelog-v2.xml is added to the databasechangelog table.</p><p><em>To download the above used IOU application, you can clone below URL, switch to the database-migration-tutorial branch, and use </em><a href="https://github.com/corda/samples/tree/database_migration_tutorial/database-migration-tutorial"><em>database-migration-tutorial</em></a><em> project.</em></p><pre>git clone <a href="https://github.com/corda/samples.git">https://github.com/corda/samples.git</a></pre><p><em>Thanks to Szymon and The Corda Team</em></p><p><em>Thanks for reading — Sneha Damle, Developer Evangelist (R3).</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c2931e28b9b4" width="1" height="1" alt=""><hr><p><a href="https://medium.com/corda/cordapp-database-upgrade-migration-development-perspective-c2931e28b9b4">CorDapp Database Upgrade/ Migration-Development Perspective</a> was originally published in <a href="https://medium.com/corda">Corda</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>