threshold-network / merkle-distribution

Threshold Network rewards generation and distribution
https://threshold.network
1 stars 6 forks source link

REDO: Add requirements script for node operator transparency and monitoring #125

Closed somaweb3 closed 1 week ago

somaweb3 commented 5 months ago

This PR adds the ability for a node operator to easily check their current tbtc rewards requirements status based on the Source of Truth data used for rewards calculations.

The motivation is to improve transparency for node operators and provide an ability to monitor their nodes and act accordingly when a node is in danger of not meeting requirements. Nobody wants to get to the end of the month only to find that they have not met requirements.

See src/scripts/tbtcv2-rewards/MONITORING.md for details and instructions.

Summary of changes:

Created requirements.ts|sh for usage more appropriate to monitoring. This involved copying over rewards.ts|sh, removing unneeded code that only applied to monthly rewards, and using operator address instead of staker address. Use of staker address is not very performant for the monitoring use case because you have to loop through every operator address in the bootstrap data and make eth contract calls to resolve.

Created staker2operator.ts|sh to make it easy to obtain operator address from staker address

An important aspect of this PR is the refactoring of common code for both rewards.ts and requirements.ts to use. I did this so that changes in code that is used for rewards.ts also applies to requirements.ts, we don't want requirements monitoring to be forked from rewards code. I simply moved shared code to Utils as a low-cost way to do the refactor.

I verified that rewards.sh|ts are working, but this should be double-checked for merging this PR.

manumonti commented 1 week ago

Let's close this because of inactivity. We can reopen it in the future if needed.