Corda Bootcamp post-mortem: Winging it in the B2D space
Come for the bootcamp, stay for the fun
It’s been years since the word blockchain first came into existence, and yet the pace at which the industry is moving is fast, and the stride of the development in this space is significant.
When anything you put out in production has any degree of decentralization, it’s basically taming the chaos. An issue that’d be a small bump on the road in a controlled environment is multiplied by a hundred when you have an autonomous system of entities—live people—acting as people and generally being independent.
That’s why there are things happening in the blockchain space daily, hardly a month goes by without an experiment, and that’s why it’s fun.
What’s also extremely fun is being a company with a developer-first approach in what’s essentially the nascent industry of experimenting developers.
And being the business-to-developers (B2D) company that we are, we love the attitude, the experiment, and sharing the post-mortems. B2D is a tag that we wear proudly, so what follows is a complete write-up on the Corda bootcamp that we had, how it came about, what happened and what should have happened, and generally all the useful experience you get out of a post-mortem.
This was not our first bootcamp and not our first fun one either. See Behind the scenes of the Fabric Bootcamp.
For this one, running on our long-standing relationship with R3—exemplified by Chainstack being the first company to offer managed Corda services—we teamed up with Corda to do the bootcamp.
All we needed was an idea to join our forces around.
People—especially in business—generally do things for a reason, so we had our objectives for the bootcamp too.
For you—to be a part of a hands-on blockchain experiment that involves decentralization, get to use Corda and Chainstack, and learn something new. All for free.
For R3—to get you familiar with Corda. There’s so much to learn about Corda and the opportunities it creates with its blockchain model.
For us—to get you, the developers, familiar with Chainstack. We are quite proud of how easy to use and stable our platform is. We love getting developers to try it.
It’s a win-win-win. (Yes, a triple one).
After a bit of back and forth, we came up with the idea that should cover all the win-win-win points and be risky enough not to be boring. Risky as in when the power to control the experiment belongs to the people and no one at the same time.
Together with the Corda team, we decided to use their tutorial CorDapp that they had recently produced—eAuction—and attempt the following scenario:
- Create an auction on Corda.
- The auction must feature a number of items.
- The bootcamp participants must be able to bid on the items on the auction.
- There must be a clear result to the auction that’d give the participants the extra push to be a part of the scenario.
It’s a simple enough four-point run but executing it is where the details come pouring in.
Let’s run through it again.
Create an auction on Corda
What this involves is:
- There must be a consortium Corda network running.
- There must be Corda nodes that belong to the bootcamp participants—to maintain the true sense of ownership.
- The Corda nodes that belong to the participants must be a part of the deployed Corda network.
- Each of the nodes must have a CorDapp installed.
- Each CorDapp is a two-component entity: a workflow and a contract. So each node must have both the workflow and the contract installed by each node owner.
As you see, the very first step of the idea has already grown very complex. But that’s exactly where Chainstack shines the most—all of the steps that’d otherwise require hours and hours (or even days) of crazy coordination, communication, and non-trivial knowledge from the participants, is a 15-minute breeze through the UI on Chainstack.
The auction must feature a number of items
This is an easy part—we decided to do three items that would correspond to three real-world charities. And whichever charity would get the most bids, both Chainstack and R3 would donate an amount of real money to the charity.
The charities we picked—Save the Children, UNHCR, and WWF.
So that people who care for people can bid on Save the Children and UNHCR, and those who prefer animals can go with WWF.
Going back to the eAuction CorDapp at this point, what is an auction really? There must be an asset, there must be a flow for this asset, and there must be participants triggering the flow.
There are three assets—Save the Children, UNHCR, WWF. Because each of the assets must be auctioned off, there must be three auctions. Which, in turn, means there must be three flows—one per auction—for the participants to interact with.
Okay, so far so good.
The bootcamp participants must be able to bid on the items on the auction
For the concept of bidding to work, there must be at least two requirements fulfilled:
- Participants must have something to bid with. A currency.
- Participants must have a finite amount of currency. There’s no endgame with an infinite amount of cash.
To issue some currency and distribute it to participants, there must be a CorDapp that does that—and there is, it’s called Corda finance. Each CorDapp is a workflow and a contract, and each participant must install both on their node. Which brings us to point one—two more installations on the node. Chainstack can handle that easily, just a few extra clicks in the UI.
There must be a clear result to the auction
At this point, our little auction is shaping up to be less of a real auction but more of a point distribution contest:
- The participants have a finite amount of cash. We settled on 100 USD (imaginary).
- Each of the participants must be able to distribute their 100 USD between the three auctioned assets as they see fit.
- The asset that gets the most cash wins.
So it’s not really bidding but a very similar framework nonetheless.
The Corda team modified the eAuction CorDapp to accommodate the bootcamp requirements:
- Remove the requirement that each new bid must be higher than the previous one. Each bid can now be whatever the participants bid. The only limit is their finite amounts of issued cash.
- Instead of making the highest bid win the auction and not keeping the past bids logged, make each bid add up on the auctioned asset.
Voila, that’s how you turn an auction into a decentralized voting contest. If you want to get fancy, you can even go ahead and call it a Decentralized Autonomous Organization prototype.
At this point, we have our bootcamp set up. In theory.
The two missing ingredients for the scenario by now are the obvious ones:
We went ahead and did a run through the scenario a few times with several nodes up and running—a vanilla environment and something that is never happening in blockchain.
And then we prepared the documentation in the project’s README on GitHub. Not everyone comes prepared for a bootcamp, but some will. So we made sure those that like to plan and prepare in advance—the most passionate and interested really—have the pre-bootcamp instructions that they can use.
There are two sides to learning—theory and practice. Now that we have the practical part lined up and tested, it’s a good idea to add some theory in. A bit of theoretical knowledge and a challenge in the form of a quiz will push people on the exploration path and will get them to learn more than they would with a hand-holding practical experiment.
So we prepared a quiz. And then we added in the correct answer explanations. Have a look: Test your knowledge: Corda.
Things done and ready:
- A modified auction CorDapp
You can watch the recording of the actual bootcamp.
Since this is a post-mortem, you don’t have to watch the whole thing.
Instead, here’s a schematic representation of the entire sequence:
- Deploy a consortium Corda network ✅
- Get participants to deploy the nodes in the network ✅
- Get participants to install the two CorDapps—or four JAR files—on their nodes ✅
- Get participants to connect to their nodes ✅
- Create three assets—Save the Children, UNHCR, WWF ✅
- Start three auctions for the three assets ✅
- Issue 100 USD to each of the participating nodes ✖
Even in vanilla environment, things don’t always work right, but in a real experiment that involves decentralization, a small bump can (and will) send the whole thing haywire.
The CorDapp stopped at the issue-and-distribute-cash to all participants part. This put an end to the whole experiment.
So what happened there?
The command itself is
start IssueCash amount: 100 USD—this is the entirety of the command that starts the cash issuing flow. Can you spot what’s not exactly production-ready with it?
It’s missing the list of participants to distribute the cash to. Instead, it just issues the cash to each node on the network one by one.
And if there’s at least one node on the network down, the flow goes into pending forever, and the cash distribution basically grinds to a halt.
This makes sense, and it’s something that will always happen in a real live network. There’s simply no universe in which a node in a network does not go down.
And it’s also something that other developers have brought up.
However, even with that, a node randomly going down is not what actually happened during the bootcamp. What did happen is the cool feature of Chainstack that lets you stop your nodes to save the resources. A participant deployed their node before the bootcamp by following our carefully crafted instructions, then—apparently experimenting with what else was there—stopped the node.
The CorDapp attempted to issue cash to a node that was stopped and thus rendered down, which halted the whole experiment.
And because there was no way to issue cash to a list of nodes instead of everyone on the network, there was no way to proceed with the experiment.
Blockchain is fun, and so is being a B2D company in a highly experimental space and writing post-mortems.
When things go wrong in a decentralized experiment, they really go wrong.
The CorDapp has since been modified to do the cash distribution to a list of nodes instead of every node on the network.
What follows a complete walkthrough. Try it, see what it’s like. And also fork the bootcamp auction project and create your own version of the CorDapp.
See the video on the Chainstack YouTube channel for the complete walkthrough as well.
Deploy a Corda network
Add a couple of nodes to the deployed network
Create a cordapps directory
On your local machine, create a directory called
cordapps. You will need this directory to interact with the CorDapps when connected to your nodes.
Download the auction CorDapp
Download the workflow and the contract JAR files from the Releases tab of the project repository. Put them in the
Download the Corda finance CorDapp
Download the workflow and the contract of the Corda finance CorDapp:
Put them in the
Install the auction CorDapp
Install the bootcamp auction workflow and contract one after the other on your Corda node.
See Installing a CorDapp.
Install the Corda finance CorDapp
Install Corda finance workflow first on your node. Then install the Corda finance CorDapp on your node. It’s important that you install the workflow first and only then the contract. Otherwise the installation will not work.
See Installing a CorDapp.
Connect to your node
Connect to one of your nodes as described in Corda tools. Note that you will need to have either Java 8 installed or Docker as described in the documentation. For the Java version, see Corda standalone shell; for the Docker version, see Chainstack standalone shell.
To ensure you did everything correctly, once connected to your node, run the
flow list command. The output should show you all the CorDapps installed.
Create an asset
start CreateAssetFlow title: WWF, description: World Wildlife Fund Desc, imageURL: none
Get the asset ID
Get the created asset ID:
run vaultQuery contractStateType: net.corda.samples.states.Asset
Start the auction
Start the auction for the asset:
start CreateAuctionFlow basePrice: 10 USD, auctionItem: 73f5d1cd-b784-4845-9517-dbc3c6e832db, bidDeadLine: 2020-11-14T15:45:01.000Z
auctionItem is the asset ID you have queried earlier and
bidDeadLine is when the auction ends. Replace both values with your own.
Issue cash to all the nodes that you want to take part in the bidding:
start IssueCash amount: 100 USD, recipients: ["PartyA", "PartyB", "PartyC"]
Where PartyA, PartyB, PartyC and so on are the
Legal name values of your nodes. See View node access and credentials.
Connect to a different node
See Corda tools.
Check currency on the node
Check that you have the issued amount:
run vaultQuery contractStateType: net.corda.finance.contracts.asset.Cash$State
start BidFlow bidAmount: 20 USD, auctionId: d9032f99-c86c-4863-85a3-17737ddd958d
auctionID is the auction ID you can query with
run vaultQuery contractStateType: net.corda.samples.states.AuctionState.
Check the auction state
Check the auction state to see that your bid has been logged:
run vaultQuery contractStateType: net.corda.samples.states.AuctionState
totalBids value in the output.
Connect with the community
- To learn more about Chainstack, visit our Knowledge Center or join our Discord server and Telegram group.
- Sign up for a free Developer account, or explore the options offered by Growth or Business plans here.
- Take a look at our pricing tiers using a handy calculator to estimate usage and number of nodes.
Have you already explored what you can achieve with Chainstack? Get started for free today.