2023 06 23 Hyperledger India Chapter - Debugging with Spydra

2023 06 23 Hyperledger India Chapter - Debugging with Spydra

Show Video

Ashwath - Spydra: Okay, I've started the recording. So let's continue. Ashwath - Spydra: yeah. So basically, as I was saying, right, while we were developing our own developing chain code for for our own platform, right? It was really getting difficult for us to Ashwath - Spydra: basically So we put the same code in real time and truly do an iterative kind of Ashwath - Spydra: development in for hypology fabric. Right? And that's where

Ashwath - Spydra: that's where we Ashwath - Spydra: started looking at. What are the different options for actually debugging chain code. Right? So what I'm going to cover today is basically some of our experiences while doing that. so the different approaches for debugging chain code that already exist. Ashwath - Spydra: So I'll cover some of that, and then I'll also cover a particular you know, extension for Vs code that we have developed as part of side. Right? It's maybe we have made it open source. So you know, you can use it Ashwath - Spydra: and as contributed as well. But we'll look at you know the ipod is a fabric Vs code extension, and see you know how that can easily make that process a bit more easy to debug Ashwath - Spydra: chain code, right with from within within visual studio port as such.

Ashwath - Spydra: So basically, you know, first of all, what are the challenges while developing a chain code for hyperbolic fabric. Right? Ashwath - Spydra: First of all, you know, the chain code literally runs within within the fabric environment. Right? So the first thing that you need to have is a fabric environment itself, which means, you know, you need to deploy the peers orders. And you know, basically set up the entire hybrid fabric network. Right? Of course you have, you know. Ashwath - Spydra: default out of the box test network and scripts available to do that, but that still becomes a prerequisite. First of all. Ashwath - Spydra: then the second, that more, you know, painful process really is the Ashwath - Spydra: updating of the chain code, right? So when you are developing Ashwath - Spydra: something you will obviously update, and then you have to test it. And that is not a very simple process as such. Right? You have to install. You have to approve the chain port. You have to install the chain code on all the peers that are in the network. Then you have to approve the chain code Ashwath - Spydra: and the approval has to be done by each organization which is part of the network. And then the chain code has to be committed on the network. And then only, you know, it'll run basically right? Ashwath - Spydra: So every time you update the chain code. You'll have to go through this entire chain code lifecycle passage to to do that.

Ashwath - Spydra: And then the third thing is, you know, even if you do this right. unlike traditional other languages and frameworks, right where you can literally run the chain code within an ide Ashwath - Spydra: and put a breakpoint. And then, you know, do line by line, debugging that is still not possible, really out of the box. Right? That's that requires there are some approaches to do that which I'll talk about. But you know, those are things which typically is a challenge for for Ashwath - Spydra: hyper developers. Ashwath - Spydra: And typically, what happens because of that rate is that people don't really do debugging within an ide as such. Ashwath - Spydra: mostly what people start out with and what we also started out with is, you know, just logging messages, or console messages and logging messages and files and things like that. And then you deploy the chain code. And then you, you basically see what the output is. And then you make some changes again, deploy the chain code. Then again, you know, see what the messages are, where the flow is, what what Ashwath - Spydra: Which code is being executed? What is the output of that? All of that, you log in messages, and then you try to figure your way around right that is very cumbersome, of of course, right? And that's what we also started to do initially. But then, you know, that was really not helping us a lot. And it was speaking a lot of

Ashwath - Spydra: the developers time over a period of time. Right? Ashwath - Spydra: So that's where we started looking at different ways of actually debugging chain port. Right? And I apologize. Fabric does support a couple of different ways. so there is the ipad of fabric dev mode Ashwath - Spydra: which I'll talk about And then, you know, starting the with the newer versions of 2 dot X, Ashwath - Spydra: hypologic or fabric versions. Right? There is this new concept of deploying chain port as a service. Now, she input as a service model, although he's used for a completely different purpose Ashwath - Spydra: or it has been built for it completely different purpose. But it can actually be used to solve this challenge of of debugging she code as well, which I will, which I'll also get into.

Ashwath - Spydra: But even these approaches right require you to basically set up your own fabric network and then do some configurations. First right to make all of that possible. Ashwath - Spydra: So let's let's look at these approaches for straight. Ashwath - Spydra: and I'll I'll cover the chain code as a service debugging method first, because that's the more recent. And you know, that's where that's the recommended model of deployment, also going forward for chain board. Right? So let's let's take a look at how that can actually be used to Ashwath - Spydra: Debug chain port while you're writing so essentially a quick background on the chain code of the service model itself. First.

Ashwath - Spydra: fundamentally, the chain port as a service model has been designed so that you know you have more control Ashwath - Spydra: on how the chain code itself is built, deployed, and run Ashwath - Spydra: so traditionally right when you, when you create a change port, you will. You basically have to Ashwath - Spydra: you know, upload it or install it on the peer and then ask the peer to basically run it. Ashwath - Spydra: So the entire entire work of building the chain port from the source code Ashwath - Spydra: deploying it in a you know, in a container where it runs, and actually running, it was maintained, was done by the by the p or node as such. Right?

Ashwath - Spydra: of course, you know that means that you can only it, you know. Run chain code with Ashwath - Spydra: which is supported by the with, you know, the Framework Versions which is supported by the peer. And you know you literally didn't have much control, and how it is built, how it is deployed, and all that right. That's where starting with the 2 dot X versions of hyperger fabric, there has been a different model where you have more to control on how the sheet port is built first of all, which is the concept of external builder, and then you. There is also the concept of where you can, you know. Ashwath - Spydra: Run the chain port by yourself so you can. You can run the chain code in your own container essentially. and then instruct the peer node Ashwath - Spydra: to connect your shing code in order to run it right? So you you are literally responsible for building, hosting the chain port and running it, and then you instruct the here to connect to it and Ashwath - Spydra: submit Ashwath - Spydra: the request to the chain ports can container or server that you are, run right. Essentially so, if I look at the code right? Let me just Ashwath - Spydra: show you some code of how that actually works.

