penumbra icon indicating copy to clipboard operation
penumbra copied to clipboard

Measure voting power in units of staking token

Open plaidfinch opened this issue 2 years ago • 1 comments

Per @hdevalence:

the voting power is measured in units of "stake that has been bonded from genesis with 0 commission and no slashing" ... we should change the math so that we measure voting power just in units of "staking token"

Currently, voting power is calculated as:

https://github.com/penumbra-zone/penumbra/blob/0f099676441885eecc0fcba7bc3b71e00c7c403d/component/src/stake/rate.rs#L131-L138

I think what we want is:

 pub fn voting_power(&self, total_delegation_tokens: u64) -> u64 { 
     total_delegation_tokens
        .checked_mul(self.validator_exchange_rate)
        .expect("voting power in possible range")
 }

In other words, removing the denominator of base_rate_data.base_exchange_rate means that we would no longer be scaling all voting power by the (global) base exchange rate for a "perfect validator" who has existed since genesis.

In the above, the effect of u64::checked_mul is the same as casting up to u128 and then checking on the downcast after the multiplication, since we don't have an intermediate division.

plaidfinch avatar Aug 17 '22 17:08 plaidfinch

This looks good, and we should also adjust the formulas in the spec while we do it.

hdevalence avatar Aug 17 '22 17:08 hdevalence

Blocked on #1481

redshiftzero avatar Jan 06 '23 17:01 redshiftzero

Blocked on using U128x128 for formulae.

plaidfinch avatar May 16 '23 17:05 plaidfinch