-
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
lens replacement, closed sync accounting #692
lens replacement, closed sync accounting #692
Conversation
function _syncIndividualCdp(bytes32 _cdpId) internal { | ||
address borrower = sortedCdps.getOwnerAddress(_cdpId); | ||
vm.startPrank(borrower); | ||
borrowerOperations.withdrawDebt(_cdpId, 1, bytes32(0), bytes32(0)); |
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.
It may not always work in some test scenarios since BorrowerOperation
has some require
conditions like if the CDP is already below MCR
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.
Good point - agreed, but in practice it has worked for the foundry tests.
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.
Agree and would change to add 1 coll and remove 1 coll
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.
Sending
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.
The CR lens is the reference implementation
SyncedCR is being swapped as reference
But no test verifies that SyncedCR and adding and removing debt maintains the reference
IMO
CRlens MUST be kept
Remove and add coll should be tested vs the CR Lens as an invariant
Also the change is redundant as you could just use syncedCR which is a simpler refactor
I question the motive of this PR and believe it reduces the soundness of the codebase
Great, I can see that perspective. So your proposal is to:
|
Suggestion:
|
Intuitively:
Alternatively:
|
Could also do some weirdness with HEVM to have the CR Lens prank BO |
scrapped |
Close syncAccounting
The open
syncAccounting
was closed to just be callable by borrower operations.This prevents using it to desort CDPs
It's called on adjust and close
We do rely on syncing CDPs on tests.
This seemed to work fine - take out and repay 1 debt unit as two actions
Replace CRLens Usage
CRLens relies on open syncAccounting.
Rather than create a CdpManagerTester with an open version, or replace syncAccounting with an open version that reinserts, I opted to remove CRLens usage for synced TCR, ICR, NICR.
These functions exist in the main code now.
CRLens method revamp
Invariants
invariant_GENERAL_12
invariant_GENERAL_13
invariant_GENERAL_14
were about confirming the CRLens values versus the native synced versions.
This was very useful to confirm synced implemenation worked.
They have been modified to reflect the above.