-
Notifications
You must be signed in to change notification settings - Fork 109
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Bug: Release vote stake not working (for very specific scenario) #3559
Comments
Further investigation:
This shows an example of an example of a successful release similar to the problem scenarios. They voted in the first election for someone who was successful in the second election.
The stake for this was released at the following block: https://polkadot.js.org/apps/#/explorer/query/59578
This means the stake for this vote was successfully released prior to the next election starting:
I was able to find other successful stake releases for votes from |
I have asked the affected users to attempt releasing now (as there is a new election in progress) as well as throughout the next few days to understand if this stake can ever be released or was just impacted by the candidates being on the current council. Will update when I get more information. One of the users was able to release their stake successfully: |
All 3 accounts appear to have been able to release stake successfully, albeit they weren't able to do so at the same stage as other users and were delayed in doing so. This means this "bug" is likely confined to only a certain subset of users and the "worst result" is that they have some delay in releasing their stake. @bedeho is this considered something that requires a fix? |
Can you add more explicitly what the handbook says should happen that is violated? |
From: https://joystream.gitbook.io/testnet-workspace/system/council#vote
|
@mochet thank you for a very nice inspection of the issue. The only place where It seems to me that the problem may be an invalid Some relevant information follows. Let's focus on user By querying QN (https://query.joystream.org/graphql), we can see new councils were elected at blocks
By looking directly into Indexer's database I've found that the user voted in the block The failed unstake happened in the block In the block We have unity test(s) that cover the whole election process, including vote unstaking; see https://github.com/Joystream/joystream/blob/master/runtime-modules/council/src/tests.rs#L167 . I haven't found the root of the problem yet, but it is likely that the increment of |
I've finally had the time to go through this issue. There are some issues with One small fix that would have allowed the votes to be unlocked during cycle 0 while council was in idle stage after the conclusion of the election would be simply replacing: joystream/runtime-modules/council/src/lib.rs Line 1217 in 9753012
with if voting_for_winner && matches!(Stage::<T>::get().stage, CouncilStage::Idle) { However if user had waited for next announcing period to start, they would still not have been able to unlock the vote because: joystream/runtime-modules/council/src/lib.rs Line 1204 in 9753012
And as had to eventually occur, the user had to wait until an additional cycle completed for the condition to be met: joystream/runtime-modules/council/src/lib.rs Line 1188 in 9753012
There is bad assumption in this One side affect of the current implementation is that any vote stake can be unlocked after 2 failed announcement stages while the same council is still elected. If my understanding is correct as long as an elected member is in the council the vote stake that contributed to electing them must not be unlocked. can you confirm this @bedeho ? Currently the council pallet does not store in which cycle the council was elected in. Adding this information would allow us to properly address the original bug described and the new one. |
After discussing with bedeo and removing some ambiguity about the way I interpreted the rules in the handbook, the final implementation to solve the bug, which is easier to read: // Check that it is a proper time to release stake.
fn can_unlock_vote_stake(vote: &CastVoteOf<T>) -> Result<(), Error<T>> {
let current_voting_cycle_id = AnnouncementPeriodNr::get();
// If the vote is for an election prior to the last concluded..
if vote.cycle_id != current_voting_cycle_id {
// ..it is always recoverable.
return Ok(());
}
// The vote is for the current election cycle.
if Stage::<T>::get().stage == CouncilStage::Idle {
// The election is concluded..
let voted_for_winner = CouncilMembers::<T>::get()
.iter()
.map(|council_member| council_member.membership_id)
.any(|membership_id| vote.vote_for == Some(membership_id));
if voted_for_winner {
// ..and vote is for a winning candidate, so it is not recoverable.
Err(Error::CantReleaseStakeNow)
} else {
// ..and vote is for a losing candidate, so it is recoverable.
Ok(())
}
} else {
// The election is ongoing, so it is not recoverable.
Err(Error::CantReleaseStakeNow)
}
} Implemented in #3783 I've created a new branch |
Two users have reported this issue so far.
This bug only seems to impact users who match a very specific set of criteria. Please see 1st comment on issue for examples showing this to be the case.
cycle id: 0
cycle id: 0
cycle id: 1
cycle id: 0
but were successfully elected incycle id: 1
chain state
>referendum.votes
balances.locks
with only locks forid: voting
as existingextrinsic
>referendum.releaseVoteStake
and got the errorreferendum.UnstakingForbidden
(details say:Unstaking has been forbidden for the user (at least for now
)Addresses/links:
5CUefaByXT5B2uxaeuAPiDrGDMVEHd8Ds52bz9XAi2xXp4y1
cycle ID: 1
5D34bqj2H1vAgHaABts6Qn4nqPCKXKKfEthA2KPQtNzDaA5j
cycle ID: 1
5GBpm9ghjsgRPjvbzjjnb3pCJarMUWLsXHnjNynKd71mRQb8
cycle ID: 1
The text was updated successfully, but these errors were encountered: