-
Notifications
You must be signed in to change notification settings - Fork 27
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
Fix rm pause #589
Fix rm pause #589
Conversation
NOTE: Rightfully fails since we mitigated the sniping |
it still depends on external interaction to explicitly trigger the "desync" and is susceptible to potential (maybe of lower likelihood) attack mentioned in #587 (review) Another brainstorm idea (maybe not necessarily a "real" worthy attack vector): Say after time wait pass and system is still in RM, now liquidator is eager to start liquidation work, but attacker could frontrun every liquidation attempt to trigger another time wait and put the system in wait forever (render Recovery Mode not working as expected). |
Pushing fixes for QA issues (error messages) |
Redemptions OptimizationGuiding ideas:
The RedemptionTotals struct now tracks the aggregate amount of collateral surplus that is sent to redeemed parties. This is required to know what the collateral of the system will be after the redemption loop is done so we can virtually calculate the TCR for Grace Period. When get this value by tracking the collSurplus for each fully redeemed Cdp, and adding them to the total in a way that fits the existing code moved "setting up the next iteration stuff" to the bottom of the core redemption loop Finally, there are some debug checks added to confirm that the live system debt and collShares at the end of the operation (after interactions) match what we expected when we did the TCR calculation for the Grace Period Next UpWe see that the Grace Period calcs for liquidations and redemptions are identical. This means it's a good candidate to dedup and move into an internal function. |
Code DedupThe liquidation and redemption grace period check logic has been distilled into _syncRecoveryModeGracePeriod function. Debug checks left in redemptions code for now. |
function applyPendingGlobalState() external; | ||
function applyPendingGlobalState() external; // Accrues StEthFeeSplit without influencing Grace Period | ||
|
||
function syncPendingGlobalState() external; // Accrues StEthFeeSplit and influences Grace Period |
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.
would be nice to add to comment: typically used by governance-privileged setters
I'd say let's get rid of Debug events Use the 1 invariant for Synching of TCR before and After and have Echidna run for a long time |
feat: cleanup debug
RM "Pause" (aka Grace Period) Cleanup
fix: nice error message when nothing to liquidate
…into fix-rm-pause
Grace Period GovernanceThere is now an auth-gated setter for the grace period, A couple additional clarity renames were sent in. |
Closes #587
MUST REVIEW
Adds a Delay of X SECONDS before allowing liquidations
Use
beginRMLiquidationCooldown
to trigger the timerUse
stopRMLiquidationCooldown
to cancel itAfter a sequence of liquidations
_checkLiquidateCoolDownAndReset
is called, to reset the timerThis can still cause risks wrt to desynch of the value, but hopefully is an improvement and a simplification of the design
TO FINISH
UNSET_TIMESTAMP_FLAG
right after?)Towards CEI Conformity
See rationale on how hooks are called
https://miro.com/app/board/uXjVMrhxeT8=/?share_link_id=950890293382
NOTE
We break CEI in the main external functions as a way to ensure we are recording the latest proper state for RM
This ensures that:
-> Repay / Closing / Opening that undos RM resets the Timer
This + Synching in Liquidations should cover the majority of Desynch Cases
Debugging Branch
DO NOT MERGE THIS!!!
https://github.com/Badger-Finance/ebtc/tree/chore-logs-revert-batch-liquidate
Weird Stuff Left
_sequenceLiqToBatchLiq
can return 0 -> Reverts with underflow / overflow_sequenceLiqToBatchLiq
seems to not be correct (TODO after)