The goal of this project is to operate a cardano testnet under constant congestion. To achieve this, an additional spammer component has been added. This component continuously generates transactions to simulate periods of congestion commonly observed on the mainnet.
This README guides you through setting up and running your own congested testnet locally. You'll be able to run a Genesis SPO node with a spammer to simulate network congestion.
To run the congested testnet, you'll need:
docker
anddocker-compose
installednodejs
(optional, for running the example)cardano-node
andcardano-cli
(can be run via Docker)
You can run your own congested testnet locally by running an spo node with Ogmios, Kupo, Faucet, and simulate congestion using the Spammer component. The congestion level can be regulated using the MEMPOOL_PAUSE_LIMIT
(max 1,000,000 bytes), which means the Spammer will run until the mempool reaches the target value.
Note: After starting the genesis SPO node, you'll need to wait approximately 10 seconds for all services to initialize properly before they become available. This includes time for the node to start, for Ogmios and Kupo to connect to the node, and for the spammer to begin generating transactions.
If the cardano-node on your machine outpaces the Spammer and you want to simulate higher congestion, you can reduce the block size, increase the slotLength, or both.
git clone https://github.com/mlabs-haskell/congested-testnet
cd congested-testnet
MEMPOOL_PAUSE_LIMIT=200000 \
SLOT_LENGTH=1 \
MAX_BLOCK_BODY_SIZE=65000 \
SPAMMER_ON=true \
FAUCET_ON=true \
SPO_ADDRESS=localhost \
docker-compose --profile genesis_spo up -d
This will start:
- A Genesis SPO node
- Ogmios on port
1337
- Kupo on port
1442
- Faucet on port
8000
- Config sharing service on port
5000
- Prometheus metrics on port
9090
To obtain tADA, you can submit a public key through an HTTP query to your local faucet. This will provide you with 1000 ADA.
# Generate key pairs with cardano-cli
cardano-cli address key-gen \
--verification-key-file "key.vkey" \
--signing-key-file "key.skey"
# Get the public key hash
PUBKEYHASHHEX=$(cardano-cli address key-hash --payment-verification-key-file "key.vkey")
# Request tADA from the faucet
curl -X POST "localhost:8000" -H "Content-Type: application/json" -d "{\"pubKeyHashHex\": \"$PUBKEYHASHHEX\"}"
To submit a transaction on your local testnet, you can use ogmios and kupo. The process is demonstrated in the js-example
, which shows:
- Withdrawing funds from the Faucet
- Submitting a tx through Ogmios
- Checking when the tx appears on chain with Kupo
To run the JS example (you may need to modify it to point to your local services):
cd examples/js-example
npm install
node .
You can use cardano-cli with HTTP requests as shown in the example, or use offchain libraries like purescript CTL or ogmios clients available in other languages.
Connect to your local services at:
localhost:1337
for Ogmioslocalhost:1442
for Kupo
You can verify that a transaction is on the ledger with kupo:
curl http://localhost:1442/matches/*@<transactionHash>
You can run bats tests using nix run .#tests
. Additionally, you can monitor your local Cardano testnet statistics with Prometheus at http://localhost:9090
. The await_time_tx
metric in Prometheus measures verification time for simple transactions.