Ashwath - Spydra: so if I so this is the basically the chain for external sample Ashwath - Spydra: from the fabric samples itself. So if I if you go to the fabric samples right. there is the asset transfer basic sample that has different. Ashwath - Spydra: that is a bit extensive, and it has different versions of it in different languages and different ways of running it. Right? So this is the input external sample that I'm actually showing you. Ashwath - Spydra: And if you look at the code for that, right the way this This works is that Ashwath - Spydra: at the bottom there is a the main method Ashwath - Spydra: and a new chain code is instantiated Ashwath - Spydra: with the smart contract that has been written. And then this chain code instance is passed to a to input server right?

Ashwath - Spydra: And the chain port server is then started. So literally we are. We are starting its input server and running it ourselves right? And while starting the change port server there are few parameters that are given. Ashwath - Spydra: One is the chain code, Id, which I'll come to what it is. And then there is an address. So this is the address. Wherever chain code server is literally running. And there are some samples. If you look at the environment variable sample provided here. Ashwath - Spydra: it's just a you know host and a port right? So it could be something like this where the she input is actually running. And on this particular port, right? Ashwath - Spydra: So that's what we are literally running the server on a particular address, and then, that's the first step right? And then the second step is typically, you know, when you deploy the chain port right? You will deploy, deploy the actual chain port on the peer. Ashwath - Spydra: But in the chain code as a service model you don't deploy the actual chain for you deploy certain files. Right? One is a metadata file Ashwath - Spydra: which basically tells you certain information like, what is the type? So there is a. So I was

Ashwath - Spydra: telling that chain code as a service basically is all about running the chain for outside right? But before that you have to build the chain port. So there is a concept of an external builder. Ashwath - Spydra: and that is an extensive topic in itself. But without going into that in too much decade, there's a, you know, inbuilt or default external builder for chain code as a service. Right? So you're basically telling that this, this, the type of the chain code is that chain code as a service, and this is just a Ashwath - Spydra: label or a name for the chain for Italy.

Ashwath - Spydra: So this the metadata dot Json doesn't contain much except for telling that this type, this chain code is of type chain code as a service right? And then the current connection information basically tells the instructs the peer that it should connect with this particular address in this particular port to actually submit the request to Ashwath - Spydra: to run the chain port. Yeah. Ashwath - Spydra: So that's how these 2 are linked. And then it's the connection. Dot Json file and the metadata dot Json 5, which is actually deployed on the beer instead of the chain code Ashwath - Spydra: to to support this entire mode. So we will look into that. But that's the overall High level high level concept. Ashwath - Spydra: So how do I use this now? Right to my advantage to actually debug chain code? Right? So the way to do that is let's say. Ashwath - Spydra: you know, if you look at the code here, right? Ashwath - Spydra: this is a go go and chain code. Right? So what if I simply try to run this within visual studio code, right? And the way to do that normally in visual studio code is that you go to the Ashwath - Spydra: run and debug section Ashwath - Spydra: and basically create a launch file. First of all, right. And when I create a launch file, it will basically detect that, okay, this is a go length

Ashwath - Spydra: language, and it'll give you some options. So launch a package right? This is what we want to do. Ashwath - Spydra: so it will give you some configuration like this. Right, let me save that, and then I can actually click Ashwath - Spydra: this to debug. But if you do this plainly like this, right I need to select the Ashwath - Spydra: go and file first. Where the main method is. This is the file with the Ashwath - Spydra: main method, and then I can go and Ashwath - Spydra: start debugging right. Ashwath - Spydra: But if I do that Ashwath - Spydra: once it starts, it will actually to an exception Ashwath - Spydra: it should. It's still trying to start.

Ashwath - Spydra: That's because, you know, it's when the exception. Yeah, it's through an exception. And it's basically saying, the CC Id must be specified. So it's coming from our code only because, you know, as we saw in our code. there was a chain code, Id and address where it starts. And we haven't configured those those environment variables. Yet, right? Ashwath - Spydra: So what I'm going to do now is that you know, because we know that we visual, sure, you can actually run this code. Now. Ashwath - Spydra: what I'll do is I'll Ashwath - Spydra: configure the chain port address to be local host. Right? Ashwath - Spydra: So simply, what we'll do is this should be this sad press. Right? The connection.

Ashwath - Spydra: Okay, so not this access. So basically, we will configure. And I'll come to that. How to do that. But we'll we'll ask the The first step is to ask the visual to give port to Ashwath - Spydra: launch the chain code at local host Ashwath - Spydra: 9 9, 9, right? So that's the. And I will also provide a she input id, which will get Ashwath - Spydra: right. So those 2 we have to provide somehow, and we will run the chain for it local. First. the then, what we'll do is we will instruct the peer Node Ashwath - Spydra: to connect to the chain code that is running on local host. Now the Pr. Node right. What we'll do before that is that we have to deploy the peer node.

Ashwath - Spydra: So for that, I've already, you know, deployed that in the interest of time. I haven't. So let me just Ashwath - Spydra: start backs list. So that is the typical network. Ashwath - Spydra: let me copy that command. So I'll just So this is the, you know. Test this network that comes in the fabric samples. And

Ashwath - Spydra: I'll just say, start the network with the Ashwath - Spydra: start, the network with the oops Ashwath - Spydra: in place. Ashwath - Spydra: Okay, so I'll just say, start the network with the channel. That is all with by creating a channel, my channel right. Ashwath - Spydra: and when I do that it will, there is a fabric network that it will bring with 2 organizations like or one and or 2. So it will do that, all of that behind the seats.

