nodeset-org / constellation

GNU General Public License v3.0
5 stars 0 forks source link

Node Op's `activeValidatorCount` isn't using the historical value during `YieldDistributor.harvest()` #274

Closed jclapis closed 1 month ago

jclapis commented 2 months ago

When the harvest function is called, it looks at the node operator's activeValidatorCount at the time of calling. Since this can be used to get rewards for legacy intervals (which have maxValidators snapshotted for the time the interval was finalized), it's easy to imagine a world where the following happens:

I then do a harvest on intervals 1-3, and according to this line: https://github.com/nodeset-org/constellation/blob/9f0b8e5dc6217b21535d79b0f72f99be3f2e66e4/contracts/Operator/YieldDistributor.sol#L173

I will get rewards for 1-3 as though I had 5/5 minipools during 1-3, so more than I should have received. There needs to be a mechanism for storing each node's active minipool count at the time of snapshotting; at RP we did this with the Merkle claim system but I'm assuming that needs to be avoided here.

jclapis commented 2 months ago

Related but the math in the lines below for the exponentiation function probably don't do what you want them to do, I'll show you after lunch.