Post
Share your knowledge.
What’s the best way to handle Testnet data wipes in production pipelines?
My CI/CD pipeline relies on Testnet, but data wipes keep breaking it. How can I automate recovery or mitigate these disruptions
- Sui
- Transaction Processing
- Move
Answers
7Handling Testnet data wipes in a production pipeline, especially in the context of CI/CD for Sui or any blockchain, requires strategies that automate recovery and mitigate disruptions caused by frequent resets or wipes. Testnets are often reset or wiped to reflect network upgrades or to provide a fresh state for testing. Here’s how you can deal with these disruptions effectively:
1. Automate Recovery Using Snapshotting
-
Snapshots are a great way to store a known good state of the network that you can quickly restore after a data wipe.
-
Automated Recovery Script: Create a recovery script that:
- Automatically fetches the latest Testnet snapshot (if provided by the Testnet team).
- Restores the snapshot to your local Testnet node or setup.
- Re-initializes any necessary data (such as validators, stake information, or stateful resources) for your pipeline’s needs.
Steps:
- Set up periodic snapshot backups of your local environment.
- Use tools like Docker, Kubernetes, or Terraform to automate deployment and state management.
- Store snapshots in a cloud storage service or a dedicated backup server that is easily accessible and recoverable.
# Example of a simple snapshot recovery script
# Assuming you're using Docker or another containerized environment
docker-compose down
docker-compose pull
docker-compose up --build
2. Set Up Auto-Recovery for Critical Dependencies
-
Critical dependencies in your CI/CD pipeline (e.g., test databases, nodes, or blockchain states) should have auto-recovery mechanisms.
-
Use health checks and watchdogs to monitor if your Testnet node has wiped or restarted.
-
On failure (due to wipe or reset), your pipeline should trigger a script that:
- Re-deploys the necessary dependencies.
- Resets state (for blockchain, wallet, and contract deployment).
Example: If using Docker and Kubernetes, configure the healthCheck endpoint for automatic detection and recovery.
# In a Kubernetes deployment YAML example
readinessProbe:
httpGet:
path: /health
port: 8080
initialDelaySeconds: 5
periodSeconds: 10
3. Leverage Clean Start Automation
-
Testnet State Reset: If your pipeline depends on stateful data (e.g., accounts, assets, tokens), automate restarting from scratch by recreating the required test state after a wipe.
-
Automate the state initialization process as part of the pipeline:
- Fund wallets (e.g., via faucet) on each pipeline run.
- Deploy smart contracts and set up necessary resources like tokens, NFTs, etc.
- Run initial setup tasks for your tests.
Steps:
- Create a pre-test automation step that checks if a wallet has sufficient funds and resets it if necessary.
- Programmatically recreate tokens, assets, or any stateful contract interactions from scratch.
# Example script to fund a wallet
curl -X POST https://testnet.faucet.sui.io/fund -d '{"address": "<wallet-address>"}'
4. Testnet Faucet Integration for Automatic Wallet Funding
- Integrate a faucet that can automatically fund your wallets on Testnet after each wipe.
- Programmatically call the faucet service as part of the CI/CD pipeline before each test to ensure the wallets are funded with Testnet tokens.
Example:
# Automatically claim tokens from Testnet faucet for each wallet
curl -X POST "https://faucet.sui.io/fund" -d '{"address": "<wallet-address>"}'
Automate this step within your test setup to ensure your pipeline runs smoothly, even after a wipe.
5. Stable Testnet Providers or Forking
- If data wipes are too frequent or disruptive on your Testnet provider, consider forking the Testnet to a local network that you can control and reset only when needed.
- You can create your own local fork of the Testnet with the data you need, which is not affected by external wipes.
Steps:
- Use Sui’s local node setup or another blockchain emulator like Ganache for Ethereum-based tests to run a local instance.
- Take periodic snapshots of the forked network to restore it quickly in case of a wipe.
- This approach might require a bit more setup but can give you full control over your test environment.
6. Configure Data Persistence in Pipeline
- Make sure that persistent data (such as wallet addresses, contract states, or NFTs) that are vital for your tests are backed up or stored externally.
- Store important test data in external databases, cloud storage, or persistent volumes if you’re using containerized environments.
Example:
- Store Testnet configurations, wallet addresses, and asset information in JSON files or a database, so you can restore the state easily after wipes.
7. Use Multiple Testnets or Networks
- Set up multiple Testnet environments or use different test networks. This helps to avoid dependency on one network and reduces the risk of repeated disruptions affecting your pipeline.
- Split tests across different Testnet chains or even use local emulators to run parallel tests in isolated environments.
8. Monitoring and Alerts
- Use monitoring and alerting tools (e.g., Prometheus, Grafana, Sentry) to detect issues early in the pipeline. This could be useful for detecting when a data wipe occurs and triggers recovery processes immediately.
- Set up alerts for key events like Testnet node resets or missing epochs.
Conclusion:
To handle Testnet data wipes in a production pipeline:
- Automate the recovery process through snapshotting, reinitializing state, and using health checks.
- Ensure wallet funding and state restoration are automated.
- Leverage local forks or Testnet providers with more stability for a more controlled environment.
- Use persistent storage for critical data and configure your pipeline to be resilient to external wipes or disruptions.
These strategies will help ensure your pipeline remains stable even in the face of frequent data resets on Testnets.
Testnet data wipes are expected and unavoidable. To mitigate disruptions in CI/CD pipelines, do not rely on persistent Testnet state. Instead, design your pipeline to redeploy all necessary contracts and reinitialize test data from scratch on each run. Automate setup using scripts that publish packages, create test objects, and configure accounts via the Sui CLI or SDK. Use deterministic addresses where possible and store configuration (e.g., package IDs) in environment variables. Treat Testnet as ephemeral—always assume a clean state. For stable environments, consider using Sui localnet for testing when possible.
Treat Testnet as ephemeral: don't rely on persistent data. Use scripts to redeploy and reseed test data on every run. Automate setup with deterministic addresses (e.g., mnemonic-based) and cache deployment outputs. Isolate test dependencies and run integration tests after fresh deployment—never assume state.
-
Use scripts to automatically re-deploy smart contracts after each data wipe.
-
Store deployment addresses and relevant state in a config file or database.
-
Detect Testnet wipes by checking for known object IDs or version hashes.
-
Automate funding of accounts with test SUI using faucet APIs.
-
Set up monitoring to catch broken links to on-chain objects.
-
Separate deployment logic from business logic in your CI/CD pipeline.
-
Consider using Localnet for tests that don’t need live network conditions.
-
Use mocks or snapshots for data dependencies when possible.
-
Cache common artifacts and only rebuild if necessary.
-
Subscribe to Testnet update notifications or RSS feeds to anticipate changes.
To handle Testnet data wipes in your production or CI/CD pipelines effectively, you should build resilience into your deployment scripts by automating object re-creation, maintaining deployment state off-chain, and using versioned packages or mocks. Testnet resets are expected behavior on Sui—they wipe all on-chain data, including published packages, shared objects, and coin balances—so your pipeline must treat it as a recoverable state rather than a terminal error.
Start by automating module publishing and object initialization as part of your CI step. Store essential deployment metadata (e.g., package IDs, object IDs, gas coins) in an off-chain state file like .env, JSON, or a key-value store. If these IDs are no longer valid due to a wipe, your script should detect this—e.g., by trying to fetch the object or checking module existence—and fall back to running a full deployment flow.
Here’s a recommended flow:
- Use the Sui CLI or TypeScript SDK to check if the package is published by calling
getNormalizedMoveModule. - If not found, re-publish your package using
sui client publishorpublishPackagein SDK. - Recreate any shared objects, initialize state, and mint coins as needed.
- Store the new object/package IDs locally for downstream steps.
Example in TypeScript SDK:
try {
await client.getNormalizedMoveModule({ package: packageId, module: 'MyModule' });
} catch (e) {
const result = await publishMyPackage(txBlock, signer);
savePackageId(result.packageId);
}
You should also maintain Testnet faucet integration to request fresh SUI on every reset and validate that your wallet has a sufficient balance before each run.
To reduce downtime, consider spinning up a localnet or staging devnet that mirrors Testnet logic without the resets. This allows you to decouple critical tests from network volatility.
For recovery automation and latest Testnet state, monitor the reset announcements or status here: https://docs.sui.io/network/testnet
Do you know the answer?
Please log in and share it.
Sui is a Layer 1 protocol blockchain designed as the first internet-scale programmable blockchain platform.
- How to Maximize Profit Holding SUI: Sui Staking vs Liquid Staking616
- Why does BCS require exact field order for deserialization when Move structs have named fields?65
- Multiple Source Verification Errors" in Sui Move Module Publications - Automated Error Resolution55
- Sui Move Error - Unable to process transaction No valid gas coins found for the transaction419
- Sui Transaction Failing: Objects Reserved for Another Transaction410