Now. Ashwath - Spydra: what we have to do is we have to basically deploy the Ashwath - Spydra: connection dot Jason and Ashwath - Spydra: metadata dot Json right into this network and then instruct Ashwath - Spydra: the chain peer node to connect to my chain port right? So for that. What I'll do is instead of this address, right? Ashwath - Spydra: What we will do is we will ask the Ashwath - Spydra: Do you have a node Ashwath - Spydra: to connect to the Ashwath - Spydra: local host. 9, 9, 9, 9. But remember that the peer Node is running inside a docker container. So for docker container, for a for a container running inside docker to access my local host. You have to, use a different way of doing it. You can either use the IP address of the bridge, or there's an internal, you know, Dns, which is host host or to top locker dot internal, which you can use, which basically instructs the Ashwath - Spydra: any containers that you have to go to the Ashwath - Spydra: local host on the host where the docker and docker is running right? Ashwath - Spydra: So this is what we are doing by doing this right? So the my chain connection dot Json, looks like this.

Ashwath - Spydra: and the metadata or dot chase on is pretty simple. I think no changes there, right? So I've already. So and how do I deploy this? So you have to basically create a zip file Ashwath - Spydra: with the connection, or Jason, but it's simply zipping it into code org. Ashwath - Spydra: And then, you know. you ate this

Ashwath - Spydra: a as well as the metadata or Jason, and then zip it again. Right? So these things I've already done, and If I look at the Ashwath - Spydra: sample folder. Ashwath - Spydra: I already have that zip file here. Right? So once you have the zip file, what you have to do is you have to simply Ashwath - Spydra: installed that zip 5 Ashwath - Spydra: in onto the network that we just created. Ashwath - Spydra: So the above portions here, these are just setting some, you know, environment variables which you would normally do. You know, even

when you want to run any command, using the Ashwath - Spydra: on to the Ashwath - Spydra: on to the test network that I just deployed right? So I am using the or one. So this is a test network that has 2 organizations. Right? So I'm using our one. And Ashwath - Spydra: what I do is install that Zip 5 with those 2 Json files, the connection, Jason and and the meterator Jason Ashwath - Spydra: as the chain code. So I'm actually not installing the real chain code or anything. Just so the zip file, right? And that is successful. Ashwath - Spydra: And then what you get out of this is the package identifier. So this is the chain code that the CC Id. That we are talking about. Right? So let me just copy this and use it here. Ashwath - Spydra: Since we have that right? Then what we need to do is to basically and just setting it as a environment variable. And then the next step is to approve the chain code. So this is nothing different particular change would approve. As you can see, it's Ashwath - Spydra: It's nothing different. we are using the name as Debug, PC. For the chain code, and we are providing the package Id that we got earlier, and the rest is, you know, providing the order of information. The Dls information channel. Ashwath - Spydra: and so on and so forth. Right? So let me just do that approve on behalf of. or one

Ashwath - Spydra: which is basically successful. Ashwath - Spydra: And then let me approve on behalf of or 2. Ashwath - Spydra: And once the chain code is approved you basically commit the chain code, which is again, nothing different normally. How you do that by providing the

Ashwath - Spydra: the Chain code name. The peer addresses the Order addresses the Tls configuration. Ashwath - Spydra: All of that. So this is, you know how you would normally do that. Nothing different. Ashwath - Spydra: And Once that is done, you'll see that you know the chain port is now committed to the channel right? The channel that we have. Ashwath - Spydra: So what we have really done is we have committed the we have deployed so chain code as a service way of doing it and set that okay. The peer should now connect to local host or my host Ashwath - Spydra: to submit the chain code. Request. Right? No. let's come back to my Ashwath - Spydra: visual studio, right? So, as I was saying, now we have to run the Visual Studio chain chain code with individuals, should you and basically provide these 2 pieces of information? Right? So that is where we have to add those as environment variables here. Right? So what I'll do is I'll add the

Ashwath - Spydra: these environment variables in the launch dot Json. give a configuration. Ashwath - Spydra: So what I said is that the change code server address is local host 9, 9, 9, 9, where we want to run it. And the chain code Id is what we got from Ashwath - Spydra: the package. Id when we when we execute it Ashwath - Spydra: the installed command. Right? So this is a package identifier. It's the same that we have configured here.

Ashwath - Spydra: So that's pretty much it. Right now. We have instructed the You should be able to launch the chain code and Ashwath - Spydra: connect here right and run it. Now let's see what Ashwath - Spydra: what happens if we run the chain code Ashwath - Spydra: again. Ashwath - Spydra: Okay, I have to select the go and file first Ashwath - Spydra: and run. Ashwath - Spydra: So now it will run, and it shouldn't give any exception right? So it's still trying. But it' yeah, it's it's it's it's started running right. But nothing has happened to now, because it has just started running for the chain code. So what has started Ashwath - Spydra: right? So now, the next step, typically you write to invoke a chain port Ashwath - Spydra: invoke a chain port. is to

Ashwath - Spydra: basically Ashwath - Spydra: is to basically invoke a chain code method right? And the way to do that Ashwath - Spydra: normally people. How you they do that is using the fabric cli again. So let me go back here and let's try to invoke a method. Right? So this chain code has an initialized in it ledger method. And I'm just invoking it Ashwath - Spydra: from the Ashwath - Spydra: yeah. So let me try that. Okay, before that. What I'll do is now, you know, supposedly the debugging should work. So let me locate the unit chain for initialize. Ashwath - Spydra: Oh. Ashwath - Spydra: so the call you need legend method, and I've already put a break point. But you can put a very quick point anywhere you want. Right? Ashwath - Spydra: So let me just invoke it.

Ashwath - Spydra: And now you can see that something is already blinking here. And Ashwath - Spydra: you can see that the break point is hit. So now, literally, the change input is running in visual should be a code, and when I submit a request to the peer, the peer calls or chain 4, and which is running with the visual studio, and then the breakpoint gets set right. So now you can actually ins inspect, you know everything that's If I. If you can do line by line debugging, you can inspect the variables. Right? What's happening? What are the values? You can look at the context. Ashwath - Spydra: you can, you know. Do F, 10 f, 11 step into step over all of that you can continue right. And I just pressed a 5 so that it continues, and then Ashwath - Spydra: you can see that the chain code invo is successful and you get the result. So this is one way of doing it right. So the chain code as a Ashwath - Spydra: jin put as a service external service model, you can actually use to your advantage to start debugging. Now, right once you do all this configuration? Right? Ashwath - Spydra: yeah. So that's that's one way of doing it.

This. Ashwath - Spydra: yeah. So so this is this is this, this is literally what we did right? So Ashwath - Spydra: irrespective of what language it is, it's go lang, or Nodegs, or Java. As long as you configure visual studio to debug the language corresponding language. First, then, you can do these additional steps of configuring the connection. Dot Json emitted it, or torches from properly, and then start debugging it right? Ashwath - Spydra: So so this is. You know what what we went through. Ashwath - Spydra: There is a another way of doing this also which is using the fabric dev mode.

Ashwath - Spydra: So I' not you know. Give you a demo of this because this is a little bit more complicated to set up Ashwath - Spydra: the first thing, you know, because there are certain different requirements for this. First of all, you know, there is no Ashwath - Spydra: test network kind of out of the box script per say, which will set set this up for you, so you'll have to. Ashwath - Spydra: you know. Download the peer download or build the peer binaries, and then, you know, run the order, peer, cli binaries yourself, and then do the configuration for this to work.

Ashwath - Spydra: But the way this works is that you know. So this will work with Ashwath - Spydra: So the earlier model that I was showing you right, the chain would, as an external service that will work with only code which is written for the newer Ashwath - Spydra: external service market. This will work with anything right? Literally, because this here you will. Basically, you are basically confusing Ashwath - Spydra: peer to run in what is called as a Dave mode, and there is some documentation, you know, in the Hyper Ledger fabric Ashwath - Spydra: documentation site which tells you how to do that. But basically, what in order for this to work right? or what this does basically is Ashwath - Spydra: it runs here in such a way that when you update the chain code right? Ashwath - Spydra: You don't have to redeploy it. So the Ashwath - Spydra: the sorry you don't have to re approve it and commit it again. So the the steps of

Ashwath - Spydra: committing the chain code and approving the chain code by each organization and Ashwath - Spydra: committing the chain code need not happen every time you can Ashwath - Spydra: change the chain code upload it again, and it will run the new change code without these additions to be done. So that is what fundamentally it does right at a very high level. Ashwath - Spydra: But for it to work right. First of all, you have to use solo, as the instances solo, as we all know, is sort of deprecated at this time, but it still works right. So for this particular reason of debugging, you can still use it because it's not really production port production deployment that you're doing here. Right? So you you'll have to use so low. So you know, you'll have to Ashwath - Spydra: create the Genesis block by running conflict the exchange with solo as the profile right? And then, while. Ashwath - Spydra: while starting the order of node. Right? You have to use the solo profile and the the samples, for that is given in this particular location right?

Ashwath - Spydra: And then what then? What you'll have to do is when you start the peer node right? You'll have to start it in with an additional switch. Ashwath - Spydra: same here chain code dev is equal to true. Ashwath - Spydra: So what happens by doing that? And then you you'll have to install the chain code that you're written, and then approve and change and port one time. Right? So this this task you are to do one time. Ashwath - Spydra: So what happens by doing this right is that as you saying 2 things right? One is. Ashwath - Spydra: you don't have to do the pro and commit chain code again the second time you' up, update the chain code second time, and also that in this model also, instead of Ashwath - Spydra: the chain code being run by the peer.

Ashwath - Spydra: you can actually run the chain code outside. Ashwath - Spydra: right? which is what it does. And the way you do that is, when you run similar to what we saw in the so input as a service model, you can actually run the chainput within visuals, should you, code? And while you are starting the chain port. Right? You basically configure some other Ashwath - Spydra: environment variables like the name Ashwath - Spydra: Tls has to be disabled because, you know, solo doesn't work with Ashwath - Spydra: well, with the Ts. And for that matter, we are to disable t us and then, what we say, what we do is that when we start the chain port we have to pass the Ashwath - Spydra: peers address Ashwath - Spydra: to which the chain code should connect. This here is the reverse. Right in the earlier chain code and service model. We were inspect in instructing the peer to connect to the chain code to submit request. But here we are doing the reverse. When when we are starting the chain code to connect to the here at this particular location, and then establish a connection to the peer, so that when the peer

Ashwath - Spydra: tries to run a chain port instead of the peer running by itself. It knows where to send the request to which is chain code which is running within our, we just should be a code environment. Ashwath - Spydra: right? So Ashwath - Spydra: it's a similar model, but works slightly different. And you know that the doc's link that I pointed to has some details on how to set it up. Ashwath - Spydra: the site complication with this method is that Ashwath - Spydra: you know, first of all, you have to do more work to actually set up the network. And then the second thing is, you know, depending upon the language, right the way you configure Ashwath - Spydra: the chain port. Individuals, should you like you go for go you do this, but for nodejs Ashwath - Spydra: You have to slightly give the arguments in a different way. So the program, the way that you launch the

Ashwath - Spydra: in go right, you have to launch you can directly launch the go file while in Node. Js, you have to launch Ashwath - Spydra: no module, basically. And then give your file as a argument to that. And you have to give some additional arguments. So the there is slightly different things to be done. And but still you know that this is another way of Ashwath - Spydra: debugging the chain code within visual studio code or any Id, for that matter, where you run. that you can go right?

