Being a validator on the Ethereum mainnet comes with significant responsibility. If the validator is down, the owner loses out on staking rewards. If the validator gets slashed, the owner is at risk of losing funds. Just like in devOps, a validator operator should be notified immediately if they find out that their validator is down or got slashed so that they can take the appropriate actions.
This is surprisingly difficult -- the validator needs to scan every block in the beacon chain, parse the blocks, and set up their own monitoring system. Staking Monitor makes that a 1-click process.
What it does
Staking Monitor monitors the beacon chain for validator pubkeys that have committed double signing (slashable), or are offline. Validators can input their pubkeys into the Staking Monitor interface and get notified immediately via Telegram if their validator pubkey was at risk.
How I built it
First, the Staking Monitor implements a function in the Prysmatic ETH2.0 client that detects double signing events. Currently, this is left as a TODO in the Prysmatic repository. It also stores all the block data for every epoch, and is able to check if a validator had participated in the epoch, or whether it was offline.
Secondly, the Staking Monitor operates a webserver that is capable of sending out Telegram notifications. Whenever the Staking Monitor detects a double signing event or validator downtime, it sends out a Telegram notification to the owner of the validator pubkey. As a validator operator, all I need to do is input my Telegram ID and my validator pubkey to subscribe to downtime and staking notifications.
Challenges I ran into
I struggled with detecting a double signing event on the beacon chain for a couple of reasons:
- It was difficult to run the beacon chain locally
- It was difficult to adapt the validator client to forcefully create a double signing event
- It was not straightforward as to how to detect the double signing event by looking at beacon chain block data.
Accomplishments that I'm proud of
Being able to contribute to the ETH2.0 project by filling in gaps in Prysmatic Labs' ETH2.0 client.
What I learned
Understanding how the beacon chain works, the data structure of blocks, and mostly how Prysmatic Labs' ETH2.0 client works. Most of my time was spent trying to understand the way Prysm interacts on a p2p layer, the data structures that get communicated to peers, and how the client itself is able to understand that data.
What's next for Staking Monitor in Ethereum 2.0
Staking Monitor can be configured in any arbitrary way -- it can be used to notify if other validators are down, it can be used as an API for slasher services to detect and slash validators, it can be extended to more forms of notification other than Telegram.