testsuite/pangu_lib/README.md
Pangu (Chinese: 盤古, PAN-koo) is a primordial being and creation figure in Chinese mythology who separated heaven [testnet formation] and earth [infrastructure] and became geographic features such as mountains and rivers.
Pangu is a testnet creation and management CLI, which deploys on top of existing infrastructure.
Ever had to wait for the Aptos devnet/testnet releases to test a new feature? Or, create a PR to launch testnets through Forge? Well, these will be a thing of the past with Pangu.
Pangu is a modular, customizable, and next-gen Aptos testnet creation-management CLI tool written in Python. Pangu allows you to create, and manage testnets on demand, and blazingly fast 🚀🚀🚀
Pangu is inherently faster than its predecessors (Forge testnet creation) because:
Also, Pangu’s source code is significantly easier to read because it is written in strictly-typed Python 3.0, and in a modular manner.
Pangu is meant to be used by researchers/devs that want to create a testnet quickly. But, Pangu also aims to replace how testnets are created and deployed in Forge.
The Forge integrations are outside of the scope of the initial iteration built by @Olsen Budanur , but (🤞) Forge will eventually call the Pangu CLI to do testnet creation, and management.
Here is a brief overview of all the commands offered by the Pangu CLI. For more information about the options + arguments, use pangu [testnet/node] [command] -h.
pangu testnet create [OPTIONS] : Creates a testnet with the configurations given in the options in the connected cluster
pangu testnet delete [TESTNET_NAME] : Deletes testnet in the connected cluster
pangu testnet get: Displays all active testnets in the connected cluster
pangu testnet get [TESTNET_NAME]: Displays the nodes of a singular testnet in the connected cluster
pangu testnet healthcheck [TESTNET_NAME]: Healthcheck a singular testnet in the connected cluster (WIP)
pangu testnet restart [TESTNET_NAME]: Restart all nodes in a singular testnet in the connected cluster
pangu testnet update [TESTNET_NAME] [OPTIONS]: Update all nodes in a singular testnet in the connected cluster using the options
pangu testnet transaction-emitter [TESTNET_NAME] [OPTIONS]: Create a transaction emitter for a testnet by name.
pangu node stop [TESTNET_NAME] [NODE_NAME]: Stops a nodes in a singular testnet in the connected cluster
pangu node start [TESTNET_NAME] [NODE_NAME]: Starts a nodes in a singular testnet in the connected cluster
pangu node restart [TESTNET_NAME] [NODE_NAME]: Restarts a nodes in a singular testnet in the connected cluster
pangu node profile [TESTNET_NAME] [NODE_NAME]: Shows you node profiling tools created by @Yunus Ozer
pangu node wipe [TESTNET_NAME] [NODE_NAME]: Wipes a nodes in a singular testnet in the connected cluster (WIP)
pangu node add-pfn [TESTNET_NAME] [NODE_NAME] [OPTIONS]: Adds a pfn in a singular testnet in the connected cluster using the options (WIP)
pangu testnet create [OPTIONS] : Creates a testnet with the configurations given in the options in the connected cluster
CREATE OPTIONS:
-pangu-node-configs-path:
-pangu-node-configs-path /path/to/node/configs.yaml-layout-path:
-layout-path /path/to/layout.yaml-framework-path:
util.TEMPLATE_DIRECTORY/framework.mrb-framework-path /path/to/framework.mrb-num-of-validators:
10-num-of-validators 20-workspace:
-workspace /path/to/workspace-dry-run:
true if you would like to run genesis without deploying on Kubernetes (K8S). All Kubernetes YAML files will be dumped to the workspace. If you don’t provide a workspace, all the YAML files will be dumped to a tmp folder.False-dry-run true-aptos-cli-path:
aptos-aptos-cli-path /path/to/aptos-name:
-name MyTestnetblueprints:
nodebp: # Must to be all lowercase, and distinct
validator_config_path: "" # Should provide an absolute path. Can leave empty for the default
validator_image: "" # Can leave empty for the default
validator_storage_class_name: "" # Can leave empty for the default
vfn_config_path: "" # Should provide an absolute path. Use empty str if create_vfns: false. # Can leave empty for the default
vfn_image: "" # Can leave empty for the default
vfn_storage_class_name: "" # Can leave empty for the default
nodes_persistent_volume_claim_size: "" # Can leave empty for the default
create_vfns: true # CANNOT BE MODIFIED AFTER DEPLOYMENT
stake_amount: 100000000000000 # CANNOT BE MODIFIED AFTER DEPLOYMENT
count: -1 # CANNOT BE MODIFIED AFTER DEPLOYMENT... This is count of validators. In the template, the count doesn't matter as it gets overriden by either the default (10), user's --num-of-validators, or user's custom pangue node config.
# nodebpexample1:
# validator_config_path: ""
# validator_image: ""
# validator_storage_class_name: "" # Can leave empty for the default
# vfn_config_path: ""
# vfn_image: ""
# nodes_persistent_volume_claim_size: "" # Can leave empty for the default
# create_vfns: false #
# stake_amount: 100000000000000
# count: -1
# nodebpexample2:
# validator_config_path: ""
# validator_image: ""
# validator_storage_class_name: "" # Can leave empty for the default
# vfn_config_path: ""
# nodes_persistent_volume_claim_size: "" # Can leave empty for the default
# vfn_image: ""
# vfn_storage_class_name: "" # Can leave empty for the default
# create_vfns: false #
# stake_amount: 100000000000000
# count: -1
Pangu allows you to use a default template to create n number of nodes without much customization. However, if you want to create a testnet with varying node configurations and pod images, this is also possible through a custom pangu config.
To create a testnet with a custom topology, create a new pangu config file and pass it with the option "--pangu-node-configs-path"
1- Have aptos-core installed locally, and navigate to the testsuite directory.
2- The entrypoint for all python operations is [poetry](https://python-poetry.org/):
poetry install3- To set up the pangu alias
alias pangu="poetry run python pangu.py"
4- Have a K8s environment set up. For testing purposes, I suggest you use KinD. Here is a script that can be used to set up KinD.
5- Use “pangu -h”, “pangu node -h”, and “pangu testnet -h” commands to get more info about the Pangu commands
Pangu lives in aptos-core/testsuite. Tips for navigating the codebase:
@Olsen Budanur tested Pangu’s performance by creating testsnets of varying sizes in a standard GKE cluster. The table below shows how long it took Pangu to run genesis + apply all the k8s resources.
Unlike Forge, Pangu was ran from a different cluster than where the testnet is deployed. Thus, it was disadvantaged in that regard during testing.
| Run | 4 Vals | 7 Vals + 5 VFNs | 100 Vals + 100 VFNs | 100 Vals + 0 VFNs |
|---|---|---|---|---|
| 1 | 5 s | 9 s | 111 s | 65 s |
| 2 | 5 s | 12 s | 116 s | 65 s |
| 3 | 6 s | 10 s | 112 s | 65 s |
| 4 | 6 s | 10 s | 111 s | 66 s |
| 5 | 5 s | 10 s | 113 s | 63 s |
| 6 | 5 s | 10 s | x | x |
| 7 | 5 s | 10 s | x | x |
| 8 | 6 s | 13 s | x | x |
| 9 | 6 s | 12 s | x | x |
| 10 | 5 s | 12 s | x | x |
| ———————— | ———————— | ————————— | ———————————— | ————————— |
| AVG | 5.4 s | 10.8 s | 112.6 s | 64.8 s |
| Forge AVG | ~121 s | ~148 s | x | x |
| Diff | Pangu ~22x Faster | Pangu ~14x Faster | x | x |
| Savings | *see below | *see below | x | x |
The entrypoint for all python operations is poetry:
poetry installpoetry runpoetry run poeYou will have a few kubernetes clusters to manage. At least one in GCP, one on your dev machine via KinD, etc.