Documentation Index
Fetch the complete documentation index at: https://cowswap-mintlify-audit-seo-quality-1775466652.mintlify.app/llms.txt
Use this file to discover all available pages before exploring further.
Storage Architecture
The Watch Tower uses a key-value database to maintain state about programmatic orders and block processing progress.Why LevelDB?
The chosen architecture is LevelDB, a NoSQL key-value store, for several reasons:ACID guarantees
LevelDB provides ACID guarantees, ensuring:- Atomicity - All operations complete or none do
- Consistency - Database remains in a valid state
- Isolation - Concurrent operations don’t interfere
- Durability - Committed writes survive crashes
Simple interface
LevelDB offers a straightforward key-value API that maps well to the watch-tower’s storage needs:- Store programmatic orders by owner
- Track last processed block
- Manage notification state
Batch writes
All database writes are performed atomically using batch operations. The watch-tower groups multiple updates into a single transaction:Error handling and recovery
The watch-tower implements a robust error handling strategy:Write failures
If a batch write fails:- The watch-tower throws an error and exits
- The database remains in its previous consistent state
- No partial updates are committed
Recovery on restart
When the watch-tower restarts:- It reads
LAST_PROCESSED_BLOCKfrom the database - It resumes processing from that block number
- Events may be reprocessed, but the system becomes eventually consistent
Database location
By default, the database is stored at:--database-path CLI option:
Implementation
The storage is implemented as a singleton service (DBService) with these key features:
- Value encoding: JSON serialization for all values
- Create if missing: Database directory is created automatically
- Error handling: Descriptive errors for open/close failures