-
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
Fully Backed Sortition Pools tweaks #89
Conversation
Removed interffaces that were defined for BondedSortitionPool and SortitionPool. The interfaces are not being used anywhere and they are not up-to-date. In keep-ecdsa we are using the contracts directly.
The pool was updating the minimum bondable value for each selectSetGroup call. The idea was to automatically remove from the pool operators that are no longer able to satisfy application needs about the minimum available bondable value and prevent operators with too low value griefing signer selection. We now have two minimum bond values: one defining the minimum unbonded value the operator needs to have so that it can join and stay in the pool, and another defining the required bond value for the current selection. If the given operator has enough unbonded value to stay in the pool but it does not have enough unbonded value for the current group selection, it is skipped. We assume a reasonable minimum bondable value is set on the pool creation and it can be later updated by the pool owner (application). We move the responsibility of keeping this value sane to the application. If the application defines allowed lot sizes, just like tBTC, the application may set the minimum bondable value to the minimum lot size and later skip operators that are not eligible to satisfy bond for the current selection instead of removing them from the pool. All operators without at least the minimum unbonded value are removed from the pool during the group selection. The change was originally implememnted to BondedSortitionPool in 46d187a.
We created a dedicated interface for the fully backed bonding as there will be specific rules to verify for the group selection. For regular BondedSortitionPool we had a staking contract reference holding informations like eligibleStake, here we don't use staking contract but all required informations are received from bonding contract.
When a bonding relationship gets delegated in the bonding contract it has to pass some initialization period. In getEligibleWeight that is invoked on operator registration in the pool we are checking if the initialization period has passed. If not we're not letting the operator to register in the pool.
Updated BondingContractStub to implement IBonding interface. Added stub for FullyBackedBonding that implements IFullyBackedBonding interface and extends BondingContractStub.
fullyBackedFactoryTest.js: - use correct bonding contract - added awaits - set operator initialization in bonding stub fullyBackedSortitionPoolTest.js: - use correct bonding contract - added awaits - set operator initialization in bonding stub - use bn-chai to verify BN values - use bond value instead of weighted value for operator preparation - get operator initialiation period from contract and use it for blocks mining - updated tests for group selection - added tests for minimum bondable value configuration - added tests for joinPool (getEligibleWeight).
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.
Looks good to me (once the tests are debugged)
Because operators are selected randomly, there was a 1/4 possibility that Carol might not be picked, causing the check for the removal of ineligible operators to fail. By increasing Carol's initial bond to 100x that of the others, the probability of Carol being skipped becomes roughly 1 in a million.
BondingContractStub doesn't implement initialization status functions. This caused the work selection distribution tests to fail. Switch to FullyBackedBondingStub and set initialization status when preparing operators.
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.
One non-blocking comment.
@@ -118,13 +147,23 @@ contract FullyBackedSortitionPool is AbstractSortitionPool { | |||
); | |||
|
|||
// Don't query stake if bond is insufficient. |
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.
This comment is not correct, it should say "don't check initialization if..."
We removed interfaces for SortitionPools that were not implemented by the pools, so they were outdated. The interfaces are not being used in keep-ecdsa anyways as we're using the implementation of the contract.
This PR contains also couple of tweaks to Fully Backed Sortition Pools:
isInitialized
function to check if the operator delegation in a bonding contract has passed initialization period,Depends on #87
Depends on #97
Closes #86
Refs keep-network/keep-ecdsa#483