ebtc-protocol / ebtc

GNU General Public License v3.0
48 stars 24 forks source link

Release 0.6 invariant failures #764

Closed dapp-whisperer closed 5 months ago

dapp-whisperer commented 5 months ago

we ultimately had two failures here:

 Error: L-17: Debt Redistribution Error Accumulator should be less than Total Stakes immediately after a debt redistribution
 Error: L-12: TCR must increase after liquidation with no redistributions

L-17 Spec

Note that L-17 is new! And may not be correct.

After any liquidation target handler:

confirm that the error accumulator is not >= totalStakes. If it is, it should have been redistributed to the system.

However, is this correct? I'm not sure if this is actually the case. Would it instead be the case that this would be true on the next operation after a liquidation?

Note that I also changed it from a "true" check to an "lt" check so we see the outputs.

[FAIL. Reason: Assertion failed.] test_release06_debt_accumulator_0() (gas: 3395443)
Logs:
  Error: L-17: Debt Redistribution Error Accumulator should be less than Total Stakes immediately after a debt redistribution
  Error: a < b not satisfied [uint]
    Value a: 5486855106715114504
    Value b: 3888867097958198299

[FAIL. Reason: Assertion failed.] test_release06_debt_accumulator_1() (gas: 3243796)
Logs:
  Error: L-17: Debt Redistribution Error Accumulator should be less than Total Stakes immediately after a debt redistribution
  Error: a < b not satisfied [uint]
    Value a: 3306219944562981780
    Value b: 2811720019729718960

[FAIL. Reason: Assertion failed.] test_release06_debt_accumulator_2() (gas: 3610423)
Logs:
  Error: L-17: Debt Redistribution Error Accumulator should be less than Total Stakes immediately after a debt redistribution
  Error: a < b not satisfied [uint]
    Value a: 4075421782886386025
    Value b: 2000000000000016861

[from @rayeaster ] this invariant should only check when there is a debt redistribution in the test. fixed in commit https://github.com/ebtc-protocol/ebtc/pull/764/commits/498c7a1b7d605c82bc8f3616aefad70dfe4bc6fb#diff-18525b035e0d27c42350acd0a3a8545337251874a7b8b4227056f1c20ba58fbaR454

L-12 Failure

It seems like TCR did indeed decrease after a liquidation here.

We had a lot of negative rebases...

[FAIL. Reason: Assertion failed.] test_release06_L12_0() (gas: 3436411)
Logs:
  Error: L-12: TCR must increase after liquidation with no redistributions
  Error: a >= b not satisfied [uint]
    Value a: 1080600738948755413
    Value b: 1080600738948757216

[from @rayeaster ] this invariant should only check when the liquidated ICR is less than TCR before liquidation. fixed in commit https://github.com/ebtc-protocol/ebtc/pull/764/commits/498c7a1b7d605c82bc8f3616aefad70dfe4bc6fb#diff-18525b035e0d27c42350acd0a3a8545337251874a7b8b4227056f1c20ba58fbaR237

