Practice Exams:

Blockchain CBSA – Objectives – Hyperledger Part 3

  1. Demo – Channels

Now I’m in the IBM blockchain as a service starter plan and what I like to do is just talk about channels and just deploy an additional channel. So when we create a channel we want to go over here to channels and it will go ahead and bring up the channel interface. And it usually doesn’t take this long, but sometimes it does. But you can see that we have a channel that is the default channel. This is created automatically for us when we deploy the blockchain as a service. So when I look at the channel configuration you’ll see that it’ll have the overview, it’ll have members, the ACL and chain code that’s installed. Now you can see that it has block number.

Our Genesis block for the channel is zero. And when I select this you can see that it says Genesis. And I have the ability to view the details and it will tell me any information on it. And then we have block one and it will say block one is an update and we can do the same thing, view details. Again, not much there because this is the initialization part.

And then we have block two because there’s no activity yet on the channel. There isn’t much really going on. I go to members and now the members will be basically company A which is. org one and Company B which is. org two. And you can see that we have Company and Company B. And then ACLs will be blank and chain code will be blank because we’ve yet to get to that point in the demo part of the course.

So that’s channels. But if we want to go and create a channel, the first thing we want to just take a look at is just go ahead and just double check. When the channel was created. You can see 21 hours since it was created. There’s three blocks, two recent invocations. So again that’s our default channel. So we go back to the channel interface and this will bring us back to channel. We’ll come back whenever it is stopped. Okay, so I’m back at channels. We have our default channel. I go over here and request a channel. And normally it’s not this slow. It’s all about the time of day, the latency, the workload. You just never know. So what I want to do is just create a channel called, let’s see, Blockchain Training. And it has to be of course all lower case. Let me go ahead and fix that, that’s a B. And then I’ll just call this test and then we have advanced configuration options.

Now this is basically where we want to go if we want to specify specific concerns around block size, the maximum bytes for the block a timeout, areas of that nature. So we could select that as well. When we choose to create a channel. In this case there’s really no need to. I’m just going to go next and you could see that company A is there and I could go ahead and add operator to company A and then I could also add another member as well. And you can see that will add both members to that channel. And I could have basically them both operators or not.

I could have one, just a reader or writer. Again, whatever role I want to select I could do. So I’m going to go ahead and go next. And now what I want to do is I have to select how many operators can accept the request to update the channel. In this case I could just have one or I could have both. And if I had more organizations now in the starter plan you’re pretty limited, but in the enterprise plan you can scale up quite a bit. I’m going to go ahead and submit the channel and then the next thing that’s going to happen is I have to define an ACL, create my policies, I could select my resources. So for example, I want to specify any kind of policies like who can update chain code, who can basically view blocks or propose on the network. Also too, there’s one thing I just would like to talk about before I forget. Here is where it says here it is get initialized chain code or instantiated chain code, right? So again, this one here, this is a query to get blocked by number. And you may want to be careful when you define your ACLs because the channel members will be limited to those specific actions.

So for example, if I want to create a blockchain network that is going to be just for compliance officers or auditors, I just want to give them view access. I don’t need to give them access to go ahead and initialize chain code. Maybe they just need to get chain info or maybe they just want to go over here and get the block IDs or get blocked by hash or whatever is required, right? And then I could just submit the request. If I don’t want to get granular, I don’t have to. But again, the channel is going to be part of that. Now this is showing up. You can see here vote pending, I go review request and then I can look at the policy. It says one member ACL is blank, we didn’t create anything. Current members is listed there and then I just go approve. So basically for this channel to be live, I need to have one approver and the vote is accepted. Now let’s go back and I’m on company A.

Let’s go check out company B. When I go to company B, it’ll bring up essentially the same view when I go to channels. But let me get it over to the overview first. But normally again, it’s not normally the slow, but sometimes I see in a slow, again, not much you can do about it. It’s just all about the luck of the draw. So I go over your notifications and you can see that it’s just popping up. Voting Closed. Why did it say voting closed? Well, because there are two members and only one member had to approve the channel. And again, that’s all that occurred. And you get a pending and you can see that the voting is closed. So again, I didn’t have to vote, and if I hit submit request, it will clear up the error and submit. I could still vote on it, but it doesn’t matter.

The channel is still available. With that said, you can see that change is pending. And then I go back and I have my two channels that are listed in both Company A and Company B. That’s simply how you would create a channel in the blockchain as a service for Hyper Ledger. Let’s go ahead and move on.

  1. Whiteboard Hyperledger Fabric Development

In this module. Let’s proceed and talk about hyperledger development. Now, what I have set up in this, basically whiteboard is essentially an approach generally used to develop with Hyperledger Composer. Now, the first thing to point out here is, is that we have our blockchain network over here, and we have, of course, our hyperledger fabric services such as the MSP. The CACT would be over in this area here. So basically in the network, we’re going to have our peers, basically our different types of peers that are going to run the chain code services, essentially. And then we’re going to have a client app that we want to use to essentially connect to hyperledger fabric. And it’s going to do this via a Rest server, which is going to use what, a Rest API.

With that said, generally, we’re going to want to test out and develop our services with Composer to ensure that, again, our services are going to connect. We’re going to, of course, set up our BNA. Now, the BNA is, of course, the Banana file. This is our business network composition to allow us to connect to the services. And there is a CLI, of course, that’s involved as part of the hyperledger Composer framework. Now, when you deploy your business network, for example, on an existing fabric network, you want to use, of course, the same DNA file.

