witnet-rust icon indicating copy to clipboard operation
witnet-rust copied to clipboard

Validator with withdrawer address different from the validator address is never eligible to mine

Open drcpu-github opened this issue 1 year ago • 0 comments

A validator which has a stake for which the withdrawer address is not the validator address can never mine a block. This is due to the way his power is calculated. In mining.rs, a StakeKey is contructed where own_pkh is the pkh of the validator:

let key = StakeKey::from((own_pkh, own_pkh));

This StakeKey is later on used to query the power of the validator (which will determine its mining eligibility) using the self.by_key staking tracker. However, since that structure is indexed by a StakeKey<validator, withdrawer> no StakeEntry is found and this his power and eligibility is zero.

Either the query_power should use the by_validator structure (not sure if this has other implications) or the validator should construct its StakeKey using the correct withdrawer as second argument (and I don't know how it can currently know the withdrawer address)?

drcpu-github avatar May 25 '24 05:05 drcpu-github