getrecon-bot commented 5 months ago
Job ID 76e2cccf-7c46-411d-952b-c04880fde0ed
Command yarn && git submodule init && git submodule update && solc-select use 0.8.17 && cd packages/contracts/ && yarn echidna --test-mode assertion --test-limit 600000
Instance ID i-03f7ad3976fadd092
Instance Type c5.2xlarge
Status Started
Elapsed
getrecon-bot commented 5 months ago
Job ID 76e2cccf-7c46-411d-952b-c04880fde0ed
Command yarn && git submodule init && git submodule update && solc-select use 0.8.17 && cd packages/contracts/ && yarn echidna --test-mode assertion --test-limit 600000
Instance ID i-03f7ad3976fadd092
Instance Type c5.2xlarge
Status Running
Elapsed 39 seconds
getrecon-bot commented 5 months ago
Job ID 76e2cccf-7c46-411d-952b-c04880fde0ed
Command yarn && git submodule init && git submodule update && solc-select use 0.8.17 && cd packages/contracts/ && yarn echidna --test-mode assertion --test-limit 600000
Instance ID i-03f7ad3976fadd092
Instance Type c5.2xlarge
Status Running
Elapsed 40 seconds
getrecon-bot commented 5 months ago
Job ID 5cd0def4-679f-403d-a098-6cd5d526440b
Command yarn && git submodule init && git submodule update && solc-select use 0.8.17 && cd packages/contracts/ && yarn echidna --test-mode assertion --test-limit 600000
Instance ID i-01ced88c2f23beff8
Instance Type c5.2xlarge
Status Started
Elapsed
getrecon-bot commented 5 months ago
Job ID 5cd0def4-679f-403d-a098-6cd5d526440b
Command yarn && git submodule init && git submodule update && solc-select use 0.8.17 && cd packages/contracts/ && yarn echidna --test-mode assertion --test-limit 600000
Instance ID i-01ced88c2f23beff8
Instance Type c5.2xlarge
Status Running
Elapsed 38 seconds
getrecon-bot commented 5 months ago
Job ID 5cd0def4-679f-403d-a098-6cd5d526440b
Command yarn && git submodule init && git submodule update && solc-select use 0.8.17 && cd packages/contracts/ && yarn echidna --test-mode assertion --test-limit 600000
Instance ID i-01ced88c2f23beff8
Instance Type c5.2xlarge
Status Running
Elapsed 39 seconds
getrecon-bot commented 5 months ago
Job ID bc9227b3-8d3c-4e0e-923f-15c4e7652d75
Command yarn && git submodule init && git submodule update && solc-select use 0.8.17 && cd packages/contracts/ && yarn echidna --test-mode assertion --test-limit 600000
Instance ID i-0c08547d710aa89be
Instance Type c5.2xlarge
Status Started
Elapsed
getrecon-bot commented 5 months ago
Job ID bc9227b3-8d3c-4e0e-923f-15c4e7652d75
Command yarn && git submodule init && git submodule update && solc-select use 0.8.17 && cd packages/contracts/ && yarn echidna --test-mode assertion --test-limit 600000
Instance ID i-0c08547d710aa89be
Instance Type c5.2xlarge
Status Running
Elapsed 38 seconds
getrecon-bot commented 5 months ago
Job ID bc9227b3-8d3c-4e0e-923f-15c4e7652d75
Command yarn && git submodule init && git submodule update && solc-select use 0.8.17 && cd packages/contracts/ && yarn echidna --test-mode assertion --test-limit 600000
Instance ID i-0c08547d710aa89be
Instance Type c5.2xlarge
Status Running
Elapsed 39 seconds
getrecon-bot commented 5 months ago
Job ID 5cd0def4-679f-403d-a098-6cd5d526440b
Command yarn && git submodule init && git submodule update && solc-select use 0.8.17 && cd packages/contracts/ && yarn echidna --test-mode assertion --test-limit 600000
Instance ID i-01ced88c2f23beff8
Instance Type c5.2xlarge
Status Success
Elapsed 1 day 10 hours 42 minutes 55 seconds
GalloDaSballo commented 5 months ago

Haven't checked repro and happy to if you have it handy

That said, please keep in mind that if all CDPs are underwater then l-12 may break, so please do check for that edge case

getrecon-bot commented 5 months ago
Job ID 76e2cccf-7c46-411d-952b-c04880fde0ed
Command yarn && git submodule init && git submodule update && solc-select use 0.8.17 && cd packages/contracts/ && yarn echidna --test-mode assertion --test-limit 600000
Instance ID i-03f7ad3976fadd092
Instance Type c5.2xlarge
Status Error
Elapsed 1 day 19 hours 54 minutes 47 seconds
getrecon-bot commented 5 months ago
Job ID bc9227b3-8d3c-4e0e-923f-15c4e7652d75
Command yarn && git submodule init && git submodule update && solc-select use 0.8.17 && cd packages/contracts/ && yarn echidna --test-mode assertion --test-limit 600000
Instance ID i-0c08547d710aa89be
Instance Type c5.2xlarge
Status Success
Elapsed 1 day 19 hours 12 minutes 53 seconds