Commit 93cb636
authored
Enable Solidity IR Optimizations (#71)
This PR turns on the IR optimization flag when invoking the Solidity
compiler for the Safe token lock contracts. There are small gas savings
across the board (exception with small gas overhead when withdrawing 0
amounts, which we do not need to optimize for) and moderate code size
savings:
### Before
```
·----------------------------------|---------------------------|------------------|-----------------------------·
| Solc version: 0.8.23 · Optimizer enabled: true · Runs: 10000000 · Block limit: 30000000 gas │
···································|···························|··················|······························
| Methods │
··················|················|·············|·············|··················|·············|················
| Contract · Method · Min · Max · Avg · # calls · usd (avg) │
··················|················|·············|·············|··················|·············|················
| SafeTokenLock · lock · 44146 · 87946 · 74071 · 31 · - │
··················|················|·············|·············|··················|·············|················
| SafeTokenLock · recoverERC20 · - · - · 52052 · 1 · - │
··················|················|·············|·············|··················|·············|················
| SafeTokenLock · unlock · 52127 · 52151 · 52128 · 78 · - │
··················|················|·············|·············|··················|·············|················
| SafeTokenLock · withdraw · 24190 · 82140 · 68218 · 25 · - │
·-----------------|----------------|-------------|-------------|------------------|-------------|---------------·
```
```
SafeTokenLock 5089 bytes (limit is 24576)
```
### After
```
·----------------------------------|---------------------------|------------------|-----------------------------·
| Solc version: 0.8.23 · Optimizer enabled: true · Runs: 10000000 · Block limit: 30000000 gas │
···································|···························|··················|······························
| Methods │
··················|················|·············|·············|··················|·············|················
| Contract · Method · Min · Max · Avg · # calls · usd (avg) │
··················|················|·············|·············|··················|·············|················
| SafeTokenLock · lock · 43639 · 87439 · 73564 · 31 · - │
··················|················|·············|·············|··················|·············|················
| SafeTokenLock · recoverERC20 · - · - · 51886 · 1 · - │
··················|················|·············|·············|··················|·············|················
| SafeTokenLock · unlock · 51633 · 51657 · 51634 · 78 · - │
··················|················|·············|·············|··················|·············|················
| SafeTokenLock · withdraw · 24261 · 81598 · 67836 · 25 · - │
·-----------------|----------------|-------------|-------------|------------------|-------------|---------------·
```
```
SafeTokenLock 4536 bytes (limit is 24576)
```1 parent 2226f29 commit 93cb636
File tree
4 files changed
+27
-55
lines changed- test
4 files changed
+27
-55
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
38 | 38 | | |
39 | 39 | | |
40 | 40 | | |
| 41 | + | |
41 | 42 | | |
42 | 43 | | |
43 | 44 | | |
| |||
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
12 | | - | |
| 12 | + | |
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
963 | 963 | | |
964 | 964 | | |
965 | 965 | | |
966 | | - | |
967 | | - | |
968 | | - | |
969 | | - | |
970 | | - | |
971 | | - | |
972 | | - | |
973 | | - | |
974 | | - | |
975 | | - | |
976 | | - | |
977 | | - | |
978 | | - | |
979 | | - | |
980 | | - | |
981 | | - | |
| 966 | + | |
982 | 967 | | |
983 | 968 | | |
984 | 969 | | |
| |||
1012 | 997 | | |
1013 | 998 | | |
1014 | 999 | | |
| 1000 | + | |
| 1001 | + | |
| 1002 | + | |
| 1003 | + | |
| 1004 | + | |
| 1005 | + | |
| 1006 | + | |
| 1007 | + | |
| 1008 | + | |
| 1009 | + | |
| 1010 | + | |
| 1011 | + | |
| 1012 | + | |
| 1013 | + | |
| 1014 | + | |
1015 | 1015 | | |
1016 | 1016 | | |
1017 | 1017 | | |
| |||
0 commit comments