And when you deploy your business network on an existing hyperledger fabric network, essentially you want to go ahead and connect with the fabric network. And to do that, you want to use, of course, the API. Now, as part of the API, there’s a demo on the Swagger UI, which is again, open API that shows you essentially what you need to do to connect to the blockchain network. And you could copy the commands, insert them into your application that you’re using. But again, with Composer, it has a set of commands that’s going to essentially create and start a fabric network. And with Composer, it is only in solo ordering. So it’s really meant for testing, it’s not meant for production.

And I’ll let you go ahead and determine how well your connection is, how everything works together with the smart contracts. And again, the goal is to develop your applications and then connect it directly with your ledger, essentially through, of course, the API services. Now, with the business network definition, it’s important to realize that you’re going to deploy this on a fabric network. You’re going to then develop applications that you want to interact with. After you do that, you want to, of course, connect up any kind of third party apps or apps that you develop for your client apps. And that allows you, again, to run your client app, your business apps, blockchain apps, whatever you want to call them, on the hyper ledger fabric network.

And once again, the goal is to enable development as quickly as possible with Composer. Now, just a quick note too. The Rest API essentially is using a Rest server course, but it is based on NodeJS. And with that said, it does come with a web UI that allows you to test your API calls. And there’s a demo for Swagger again in the course that will show you how that works. Basically. Again, the main goal is to develop use composer to test out your theories. Validate everything. Once you’re done validating your ideas, you can then ramp it up and deploy this on API, your business network. Let’s go ahead and move on.

  1. Whiteboard – Hyperledger Nodes

Well, let’s talk about the different nodes and peers in a hyper ledger fabric because this is generally where a lot of confusion can come in for sure. And so I think it makes sense to take a few minutes and just talk about each of these, draw out how typically they may be structured. So we have an idea as well when it comes to our peers and nodes. Now the first thing to point out is again, some of the terminology I mentioned in the PowerPoint module can be confusing or some of the terminology is sort of used interchangeably, I guess as a way to look at it. So for example, like with the order service node, sometimes we call that the orderer the ordering node or the order service node. It’s really the same thing. It’s just again, the jargon that’s been used in hyper ledger fabric from a development perspective can be confusing. But when it comes to the peer nodes or nodes and peers, you can see for example here I have nodes and peers but then in some of the documentation you’ll see peer nodes. And so again, I don’t have a good explanation over how they decided to name a lot of this. I’m just the messenger. I’m just trying to explain what this means.

So just be aware that if you get sort of confused hearing some of these names of the nodes and peers and what is the difference between a node and a peer, you’re rightly to be confused. So let’s go ahead and talk about it from the perspective of hyperledger. The first thing that we have essentially is an anchor pier. So the anchor pier is essentially used between organizations. So for example, if I wanted to I get set up a separate peer that is going to identify between different organizations. Now what I could do here is I could add another pier here and I would have, for example, here probably the best way to do this is to draw a little line and have another one here. So what I could do is have one anchor here and another one there. Now do we need to have that? No we don’t. But it could be a way to structure our blockchain to maybe provide some kind of efficiencies.

The next one would be a committing peer. Now a committing peer essentially, to be honest, is again confusing because the reality is it’s going to be a peer node and every peer that’s on the blockchain that has the ledger is really a committing peer. I just put it over here. But in reality any peer that you have, for example, like any of the peer nodes, this would be essentially also a committing peer. I’m just going to put there to make it short and this is going to commit and then broadcast to the other peers. Once again, I didn’t name this. This is just how the documentation is and how you would sort of look at it. The next one is an Endorsing pier.

So the Endorsing pier is what? This is going to be a peer that is going to have a smart contract installed. So every peer on the hyperledger blockchain does not need to have a smart contract, only ones that are going to do what endorse. So I’m going to go ahead and put smart contract on this. Now, we know smart contract equals what in hyperledger. This is chain code. So the Endorsing peers are going to of course have the smart contract installed. So for example, if I have, let’s say one here, two here, then this endorsing peer that I’m using will try to make a transaction with this organization here. So again, even though I might have peers, I still need to of course have another Endorsing peer, in this case on the other organization. And I’m going to just call this the Endorsing peer here. End, just for short. Okay? So with that said, this is sort of where this is going. Now the next one is called the leader peer. Now to be honest, I’ve never set up a leader peer, never had to, never seen anyone. However, let’s say you’re an organization, you have multiple peers in the channel. You want to designate one to essentially distribute the transactions from, for example, the OSN.

So if you have an OSN, so by default, if you have your OSN and this is if you’re going to scale, but it generally you don’t see a lot of this, you want to have just one peer. So to be the leader, basically the ones that are going to do what, they’re going to essentially take charge of the peers and ensure that the right peers receive the right transactions. But once again, this is sort of a default sort of capability that’s already sort of on the peers when you install them. But you may want to think about it as well. So you could definitely do that. And then one more thing to cover is it’s not really a peer, but I want to put it in there because it’s important because the peers need to of course have certificates and be able to access and make blockchain transactions.

So we need to have an MSP and a CA. So the membership service provider is going to have what our route certificate also going to issue via the CA, our transaction certificates. So that our client applications and our peers can of course perform transactions. Now, one of the things too, when it comes to peer nodes, when I put up your peer nodes, again, this is a sort of a wide distribution. A peer node could be pretty much one or all of these on a node as well. So just be aware. But it’s going to have a copy of the ledger. So pretty much any Endorsing peer, we’ll have a copy of the ledger in most cases, right? So once again, a lot of challenges and learning these nodes and peers and hyper ledger fabric. Let’s go ahead and move on to the next module.