Skip to content

Record and provide more information on groups#1567

Merged
pdyraga merged 16 commits intomasterfrom
terminated-group-tracking
Apr 16, 2020
Merged

Record and provide more information on groups#1567
pdyraga merged 16 commits intomasterfrom
terminated-group-tracking

Conversation

@eth-r
Copy link
Copy Markdown
Contributor

@eth-r eth-r commented Apr 7, 2020

Refs: #1602
We can't implement external rewards for beacon signers if we erase records of expired groups or delete members when they withdraw rewards. This PR packs an additional terminated flag in each group's information, and changes the reward withdrawal logic to get all rewards for the named operator and flagging that operator as withdrawn.

To prevent stub contract deployments from running out of gas, the operator contract and its libraries have been refactored slightly.

eth-r added 7 commits April 7, 2020 16:48
This function does a lot of storage operations,
so the overhead of a cross-contract call is insignificant.
Not ideal, but necessary so stub deployments don't OOG
Rename `terminatedGroups` to `activeTerminatedGroups`
to reflect the fact that expired groups get removed from it.
Pack group termination status in the `Group` struct itself
by reducing blockheight size from 256 to 64 bits.

Add `groupIndices` mapping the group public key to its index
(flagged with the most significant bit to distinguish the index 0)
to avoid O(N) loops when looking for the index of a group
identified by the group pubkey.
Instead of deleting members when they withdraw rewards,
a member is flagged as having withdrawn their rewards.

This requires that all rewards for the same operator be withdrawn at once,
so the contract now iterates through all members
and sums rewards for each instance of the same operator address.
Also remove the redundancy in `membersOf/getGroupMembers`.
@eth-r
Copy link
Copy Markdown
Contributor Author

eth-r commented Apr 8, 2020

The failing tests are intermittent errors, afaik unrelated to the changes in this PR.

@eth-r eth-r requested a review from pdyraga April 8, 2020 15:15
Comment thread solidity/contracts/KeepRandomBeaconOperator.sol Outdated
Comment thread solidity/test/random_beacon_operator/TestPricingRewardsWithdraw.js Outdated
Comment thread solidity/contracts/KeepRandomBeaconOperator.sol Outdated
Comment thread solidity/contracts/KeepRandomBeaconOperator.sol
Comment thread solidity/contracts/KeepRandomBeaconOperator.sol
Comment thread solidity/contracts/libraries/operator/Groups.sol
Comment thread solidity/contracts/libraries/operator/Groups.sol
Comment thread solidity/contracts/libraries/operator/Groups.sol
Comment thread solidity/contracts/libraries/operator/Groups.sol Outdated
@eth-r
Copy link
Copy Markdown
Contributor Author

eth-r commented Apr 16, 2020

@pdyraga comments addressed and ready for final review.

return memberRewards.mul(memberCount);
}

function withdrawableRewards(
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

We should add docs to awaitingRewards and withdrawableRewards.

// Register new group and request new entry so we can expire the previous two groups
await operatorContract.registerNewGroup(group3)
await serviceContract.methods['requestRelayEntry()']({value: entryFeeEstimate, from: requestor})
let beneficiary2balance = web3.utils.toBN(await web3.eth.getBalance(beneficiary2))
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Should this one be used?

Copy link
Copy Markdown
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.

Two non-blocking comments, we can address them in a separate PR.

@pdyraga pdyraga merged commit a1d3409 into master Apr 16, 2020
@pdyraga pdyraga deleted the terminated-group-tracking branch April 16, 2020 22:26
r-czajkowski added a commit that referenced this pull request Apr 17, 2020
Adjust the dapp to changes from #1567.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants