makerdao / dss-auto-line

GNU Affero General Public License v3.0
7 stars 16 forks source link

Cleanup, docs, makefile, optimization, and tests #3

Closed brianmcmichael closed 4 years ago

brianmcmichael commented 4 years ago

Some of these changes were inspired by https://github.com/makerdao/dss-auto-line/pull/1, which is out of sync with the latest design.

brianmcmichael commented 4 years ago

Changes made based on feedback. If we wanted to be a little more extreme we could remove another storage slot with something like:

struct Ilk {
        uint224  line;  // MAX: 26959946667150639794667015087019630673637144422540572481103610249215
        uint32    ttl;  
        uint216   gap;  // MAX: 105312291668557186697918027683670432318895095400549111254310977535
        uint8      on;
        uint32   last;  
    }
brianmcmichael commented 4 years ago

That would mean max collateral line of 26959946667150639794667 * RAD and max gap of 105312291668557186697 * RAD

gbalabasquer commented 4 years ago

Quick question before approving and merging, have you check that indeed the gas costs have decreased? As far as I know it will only do it if we use optimization, otherwise it will do one SLOAD for each variable. Anyway I think we should deploy it optimized.

brianmcmichael commented 4 years ago

Before and after.

[PASS] test_exec() (gas: 129931)
[PASS] test_exec_multiple_ilks() (gas: 498117)
[PASS] test_exec_line_decrease_under_min_time() (gas: 86634)
[PASS] test_exec_not_enough_time_passed() (gas: 66442)
[PASS] test_ilk_not_enabled() (gas: 62224)

[PASS] test_exec() (gas: 129183)
[PASS] test_exec_multiple_ilks() (gas: 495334)
[PASS] test_exec_twice_failure() (gas: 127739)
[PASS] test_exec_line_decrease_under_min_time() (gas: 86212)
[PASS] test_exec_not_enough_time_passed() (gas: 65764)
[PASS] test_invalid_exec_ilk() (gas: 5141)
[PASS] test_ilk_not_enabled() (gas: 61799)