Skip to content

Q-AJN-8: Old Version of Solidity#73

Merged
grandizzy merged 1 commit intomainfrom
quantstamp-ajn-8
May 8, 2023
Merged

Q-AJN-8: Old Version of Solidity#73
grandizzy merged 1 commit intomainfrom
quantstamp-ajn-8

Conversation

@grandizzy
Copy link
Copy Markdown
Contributor

@grandizzy grandizzy commented May 8, 2023

Description of change

High level

  • Update solidity version from 0.8.16 to 0.8.18
    • The contracts are currently set to be compiled with Solidity version 0.8.16 according to their pragma statements. However, an important bug was fixed in 0.8.17 .

Description of bug or vulnerability and solution

Contract size

Pre Change

| Contract              | Size (kB) | Margin (kB) |
|-----------------------|-----------|-------------|
| AjnaToken             | 8.14      | 16.436      |
| BurnWrappedAjna       | 5.277     | 19.299      |
| GrantFund             | 19.422    | 5.154       |
| SigUtils              | 0.549     | 24.027      |
| Maths                 | 0.142     | 24.434      |

Post Change

| Contract              | Size (kB) | Margin (kB) |
|-----------------------|-----------|-------------|
| AjnaToken             | 8.14      | 16.436      |
| BurnWrappedAjna       | 5.277     | 19.299      |
| GrantFund             | 19.402    | 5.174       |
| SigUtils              | 0.549     | 24.027      |
| Maths                 | 0.142     | 24.434      |

Gas usage

Pre Change

| src/grants/GrantFund.sol:GrantFund contract |                 |        |        |        |         |
|---------------------------------------------|-----------------|--------|--------|--------|---------|
| Deployment Cost                             | Deployment Size |        |        |        |         |
| 4739351                                     | 23668           |        |        |        |         |
| Function Name                               | min             | avg    | median | max    | # calls |
| claimDelegateReward                         | 1407            | 57897  | 58540  | 65340  | 341     |
| executeExtraordinary                        | 7387            | 39097  | 39802  | 95823  | 11      |
| executeStandard                             | 9009            | 30094  | 38140  | 47894  | 8       |
| findMechanismOfProposal                     | 613             | 2043   | 799    | 4719   | 3       |
| fundTreasury                                | 8001            | 45104  | 44641  | 65872  | 29      |
| fundingVote                                 | 1584            | 106444 | 106376 | 409345 | 356     |
| getDelegateReward                           | 2975            | 3465   | 2975   | 5017   | 5       |
| getDistributionId                           | 374             | 410    | 374    | 2374   | 818     |
| getDistributionPeriodInfo                   | 1046            | 1743   | 1046   | 5046   | 86      |
| getExtraordinaryProposalInfo                | 992             | 992    | 992    | 992    | 4       |
| getExtraordinaryProposalSucceeded           | 2245            | 2664   | 2740   | 3008   | 3       |
| getFundedProposalSlate                      | 1133            | 1309   | 1368   | 1368   | 4       |
| getFundingPowerVotes                        | 15500           | 15688  | 15751  | 15751  | 4       |
| getFundingVotesCast                         | 1577            | 2317   | 2317   | 3057   | 2       |
| getMinimumThresholdPercentage               | 471             | 629    | 471    | 2471   | 16      |
| getProposalInfo                             | 980             | 980    | 980    | 980    | 110     |
| getSlateHash                                | 872             | 880    | 884    | 884    | 3       |
| getSliceOfNonTreasury                       | 1577            | 3743   | 1577   | 8077   | 3       |
| getSliceOfTreasury                          | 781             | 1781   | 1781   | 2781   | 2       |
| getTopTenProposals                          | 1187            | 2451   | 2363   | 3304   | 16      |
| getVoterInfo                                | 1002            | 1002   | 1002   | 1002   | 5       |
| getVotesExtraordinary                       | 764             | 7665   | 7681   | 8755   | 887     |
| getVotesFunding                             | 2389            | 6565   | 2797   | 11518  | 15      |
| getVotesScreening                           | 5313            | 5352   | 5347   | 6489   | 697     |
| hasVotedExtraordinary                       | 683             | 1683   | 1683   | 2683   | 2       |
| hashProposal                                | 3843            | 3843   | 3843   | 3843   | 85      |
| proposeExtraordinary                        | 4731            | 63309  | 82166  | 86505  | 18      |
| proposeStandard                             | 4709            | 78463  | 82561  | 82900  | 81      |
| screeningVote                               | 1847            | 44636  | 37699  | 399146 | 375     |
| screeningVotesCast                          | 663             | 1329   | 663    | 2663   | 3       |
| startNewDistributionPeriod                  | 617             | 48521  | 53163  | 75597  | 20      |
| state                                       | 1337            | 4534   | 3934   | 7331   | 20      |
| treasury                                    | 396             | 396    | 396    | 396    | 12      |
| updateSlate                                 | 971             | 58653  | 69985  | 318329 | 17      |
| voteExtraordinary                           | 565             | 29360  | 29458  | 31424  | 884     |


| src/token/AjnaToken.sol:AjnaToken contract |                 |       |        |       |         |
|--------------------------------------------|-----------------|-------|--------|-------|---------|
| Deployment Cost                            | Deployment Size |       |        |       |         |
| 2200269                                    | 13095           |       |        |       |         |
| Function Name                              | min             | avg   | median | max   | # calls |
| DOMAIN_SEPARATOR                           | 397             | 397   | 397    | 397   | 11      |
| allowance                                  | 778             | 778   | 778    | 778   | 2       |
| approve                                    | 24622           | 24622 | 24622  | 24622 | 1       |
| balanceOf                                  | 584             | 1162  | 584    | 2584  | 38      |
| burn                                       | 23087           | 23087 | 23087  | 23087 | 1       |
| decimals                                   | 245             | 245   | 245    | 245   | 1       |
| delegate                                   | 26825           | 54145 | 69697  | 73004 | 9       |
| delegates                                  | 576             | 576   | 576    | 576   | 6       |
| getPastVotes                               | 1244            | 1600  | 1570   | 2018  | 4       |
| getVotes                                   | 612             | 1368  | 1064   | 2612  | 33      |
| name                                       | 3249            | 3249  | 3249   | 3249  | 1       |
| permit                                     | 51347           | 51347 | 51347  | 51347 | 1       |
| symbol                                     | 3291            | 3291  | 3291   | 3291  | 1       |
| totalSupply                                | 372             | 1705  | 2372   | 2372  | 3       |
| transfer                                   | 594             | 621   | 621    | 649   | 2       |
| transferFrom                               | 24099           | 26819 | 26819  | 29539 | 2       |
| transferFromWithPermit                     | 24390           | 25502 | 25502  | 26614 | 2       |

Post Change

