Skip to content

Add multi-testnet support (Asimov + Bradbury)#393

Open
rasca wants to merge 2 commits intodevfrom
bradbury
Open

Add multi-testnet support (Asimov + Bradbury)#393
rasca wants to merge 2 commits intodevfrom
bradbury

Conversation

@rasca
Copy link
Contributor

@rasca rasca commented Mar 8, 2026

Summary

  • Adds multi-network support to track validators across both Asimov and Bradbury testnets
  • Validators can run on one or both networks, earning 1 uptime point per network per day
  • Both networks share the same RPC URL but have different staking/factory contract addresses
  • All existing data is automatically tagged as 'asimov' via migration default

Backend Changes

  • Models: ValidatorWallet gets network field with composite unique constraint (address, network); new ValidatorWalletStatusSnapshot model for daily status recording
  • Settings: TESTNET_NETWORKS dict with per-network contract addresses, explorer URLs; backward-compatible fallback to old env var names
  • Service: GenLayerValidatorsService accepts network_key param; sync_all_networks() iterates configured networks; records daily status snapshots
  • Uptime: add_daily_uptime command uses lookback window (UPTIME_LOOKBACK_DAYS) to check ValidatorWalletStatusSnapshot for active status per network
  • API: ?network= filter param, network_stats in list response, /networks endpoint returning configured networks
  • Admin: Network column/filter on ValidatorWallet, registered ValidatorWalletStatusSnapshotAdmin
  • Commands: backfill_status_snapshots for initial deployment
  • Deploy scripts: Bradbury SSM parameters added to both prod and dev

Frontend Changes

  • Validators table: Network filter tabs (All/Asimov/Bradbury), network column with colored badges
  • Profile page: Network badges on wallet cards, dynamic explorer URLs from API
  • blockchain.js: NETWORKS dict supporting both networks, ensureNetwork() function
  • API client: getNetworks(), network param on wallet endpoints
  • UI text: "Testnet Asimov"/"Testnet Bradbury" updated to "Testnets" across all pages

Test plan

  • Run migration: python manage.py migrate — verify existing wallets get network='asimov'
  • Trigger sync: verify Asimov wallets sync (Bradbury skipped until env vars set)
  • Add Bradbury env vars, re-sync — verify Bradbury wallets appear with network='bradbury'
  • Run add_daily_uptime --verbose --dry-run — verify per-network point awards
  • Check GET /validators/wallets/ — verify network field and network_stats
  • Check GET /validators/wallets/?network=asimov — verify filtering
  • Check GET /validators/wallets/networks/ — verify available networks
  • Frontend: Validators table shows network column and filter tabs
  • Frontend: Profile page shows network badges on wallet cards
  • Admin: ValidatorWallet shows network column and filter
  • Run backfill_status_snapshots --days=7 after migration

rasca and others added 2 commits March 8, 2026 22:03
- Add network field to ValidatorWallet model with composite unique constraint
- Add ValidatorWalletStatusSnapshot model for daily status recording
- Add TESTNET_NETWORKS config in settings with per-network contract addresses
- Refactor GenLayerValidatorsService to accept network_key parameter
- Add sync_all_networks() class method for multi-network sync
- Update add_daily_uptime command with per-network lookback logic
- Add network and explorer_url to serializers
- Add ?network= filter, network_stats, and /networks endpoint to views
- Add network column and filter to ValidatorWallet admin
- Add backfill_status_snapshots management command
- Update deploy scripts with Bradbury SSM parameters
- Add network filter tabs and network column to Validators table
- Add network badges to Profile wallet cards
- Refactor blockchain.js with NETWORKS dict supporting both networks
- Update API client with network param support and getNetworks()
- Update UI text from "Testnet Asimov" to "Testnets" across all pages
- Update .env.example files with per-network configuration
…, N+1 query

- Fix duplicate uptime on deployment day: asimov check now matches legacy
  notes without network marker (old format had no "(asimov)" suffix)
- Fix dual $effect race condition in Validators.svelte causing two API
  calls on mount — merged into single effect tracking both dependencies
- Replace N+1 update_or_create loop in _record_status_snapshots with
  bulk_create(update_conflicts=True)
- Handle unknown network values in validator table badge display
- Prevent UPTIME_LOOKBACK_DAYS crash on empty string env var
- Add warning to backfill command about current-status limitation
- Use TESTNET_NETWORKS config in users/views.py instead of deprecated
  VALIDATOR_CONTRACT_ADDRESS setting
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants