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

Fully Backed Sortition Pools tweaks #89

Merged
merged 10 commits into from
Oct 27, 2020
Merged

Fully Backed Sortition Pools tweaks #89

merged 10 commits into from
Oct 27, 2020

Conversation

nkuba
Copy link
Member

@nkuba nkuba commented Aug 20, 2020

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:

  • added minimum bondable value and current selection as we already did in Bonded Sortition Pools (Minimum bondable value for pool and bond value for the current selection #84),
  • defined IFullyBackedBonding interface that should be implemented by bonding contract dedicated for FullyBackedSortitionPool usage
  • the IFullyBackedBonding interface defines a isInitialized function to check if the operator delegation in a bonding contract has passed initialization period,
  • we check if the bonding initialization period has passed if not don't let the operator register in the pool,
  • updated existing unit tests and added new ones.

Depends on #87
Depends on #97
Closes #86
Refs keep-network/keep-ecdsa#483

nkuba added 6 commits August 20, 2020 07:50
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).
@nkuba nkuba requested review from pdyraga and eth-r and removed request for pdyraga August 20, 2020 06:36
@nkuba nkuba marked this pull request as draft August 20, 2020 06:40
Base automatically changed from lint to master August 20, 2020 07:56
@nkuba nkuba marked this pull request as ready for review August 20, 2020 17:02
@nkuba nkuba mentioned this pull request Aug 20, 2020
2 tasks
eth-r
eth-r previously approved these changes Sep 22, 2020
eth-r
eth-r previously approved these changes Oct 13, 2020
Copy link
Contributor

@eth-r eth-r left a 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)

@eth-r eth-r dismissed their stale review October 13, 2020 13:33

Debugging tests first

eth-r added 2 commits October 13, 2020 14:45
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.
Copy link
Member

@pdyraga pdyraga left a 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.
Copy link
Member

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..."

@pdyraga pdyraga merged commit 6093785 into master Oct 27, 2020
@pdyraga pdyraga deleted the fully-backed-tweaks branch October 27, 2020 11:26
@pdyraga pdyraga added this to the v1.1.1 milestone Sep 29, 2022
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.

Minimum bondable value for Fully Backed Sortition Pool
3 participants