staking-expiry-checker
Description
The staking-expiry-checker program is a core service that manages the transitions for Phase 1 delegations that have not transitioned to Phase 2. It does this by monitoring the expiration of the timelocks as well as unbonding and withrawing Bitcoin transactions.
This program is responsible for:
timelock expiry monitoring — ensuring delegations that expired are set to unbonded
unbonding transaction detection — updating delegations based on unbonding transactions
withdrawal transaction tracking — detecting when withdrawal transactions occur
storing and updating delegation statues in the shared MongoDB database
Here are its key functionalities:
BTC Subscriber Poller — subscribes to Bitcoin spend notifications for staking/unbonding transaction spends to update the database
Expiry Checker Poller — regularly polls the timelock queue table to identify delegation timelock expiry
Invariants
State updates should be well-defined and consistent, so delegations can only transition through states in the correct sequences
Delegation statues should be reliable and accurate, reflecting the true state of the blockchain at the current time
Test coverage
Cases not covered
Tests to verify general functionality of the program
Correct processing of delayed or malformed Bitcoin notification data
Graceful error handling and recovery
Attack surface
The attack surface for the program is malicious or malformed Bitcoin transaction data that may cause the program to fail. For example, this could come from a malicious transaction sent by an attacker, or by a compromised Bitcoin node.