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

Allows deposit size to scale with minipool queue space #251

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

Valdorff
Copy link
Contributor

Valdorff added 2 commits July 26, 2022 19:14
… deposit pool space

- Also allows assignment to scale with value of deposit
MinipoolAssignment[] memory assignments = new MinipoolAssignment[](maxAssignments);

// Prepare half deposit assignments
count = rocketMinipoolQueue.getLength(MinipoolDeposit.Half);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

If we could iterate across the deposit type, we wouldn't need to copy-paste the code for half/full

// Prepare full deposit assignments
count = rocketMinipoolQueue.getLength(MinipoolDeposit.Full);
minipoolCapacity = rocketDAOProtocolSettingsMinipool.getDepositUserAmount(MinipoolDeposit.Full);
for (i; i < i + count; ++i) { // NOTE - this is a weird line - we continue the indexing from the half deposit loop
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Wasn't sure if this weirdness was worth it. The alternative would be to have an assignment index variable and track/increment that across both loops but let i reset. The current way saves a variable 🤷

uint256 count = 0;
uint256 minipoolCapacity = 0;
for (uint256 i = 0; i < maxAssignments; ++i) {
// Optimised for multiple of the same deposit type
if (count == 0) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

It seems there's no way to handle running out of one deposit type and moving on to the next one?
We only getNextDeposit() on the first loop, so then we're stuck with that deposit type.
If we run out of that queue, I'm not really sure what happens when dequeueMinipoolByDeposit fails because there's nothing more in the queue (the require in that function fails, but I'm not sure where that ends up putting us cuz I'm a solidity newbie).

require(capacity <= rocketDAOProtocolSettingsDeposit.getMaximumDepositPoolSize() + rocketMinipoolQueue.getEffectiveCapacity(),
"The deposit pool size after depositing (and matching with minipools) exceeds the maximum size");
} else {
require(capacity <= rocketDAOProtocolSettingsDeposit.getMaximumDepositPoolSize(),
Copy link
Member

Choose a reason for hiding this comment

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

Can replace this require with a revert because this condition is already tested above.

// case where capacityNeeded fits in the deposit pool without looking at the queue
if (rocketDAOProtocolSettingsDeposit.getAssignDepositsEnabled()) {
RocketMinipoolQueueInterface rocketMinipoolQueue = RocketMinipoolQueueInterface(getContractAddress("rocketMinipoolQueue"));
require(capacity <= rocketDAOProtocolSettingsDeposit.getMaximumDepositPoolSize() + rocketMinipoolQueue.getEffectiveCapacity(),
Copy link
Member

Choose a reason for hiding this comment

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

capacity should be capacityNeeded

- 2 comments in PR
- Need for a hard max on assignments to ensure there's enough gas in a block
- Unrelated; did away with the weird counter-spanning-for-loops trick to be more explicit
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