Ashwath - Spydra: So those are, you know, 2 methods that exist sort of out of the box within the hyperlink of fabric itself, which you can use to your advantage. Ashwath - Spydra: but of course, as we saw right, you still need to deploy the network first, that's one thing, and then you have to understand these additional configurations that you have to do. You have to do it in the right way. Ashwath - Spydra: and then only things will work right? Ashwath - Spydra: So that's where you know. Then we thought, why not automate. Ashwath - Spydra: or this that we have already talked about right? And can we do something much simpler? Right then? That's where we, as Spider, created the hyperlink of fabric debugger extension which I which I'll talk about going forward.

Ashwath - Spydra: So I think it. Let me dive into the actual extension itself, which will give you a better idea. Ashwath - Spydra: So let's take the same chain code, right? Which is the chain code? External? Yeah. Ashwath - Spydra: And I'll open a different Ashwath - Spydra: open it into a different window. Ashwath - Spydra: Yeah. So this is the same same chain code.

Ashwath - Spydra: But I've named it differently, but it's so opened in a different window, as you can see there's nothing in the lot launch, Dot Json, or anything. Right? So this is a fresh fresh sample that I just open. Think of it that way Ashwath - Spydra: right now, what you can do is that there is an extension called hyperbolic fabric debugger. Right? You can basically search it within. We just Ashwath - Spydra: the marketplace, and it will come up like this hypothetical, and once you install it right it will come up in the left wing. Now, if you go here, there's nothing there right now. But because we have not done anything right. Ashwath - Spydra: So let's say you, you want to debug the go land chain code here, right? And this is the same change. But as I was saying, which is written for a change, but it's an external service. Yeah. Ashwath - Spydra: So in this particular case. Ashwath - Spydra: I see there are some questions. I'll take the questions in the chat, you know, towards the end of the

Ashwath - Spydra: presentation. But let me just cover the Kamlesh Nagware: first. There will be question, I think. secondly, this port Kamlesh Nagware: double and double and port number is a hard coded, or what? Ashwath - Spydra: Sorry? Which? Which? What was the question? The question from Ravi he mentioned, is chain code, port number, double line, 99 is hard coded port, or can we customize it? Ashwath - Spydra: Yeah, you can customize it. You can put whatever port you want. It's just a port where you know the chain code will be launched. So whatever you configure. So let me go back to that example. So whatever you configure here, right Ashwath - Spydra: the same you have to put here right to be should match. Ashwath - Spydra: So this is where you are saying where the same code should be launched. And this is the section where we are saying, you know it's in the beer where it should connect, so these should match that. So it's not hard coded you can. You can put whatever you want. I think that he mentioned the what are the types we have? I didn't get. What is the question? Maybe that we can ask.

Ravinayag: Oh, okay, So if you look at this maternity, guess. And Ravinayag: you have what times to define? Right? C, so is it? What are the types that we have. Ashwath - Spydra: Yeah, so this is the only built in type, literally. But basically, this type you can use to. So there is this concept of external builder

Ashwath - Spydra: in in fabric, right where you can say that Ashwath - Spydra: you can customize the way the fabric here will build your core, so you can define your own type, and then you can define a builder for that. If you look at here right, there is a sample builder that is given here. so this builder is what will basically use this type at the end of the day. So if you want to create your own builder right, we can define your own type and then use a custom builder for that. Ashwath - Spydra: so you can look at the how the external builder works in in fabric, and that will give you a much better understanding of how Ashwath - Spydra: how? How that kills? Ashwath - Spydra: Yeah. So here, if you see. Ashwath - Spydra: yeah. So we have to hardcore this in the sample builder for the type that we are going to do whatever. Yeah, whatever you define here, you have to use that in the builder. Essentially.

Ravinayag: okay. But this is a built in type, essentially, that fabric. It's a Ashwath - Spydra: yeah. Ashwath - Spydra: Okay. Ashwath - Spydra: so let me switch back to the other screen port, right? So this is the same external chain code, but a fresh one right where, when we have not done anything. But we have just installed the hypothesis fabric deeper the extension. Yeah. Ashwath - Spydra: So the the the process is similar. If I have to debug, I have to first of all create a launch.ch. Inside, right.

Ashwath - Spydra: So I'll create a launch for this on 5. Ashwath - Spydra: But you you see that there is an add configuration option here, right? Which, anyway comes. Ashwath - Spydra: So if you go to add configuration right Ashwath - Spydra: and scroll down to the Google section, you'll see that there is a option to debug fabric. Ashwath - Spydra: So this is this doesn't come automatically. This is coming here because I've installed the extension. So this extension is contributing this additional option here. So if you Ashwath - Spydra: select this right, what it has done is, it has created another configuration section here. Right? So there. Now, you can see there are 2 configuration section one is the default, one which.

Ashwath - Spydra: which visual studio code create, which is the just saying, I can debug go go chain for. Ashwath - Spydra: And now there is another configuration section that is created here. Ashwath - Spydra: So the first one is called launch package, and the second one that has been created with the blockchain port. And if you see here, right in the Debug section. Ashwath - Spydra: does it drop down where? Ashwath - Spydra: Let me save it. It's not saved. Yeah. Now, if you go to the drop down, you'll see those 2 options here, right? So delete the other one, which is a default go one because it wouldn't work out of the box, anyway. And now you'll see that there's only one option here, right? Ashwath - Spydra: And if you see the configuration options here, one is just a name, the other is the type. So the

Ashwath - Spydra: the extension basically supports golank and node. Ashwath - Spydra: So hs go is for go line. So this is good. And and if you change it to Node, and I'll show that. Come to that later. It's the it'll support Node. Ashwath - Spydra: And then there is another flag, which is this is a chainboard as a survey. So we are talking about. You know, there are 2 ways of developing chicken code right? Such a inquiry service way, or the older way, because it is a chain code as a service kind of a code. I'll switch this to true Ashwath - Spydra: right to instruct the debugger that the port has been developed to work with chain put as a service market right? Ashwath - Spydra: And that's pretty much it right? You don't have to. So what I'll do is I will also, just to be sure, what I'll do is I'll remove the network that we created. Right? So Ashwath - Spydra: I will. Okay, so Ashwath - Spydra: I will do dot slash Ashwath - Spydra: down. So I'll bring down the network right? The earlier one that we have created. So we don't have that network anymore. And all that we have done is open the chain port and created this configuration file right?

Ashwath - Spydra: And that's it. Now, if I click on the book Ashwath - Spydra: now you see that some things are happening here. it's a starting local fabric network. And there is some things happening right? So it's actually creating a beer node, it's actually creating. Ashwath - Spydra: So if I look through the so what the message is here Ashwath - Spydra: everything that was done to create a network. Ashwath - Spydra: right Ashwath - Spydra: is being done automatically by the change code. Okay, I got an error because you know, as again, I have to select go find before I click the debug, which I always forget. Ashwath - Spydra: Let me do that again. Ashwath - Spydra: and if I look at the output here, right is, as you can see, it's creating a Ca container cli, container, order or peer. So everything that happens when you create a network is automatically happening here. So the chain code, the the extension, actually does all of that for you right? And then it deployes creates the channel. If I look through all of that it's it's creating a channel, and then it's deploying the chain port

Ashwath - Spydra: into that channel. And you know. Ashwath - Spydra: everything that we discussed about how to manually configure the input as a service model is being done automatically by the plug Plugin, literally, that's what is happening. Ashwath - Spydra: So now, the debug is actually started. But as you are seeing earlier in order to actually submit a request. We use the Poc I earlier, right? But that defeats the purpose right. If now again, I have to go somewhere else basically use the poly and submit a request right? So that's where the second thing that the plugin does is Ashwath - Spydra: It provides a way to submit the request right from within visual studio. and the way to do that is by creating a file with a dot fabric extension. You can name it anything right Ashwath - Spydra: like I have named the already created a file called Hes dot fabric here. but the name doesn't matter, and you can actually create as many files as you want, right? Ashwath - Spydra: So and how does the file look? It's a Json file. Basically, it's a Json file, which you know, which is an array. And there are individual objects that you can create within it. And the structure of this is, first of all, you say, whether you want to be invoked or query. So just like, you know, when you're invoking through the

Ashwath - Spydra: you say, you basically say that first. Ashwath - Spydra: and then which method? Right? So in it, ledger is a method which doesn't take any argument. So all that you have to say is invoke in it, Ledger, and you'll see that the moment you type in work. Right? So let me write something new here, create a new section. Ashwath - Spydra: I'll type in work. or Ashwath - Spydra: very. You see a send request Link appearing about right. So like here it disappearing here. Ashwath - Spydra: So you click that. and you can see that you know the result will be on the right. So the invocation is successful. Ashwath - Spydra: Similarly, I have, created a very query request and get all assets. Send request.

Ashwath - Spydra: And you don't need to basically Ashwath - Spydra: send. Call this method and give you the results so literally. You know, you can invoke the chain port right from within visual studio, and of course you can put a breakpoint like, here, let me put a break point at the top. Ashwath - Spydra: So let's let me put it in. Get Ashwath - Spydra: read. Read a set here. Yeah. Ashwath - Spydra: and I go to the dot fabric file. Ashwath - Spydra: and let me Ashwath - Spydra: create new Ashwath - Spydra: section for that. But I don't have one.

Ashwath - Spydra: So it's a read as it Ashwath - Spydra: is what I want to do, and arguments because this expects some arguments. Ashwath - Spydra: and what does it expect? It expects the context. Ashwath - Spydra: And an id right? So id is a string, so let's say. oh.

Ashwath - Spydra: see! Ashwath - Spydra: So I said. One is one of the asset that has been inserted via the in It ledger. So I say, read, I said one, and send request. Yes, it is Ashwath - Spydra: exist. Ashwath - Spydra: Something went wrong in the chain code, I guess, but it's a it's a it's a Ashwath - Spydra: it's coming from within the chain, probably. So let's see what is Ashwath - Spydra: happening. Ashwath - Spydra: Let's see if I can.

Ashwath - Spydra: I think it's coming from even below about here. So let me put a breakpoint here, and if I click on 10 request. Ashwath - Spydra: so send request here. we'll see that the break point is hit, and then you can do if 10 and Ashwath - Spydra: as you can see, it cannot read for whatever reason. But basically the request is coming in, and you can see that. Ashwath - Spydra: you know, the when it's actually reading the Ashwath - Spydra: the asset doesn't exist, and Ashwath - Spydra: some of the Ashwath - Spydra: which is weird. Ashwath - Spydra: But basically, you know this, this is this is how you will.

Ashwath - Spydra: you can basically debug, right? so what? Whatever method you put right like, for example. in the create asset. Right? You can. We are calling the create asset. So I can put a break point within. Ashwath - Spydra: We then create a set here. Sorry. Let me go back here and with the big point here. Ashwath - Spydra: and if I send request the breakpoint is hit, and then you can see that the Id that was sent. Ashwath - Spydra: which is a one, is what is coming here. Right so.

Ashwath - Spydra: and then you can, you know, Ashwath - Spydra: be back as you normally would do. Ashwath - Spydra: Yeah. So that's that's the that's the quick and easy way of doing it. As I was saying, you know, this works with the go lang as well as no Gs chain port. So let me just quickly switch to a different Ashwath - Spydra: changing port, which is no gst in code. And this is again of coming from fabric samples only. And this is the chain code that I'm using. Here is the asset ledger. Ashwath - Spydra: I said, transfer legendary queries, because this has some more advanced features around varying. So let's quickly look at that. So there's a Ashwath - Spydra: chain code that I just opened individual studio code, and, as usual, I go to the Debug section for you to launch, file. Ashwath - Spydra: create. No, no, no! Just launch files this time. And as earlier.

