Run a WAX Blockchain node using AWS CDK

14 views 1:15 pm 0 Comments March 27, 2024

WAX is a blockchain-based system designed for the unique demands of the gaming industry. It provides high transaction throughput and near-instant block finality. With WAX, game developers can decouple in-game digital assets from a single in-game world and let gamers use them in new contexts such as building walls of fame, creating personal online trophy shelves, bringing assets into other compatible games, or buy and sell on third-party ecommerce platforms and marketplaces. In this post, we dive deeper into the WAX platform and how to run your own WAX blockchain nodes on AWS using the AWS Cloud Development Kit (AWS CDK).

WAX blockchain nodes and tools on AWS

The blockchain component of WAX uses Delegated Proof of Stake (DPoS) as its consensus mechanism and is based on Antelope—an open framework for building Web3 products and services. With more centralized blocks creation process and the limited number of delegates, the DPoS consensus allows to process transactions and create new blocks faster than by just Proof Of Stake (PoS) algorithms used, for example, in Ethereum. Custom tools and incentive mechanisms of WAX blockchain are designed to improve the usability of blockchain technology in gaming, ecommerce, and digital collectibles trading. Specifically, they enable developers to build decentralized applications (dApps), digital asset marketplaces, and create fungible and non-fungible tokens (NFTs). These tools include the Cloud Wallet, single-sign-on (SSO) and OAuth, a native random number generation service, a developer portal, a cross-chain bridge, and a blockchain explorer. WAX has a strong developer community and support network to help builders deliver on their vision.

You need to use WAX blockchain API nodes (explained in the next section) to access WAX from your gaming or ecommerce applications running on AWS. You can use one of the existing node providers, who will run a WAX node for you, or deploy your own nodes if you need more control over your systems and minimize network latency. To do this, you can use the infrastructure as code WAX node deployment application built by the WAX team, which we describe in more detail in the next section. This application enables deployment of the Wax node on AWS, and removes the need to grapple with the complexities of setting up the entire infrastructure. With the cdk automating the deployment, technical teams can rely on the standardization, reducing the likelihood of errors associated with manual configurations.

WAX blockchain nodes on AWS

The deployment solution is built with the AWS CDK, a framework for defining cloud infrastructure in code and provisioning it through AWS CloudFormation. The AWS CDK accelerates cloud development using common programming languages to model your applications. You can deploy WAX blockchain nodes in two configurations: as an API node or as a Ship node. WAX API nodes run software components that expose RPC APIs for clients to send new transactions to the WAX blockchain, and to query, create, or change the state of your digital assets. A WAX Ship node provides detailed historical information for all transactions processed on WAX blockchain. It exposes WebSocket-based APIs for clients to query that data. Regardless of which node type you choose, the deployment architecture of the node deployment application for AWS looks the same (as shown in the following diagram).

Wax node on AWS Architecture Diagram

The deployed AWS CDK stack has the following features:

  • Only peer-to-peer connections are allowed with the Internet to synchronize with other WAX nodes
  • Multiple processes run on a single Amazon Elastic Compute Cloud (Amazon EC2) instance:
    • A Docker container with the WAX node in one of two possible configurations (API or Ship node)
    • A Telegraf agent to collect CPU, disk, I/O, and networking metrics for internal monitoring tools
    • Victoria Metrics, a time series database for storing the metrics from Telegraf and WAX nodes
    • A Grafana dashboard to display key system and blockchain metrics from CPU and disc usage to synced blocks and sync difference
  • By default, all API ports, including the one for the Grafana web user interface, are available only to IP addresses from within the same VPC.
  • The logs of the WAX node are published to Amazon CloudWatch.

The EC2 instance deployed by the AWS CDK stack is C5A 2xLarge with a 2 TiB Amazon Elastic Block Store (Amazon EBS) gp3 volume type provisioned with 5000 IOPS and running Ubuntu Linux 20.04. This configuration should be sufficient for the node to start and process the transactions, but might require tuning for the specific needs of your application. You can use the Grafana dashboard to monitor the health of your WAX node, change the EC2 instance size, or even switch to a different instance type. You can also adjust the IOPS and throughput parameters of the EBS gp3 volume, if you find in the Grafana dashboard that the disc usage statistics are continuously at their top levels.

WAX node synchronization methods

When a WAX node is first started, it needs to synchronize with the rest of the nodes on the WAX blockchain network before it can serve the correct data to dApps. When you deploy a WAX node on AWS, you can choose to use snapshots or full sync.

With snapshots regularly produced by WAX community, you can save multiple days compared to the full sync process. Synchronization from a snapshot takes less than 1 hour. During the process, the node downloads and extracts the latest node data from the snapshot, and then syncs the most recent blocks to catch up with all other active nodes. Although using snapshots is quick, it also assumes that you trust the source that produced the snapshot.

Alternatively, with full sync, the node downloads all the blocks in the WAX blockchain network and validates transactions one by one. With this process, the node verifies the integrity of all transactions, but syncing can take about a week. Generally speaking, games and most of the other dApps can rely on snapshot synchronization when deploying either the API or Ship node. The applications that need a cryptographically verified data source are usually block explorers and applications operated in regulated industries, such as the financial sector.

Conclusion

In this post, we discussed WAX, a purpose-built blockchain for the gaming industry. We introduced the API and Ship node types and discussed the deployment architecture of the solution developed by the WAX team with the AWS CDK to deploy nodes on AWS. We then discussed the details of a preconfigured infrastructure for operating a WAX node on the AWS platform and concluded with comparing snapshot and full sync options to initialize your node. For more information and support, check out the WAX community page.


About the Authors

Nikolay Vlasov is a Senior Solutions Architect with the AWS Worldwide Specialist Solutions Architect organization, focused on blockchain-related workloads. He helps customers to run workloads for decentralized web and ledger technologies on AWS.

Raj Seshadri is a Senior Partners Solutions Architect with AWS and and a valued member of the Technical Field Community for both containers and blockchain. With an insatiable appetite for exploring blockchain technology, Raj is particularly drawn to Ethereum, Web3, NFTs, generative AI and defi. Before joining AWS, Raj acquired significant industry experience with notable companies such as Aqua Security, Red Hat, Dell, and EMC. In his spare time, he plays tennis and enjoys traveling around the world. Follow him on Twitter @texanraj to stay up-to-date on his latest thoughts and insights.

Deepansha Tiwari is a Solutions Architect at AWS based in Northern Virginia. As part of AWS for Games, she collaborates with game companies and offers expertise in architecting solutions and navigating them through their cloud journey. With a background in software design and development, she guides customers in implementing best practices in architecture and design on AWS.