Skip to content

Conversation

@cameron1024
Copy link
Contributor

As mentioned in #750 , the total_stake field in PrivateTallyState::Encrypted is redundant, since we track it in EncryptedTally now. This PR removes the unnecessary field

}

pub fn private_encrypted(&self) -> Result<(&EncryptedTally, &Value), TallyError> {
pub fn private_encrypted(&self) -> Result<(&EncryptedTally, Value), TallyError> {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is the stake return value used somewhere? I don't think so, as we don't have such thing for the public tally

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's used in ProposalManager somewhere, I guess it could probably just return a Result<&EncryptedTally>

}
}

pub fn max_stake(&self) -> u64 {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this is necessary and exposing this only for EncryptedTallies seems a bit strange to me

match self {
Self::Private {
state: PrivateTallyState::Encrypted { encrypted_tally },
} => Ok(encrypted_tally.max_stake()),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we get rid of the private_total_power function?

r: Vec<Ciphertext>,
fingerprint: ElectionFingerprint,
max_stake: u64,
pub max_stake: u64,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wait, how did this get public again?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought that was what you were suggesting on the pub fn max_stake(&self) -> u64 above. I guess this way makes me a bit uneasy, since it makes it possible to corrupt the internal state, was there something else you had in mind? FWIW, the only use of the field outside the module is a single function in ProposalManager

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think it should be needed anywhere outside of this module

r: Vec<Ciphertext>,
fingerprint: ElectionFingerprint,
max_stake: u64,
pub max_stake: u64,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think it should be needed anywhere outside of this module

}

if self.check((*total_stake).into(), governance, &result) {
if self.check(Stake(encrypted_tally.max_stake), governance, &result) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it was a mistake also in the previous implementation, this should be the total available voting power, not the one that participated in the election (which can be obtained just by looking at the results)

}

if self.check((*total_stake).into(), governance, &result) {
if self.check(result.participation(), governance, &result) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry if I was misleading, I meant to say we should use something like token_distribution.get_total(), which btw is what we do on master. Rebasing should fix this

Copy link
Contributor

@zeegomo zeegomo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please fix the lint, otherwise good to merge

@cameron1024 cameron1024 closed this Mar 8, 2022
@cameron1024 cameron1024 reopened this Mar 8, 2022
@cameron1024 cameron1024 merged commit feaae11 into master Mar 8, 2022
@cameron1024 cameron1024 deleted the remove-total-stake-private-tally branch March 8, 2022 15:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants