-
Notifications
You must be signed in to change notification settings - Fork 4
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
Conversation
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 :)
ETH-617 Voter selection
Voter selection should use the best randomness available in the network. Eth mainnet for instance has verifiable randomness in Add Add 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
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
packages/network-contracts/contracts/OperatorTokenomics/SponsorshipPolicies/VoteKickPolicy.sol
Outdated
Show resolved
Hide resolved
packages/network-contracts/contracts/OperatorTokenomics/SponsorshipPolicies/VoteKickPolicy.sol
Outdated
Show resolved
Hide resolved
…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
…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)
* 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) ...
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