Repository navigation
refactor(contract): move parameter votes from RunningContractState to MpcContract - #4869
SimonRastikian wants to merge 8 commits into
Conversation
Pull request overviewMoves pending Changes:
Reviewed changesPer-file summary
FindingsBlocking (must fix before merge):
Non-blocking (nits, follow-ups, suggestions):
|
kevindeforth
left a comment
There was a problem hiding this comment.
Thank you, just some nits.
I think this is good. I suspect we could simplify the code a bit, but that will become easier once we already use the generic votes struct, so it's a bit of a chicken-and-egg problem.
|
@claude review |
Pull request overviewMoves the pending This revision addresses every blocking point from the earlier review: contract-level tests now cover the Changes:
Reviewed changesPer-file summary
FindingsI traced every transition against the pre-PR behaviour: Running→Resharing (vote or kickout), Running→Initializing, Initializing→Running (keygen done or cancelled; nothing can vote in Initializing, so the store is already empty), Resharing→Resharing (re-proposal), Resharing→Running (complete or cancelled). The only path that keeps votes is resharing cancellation, which matches the old code where Non-blocking (nits, follow-ups, suggestions):
✅ Approved |
| @@ -107,6 +104,7 @@ impl RunningContractState { | |||
| &mut self, | |||
There was a problem hiding this comment.
does this still need to be &mut?
There was a problem hiding this comment.
Yes because the inner functions transition_to_resharing_no_checks needs it
netrome
left a comment
There was a problem hiding this comment.
Thanks, looks good to me. A few minor questions.
| /// Shadow of the `3.17.0` `GovernanceThresholdParametersVotes` layout. | ||
| #[derive(Debug, BorshSerialize, BorshDeserialize)] | ||
| struct OldGovernanceThresholdParametersVotes { | ||
| proposal_by_account: BTreeMap<AuthenticatedAccountId, ProposedGovernanceThresholdParameters>, | ||
| } |
There was a problem hiding this comment.
Why do we shadow this type here rather than reusing the existing type? They seem identical.
| tee_verifier_account_id: old.tee_verifier_account_id, | ||
| tee_verifier_votes: old.tee_verifier_votes, | ||
| available_attestation_grants: old.available_attestation_grants, | ||
| parameters_votes: GovernanceThresholdParametersVotes::default(), |
There was a problem hiding this comment.
Why not preserve the votes through the migration here?
There was a problem hiding this comment.
Note: I see this simplifies the next PR quite a bit: #4870 (review)
| &self, | ||
| prospective_epoch_id: EpochId, | ||
| proposal: &ProposedGovernanceThresholdParameters, | ||
| votes: &mut GovernanceThresholdParametersVotes, |
There was a problem hiding this comment.
I'm not too fond of taking a mutable reference here but it seems like the least bad option without making any other major changes.
This is part of the issue that allows replacing unnecessary old voting structures for different functions on the smart contract, with one single generic struct:
Votes. The replacement could mean modifying an existing struct to some form of a wrapper forVotes.The current struct that we are targeting in this issue is
GovernanceThresholdParametersVotes.Recall:
Votes<V>struct contains two information: which participants has voted for a certain proposalhash, and which proposalHashes have been voted for by a certain participant. We thus no more focus on the proposals per-se but on their hashes.In this PR:
RunningContractStatetoMpcContract.parameters_votes(see parameter_votes variable)RunningContractStateremoves a reset that happens automatically (and that needs to be restored)The next final PR should deal with transforming
GovernanceThresholdParametersVotesinto a wrapper forVotesand hashingProposedGovernanceThresholdParameters