|
42 | 42 |
|
43 | 43 | # When we are interested in knowing when a transaction reaches finality, we subscribe to the Finality Listener Manager for the finality event of that transaction. |
44 | 44 | # This configuration specifies the way the manager is instantiated (i.e., how it gets notified about the finality events, how often it checks). |
45 | | - finality: |
| 45 | + finality: |
46 | 46 | # Only applicable for fabric networks. |
47 | 47 | # The manager subscribes to the delivery service and receives all final transactions. |
48 | 48 | # This manager keeps two structures: an LRU cache of recently finalized transactions, and a list of listeners that are waiting for future transactions. |
@@ -209,6 +209,56 @@ token: |
209 | 209 | # on every sweep until it either resolves or an operator intervenes. |
210 | 210 | notFoundGracePeriod: 30m |
211 | 211 |
|
| 212 | + # storage service configuration |
| 213 | + storage: |
| 214 | + # cleanup config controls automatic deletion of cryptographic keys from the keystore |
| 215 | + # for tokens that have been deleted (spent, expired, or invalidated). |
| 216 | + # If omitted, the cleanup manager uses its built-in defaults (disabled by default). |
| 217 | + cleanup: |
| 218 | + # enabled determines whether keystore cleanup runs. Default: false. |
| 219 | + # Must be explicitly enabled. This is a conservative default to prevent |
| 220 | + # unexpected key deletion in existing deployments. |
| 221 | + enabled: false |
| 222 | + |
| 223 | + # ttl is the minimum age of deleted tokens before their keys are eligible for cleanup. Default: 24h. |
| 224 | + # This ensures tokens are truly finalized before key deletion. |
| 225 | + # Increase this value for additional safety margin in high-latency networks. |
| 226 | + # Relationship: Should be significantly greater than transaction finality time. |
| 227 | + ttl: 24h |
| 228 | + |
| 229 | + # scanInterval is how often the cleanup manager scans for deleted tokens. Default: 1h. |
| 230 | + # Lower values provide faster cleanup but increase database load. |
| 231 | + # Higher values reduce overhead but delay key removal. |
| 232 | + # Relationship: Should be less than ttl to ensure timely cleanup. |
| 233 | + # Performance impact: Each scan queries the token database for deleted tokens. |
| 234 | + scanInterval: 1h |
| 235 | + |
| 236 | + # batchSize is the maximum number of deleted tokens processed per scan. Default: 100. |
| 237 | + # Limits the number of tokens processed in a single cleanup sweep. |
| 238 | + # Increase for high-volume environments with many deleted tokens. |
| 239 | + # Performance impact: Larger batches reduce scan overhead but increase memory usage and processing time per sweep. |
| 240 | + batchSize: 100 |
| 241 | + |
| 242 | + # workerCount is the number of local workers that process tokens in parallel. Default: 1. |
| 243 | + # Increase to improve cleanup throughput in high-volume scenarios. |
| 244 | + # Decrease to reduce resource consumption on constrained systems. |
| 245 | + # Performance impact: More workers increase CPU utilization during cleanup sweeps. |
| 246 | + workerCount: 1 |
| 247 | + |
| 248 | + # advisoryLockID is the PostgreSQL advisory lock identifier used for cleanup leader election. |
| 249 | + # This ensures only one replica performs cleanup sweeps at a time in multi-instance deployments. |
| 250 | + # Default: 8389190333894887277 (hex: 0x74746b636c65616e, ASCII: "ttkclean") |
| 251 | + # The default value is derived from the ASCII encoding of "ttkclean" (Token Transaction Keystore Cleanup). |
| 252 | + # Only change this if you need to run multiple independent cleanup managers on the same database. |
| 253 | + # Note: PostgreSQL advisory locks use 64-bit integers. This value must be unique across your application. |
| 254 | + advisoryLockID: 8389190333894887277 |
| 255 | + |
| 256 | + # instanceID identifies this replica in logs and monitoring. |
| 257 | + # If empty, a unique identifier is generated automatically at startup. |
| 258 | + # Set this explicitly in containerized environments for consistent identity across restarts. |
| 259 | + # This helps with debugging and tracking which instance performed cleanup operations. |
| 260 | + instanceID: |
| 261 | + |
212 | 262 | # auditor-specific settings |
213 | 263 | auditor: |
214 | 264 | # locker configures the distributed locking strategy for the auditor's |
@@ -445,6 +495,79 @@ Default values: |
445 | 495 | - Increase `workerCount` to 8-16 to improve parallel processing |
446 | 496 | - Decrease `scanInterval` to 2-3s for faster recovery detection |
447 | 497 |
|
| 498 | + |
| 499 | +### Optional: token.tms.<name>.services.storage.cleanup |
| 500 | + |
| 501 | +If not specified, the default configuration is: |
| 502 | + |
| 503 | +```yaml |
| 504 | +token: |
| 505 | + tms: |
| 506 | + <name>: |
| 507 | + services: |
| 508 | + storage: |
| 509 | + cleanup: |
| 510 | + enabled: false |
| 511 | + ttl: 24h |
| 512 | + scanInterval: 1h |
| 513 | + batchSize: 100 |
| 514 | + workerCount: 1 |
| 515 | + advisoryLockID: 8389190333894887277 |
| 516 | + instanceID: |
| 517 | +``` |
| 518 | + |
| 519 | +Default values: |
| 520 | + |
| 521 | +- enabled: false |
| 522 | +- ttl: 24h |
| 523 | +- scanInterval: 1h |
| 524 | +- batchSize: 100 |
| 525 | +- workerCount: 1 |
| 526 | +- advisoryLockID: 8389190333894887277 (`0x74746b636c65616e`) |
| 527 | +- instanceID: empty, auto-generated when the cleanup manager starts |
| 528 | + |
| 529 | +**Parameter Relationships and Tuning:** |
| 530 | + |
| 531 | +- **Cleanup is disabled by default** and must be explicitly enabled. This is a conservative default to prevent unexpected key deletion in existing deployments. |
| 532 | +- **Only deleted tokens older than `ttl` are considered for cleanup** to ensure tokens are truly finalized before key deletion. |
| 533 | +- **The manager validates** that `ttl`, `scanInterval`, `batchSize`, and `workerCount` are all greater than zero. |
| 534 | +- **`advisoryLockID`** is used to acquire PostgreSQL advisory-lock leadership so that only one replica performs a cleanup sweep at a time. The default value (8389190333894887277 or 0x74746b636c65616e) represents the ASCII string "ttkclean" (Token Transaction Keystore Cleanup) encoded as a 64-bit integer. |
| 535 | +- **`instanceID`** is used to identify this replica in logs and monitoring; if omitted, the manager generates a unique identifier automatically at startup. |
| 536 | + |
| 537 | +**Tuning Recommendations:** |
| 538 | + |
| 539 | +1. **For High-Volume Environments:** |
| 540 | + - Increase `batchSize` to 200-500 to process more tokens per sweep |
| 541 | + - Increase `workerCount` to 8-16 to improve parallel key deletion |
| 542 | + - Decrease `scanInterval` to 30m for more frequent cleanup |
| 543 | + |
| 544 | +2. **For Resource-Constrained Systems:** |
| 545 | + - Decrease `workerCount` to 2 to reduce CPU usage |
| 546 | + - Increase `scanInterval` to 2-4h to reduce database load |
| 547 | + - Keep default `batchSize` to limit memory usage |
| 548 | + |
| 549 | +3. **For Security-Sensitive Deployments:** |
| 550 | + - Decrease `ttl` to 12h for faster key removal |
| 551 | + - Decrease `scanInterval` to 30m for more frequent cleanup |
| 552 | + - Monitor cleanup metrics to ensure timely processing |
| 553 | + |
| 554 | +4. **For Multi-Instance Deployments:** |
| 555 | + - **PostgreSQL Required**: Multi-instance deployments require PostgreSQL for distributed coordination via advisory locks |
| 556 | + - Keep default `advisoryLockID` unless running multiple independent cleanup systems |
| 557 | + - Consider setting explicit `instanceID` values for easier debugging and monitoring |
| 558 | + |
| 559 | +5. **For Single-Node Deployments:** |
| 560 | + - **SQLite Supported**: SQLite can be used for single-node deployments and handles node restarts gracefully |
| 561 | + - Cleanup works automatically after node restarts by scanning for eligible tokens |
| 562 | + - **Important**: Do not use SQLite with multiple replicas as it lacks the advisory lock mechanism for leader election |
| 563 | + |
| 564 | +**Performance Considerations:** |
| 565 | +- Each scan queries the token database, so `scanInterval` directly affects database load |
| 566 | +- `workerCount` affects CPU utilization during cleanup sweeps |
| 567 | +- `batchSize` affects memory usage and the duration of each cleanup sweep |
| 568 | +- The relationship `scanInterval < ttl` ensures timely cleanup without premature processing |
| 569 | + |
| 570 | +--- |
448 | 571 | --- |
449 | 572 |
|
450 | 573 | ### Optional: token.tms.<name>.auditor.lock |
|
0 commit comments