Blockchain CBSA – Bonus Lectures
- Bonus Lecture – Facebook Libra Demo on Google Cloud Platform
Welcome aboard, everyone. Let’s go ahead and talk about installing the Libre testnet on Google Cloud Platform. Now, to install the Libretest net on Google Cloud Platform is a relatively simple process. Now you can go ahead over to the link in the description and download the instructions. The instructions are going to essentially look like this. So let me go ahead and bring over my screen and show you what they look like.
Now, when you download this PDF file, it’ll be over 23 pages or so, and I’ll walk you through exactly step by step on how to set up Compute Engine. How to also set up I am an admin, and then also go over to basically how to connect to an instance, and then also finally install the library testnet and run some transactions as well. Now, another thing we need to do as well is install git before we run the testnet set up. So that’s something that will also be required. But overall, this whole process takes less than an hour. So it’s relatively simple.
Let’s go ahead and get started. The first thing I want to do is go over to Compute Engine. Now, you can see that I have a VM already running. What I want to do is create an instance. Now, specifically for my blockchain service for Libra. I’m going to call this My blockchain VM. Number one, I’m going to go ahead and deploy this in Iowa. Now, for the purposes of this demo, I’m not going to walk you through any GCP basics or anything like that, just more of a short little demo on how to install Libra.
Now what we want to do is I’m going to go ahead and use a GP VM. However, you certainly could go over here and change this to a micro in the free tier if you so choose. It will work. I’m just going to go ahead and deploy it like this. And what we have to do here is make sure we enable the firewall to allow web traffic. What we want to do is go create. Now, what is going to happen here is it’s going to boot up our virtual machine. This will take about 30 seconds or so. We’ll come right back when it’s done.
And now it’s done. What I want to do is select the My blockchain VM and just validate that we’re good to go. So we have our internal IP set or external IP set. Perfect. All right. Now the next step we’re going to do is we need to go and set up IAM before we deploy anything on the virtual machine. What we have to do now is I have to set up Compute Engine to be able to access, first of all, the Internet. I need to also set it up to allow my account to be a Compute Engine admin.
Because I’m going to install essentially the Libretest net and GitHub, I have to have the ability to not only view the VM, but I have to be able to deploy that VM. So with that said, and I already have the permission set, but I just want to double check for folks that might not have had their account set up correctly.
So let’s go over here before we deploy anything on the VM, just to make sure you’re set up right, what you need to do is ensure that you have Compute Engine set up on your account, which is actually right here. Compute engine. Basically admin owner. So it says Compute admin owner. Now if I select this, I could go over here and view the account or edit it. If I select Edit, you can see that I’m the owner.
My role is the owner. But if I go over here and I type Compute, there’s actually different levels of permissions. In this specific case, I want to just be the admin. Now if I’m viewer or storage admin, this isn’t going to give me the permissions that I need. So with that said, just set yourself up as Compute Admin in this specific demo. Now one thing to be aware of is, again, it depends on your corporate security posture. If you want to set this up different, you’re going to use different levels of IAM.
That’s up to you. I’m just setting this up for a short quick demo. So I’m going to go ahead and cancel that. We’re good to go. Let’s go back to Compute Engine and get started. Okay. I’m going to select Compute engine. Let’s go ahead and have some fun. Now what we want to do is log in to this virtual machine.
So I’m going to go over here, select SSH, and I could log into the virtual machine this way. Now that’s your call if you want to. I’m going to go ahead and minimize this and what I want to do is actually get this set up a little bit better right over here so that I could be seen. And what I want to do is actually select the drop down and the reason is because I’m going to use my local SDK kit. I just prefer to do that instead. So I’m going to go view G Cloud Command.
Also too, another thing to think about when you deploy the VM is the policy that you could set for your certificates. I’ll leave that up to you again to talk with the corporate security and what you want to do. I like to use the project wide certificates so I don’t have to configure different certificates. Okay. Now what I’m going to do is bring up my local SDK and you can see that it is now open and let me go ahead and just take a second to make this a little bit easier to see.
And again, it might be a little bit off the screen. In this case, I’m just going to go ahead and copy and paste this in there and what I want to do is just hit Enter. Now what’s going to happen is it’s going to pop up as expected, the SSH fingerprint warning that’s okay, I’m going to go ahead and select yes, I’m using Putty. What I want to do now is I’m going to go ahead and get this out of the way.
I’m going to go ahead and bring this up and maximize this. Now actually a couple of things before we get started is when we’re using the local SDK or the CLI locally, basically it’s going to be set to a certain project and there’s a whole area of set up that you probably want to go through. So let me go through and show you how to get started.
Okay, now that we’re logged in, we’re ready to go. I’ve adjusted the resolution so you should be able to see this good. What we need to do is go over to the Libra homepage here and talk about a few things. So the first thing is it’s telling us here some assumptions.
So the first thing is we need to be running a proper version of Linux and with basically Google Cloud, the default is of course going to fit in this case. Now the second thing is we need to have an Internet connection which we have and then we need to install git. And if you’re running Mac then you need to worry about homebrew being there. Then we also need to install basically Yum or app Get as well. Now with that said, let’s go over and get git installed. So what I want to do is bring out my SDK and what we have to do is install Get.
So the first thing is we need to go and get the proper command for git and in the worksheet it is right there for you to pick out. And the first thing we want to do is just validate the git if it’s available, which it isn’t going to be on a new VM on Google Cloud, as you see it comes up blank. So the next thing we want to do is basically we have to sudo and then get our updates. I’m going to go ahead and copy the command in and as you see it’s going to go ahead and install the packages. The next thing we want to do is again validate that the package installed. Okay, it says it’s done so we’re good there and then we need to go ahead and put in the install Get.
So now that we got it, we’re going to go ahead and install it. Now you can see down the bottom it says do you want to continue? What we have to do is basically go ahead and complete the install. It’s just saying, do you want to go ahead and install? It’s going to have to have some space. It only needs like 13 meg. And on the default config of Google Cloud. There’s plenty of space, so you don’t need to really worry about it. Yes. Going to go ahead and install and this will take approximately a minute to complete. So we’ll come back when it’s done. It is now completed. So let’s just validate that it is there. Type which get and now we have our user bin directory.
Okay, so what we’ve done so far is we download a git. We’ve installed git, but we haven’t actually initialized it. So what we have to do is go and type get in it and it basically says that the directory has been initialized. Then what we have to do is then run the command to create basically directory tree and then I’m going to go get and then go add and basically again, actually it’s git add. Sorry about that. And now we’re good to go. Okay, so now we’re actually in a good position. Now that we’ve installed git, we’re good to go. We have our directory structure in place, our directory tree, that is. Everything’s been initialized. What we want to do now is start downloading the lever testnet.
So we want to go back here to basically our first transaction. Go over here and make sure you read this before you get started. Now over here you can see that it says clone and build the libra course. So let’s copy that, go back over to our window, paste that in and it’ll go ahead and clone the libra testnet directory.
And then let’s go back over here and go ahead and copy our change directory and our script. Okay, basically what is being asked now is it says you need to make sure you have the proper dependencies and in this case, we’re already good. We have get our directory structure set. So we’re good on Google Cloud. Now when we’re on AWS, things are going to be a little different. But with that said, let’s go ahead and go. Yes. All right, so what’s going to happen now is it’s going to go ahead and download basically the components.
This is going to take about a minute, or a few minutes I should say, and we’ll come back when it is ready. Okay, so it completed in about two minutes, a little bit less, but I think it was like an hour and 42 seconds, so didn’t take too long. Now what we have to do is go back to the libra testnet page, copy a script to get started. Now what we’ve done is set everything up. We’re ready to go for basically setting up our test net. Basically we have our Rest components installed, we have our git. Of course. We also have the software loaded and the baseline as well that we need. So what we have to do now is go over here and start what’s called the cargo structure. So this is basically a package manager. It actually says right there. Now it’s very simple, you don’t have to run the cargo command directly or anything. The script is going to do it for you.
So just go copy, go back over to your window and kick this off. Okay. Now this is where you want to go to Starbucks and come back in about 15 minutes. This is going to take a little bit of time at least for me. Every time I’ve ran it it’s taken at least twelve minutes or so. The quickest I’ve ever seen it was about eleven and 30 seconds or so. We’ll come back when it is done. It’s going to go through and unpackage, basically unpackage everything, get it set up. It’s going to go ahead and download the repository, so on and so on. There’s a lot of work going on in the background with the script. What’s really nice is you don’t have to do anything with the cargo command and worry about getting anything wrong. It’s going to do it for you. We’ll come back when it is ready. Now you can see on the screen here quickly that it’s still installing out of 462 different components. It’s going to compile and get ready. It’s only at 21 and it’s been two minutes so we’ll come back when it is done. Okay, so it completed. Now what we want to do before we get started is go over here to the my first transaction page. Now we installed the script we’re good to go. And now what we need to do is go down here and create some accounts. Now what I’m going to do is just walk you through a quick configuration of how all this works. So the first thing that we want to realize is that we installed this of course on Compute engine. Now I did not set up load balancing in this case. If I did want to set up load balancing would be fairly straightforward. I’d create instance group and add that to it.
We do have our external IP but in this case here what I did is I just connected Compute engine externally to the net and therefore go out to the Libra test net and the port that’s used is http but the port is 8000 by default. Now as far as the wallets, what we have to do is create two accounts and those accounts are essentially Libra wallets. So what we’re going to do is create two accounts. One is Joe and one is going to be freed up again. That’s really straightforward to do. And once we do that we’ll transfer some funds back and forth and what will happen is it’ll go ahead and create our wallets and then we’ll validate against the Libra castnet. So basically we’ll validate this again. We’ll get that response back, same thing. Validate the other one, transfer some money, et cetera. Again that’s really the whole process. Now I did also want to say if you did want to what you could do instead of going out to the Internet, to the labor test net. What you could do is set up a validator node locally on Compute Engine and do that as well if you so choose or on Prem, whatever you’re doing. So you don’t have to go out to the lever test net if for some reason, for security purposes you can’t, you could set up a local validator node, which is basically a swarm instance that you’re going to set up to just go ahead and play around with and learn on. All right, let’s go ahead and go back to our interface. All right.
Now what we want to do is I want to go ahead and type account list. Let’s validate that we don’t have any accounts. Okay, so we don’t have any accounts. So I need to create two accounts. And to do that I’m going to type account and I’m going to go ahead and go create Joe. Now you can see that it created one account and it gives me a wallet address. Now what I’d like you to do is pay attention to number zero. That is basically the account number. That’s zero. And this would be the wallet address. For reference purposes, we’re going to go ahead and create another account and I’m going to call this one Frida. And you notice that it’ll go ahead and add one to that. Now if I wanted to play around more and get deep into some of the commands, I could go back over to my first transaction page and do that. So let’s go ahead and validate. We have our accounts. Okay, so we have our two accounts. Now the next thing we want to do is basically we have our accounts here, but we don’t have any funds in it. So we need to create the two accounts with funds. So we have the accounts actually created, I should say. But what we want to do is add funds to the creative accounts.
So the first thing I want to do is go to Account and Mint and I’m going to go account zero. I’m going to add 1000 libra. And now it submitted the request. And now what I want to do is add libra to the other account. Okay. So now what we did is I’ve added 1000 libra to both accounts. So let’s go over here and just type account list and you can see that the accounts show up fine. Now what I want to do is I got to really just validate what the balance is. So let’s go ahead and balance zero. Okay. So we have 1000 there and let’s go check one. So again, we have a lot of fun stuff we could do with this. For time purposes. I won’t go through too much more. You go ahead and transfer coins back and forth over here.
For example. Go over here to the steps. You could list accounts again. You could transfer funds down here. You can see that we queried our coins, then we could submit another transaction. We could transfer funds from one account to another, and then they have other commands you could try out as well. Essentially, you have a work in testnet, if you so choose. And again, to be honest, there isn’t a whole lot you can do right now. It’s in the early stages. However, I’d recommend if you did want to play around also, too, this is a cool command. So let’s go over here.
And one more thing before we go is query the account state. Now, what this is actually showing you is when I query the account state, this is showing us the state that this is in. And what that means is it’s going to let us know what the current balance is, how many bytes were received. You can see down here tells you the authorization key. Any kind of rules that have been set on the account are listed as well. With that said, I hope you have fun with this. For those interested in learning how to deploy this on AWS, I have a video for you as well.
Feel free to go to YouTube and find out as well. With that said, let’s continue on. And also too, one quick note. When you’re done with your resources on Google Cloud, if you’re not using them, you can always turn them off and that way you’ll save some of your free credits or your funds. If you’re not using this, again, you don’t want to burn money or free credits if you don’t need to. Have a good day. Bye.