Skip to content

feat: add feasibility_check on mined solution#483

Merged
niklasad1 merged 10 commits intomainfrom
na-add-feasibility-check
Mar 31, 2023
Merged

feat: add feasibility_check on mined solution#483
niklasad1 merged 10 commits intomainfrom
na-add-feasibility-check

Conversation

@niklasad1
Copy link
Copy Markdown
Contributor

@niklasad1 niklasad1 commented Mar 8, 2023

Close #480 #498

You don't have to review the staking-miner-playground carefully it simply updates substrate to get the latest EPM changes in the metadata.

@niklasad1 niklasad1 marked this pull request as ready for review March 21, 2023 15:59
@niklasad1 niklasad1 changed the title WIP: feat: add feasibility_check on mined solution feat: add feasibility_check on mined solution Mar 21, 2023
@niklasad1 niklasad1 requested a review from kianenigma March 22, 2023 08:36
pub fn mock_votes(voters: u32, desired_targets: u16) -> Vec<(u32, u16)> {
assert!(voters >= desired_targets as u32);
(0..voters).zip((0..desired_targets).cycle()).collect()
pub fn mock_votes(voters: u32, desired_targets: u16) -> Option<Vec<(u32, u16)>> {
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

refactored to not panic with weird input here

active_voters,
desired_targets.try_into().expect("Desired targets < u16::MAX"),
) else {
return Weight::MAX;
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

refactored not to panic on weird input, Weight::MAX was the best I could come with i.e, just throw away the result

@niklasad1 niklasad1 requested a review from gpestana March 28, 2023 12:57
@niklasad1 niklasad1 merged commit 96e7798 into main Mar 31, 2023
@niklasad1 niklasad1 deleted the na-add-feasibility-check branch March 31, 2023 08:37
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.

add feasiblity check on the solution before submitting

2 participants