How to Setup and Deploy a Public Tezos Node with AWS Cloud Services?
Tezos is an open-source blockchain platform for dApps and assets. Supported by a global community of researchers, validators and builders, the Tezos blockchain platform addresses some significant barriers to blockchain adoption, including open participation, smart contract safety and long term upgradability. The platform has a modular architecture and an upgrade mechanism, making it possible for the network to implement new technological innovations. Hence, one can also set up a Tezos node with cloud services like AWS.
In this article, we will go through the steps of how one can set up and deploy a public Tezos node with AWS Cloud Services:
- Step 1: Set Up AWS
- Step 2: Create a Virtual Private Cloud (VPC)
- Step 3: Create a Key Pair
- Step 4: Create a GitHub Access Token
- Step 5: Deploy a Tezos Updater
- Step 6: Deploy your Tezos Nodes
- Step 7: Confirm Tezos Nodes
Running a Tezos node in the cloud is an option you may consider if you want to run a node that:
- is resilient against outages
- you don’t have to manage
- can scale to accept numerous requests
Here, we will deploy a public testnet node. Let’s get started.
Step 1: Set Up AWS
Before beginning with the actual process to deploy Tezos node, you must set up your AWS account. You can do so by following these steps:
-
- Open the Amazon Web Services home page and select the option “Create an AWS Account.”
- Enter all information correctly, then select “Continue.”
- Now select the type of account you want to make, i.e., “Personal” or “Professional.” There is no difference in the features and functions of these accounts.
- Put in your company’s name or your personal information in the appropriate fields.
- Read and accept the AWS Customer Agreement and then select “Create Account and Continue.”
- You’ll receive a confirmation email. Open it and then sign in with your credentials.
- Go to the “Payment Method” page, enter your payment method information and select “Verify and Add.”
- Verify your phone number, select an AWS Support Plan and then wait for account activation. Account activation may take up to 24 hours to complete.Allocating resources on AWS and configuring options can be challenging to manage and tedious sometimes, as you may have to start everything from scratch if something goes wrong. Cloud Formation is a solution to this problem, as it enables you to specify all required resources and settings to complete a task in one configuration file. All stacks are the same and can be rolled back and redeployed in case of any problems.
You’ll also have to fork some necessary repositories and select the suitable network and docker image to deploy.
Tezos releases doctor images for Mainnet, Testnet and Zeronet networks and maintains both individual release versions and always-up-to-date versions. You can find them here. Pick and update your docker image accordingly.
Tezos also provides three repositories with pre-written boilerplate code:
– node-docker
– tezos-updater
– node-cloudformationYou can fork and customize them before beginning.
Step 2: Create a Virtual Private Cloud (VPC)
Deploying the VPC CloudFormation script is the next step to deploy Tezos node on AWS. VPC refers to Virtual Private Cloud, which is a virtual network where you’ll deploy your AWS resources.
Firstly, you need to create your stack.
- Go to the AWS console, log in and then navigate to “Services.”
- Then, under “CloudFormation,” select “Create Stack” and press “with new resources.”
Now, take the following steps for CloudFormation:
- Specify Template:
Go to the “Upload a template file” in the “Specify Template” section, and select “publicvpc.cloudformation.yaml” file. Press “next.”
- Specify Stack Details:
Specify the name of the stack, then press “next.”
- Configure Stack Options:
Go through the details and press “next.”
- Review:
Click on the acknowledgment checkbox and press “Create Stack.”
Resources are allocated and everything else is set up by the CloudFormation script itself. You can monitor the progress by going to “Stacks List” under “CloudFormation” in services and clicking on your VPC CloudFormation stack.
Step 3: Create a Key Pair
- Go to “EC2” under “Services.”
- From the sidebar, select “Key Pairs” from under the “Network & Security” heading.
- Press “Create Key Pair.”
- Name your key pair.
- Set the option to pem.
- Press “Create Key Pair.”
The page will navigate to a success message and the poem file download will begin. Now, move the pem file to your .ssh directory (on macOS).
$ mv ~/Downloads/new-keypair.pem ~/.ssh/ $ chmod 600 ~/.ssh/new-keypair.pem
You will use it for the authentication of SSH into your EC2s.
Step 4: Create a GitHub Access Token
Next, you need to create a GitHub Access Token to permit AWS for accessing the required repositories in order to deploy Tezos node with AWS Cloud Services.
- Go to https://github.com/settings/tokens.
- From the sidebar, select “Personal Access Token.”
- Press “Generate New Token.”
- Give a note describing its use and permissions properly.
- Tick the “repo” option.
- Click “Generate New Token.”
You have generated the access token. However, it will not be visible once you close the window. So, keep the window open or copy it so that you can use it later while deploying the CloudFormation files. You can also generate new tokens in case you lose access to it.
You have all the required credentials to move forward now.
Step 5: Deploy a Tezos Updater
For the next step to deploy Tezos node, you need to deploy a Tezos updater.
The Tezos Updater has the following two purposes:
- It downloads historic chain data from the network
- It ensures that your node data is up to date.
This step is only needed to:
- run your own node updater to control the versioning.
- deploy a node in an AWS region with no public updater available.
It is recommended to run your own updater as:
- a public updater’s new version might be incompatible with your node.
- you may want to control the chain data you see.
Providing liquidity to a Bancor pool is permissionless, i.e., no centralized authority can control the process. Liquidity providers receive pool tokens that are proportional to their share of assets in the pool.
You can skip to the next step if you don’t want to run your own updater.
Deploy the tezos-updater CloudFormation
- Go to “CloudFormation” under services, in the same area as your VPCs.
- Press “Create Stack,” and select the “With New Resources” option.
Now, take the following steps:
- Specify Template:Go to the “Specify Template” section, choose “Upload a template file,” and then select the tezos-updater.yaml file. Then click “next.”
- Specify Stack Details:
- Go to the “Stack Name” is the name you give to your tezos updater deployment CloudFormation stack.
- Under the “Parameters” section, “GitHub Configuration” will require several updates:
- The “Tezos Updater GitHub Repository” field will remain unchanged if you haven’t changed the name of the repository name for the tezos-updater fork.
- The “Branch in GitHub Repository” field will default to “testnet,” so update this field if you deploy mainnet or testnet.
- The “User” field will change to the GitHub user that forked the repository.
- In the “Personal Access Token” field, enter what you generated and copied from GitHub in Step 4.
- Under the “Parameters” section, “VPC Configuration”and “ECS Configuration”parameters will also require several updates:
- Click on the first dropdown and find the VPCs you created.
- While choosing the subnets you want to deploy to, select the subnets associated with your VPCs. Choose all three.
- To the keypair option, add the keypair you created earlier.
- For now, leave the rest of the options unchanged. We will change the number of updater tasks later.
- Under the “Parameters” section, the “Tezos Configuration” section will remain unchanged. Click “Next.”
- Configure Stack Options:Go through the details and press “next.”
- Review:Click on the acknowledgment checkbox and press “Create Stack.”
Resources are allocated and everything else is set up by the CloudFormation script itself. You can monitor the progress by going to “Stacks List” under “CloudFormation” in services and clicking on your updater CloudFormation stack. Before moving on to the next step, please ensure that you wait for the stack to finish creating.
Set Up s3 Chainbucket Requester Pays
The updater CloudFormation will create some s3 buckets, which you can locate by going to “S3” under “Services.” It will look like [stack-name]-chainbucket-[random-id] and this will store all the block data.
Public nodes will access this data. Hence, you should change the “Requester Pays” property so that instead of charging you, Amazon charges the person requesting to download the data.
- Click on the bucket name. The page will redirect to the bucket’s overview.
- Click the “Properties” tab.
- Find the “Requester Pays” section. Click on it.
- Select “Enabled” and save it.
Download Chain Data
You will need chain data to update your node. To download chain data, you have two options:
- You may update the updater’s configuration to download all the data itself.
- If you have access to another updater running the same protocol and version as you, you may transfer the data.
Here is how you can transfer data from another updater:
1. Find a Data Source
First of all, find a public chainbucket from which you’ll transfer your data. You can find one from the tezos-node cloudformation file, under the RegionMap section.
As we’re deploying a testnet node, we can only copy data from the testnet bucket in eu-west1. The bucket name you’ll need is:
alphanet-updater-chainbucket-1v6go885nadpa
2.Find the Public DNS for Our EC2
Next, you should find the Public DNS for your EC2. To do so:
- Go to the AWS console.
- Navigate to “Services” and go to “Instances” under “EC2”. Find your tezos updater instance here.
- There will be a “Description” tab at the bottom of the page. In the list of EC2 properties, locate the “Public DNS.” Copy it.
3. SSH Into EC2
Now you’ll SSH into your EC2. Also, from the inside, copy data from the public chainbucket you found in the RegionMap to your new chainbucket. Use the pem file you downloaded in step 3 to ssh into your new tezos-updater container.
In a terminal, use the public DNS for your EC2 and your pem file like this:
ssh -i ~/.ssh/[your pem file name].pem ec2-user@[your public DNS]
You will be asked if you want to add a new known host. Type “yes” and hit enter.
4. Initiate the Data Copy
You’ll have to define two variables:
- sourcebucket
- targetbucket
sourcebucket is the s3 bucket from which you’ll copy chain data. targetbucket is the s3 chainbucket you created with your CloudFormation script. Now, to initiate data copy, use the following commands in the EC2 terminal:
[ec2-user@ip-10-190-10-222 ~]$ export sourcebucket=alphanet-updater-chainbucket-1v6go885nadpa [ec2-user@ip-10-190-10-222 ~]$ export targetbucket=testnet-updater-chainbucket-167t5ylzl69jf [ec2-user@ip-10-190-10-222 ~]$ aws s3 sync --delete --request-payer requester s3://$sourcebucket s3://$targetbucket
The data will start to sync.
Update ECS Tasks
After the data has been copied and you’ve confirmed that the CloudFormation stack has finished creating, you should turn on an ECS task to keep the data updated.
- Go to the AWS console.
- Navigate to Services.
- Go to “CloudFormation” and find the stack for your updater under “Stacks.”
- Press “Update.”
- Check the “Use current template” checkbox and click “next.”
- In the “ECS Configuration” field, update the number of updater tasks from 0 to 1 and click “Next.”
- Keep clicking “Next” through the screens that follow.
You’ll be taken to the CloudFormation stack screen for your updater once you’re done. It will show “UPDATE_IN_PROGRESS.”
Now, your chainbucket will be updated regularly with new blockchain data.
As you’ve got an updater task making sure your data is up to date, you can now deploy your nodes to access that data.
Step 6: Deploy your Tezos Nodes
To deploy Tezos node, you need to deploy the frontnode-standalone CloudFormation.
In your local filesystem, find the frontnode-standalone.yaml CloudFormation script.
If you deployed a tezos-updater, you should add your new chaindata s3 bucket as a resource in the RegionMap. Find your region, add a name and the bucket name to the map and save the file. Then, create a stack:
- Go to “Services.”
- Under “CloudFormation,” select “Create Stack.”
- Choose the “With New Resources” option.
Let’s move ahead.
- Specify Template:
Use the frontnode-standalone.yaml file.
- Specify Stack Details:
- “Stack Name” is the name you give to your stack.
- Under the “Parameters” section, “GitHub Configuration” will require several updates:
- The “Tezos Updater GitHub Repository” field will remain unchanged if you haven’t changed the name of the repository name for the tezos-updater fork.
- The “Branch in GitHub Repository” field will default to “testnet,” so update this field if you deploy mainnet or testnet.
- The “User” field will change to the GitHub user that forked the repository.
- In the “Personal Access Token” field, enter what you generated and copied from GitHub in Step 4.
- Under the “Parameters” section, “VPC Configuration”and “ECS Configuration”parameters will also require several updates:
- Click on the first dropdown and find the VPCs you created.
- While choosing the subnets you want to deploy to, select the subnets associated with your VPCs. Choose all three.
- To the keypair option, add the keypair you created earlier.
- Change the number of ECS hosts from 5 to 2. This is the number of nodes that you’ll deploy.
- Leave the rest of the options unchanged for now. We will change the number of ECS tasks later.
- Under the “Parameters” section, the “Tezos Configuration” section will remain unchanged. Click “Next.”
- Ensure that the tezos network you connect with matches the tezos-updater you use in your region.
- The other fields can be left as they are for now.
- Configure Stack Options:
Go through the details and press “next.”
- Review:
Click on the acknowledgment checkbox and press “Create Stack.
Resources are allocated and everything else is set up by the CloudFormation script itself. You can monitor the progress by going to “Stacks List” under “CloudFormation” in “Services” and clicking on your node CloudFormation stack.
Update ECS Tasks
After the successful creation of the stack, you can update it to create an ECS task. Launching a task before the CodePipeline/CodeBuild will build your first artifact. The task creation will fail and cause the entire stack to fail and roll back. By deploying with 0 and then waiting for a few minutes until CodePipeline builds the first artifact, you can update the number of tasks to be more than 0 and launch the tasks successfully.
- Go to Services > CloudFormation > Stacks.
- Select the nodes stack.
- Press “Update.”
- Select “Use current template.”
- Click “Next”
- Update the number of ECS tasks from 0 to 1.
- Click “Next.”
- Save the new stack.
Now, you should have your nodes running and accessing data stored in your s3 buckets. Let’s confirm.
Step 7: Confirm the Nodes
The last step after you deploy Tezos node, you need to ensure that the nodes are up and syncing correctly. You need to get the Node Load Balancer’s or NLB’s address through which your EC2 containers are connected.
- Go to the AWS console.
- Navigate to “Services.”
- Go to “EC2”, you’ll find“Load Balancers” there.
- Click on the node load balancer for details.
- Find and copy the DNS name.
In a terminal window, you can use the following to see if your nodes are up and the timestamp on their latest block or not:
curl http://:8732/monitor/bootstrapped
For example:
$ curl http://testnet-nodes-NLB-876d45cbc59efb92.elb.us-west-2.amazonaws.com:8732/monitor/bootstrapped {"block":"BL3ZwKGAp8o986wQ5LkvThTcEtEyj84LeVfoNGGVqJnteyMjoyH","timestamp":"2020-01-24T21:55:50Z"}
This shows that the node is updated and responding.
Conclusion
Tezos is working towards dealing with some of the significant barriers of blockchain adoption while making it convenient for its users to work with the platform. By following the steps explained above, one can deploy a public Tezos node with AWS Cloud Services. However, a certain technical expertise level is still required to ensure seamless proceedings while deploying the node.
If you want to get a public Tezos node deployed with AWS Cloud Services, connect with our Tezos blockchain experts.
Start a conversation by filling the form
All information will be kept confidential.
Insights
How to create tokens on Tezos Platform?
Learn how to create tokens or digital assets on Tezos platform from our team of Tezos blockchain development experts.
How to Build a Tezos dApp?
Tezos is an open-source dApp and smart contracts platform. It is a self amending cryptographic ledger which uses the Delegated Proof of Stake (DPoS) consensus protocol.
How to Create, Test and Deploy Tezos Smart Contracts?
Tezos blockchain platform is a decentralized, self-amending crypto-ledger.It can be used to deploy smart contracts and execute P2P transactions.