Aleph Zero Blog
Technology

Aleph Zero Testnet Bots: Simulating Real-World Events

May 25, 2022

In a move that will allow us to fully utilize the Aleph Zero testnet’s experimental potential, we’ve introduced bots that will permit us to keep tabs on the network’s scalability and functionality before we enact changes on the mainnet. 

One of the challenges related to researching new features on the testnet involved the low volume of transactions performed. Over the past few months, we’ve been aware of this situation, as we’ve observed testnet users conduct the occasional transaction without exploring any of the other functionalities presented by the environment. As a result, primarily empty blocks have been produced. Once we’ve introduced staking, the testnet found more users with the caveat that most of the attention was focused on the staking mechanism, while other functionalities such as vesting were seldom used. 

Such a state of affairs resulted in a situation in which the development team behind Aleph Zero has no way of knowing whether certain particular features are functioning properly or if the scalability of the network has been properly tested. The approach we’ve taken to solve this challenge involves bots! Let’s dive into the ways in which we harnessed them to help improve the network. 

Bots as Data Harvesters 

Making smart, educated choices about the design of the Aleph Zero blockchain involves a lot of data, data that we gain through testing the various functionalities of the testnet. To simulate real-world traffic, we’ve decided to introduce bots or, as we prefer to think of them, “scenarios.” These artificial actors will perform various scripted assignments on the testnet, offering the development team the feedback they need to ensure the introduction of sensible changes to the testnet and, later, the mainnet. 

Each bot acts out a short pre-scripted plot. Some examples of what the team has experimented with so far are: 

  • Multi-signature gatherings, 
  • Canceling multi-signature aggregation
  • Sending funds from many accounts to a single one
  • Batched transfers
  • Merging vesting schedules 

These scripts are periodically launched as needed and check a single functionality during their duration. At first, we aim to research as many of the general functionalities as possible before moving to those that see less intensive use. To make this simulation as “lifelike” as imaginable, we aim to have a similar volume of transactions as found on the mainnet. Please note that this mechanism is not intended to serve as a method through which we perform load testing on the network. We will not be flooding the system with transactions for this purpose, although the larger amount of traffic generated on the blockchain will serve as a litmus test for the system’s reaction to a more considerable degree of traffic. 

The Code Behind the Bots  

To build these artificial users created to research the testnet, we used a generic code that can be applied to any Substrate-based chain. We did not introduce any AlephBFT-specific features to the source code. As of writing, the code used by the team is locked away in a private repository, effectively preventing anyone from outside the organization from having access to it. However, we are sure that we will make the code accessible to all very soon!  

The Technical Challenges of Simulated Scenarios 

Despite the promising results offered through simulating real-world traffic on the testnet, the system is not without its drawbacks. Among the two most significant challenges is the difficulty in imitating real-world traffic and reaching a similar volume of activity as found on the mainnet. Activities users enact in the real world are neither constant nor periodic; there are peaks and moments of silence.  Additionally, users sometimes behave in ways that diverge from the system’s intentions. In order to introduce more realistic imitations of actual human behavior, one of the ways we can do this is by implementing an AI framework, which at the moment is not something we are planning to introduce. Regardless of the current limitations of our system, we are quite pleased with the results and find them incredibly useful for furthering the testnet’s development.  

From a strictly technical perspective, the challenges experienced by the team revolve around the development of an auxiliary library to ensure the bots conveniently interact with the chain. Despite the existence of several public crates (Rust packages) that allow for communication with the network nodes, they are rather basic and don’t permit comfortable usage. To circumvent these limitations, we employed the substrate-api-client as the “first layer” and our in-house library as the “second layer” to ensure that the bot code is compact and practical. 

Improving the Testnet Bot by Bot

The system we’ve described for exploring the testnet’s functionality has so far proven effective, and we will continue exploring this avenue to expedite the changes brought to the testnet, which will, in turn, influence the Aleph Zero mainnet. No solution is perfect, and despite the challenges faced by the development team, we firmly believe in the potential bots carry to enact scenarios that, although not entirely true to life, are close enough to allow us to make intelligent design choices. Keep a lookout for the newest developments on the testnet! They are harbingers of things to come to the mainnet! 

Technical Expertise: Piotr Mikołajczyk

Piotr joined Aleph Zero as one of the blockchain developers in 2021. Previously, he gained experience working in Amazon, Qualtrics, Unit8, IBM, and Nokia. He completed his master’s degree in Theoretical Computer Science at the Jagiellonian University in Kraków. Besides work he is actively involved with the academic community, taking part in research projects on formal languages. In his free time, he enjoys hiking and painting miniatures.