|---------------------------------------------|-----------------|--------|--------|--------|---------|
| Deployment Cost                             | Deployment Size |        |        |        |         |
| 4729342                                     | 23618           |        |        |        |         |
| Function Name                               | min             | avg    | median | max    | # calls |
| claimDelegateReward                         | 1407            | 57738  | 58544  | 65344  | 272     |
| executeExtraordinary                        | 7387            | 44244  | 13091  | 95827  | 5       |
| executeStandard                             | 9009            | 30094  | 38140  | 47894  | 8       |
| findMechanismOfProposal                     | 613             | 2043   | 799    | 4719   | 3       |
| fundTreasury                                | 8001            | 45104  | 44641  | 65872  | 29      |
| fundingVote                                 | 1584            | 106482 | 106384 | 409433 | 287     |
| getDelegateReward                           | 2979            | 3469   | 2979   | 5021   | 5       |
| getDistributionId                           | 374             | 418    | 374    | 2374   | 673     |
| getDistributionPeriodInfo                   | 1046            | 1805   | 1046   | 5046   | 79      |
| getExtraordinaryProposalInfo                | 992             | 992    | 992    | 992    | 3       |
| getExtraordinaryProposalSucceeded           | 2247            | 2668   | 2744   | 3014   | 3       |
| getFundedProposalSlate                      | 1133            | 1309   | 1368   | 1368   | 4       |
| getFundingPowerVotes                        | 15502           | 15690  | 15753  | 15753  | 4       |
| getFundingVotesCast                         | 1577            | 2317   | 2317   | 3057   | 2       |
| getMinimumThresholdPercentage               | 471             | 723    | 471    | 2471   | 9       |
| getProposalInfo                             | 980             | 980    | 980    | 980    | 110     |
| getSlateHash                                | 872             | 880    | 884    | 884    | 3       |
| getSliceOfNonTreasury                       | 1579            | 4829   | 4829   | 8079   | 2       |
| getSliceOfTreasury                          | 783             | 1783   | 1783   | 2783   | 2       |
| getTopTenProposals                          | 1187            | 2451   | 2363   | 3304   | 16      |
| getVoterInfo                                | 1002            | 1002   | 1002   | 1002   | 5       |
| getVotesExtraordinary                       | 764             | 7569   | 7681   | 8755   | 120     |
| getVotesFunding                             | 2389            | 6567   | 2797   | 11522  | 15      |
| getVotesScreening                           | 5313            | 5354   | 5347   | 6489   | 559     |
| hasVotedExtraordinary                       | 683             | 1683   | 1683   | 2683   | 2       |
| hashProposal                                | 3843            | 3843   | 3843   | 3843   | 72      |
| proposeExtraordinary                        | 4731            | 53882  | 86337  | 86507  | 12      |
| proposeStandard                             | 4709            | 78098  | 82889  | 82889  | 74      |
| screeningVote                               | 1847            | 45864  | 40381  | 399146 | 306     |
| screeningVotesCast                          | 663             | 1329   | 663    | 2663   | 3       |
| startNewDistributionPeriod                  | 617             | 48523  | 53165  | 75599  | 20      |
| state                                       | 1337            | 4040   | 3346   | 7333   | 15      |
| treasury                                    | 396             | 396    | 396    | 396    | 6       |
| updateSlate                                 | 971             | 58656  | 69987  | 318349 | 17      |
| voteExtraordinary                           | 565             | 28719  | 29458  | 31424  | 117     |


| src/token/AjnaToken.sol:AjnaToken contract |                 |       |        |       |         |
|--------------------------------------------|-----------------|-------|--------|-------|---------|
| Deployment Cost                            | Deployment Size |       |        |       |         |
| 2200269                                    | 13095           |       |        |       |         |
| Function Name                              | min             | avg   | median | max   | # calls |
| DOMAIN_SEPARATOR                           | 397             | 397   | 397    | 397   | 11      |
| allowance                                  | 778             | 778   | 778    | 778   | 2       |
| approve                                    | 24622           | 24622 | 24622  | 24622 | 1       |
| balanceOf                                  | 584             | 1162  | 584    | 2584  | 38      |
| burn                                       | 23087           | 23087 | 23087  | 23087 | 1       |
| decimals                                   | 245             | 245   | 245    | 245   | 1       |
| delegate                                   | 26825           | 54145 | 69697  | 73004 | 9       |
| delegates                                  | 576             | 576   | 576    | 576   | 6       |
| getPastVotes                               | 1244            | 1600  | 1570   | 2018  | 4       |
| getVotes                                   | 612             | 1368  | 1064   | 2612  | 33      |
| name                                       | 3249            | 3249  | 3249   | 3249  | 1       |
| permit                                     | 51347           | 51347 | 51347  | 51347 | 1       |
| symbol                                     | 3291            | 3291  | 3291   | 3291  | 1       |
| totalSupply                                | 372             | 1705  | 2372   | 2372  | 3       |
| transfer                                   | 594             | 621   | 621    | 649   | 2       |
| transferFrom                               | 24099           | 26819 | 26819  | 29539 | 2       |
| transferFromWithPermit                     | 24390           | 25502 | 25502  | 26614 | 2       |

- update pragmas to 0.8.18
- use preverando instead difficulty (need a version of foundry containing foundry-rs/foundry#4856)
@grandizzy grandizzy added the enhancement New feature or request label May 8, 2023
Copy link
Copy Markdown
Contributor

@EdNoepel EdNoepel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Copy Markdown
Contributor

@prat-gpt prat-gpt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

Copy link
Copy Markdown
Collaborator

@MikeHathaway MikeHathaway left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@grandizzy grandizzy merged commit 88c81b8 into main May 8, 2023
@grandizzy grandizzy deleted the quantstamp-ajn-8 branch May 8, 2023 11:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants