Skip to content
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

fix: remove is_vote_valid #5363

Merged
merged 6 commits into from
Oct 30, 2024
Merged

fix: remove is_vote_valid #5363

merged 6 commits into from
Oct 30, 2024

Conversation

kylezs
Copy link
Contributor

@kylezs kylezs commented Oct 29, 2024

Pull Request

Closes: PRO-1757

Checklist

Please conduct a thorough self-review before opening the PR.

  • I am confident that the code works.
  • I have written sufficient tests.
  • I have written and tested required migrations.
  • I have updated documentation where appropriate.

Summary

is_vote_valid was only used once, and was used erroneously. Plus, if a single vote within a group is invalid then the whole extrinsic vails, effectively invalidating all the votes. We have is_vote_needed to prevent engines from submitting too many votes. So have removed it, which simplifies things too. No need to hash the data at all, we can compare the values directly in check_consensus.

@kylezs kylezs force-pushed the fix/is-vot-valid-mono-med branch from 721d3c4 to 685ca04 Compare October 29, 2024 14:49
@kylezs kylezs marked this pull request as ready for review October 29, 2024 14:51
@kylezs kylezs requested a review from dandanlen as a code owner October 29, 2024 14:51
@kylezs kylezs marked this pull request as draft October 29, 2024 15:21
@kylezs kylezs force-pushed the fix/is-vot-valid-mono-med branch from 0cb4bb4 to 4cd5a1e Compare October 30, 2024 07:12
@kylezs kylezs marked this pull request as ready for review October 30, 2024 07:13
Copy link

codecov bot commented Oct 30, 2024

Codecov Report

Attention: Patch coverage is 42.85714% with 8 lines in your changes missing coverage. Please review.

Project coverage is 71%. Comparing base (d4eff08) to head (d0727cf).
Report is 8 commits behind head on main.

Files with missing lines Patch % Lines
...lections/src/electoral_systems/monotonic_change.rs 43% 7 Missing and 1 partial ⚠️
Additional details and impacted files
@@          Coverage Diff           @@
##            main   #5363    +/-   ##
======================================
  Coverage     71%     71%            
======================================
  Files        495     497     +2     
  Lines      86434   86199   -235     
  Branches   86434   86199   -235     
======================================
- Hits       61703   61544   -159     
+ Misses     21968   21876    -92     
- Partials    2763    2779    +16     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Collaborator

Choose a reason for hiding this comment

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

is_vote_needed is currently this:

match current_vote {
			AuthorityVoteOf::<Self>::Vote(current_vote) => current_vote != proposed_vote,
			_ => false,
		}

Should it not be:

match current_vote {
			AuthorityVoteOf::<Self>::Vote(current_vote) => current_vote.value != proposed_vote.value,
			_ => false,
		}

ie. we only want a cote if the value has changed, not if the block has changed?

Otherwise the engines will just vote almost continuously.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah good point, better that way

@kylezs kylezs enabled auto-merge October 30, 2024 09:18
@kylezs kylezs added this pull request to the merge queue Oct 30, 2024
Merged via the queue into main with commit 7c403b5 Oct 30, 2024
48 of 49 checks passed
@kylezs kylezs deleted the fix/is-vot-valid-mono-med branch October 30, 2024 12:04
dandanlen pushed a commit that referenced this pull request Oct 31, 2024
* fix: correct shared data hash

* fix: remove is_vote_valid

* test: fix tests

* chore: remove stale comment

* fix: only compare value, not slot number

* chore: clippy
dandanlen pushed a commit that referenced this pull request Oct 31, 2024
* fix: correct shared data hash

* fix: remove is_vote_valid

* test: fix tests

* chore: remove stale comment

* fix: only compare value, not slot number

* chore: clippy
syan095 added a commit that referenced this pull request Nov 3, 2024
…d-migration

* origin/main:
  fix: retry with search history enabled after some attempts (#5370)
  fix: rpc subscription return types (#5374)
  chore: remove unused stream_utils (#5373)
  fix: always sweep on RPC free balance (#5376)
  fix: make boost detection more accurate (#5369)
  chore: better not contributing error message (#5368)
  chore: rename ElectoralSystemStatus -> ElectionPalletStatus (#5367)
  fix: `request_swap_deposit_address_with_affiliates` refund address is consistent with destination address type (#5360)
  feat: add sol chain tracking metric (#5366)
  fix: remove is_vote_valid (#5363)
  fix: separate lp account for lp api (#5354)
  fix: features for test-externalities (#5365)
  Update localnet polkadot runtime to v1.3.3 (#5337)
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.

2 participants