Ashwath - Spydra: basically. Ashwath - Spydra: yeah, once, once you create a launch file, you can save it. And then as earlier, right this time. What I'll do is I will take this Ashwath - Spydra: configuration and Ashwath - Spydra: replace this with that. Ashwath - Spydra: And Ashwath - Spydra: instead of go, I'll Ashwath - Spydra: say, Node, this is a node based. Input and this is not a chain code as a service. So I'll switch this to false. Ashwath - Spydra: And yeah, that's pretty much it right? And then I go back to the Ashwath - Spydra: just file and start debugging. Ashwath - Spydra: And as you can see, it's doing a similar thing, it's creating the network. launching the chain port.

Ashwath - Spydra: I know that. And once it's ready, it's Ashwath - Spydra: starts printing the message that it's fairly Again, I can period dot fabric file Ashwath - Spydra: But with the the methods that exist in this one. Right? So similarly, there's a needed ledger method in the Nodegs chain code that gets Ashwath - Spydra: initiated. Ashwath - Spydra: you can put a breakpoint. Let's do that in. Read a set here Ashwath - Spydra: upon it here. So this is a read asset and

Ashwath - Spydra: and the big point here. Ashwath - Spydra: And Ashwath - Spydra: so when I click that it comes here. And, as usual, right? I can basically Ashwath - Spydra: inspect the the variables. The I can inspect Ashwath - Spydra: the Id. Here, for example, like in step through step over all of that right now. There are some additional features that this supports the the Plugin supports like. For example, if I go to the

Ashwath - Spydra: dot fabric? 5. Right? Ashwath - Spydra: normally when you submit a argument right? Ashwath - Spydra: Everything, even if you do it, using the Ashwath - Spydra: string. So, for example, in this case, right? There is a Ashwath - Spydra: couch TV query that you can submit to query assets. But then you'll have to stringify it first like this, and then some normally right. If you look at the

Ashwath - Spydra: the sample here, that's how they do it right This is where the Gauss TV, very option way of doing it is mentioned, and you know you'll have to stringify and then submit it right Ashwath - Spydra: like this will work. Ashwath - Spydra: But this is a bit difficult, right? And especially if your Json is huge. So that's where we also the Plugin also supports, instead of signifying it and support and and submitting it, you can basically submit it as a Json itself. Right? So this, this will work. Ashwath - Spydra: And this will also work right? So when you do that. it's actually changing. But okay. Ashwath - Spydra: let me show you by calling something else. First, I just for read a set, and then if I do this. Ashwath - Spydra: as you can see, the result is coming. so you can actually

Ashwath - Spydra: so directly, right? have a json here instead of signifying it and then then submitting it. Ashwath - Spydra: if you go to the Ashwath - Spydra: extension here, there are some additional things that you see here. First of all. you this basically creates a network behind the scenes. If I go to my docker container now, right Ashwath - Spydra: there is a network that it has created with the Ca, Pr water or cli, and all of that right in you can actually manage the network. So if you're you know, if you're done with your debugging when you quit visual studio code. It will actually stop the network by itself, but it won't remove the network.

Ashwath - Spydra: So if you want to, but manually stop, start, or remove right if you want to reset the network. So the way this still work is that when you when you quit visual studio code, it will stop the network next time when you debug the same network will be reused. So any as any, anything that you have submitted right, any transactions you have made. Ashwath - Spydra: Everything will be there in the ledger as such. So you know there will be continued. But let's say you want to start from scratch right, so you can remove the network. And then then when you debug the next time you'll get a fresh network all together. So there are some, you know options to manage the network that is created automatically by the Plugin. Ashwath - Spydra: And then the other thing that you can do is you you can use, you know different users. Ashwath - Spydra: So if you have a case where you want to use different users and do some testing right by default the Plugin will create 2 users for you or an admin and user user one or when Admin has an admin role and user, one has a client role within within fabric. Ashwath - Spydra: But you can actually create more users. Right? Like, I can say, create Ashwath - Spydra: user. And let's see.

Ashwath - Spydra: And Ashwath - Spydra: that will be created. And in the Ashwath - Spydra: tested fabric right where your invoking or query you can provide an identity option with the user that you want to use Ashwath - Spydra: right? And now, when you do this. Ashwath - Spydra: And if you inspect the code here. Ashwath - Spydra: yeah. Ashwath - Spydra: somehow, the break point is not hitting Ashwath - Spydra: 1 s, let me stop this and start again.

Ashwath - Spydra: Okay. Ashwath - Spydra: so if you submit this with user 10, Ashwath - Spydra: something is Ashwath - Spydra: gone wrong. You cannot run the pier. Ashwath - Spydra: okay, I think, maybe. Ashwath - Spydra: can I do I click something here? Ashwath - Spydra: Okay, I think, I'll probably have to reset the network. But I basically, you know, when when you when when you use a different identity. It should. And if you inspect the context object, right, you should actually see the different identity. that that you Ashwath - Spydra: basically set up right? So the plugin, basically supports multiple users to be created in a wallet and things like that. Ashwath - Spydra: so yeah, that's that's pretty much what I wanted to show you. So feel free to, you know. Download the plugin and play around with it.

Ashwath - Spydra: As I was saying, you know, at Spider. We also provide a. Our mission is to, you know, make the adoption of blockchain easier. So we provide a platform that you can also Ashwath - Spydra: try around so you can go to Spider dot app, and if you go to get started right, you should be able to register yourself and try the platform out. You can create a hyperlier fabric network Ashwath - Spydra: within spider. And then you can try out the features. We provide a $400. Predict that you can use for free and try out the platform. So feel free to do that. Kamlesh Nagware: So thanks everyone. I'll take any questions that you have. Ravinayag: somebody's. Can I ask you, yeah, yeah, okay, I I just have a question. But somehow I understand that. But still I want to confirm from your side So when we do that deeper thing, and executing some transactions before launching it. Ravinayag: how then that transaction? You'll be there, I mean all the practical part of you.

Ravinayag: The the question here is, will that be a transaction, that apple mechanisms? All those things will be there, or just a simple. when you launch the chain for just executing the phonetical function. That's it. Ravinayag: Nothing, I think, blocked in the car in that account. Ashwath - Spydra: so are you asking whether the transaction actually goes to the peer? Is that what you're asking? Or are you about? Yeah, it actually does go to the period. So you know, if you so basically, the you know what the Plugin does is it actually creates a real network behind the scene. It's a single or network, as you can see. So there's no no multiple organizations. Not but it actually creates a real network behind the scenes, and the transactions are submitted to the peer.

Ashwath - Spydra: it's just that it's all managed behind the scenes for you. So you don't have to create your own network. But it's actually going to the hypothesis fabric. It's executing the code that you have written and everything. So it's nothing different. Ravinayag: Okay, okay. that is internally minded with the Ashwath - Spydra: correct, yeah, it's I internally managed by the plugin. Yes. Gourav Sarkar: yeah. I, I have a question. can I ask. Ashwath - Spydra: yeah, yeah, please go ahead. Gourav Sarkar: So just wanted to check that you mentioned. in the fabric we have the chain code as a service, and as well as the fabric, Dave mode.

Gourav Sarkar: So when you do this Gourav Sarkar: debugging. So do you support both, or is it The change as a service is the only one that you are looking for? Gourav Sarkar: We support on. My. Ashwath - Spydra: yeah, we support both actually. And in fact, you know, in the samples that I was showing you right. The Javascript one

Ashwath - Spydra: is actually written with the older way of doing it. So it's not chain, but as a service. So there is a Ashwath - Spydra: in the configuration for the debugger, right? There is a particular key whether it's a chain code as a service or not. So if you set it to false, it's the older method, and if you said it to true Ashwath - Spydra: which is the other one here. Then the the plugin works accordingly, and

Ashwath - Spydra: it does the job for you. So we support both. Yeah. Gourav Sarkar: okay. thank you. Yeah. Ravinayag: Okay, I have another question. how this private data connections or Ravinayag: the mechanism. If I've mentioned in the chain code like. If if the, for example, it's like safe conditions in the chain code, saying that only from this organization comes in, you allowed to execute the chain code.

Ravinayag: In that case, how that can be handled in the by the platform. Ashwath - Spydra: Yeah. So the Plugin plugins the reason Ashwath - Spydra: to just debug your code right it literally. So if you look at the the network that it creates, it's a single or network, and which means, you know, there's only one year to endorse. Right? So there is. No, there are no multiple peers. We are not talking about endorsement policies or Ashwath - Spydra: so private private data collection will work but endorsement. But there is no endorsement policy concept as it's in the

Ashwath - Spydra: in the network that the Plugin deploy and the the reason for that is, it's, you know, it's Ashwath - Spydra: it's not really to test any of that right? It's not even connecting to any existing network that you have. It's deploying it somewhere. Right. So the only only intention is just to Ashwath - Spydra: deeper the code that you're written right? Which is what it is really trying to solve. Ravinayag: Yeah, I agree. but I I mean, I have that some thoughts here. What if I launch the network? And can I do that? People with that particular work? Ashwath - Spydra: not using the plugin. But yes, using the manual, the way that I talked about right? that, you know, you can basically do the right configurations, either as a dev mode or as an external service in your existing network.

Ashwath - Spydra: They then you then it can do yes, but not using the plugin, but yes, in the roadmap, we want to extend the plugin so that the debug works it in the existing network that you have. We also want to provide an option to create multiple organizations and and those configure things like endorsement policies and all going forward. But right now it just creates a single single or network. Ravinayag: Thank you. Thank you. Yeah. Got it. Thank you. Ashwath - Spydra: Yeah. Is there any Doc to taste this out for the like? The step by step? Precision. Ashwath - Spydra: Yes, yes. So if you go to the Plugin itself, right? the extension plug in itself.

Ashwath - Spydra: so you can actually see the documentation right here and there are links to the other, to the github or so, and things like that. So if you see here right, there's a quick start. Ashwath - Spydra: and you can view this in the marketplace also. So there is a quick start how to do that. All the instructions are here. Right here. yogi: Yeah, I done. Thank you. Gourav Sarkar: Yeah, just I have one more question as So this this debugger support both the fabric sheen as well as the contract Api both the types of chain code writings.

Ashwath - Spydra: Yeah, yeah, it does. Actually, yes, correct, it does. Gourav Sarkar: Okay. yeah.

Kamlesh Nagware: Okay, I do. Thank you. If any other question you can ask. Otherwise we can. Kamlesh Nagware: So you can share the this Vs code extension here, I think someone asking the check. Ashwath - Spydra: Okay? Sure? Sure. Yeah. Let me just Ashwath - Spydra: share that directly.

Kamlesh Nagware: Yeah. And this recording will be available on how you call users Youtube general. So, and that will be also shared on the Hypervisor interceptor. Kamlesh Nagware: Well, So you can follow ipad in India. Ashwath - Spydra: I get to be trying to get to the chat window. Ashwath - Spydra: Yeah. Got it Kamlesh Nagware: so as well. Can you do? Can you make me cause I need to stop the recording? You don't want the commercial.

Ashwath - Spydra: Okay? And yeah. let's stop the recording.

2023-07-01 09:03

Show Video

Other news