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

ETH-617: Voter selection and pseudorandomness cleanup #665

Merged
merged 22 commits into from
Oct 3, 2023

Conversation

jtakalai
Copy link
Contributor

@jtakalai jtakalai commented Sep 30, 2023

The pseudorandomness works precisely like before (combine the slowly changing seed with keccak hashing), except now it can generate more pseudorandomness if number of selection iterations is higher

Thanks to coverage work, found and fixed an accounting bug in Sponsorship when flagger had left on a KICK result resolution. VoteKickPolicy coverage is now 100%.

Includes also #664 so might be good idea to merge that first to clean up the diff

don't mix type and object imports, from "ethers" we only get types; the utils we get from hardhat's version
don't mix type and object imports, from "ethers" we only get types; the utils we get from hardhat's version
…ndomness

so much easier to get full reviewer sets :)
@linear
Copy link

linear bot commented Sep 30, 2023

ETH-617 Voter selection

Voter selection should use the best randomness available in the network. Eth mainnet for instance has verifiable randomness in block.difficulty (randao), Polygon does not.

Add streamrConfig.bestEffortRandomNumberBetween(low, high)

Add streamrConfig.randomnessSource(zero by default) and IRandomnessSource. When randomnessSource isn't set, use keccak to produce predictable pseudorandomness, shuffle using blocktime (miner control, least caller control?).

For tests, mockRandomnessSource that allows setting seed and next number lists.

Modify tests to generate seeded+simple random numbers (always +1 the previous one?), to get full voter sets.

Also get VoteKickPolicy to full coverage with better tests

...though it's an error that's almost impossible to trigger in real setting (requires there are only 2 live operators in existence, of random oracle that picks only 2 in 20 tries)
… from "ethers"

better just import from one place, and now it's hardhat (and its modified ethers)
also add tests for full coverage of VoteKickPolicy
now the error messages show token amounts instead of wei amounts
# Conflicts:
#	packages/network-contracts/test/hardhat/OperatorTokenomics/SponsorshipPolicies/VoteKickPolicy.test.ts
#	packages/network-contracts/test/hardhat/OperatorTokenomics/deployTestContracts.ts
#	packages/network-contracts/test/hardhat/OperatorTokenomics/setupSponsorships.ts
#	packages/network-contracts/test/hardhat/Registries/StreamRegistry.test.ts
@jtakalai jtakalai requested review from samt1803 and samigabor October 2, 2023 08:17
it's now inlined in VoteKickPolicy. The interface really now exists for testing only, but MAYBE we'll be happy later it's there, just in case we find cheap and good randomness in polygon later.

also fixed a bug in secondary reviewer selection if we really would select lots of reviewers (more than 32), just use a dynamic-size memory array.
Copy link
Contributor

@samt1803 samt1803 left a comment

Choose a reason for hiding this comment

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

👍

@jtakalai jtakalai merged commit 46c86dd into master Oct 3, 2023
2 checks passed
@jtakalai jtakalai deleted the eth-617-voter-selection branch October 3, 2023 08:17
samt1803 added a commit that referenced this pull request Oct 4, 2023
…sorship

* origin/master:
  build: generate function selector list to selectors.txt (#671)
  ETH-293: Added numeric precision to StakeWeightedAllocationPolicy (#670)
  test: add a longer "scenario" test to Sponsorship (#667)
  StreamrConfig test (#666)
  ETH-617: Voter selection and pseudorandomness cleanup (#665)

# Conflicts:
#	packages/network-contracts/contracts/OperatorTokenomics/StreamrConfig.sol
#	packages/network-contracts/test/hardhat/OperatorTokenomics/Sponsorship.test.ts
samt1803 added a commit that referenced this pull request Oct 4, 2023
…s_value

* origin/master:
  build: generate function selector list to selectors.txt (#671)
  ETH-293: Added numeric precision to StakeWeightedAllocationPolicy (#670)
  test: add a longer "scenario" test to Sponsorship (#667)
  StreamrConfig test (#666)
  ETH-617: Voter selection and pseudorandomness cleanup (#665)
  Activate delegationPolicy and undelegationPolicy in _transfer (#658)
  feat: pay for slashing by burning operator's self-delegation (#657)
  Clean up tokenomics contract tests' imports (#664)
samt1803 added a commit that referenced this pull request Oct 9, 2023
* master: (32 commits)
  ETH-618: plug the malicious sponsorship / repeated deliberate slashing hole (#682)
  one bugfix with empty queue, and improved test path coverage (#681)
  refactor: moving functions around (#680)
  ETH-627: upgradeability (#677)
  ETH-636: Take fisherman's reward from self-delegation (#679)
  ETH-610 meta-transactions using minimalForwarder (#672)
  ETH-625: Add locked stake and flag info to subgraph, ETH-633: real-time earnings calculation info to subgraph (#675)
  Operator further coverage (#673)
  fix: JSON in projects data
  Test cleanups (#676)
  Eth 623 add maxOperators value to subgraph (#668)
  Eth 624 add policy checks to factories (#669)
  build: generate function selector list to selectors.txt (#671)
  ETH-293: Added numeric precision to StakeWeightedAllocationPolicy (#670)
  test: add a longer "scenario" test to Sponsorship (#667)
  StreamrConfig test (#666)
  ETH-617: Voter selection and pseudorandomness cleanup (#665)
  Activate delegationPolicy and undelegationPolicy in _transfer (#658)
  feat: pay for slashing by burning operator's self-delegation (#657)
  Clean up tokenomics contract tests' imports (#664)
  ...
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