diff --git a/state-chain/pallets/cf-elections/src/electoral_systems/composite.rs b/state-chain/pallets/cf-elections/src/electoral_systems/composite.rs index 8a2c74ef9e2..e8b80eacccf 100644 --- a/state-chain/pallets/cf-elections/src/electoral_systems/composite.rs +++ b/state-chain/pallets/cf-elections/src/electoral_systems/composite.rs @@ -364,7 +364,9 @@ macro_rules! generate_electoral_system_tuple_impls { properties: $current::ElectionProperties, ) -> Result<(), CorruptStorageError> { StorageAccess::refresh_election( + // The current election id + extra that we want to refresh. self.id.with_extra(CompositeElectionIdentifierExtra::$current(*self.id.extra())), + // The new extra we want to use. CompositeElectionIdentifierExtra::$current(new_extra), CompositeElectionProperties::$current(properties), )?; @@ -424,7 +426,7 @@ macro_rules! generate_electoral_system_tuple_impls { state: $current::ElectionState, ) -> Result { let election_identifier = StorageAccess::new_election(CompositeElectionIdentifierExtra::$current(extra), CompositeElectionProperties::$current(properties), CompositeElectionState::$current(state))?; - Ok(Self::ElectionWriteAccess::new(election_identifier.with_extra(extra))) + Ok(Self::election_mut(election_identifier.with_extra(extra))) } fn election_mut( diff --git a/state-chain/pallets/cf-elections/src/lib.rs b/state-chain/pallets/cf-elections/src/lib.rs index 2758d50cbda..3b35d1df16e 100644 --- a/state-chain/pallets/cf-elections/src/lib.rs +++ b/state-chain/pallets/cf-elections/src/lib.rs @@ -707,7 +707,10 @@ pub mod pallet { } else { ElectionProperties::::remove(election_identifier); let new_election_identifier = - ElectionIdentifier::new(*election_identifier.unique_monotonic(), new_extra); + CompositeElectionIdentifierOf::::new( + *election_identifier.unique_monotonic(), + new_extra, + ); ElectionProperties::::insert(new_election_identifier, properties); Ok(()) } @@ -775,8 +778,8 @@ pub mod pallet { Ok(SharedData::::get(shared_data_hash)) }) { // Only a full vote can count towards consensus. - Ok(Some((properties, AuthorityVote::Vote(vote)))) => Ok(Some((properties, - vote))), Ok(Some((_properties, AuthorityVote::PartialVote(_)))) => Ok(None), + Ok(Some((properties, AuthorityVote::Vote(vote)))) => Ok(Some((properties, vote))), + Ok(Some((_properties, AuthorityVote::PartialVote(_)))) => Ok(None), Ok(None) => Ok(None), Err(e) => Err(e), } @@ -1224,8 +1227,6 @@ pub mod pallet { ConstU32, >, ) -> DispatchResult { - Self::ensure_initialized()?; - let (epoch_index, authority, authority_index) = Self::ensure_can_vote(origin)?; ensure!(!authority_votes.is_empty(), Error::::NoVotesSpecified); @@ -1673,10 +1674,6 @@ pub mod pallet { Ok(()) } - pub fn ensure_initialized() -> Result<(), DispatchError> { - Self::with_status_check(|| Ok(())) - } - /// Provides access into the ElectoralSystem's current election /// identifiers. pub fn with_election_identifiers<