Skip to content
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

doc: internal audit ref AIP-1/Bonding #180

Merged
merged 82 commits into from
Aug 3, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
82 commits
Select commit Hold shift + click to select a range
abe2a98
chore: update tokenomics implementation address
kupermind Jul 4, 2024
573d6e9
Merge pull request #161 from valory-xyz/addressing_issue_26
kupermind Jul 4, 2024
aa49aaf
Merge pull request #162 from valory-xyz/update_tokenomics
DavidMinarsch Jul 4, 2024
18f8245
doc: internal audit after fixing C4A
Jul 5, 2024
dba07d1
refactor: minimal changes according to internal audit findings
kupermind Jul 5, 2024
45089c5
fix: correcting removed nominees value adjustments after not issuing …
kupermind Jul 6, 2024
7eedd6c
doc: adding important comment for nominee removal
kupermind Jul 6, 2024
8805e41
refactor: addressing issue L-08
kupermind Jul 12, 2024
fa2c187
doc: adding deployment procedure for Tokenomics 1.2.0
kupermind Jul 12, 2024
c0064d1
Merge pull request #169 from valory-xyz/bridge_testing
kupermind Jul 12, 2024
af692db
Merge pull request #168 from valory-xyz/v1.2.2-internal-audit
kupermind Jul 12, 2024
9f29a7b
Merge pull request #166 from valory-xyz/addressing_issues_56_27
kupermind Jul 12, 2024
3108ab6
Merge pull request #165 from valory-xyz/addressing_issue_37
kupermind Jul 12, 2024
28f904b
Merge pull request #164 from valory-xyz/addressing_issue_61
kupermind Jul 12, 2024
8eb3685
Merge pull request #163 from valory-xyz/addressing_issue_67
kupermind Jul 12, 2024
f3fad06
Merge pull request #160 from valory-xyz/addressing_issues_32_5
kupermind Jul 12, 2024
61fb1a7
Merge pull request #159 from valory-xyz/addressing_issues_45_4
kupermind Jul 12, 2024
f1ae5a9
Merge pull request #158 from valory-xyz/addressing_issue_29
kupermind Jul 12, 2024
c41d402
Merge pull request #157 from valory-xyz/address_issue_20
kupermind Jul 12, 2024
949e7a7
Merge branch 'main' into addressing_issue_22
kupermind Jul 12, 2024
a423fb7
chore: updating Dispenser ABI
kupermind Jul 12, 2024
660e67c
test: splitting two time-dependent tests
kupermind Jul 12, 2024
10bdd73
Merge pull request #156 from valory-xyz/addressing_issue_22
DavidMinarsch Jul 12, 2024
4d2f266
doc: catch up on changes
Jul 15, 2024
8b49e18
chore: Tokenomics V1.2 deployment procedure update
kupermind Jul 15, 2024
ea67131
chore: diepenser deployment script
kupermind Jul 15, 2024
3c5c064
chore: deployment scripts
kupermind Jul 15, 2024
5291640
chore: gitleaksignore
kupermind Jul 15, 2024
6a6dad9
chore: gitleaksignore
kupermind Jul 15, 2024
abeb2f6
Merge pull request #171 from valory-xyz/catchup_changes
DavidMinarsch Jul 15, 2024
58273b3
Merge pull request #172 from valory-xyz/deployment_v1.2
DavidMinarsch Jul 15, 2024
7cf3cd1
chore: adding base scripts
kupermind Jul 17, 2024
78ba6ea
chore: gitleaksignore
kupermind Jul 17, 2024
cfe4b80
chore: adding celo deployment scripts
kupermind Jul 17, 2024
3781d38
chore: gitleaksignore
kupermind Jul 17, 2024
b439787
chore: gitleaksignore
kupermind Jul 17, 2024
80c9b27
Merge pull request #173 from valory-xyz/base_scripts
kupermind Jul 18, 2024
a65ea20
chore: adding staking claiming events info
kupermind Jul 18, 2024
cdbe1f1
Merge pull request #174 from valory-xyz/claiming_events
DavidMinarsch Jul 19, 2024
184fb9d
chore: adding unit types and ids into dev incentives event
kupermind Jul 19, 2024
ff13c51
Merge pull request #175 from valory-xyz/event_dev_incentives
kupermind Jul 19, 2024
5ee1475
chore: updating ABI and scripts
kupermind Jul 19, 2024
e09cdb5
Merge pull request #176 from valory-xyz/dispenser_deployment
DavidMinarsch Jul 19, 2024
e9945cd
chore: staking deployment scripts
kupermind Jul 19, 2024
583c448
chore: gitleaksignore
kupermind Jul 19, 2024
d3c5ea3
chore: updating globals
kupermind Jul 19, 2024
d79d621
chore: deploying staking contracts
kupermind Jul 19, 2024
b92c814
chore: deploy target dispensers
DavidMinarsch Jul 19, 2024
a1fb94f
chore: prepp staking/deploy_09
DavidMinarsch Jul 19, 2024
b8f1fe4
chore: continue with deployment scripts
kupermind Jul 20, 2024
edaf3aa
Merge branch 'staking_deployment' of github.com:valory-xyz/autonolas-…
kupermind Jul 20, 2024
fbab175
chore: linter
kupermind Jul 20, 2024
5da0726
chore: gitleaksignore
kupermind Jul 20, 2024
28a4c20
chore: linter
kupermind Jul 20, 2024
b616524
chore: adding scripts to update owners on L2
kupermind Jul 22, 2024
05c1937
chore: gitleaksignore
kupermind Jul 22, 2024
de29c4c
chore: gitleaksignore
kupermind Jul 22, 2024
2ac921b
chore: linter
kupermind Jul 22, 2024
be06fac
chore: adding contract addresses into configuration files
kupermind Jul 22, 2024
b74f36b
chore: updating static audit
kupermind Jul 22, 2024
5e43d54
chore: static audit
kupermind Jul 22, 2024
b946818
chore: gitleaksignore
kupermind Jul 22, 2024
7208470
chore: space
kupermind Jul 22, 2024
f3c9b3f
Merge pull request #178 from valory-xyz/staking_deployment2
DavidMinarsch Jul 22, 2024
7199f38
chore: updating static audit script
kupermind Jul 23, 2024
9cc1126
Merge pull request #177 from valory-xyz/staking_deployment
DavidMinarsch Jul 23, 2024
a5f5c34
doc: internal audit ref AIP-1/Bonding
Jul 26, 2024
44d9345
doc: updating changelog
kupermind Jul 29, 2024
a10e6b8
refactor: addressing interim internal audit findings
kupermind Jul 29, 2024
6f9f16f
refactor: tokenomics dev incentives debugging
kupermind Jul 31, 2024
f363668
Merge pull request #181 from valory-xyz/chg
kupermind Aug 1, 2024
7a72025
test: fixing tokenomics tests
kupermind Aug 1, 2024
4f03ded
refactor: making code more readable
kupermind Aug 1, 2024
1d079de
test: forge test
kupermind Aug 1, 2024
fbadbbb
chore: comments
kupermind Aug 1, 2024
ecb362b
chore: changing internal audit number
kupermind Aug 2, 2024
c76a04a
chore: merging main
kupermind Aug 2, 2024
23e803b
chore: making the map public
kupermind Aug 2, 2024
88f30e8
doc: re-audit
Aug 2, 2024
1417b2d
test: adding part of test
kupermind Aug 2, 2024
38ebd10
Merge pull request #183 from valory-xyz/v1.3.0-internal-audit2
DavidMinarsch Aug 3, 2024
927a3b8
Merge pull request #182 from valory-xyz/aip1_3
DavidMinarsch Aug 3, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions audits/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,7 @@ An internal audit with a focus on depository implementation v.1.0.1 is located i

An internal audit with a focus on PoAA Staking is located in this folder: [internal audit 4](https://github.com/valory-xyz/autonolas-tokenomics/blob/main/audits/internal4).

An internal audit with a focus on AIP-1 (bonding) is located in this folder: [internal audit 5](https://github.com/valory-xyz/autonolas-tokenomics/blob/main/audits/internal5).

### External audit
Audit reports: [v1](https://github.com/valory-xyz/autonolas-tokenomics/blob/main/audits/Autonolas%20Tokenomics%20Smart%20Contract%20Audit.pdf) and [v2](https://sourcehat.com/audits/AutonolasTokenomics/).
61 changes: 61 additions & 0 deletions audits/internal5/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
# Internal audit of autonolas-tokenomics
The review has been performed based on the contract code in the following repository:<br>
`https://github.com/valory-xyz/autonolas-tokenomics` <br>
commit: `12101b49a2dcdc7a7378f416ddb1611e10459b67` or `tag: v1.3.0-pre-internal-audit`<br>

## Objectives
The audit focused on contracts related to AIP-1 implementation (Bonding) in this repo.

### Flatten version
Flatten version of contracts. [contracts](https://github.com/valory-xyz/autonolas-tokenomics/blob/main/audits/internal5/analysis/contracts)

### Coverage: N/A
In this commit, the tests are in the process of being reworked and therefore the coverage section does not make sense.

### Storage and proxy
Using sol2uml tools: https://github.com/naddison36/sol2uml <br>
```
npm link sol2uml --only=production
sol2uml storage contracts/ -f png -c Tokenomics -o audits/internal4/analysis/storage
Generated png file audits/internal5/analysis/storage/Tokenomics.png
```
[Tokenomics-storage](https://github.com/valory-xyz/autonolas-tokenomics/blob/main/audits/internal5/analysis/storage/Tokenomics.png) <br>
current deployed: <br>
[Tokenomics-storage-current](https://github.com/valory-xyz/autonolas-tokenomics/blob/main/audits/internal4/analysis/storage/Tokenomics.png) <br>
The new slot allocation for Tokenomics (critical as proxy pattern) does not affect the previous one.

### Security issues.
#### Problems found instrumentally
Several checks are obtained automatically. They are commented. Some issues found need to be fixed. <br>
All automatic warnings are listed in the following file, concerns of which we address in more detail below: <br>
[slither-full](https://github.com/valory-xyz/autonolas-tokenomics/blob/main/audits/internal5/analysis/slither_full.txt) <br>

#### Issue
1. minOLASLeftoverAmount never setupped/updated
```
// Minimum amount of supply such that any value below is given to the bonding account in order to close the product
uint256 public minOLASLeftoverAmount;
```
2. Reentrancy after ERC721 "safe" mint in deposit
```
External calls:
- _safeMint(msg.sender,bondId) (Depository-flatten.sol#891)
- require(bool,string)(ERC721TokenReceiver(to).onERC721Received(msg.sender,address(0),id,) == ERC721TokenReceiver.onERC721Received.selector,UNSAFE_RECIPIENT) (Depository-flatten.sol#461-465)
After adding _safeMint(msg.sender, bondId), it became clearly susceptible reentrancy attack.
We need to add explicit protection against reentrancy.
```
#### Genaral notes: more tests need to be done, needed re-audit later
```
trackServiceDonations requires a large number of tests and coverage of all scenarios.
```
#### Notes for discussion: epsilonRate
```
in this implementation epsilonRate is deprecated and simply not used. perhaps it makes sense (?) to use this dimensionless coefficient as a limiter.
// The IDF depends on the epsilonRate value, idf = 1 + epsilonRate, and epsilonRate is bound by 17 with 18 decimals
new
// IDF = 1 + normalized booster
idf = 1e18 + discountBooster;
maybe idf = min(1e18 + discountBooster, 1e18 + epsilonRate)
Moreover, according to calculations discountBooster <= 1e18 << max(epsilonRate)
```

Loading
Loading