Conversation
Changed the logic which builds the `deactivatedKeeps` array to not include liquidations in the signature SLA as they distort this metric.
Added an additional keep to the test cache which doesn't contain the tested operator to add some diversity to the test set.
@@ -0,0 +1,22 @@ | |||
{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As we initiate a new NPM package in staker-rewards
directory can we also configure JS linting? Defining this now will be super handy for following PRs.
staker-rewards/lib/sla-calculator.js
Outdated
// due to one of the following causes: | ||
// - keep has been closed after delivering a signature successfully | ||
// - keep has been terminated after not delivering a signature | ||
const deactivatedKeeps = [].concat(closedKeeps, signatureFailKeeps) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is one edge case we missed. Keep can be closed by the application even though it was never asked to provide a signature. In the case of tBTC, this is a funding timeout scenario. For example, if we generate mainnet report from the moment of deploying contracts and look at the operator 0xF1De9490Bf7298b5F350cE74332Ad7cf8d5cB181
, we see this operator has signatureCount = 159
:
It does not seem right as a significant number of closedKeeps
are funding time-out keeps that were never asked for a signature.
I think the fix should be to add a function to keep.js
that will let us say if the given keep was ever asked to provide a signature (one occurrence of SignatureRequested
is enough) and if not, filter out such keeps. For example:
const deactivatedAndAskedForSigning = deactivatedKeeps.filter(keep => wasAskedForSignature(keep))
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, done. Unfortunately, this change increases the script execution time significantly. For now, I don't see an easy way to optimize those checks.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, agreed. We have to live with it for now. In the future, we could be caching if a keep was asked for a signature refreshing all cases when the keep wasn't asked. Probably, adding some optimization with interval start/end date and whether there was a chance the signature was requested (e.g. it is not a case for closed keeps before interval start date).
Let's leave this discussion open for now - maybe we can implement some optimization in a separate PR at the very end, once we'll have all other pieces working together.
Added the `wasAskedForSignature` filter which adds a new filtering layer checking whether a deactivated keep has been requested for signing.
Refs: #602
Here we introduce the staker rewards script. This PR aims to introduce:
The script can be invoked by running the following command:
Once invoked, the script validates the passed interval, refreshes the cache, and performs computations of the SLA for each operator. An example output looks as follows:
Specific parameters for each operator are calculated based on keeps the operator is a member of, in the following way:
keygenCount
: it's the number of keeps whose creation timestamp is within the given intervalkeygenFailCount
: it's the part of keeps from thekeygenCount
number which have been eventually terminated due to a keygen failkeygenSLA
: it's a parameter calculated as100 - ((keygenFailCount * 100) / keygenCount
and rounded to the floorsignatureCount
: it's the number of keeps which changed their statuses fromactive
toclosed
or fromactive
toterminated
due to signature fail, within the given interval AND have been asked for signing at least once.signatureFailCount
: it's the part of keeps from thesignatureCount
number which changed their statuses fromactive
toterminated
due to signature failsignatureSLA
: it's a parameter calculated as100 - ((signatureFailCount * 100) / signatureCount
and rounded to the floor