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

debunk: g-08 due to ghost debt #698

Closed
wants to merge 3 commits into from
Closed

Conversation

GalloDaSballo
Copy link
Collaborator

Shows how 1 wei of ghost debt messes up the invariant

Would like advice @rayeaster @dapp-whisperer

@GalloDaSballo
Copy link
Collaborator Author

We can obviously ack and be done, but we should figure out why this is happening

@rayeaster
Copy link
Contributor

rayeaster commented Oct 17, 2023

@GalloDaSballo IMO this is similar to previous General-08 break:

  • There is a 1 wei difference between the sum of all CDP debts and the debt accounting in activePool after liquidation at step 5 due to rounding issue and is tracked by global variable lastEBTCDebtErrorRedistribution in CdpManagerStorage

  • And the debt number is so small (1 wei or 2 wei) thus the TCR comparison exceeds the expected tolerance limit:

2420000000000000022(coll) * 74280000000000000 (price) / 1 (debt) vs
2420000000000000022(coll) * 74280000000000000 (price) / 2 (debt)

The recommendation still holds for this sequence: "It might make sense for the invariant to compare the sum(cdpDebt) & activePool.getSystemDebt() directly. Similar for sum(cdpColl) & activePool.getSystemCollShares()"

@GalloDaSballo
Copy link
Collaborator Author

GalloDaSballo commented Oct 17, 2023

  • lastEBTCDebtErrorRedistribution

Can you explain to me this:

  • Will the pendingEBTC debt be redistributed in the future, or is it forever stuck?

If it will be redistributed, what's the simplest example of it happening?

@rayeaster
Copy link
Contributor

  • lastEBTCDebtErrorRedistribution

Can you explain to me this:

  • Will the pendingEBTC debt be redistributed in the future, or is it forever stuck?

If it will be redistributed, what's the simplest example of it happening?

it will be used in next liquidation with bad-debt as the redistributed debt is added by the accumulated error

image

The simplest example is to have another liquidation that cause bad-debt then the error will be used to calculate new redistributed debt per stake unit

@GalloDaSballo
Copy link
Collaborator Author

@dapp-whisperer I would merge as part of acknowledge broken invariants cases

@GalloDaSballo GalloDaSballo changed the base branch from feat/release-0.5 to main October 19, 2023 15:58
@GalloDaSballo GalloDaSballo changed the title DO NOT MERGE!!! - feat: g-08 due to ghost debt debunk: g-08 due to ghost debt Oct 19, 2023
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.

None yet

3 participants