AAVE Process Quality Review

Score 84%

This is a AAVE Protocol Process Quality Audit completed on 18 June 2020. It was performed using the Process Audit process (version 0.3). It was updaed to v0.4 on 27 July 2020 and is documented here. The audit was performed by ShinkaRex of Caliburn Consulting. Check out our Telegram.

The final score of the audit is 84%, a strong pass. The breakdown of the scoring is in Scoring Appendix.

Disclaimer

This report is for informational purposes only and does not constitute investment advice of any kind, nor does it constitute an offer to provide investment advisory or other services. Nothing in this report shall be considered a solicitation or offer to buy or sell any security, future, option or other financial instrument or to offer or provide any investment advice or service to any person in any jurisdiction. Nothing contained in this report constitutes investment advice or offers any opinion with respect to the suitability of any security, and the views expressed in this report should not be taken as advice to buy, sell or hold any security. The information in this report should not be relied upon for the purpose of investing. In preparing the information contained in this report, we have not taken into account the investment needs, objectives and financial circumstances of any particular investor. This information has no regard to the specific investment objectives, financial situation and particular needs of any specific recipient of this information and investments discussed may not be suitable for all investors.

Any views expressed in this report by us were prepared based upon the information available to us at the time such views were written. Changed or additional information could cause such views to change. All information is subject to possible correction. Information may quickly become unreliable for various reasons, including changes in market conditions or economic circumstances.

Executing Code Verification

This section looks at the code deployed on the Mainnet that gets audited and its corresponding software repository. The document explaining these questions is here. This audit will answer the questions;

  1. Is the deployed code address(s) readily available? (Y/N)

  2. Is the code actively being used? (%)

  3. Are the Contract(s) Verified/Verifiable? (Y/N)

  4. Does the code match a tagged version in the code hosting platform? (%)

  5. Is the software repository healthy? (%)

Is the executing code address(s) readily available? (Y/N)

Answer: Yes

The contract addresses are in the “Deployed Contracts” section of the Developers docs, see Appendix: Deployed Code. They are available at Address 0x398eC7346DcD622eDc5ae82352F02bE94C62d119. This Audit only covers the contract Lending Pool contract, created on Jan 8, 2020.

They are available at Address as indicated in the . This Audit only covers the contract LendingPool.

Is the code actively being used? (%)

Answer: Yes

Activity is clearly in excess of 10 transactions a day, as indicated in the Appendix.

Percentage Score Guidance

100% More than 10 transactions a day

70% More than 10 transactions a week

40% More than 10 transactions a month

10% Less than 10 transactions a month

0% No activity

Are the Contract(s) Verified/Verifiable? (Y/N)

Answer: Yes

0x398eC7346DcD622eDc5ae82352F02bE94C62d119 is the Etherscan verified contract address.

Does the code match a tagged version on a code hosting platform? (%)

Answer: 100%

In fact, I found some differences in the open zeppelin libraries but I assume they were using earlier versions. The differences do not appear relevant. The AAVE developed code matches 100%. There is no release zip as the GitHub repository seems to exist just for the presentation of the final contracts. In fact development was done on private repositories.

GitHub address : https://github.com/aave/aave-protocol/tree/master/contracts

Deployed contracts in the following file;

Is development software repository healthy? (Y/N)

Answer: 70%

A Clearly the AAVE was not developed in this GitHub, see Appendix: Healthy GitHub. In fact it appears by looking at the 34 commits it appears that this GitHub was created as the protocol neared completion as a neat place to present the finished product. The OZ Audit report mentions they use a private repository. For this reason we give a score of 70%. We believe the healthy repository exists but we cannot see it and the auditor prefers public development.

​How to improve this score

Ensure there is a clearly labelled repository holding all the contracts, documentation and tests for the deployed code. Continue to test and perform other verification activities after deployment, including routine maintenance updating to new releases of testing and deployment tools.

Documentation

This section looks at the software documentation. The document explaining these questions is here.

Required questions are;

  1. Is there a whitepaper? (Y/N)

  2. Are the basic application requirements documented? (Y/N)

  3. Do the requirements fully (100%) cover the deployed contracts? (%)

  4. Are there sufficiently detailed comments for all functions within the deployed contract code (%)

  5. Is it possible to trace software requirements to the implementation in code (%)

Is there a whitepaper? (Y/N)

Answer: Yes

Location: https://docs.aave.com/developers/

Are the basic application requirements documented? (Y/N)

Answer: Yes

Location: https://docs.aave.com/developers/

Do the requirements fully (100%) cover the deployed contracts? (%)

Answer 100%

All of the external functions of LendingPool.sol were commented in the GitBook.

​Are there sufficiently detailed comments for all functions within the deployed contract code (%)

Answer 75%

Code examples are in the Appendix: Example Code. As per the Software lines of code Appendix: Software Lines of Code, there is 65% commenting to code. Especially when considering the developers gitbook commenting, the comments in the code are very good.

How to improve this score

This score can improve by adding comments to the deployed code such that it comprehensively covers the code. For guidance, refer to the SecurEth Software Requirements.

Is it possible to trace software requirements to the implementation in code (%)

Answer 60%

​The gitbook places plain english explanations directly with the functions being called. It details the variables and places everything in context with the design requirements of the design. It give traceability at the function level, which is very useful but not at aerospace standards as yet

How to improve this score

This score can improve by adding traceability from requirements to code such that it is clear where each requirement is coded. For reference, check the SecurEth guidelines on traceability.

Testing

This section looks at the software testing available. It is explained in this document. This section answers the following questions;

  1. Full test suite (Covers all the deployed code) (%)

  2. Code coverage (Covers all the deployed lines of code, or explains misses) (%)

  3. Scripts and instructions to run the tests (Y/N)

  4. Packaged with the deployed code (Y/N)

  5. Report of the results (%)

  6. Formal Verification test done (%)

  7. Stress Testing environment (%)

Is there a Full test suite? (%)

Answer : 100%

​ There are a significant number and lines of tests in the test directory. There are over 30 test script files, scenario tests and others. As per Appendix: Software Lines of Code, there is a 231% test to code ration. The test reports indicate significant test coverage. There are defined scenarios being tested.

Code coverage (Covers all the deployed lines of code, or explains misses) (%)

Answer : 94%

The results of the code coverage tests are in the coverage directory. The Appendix: Coverage Report indicate a 94% statement coverage. The report coverage of statements, lines, functions and branches. It is not 100% coverage, but the results are high.

​Scripts and instructions to run the tests (Y/N)

Answer : No

​No scripts for testing were evident. There were no instructions in the Readme. There are json files for the build, but there were no test scripts for the .ts files.

How to improve this score

Add the scripts to the repository and ensure they work. Ask an outsider to create the environment and run the tests. Improve the scripts and docs based on their feedback.

Packaged with the deployed code (Y/N)

Answer : Yes

​Tests are in the GitHub test directory.

Report of the results (%)

Answer : 70%

The results of the coverage tests are documented in the coverage directory. The test results summary is in this Appendix: Coverage Report. It describes the resulting coverage for statements, branches and functions. There are no explanations of misses or test process.

How to improve this score

Add a report with the results. The test scripts should generate the report or elements of it.

Formal Verification test done (%)

Answer : 0%

No evidence of Formal Validation was found. This is still a rare type of test.

Stress Testing environment (%)

Answer : 100%

The addresses of the test network deployments are in the deployed contract sections, see Appendix: Testing Networks. Both the kovan and ropsten networks should recent activity indicating their continued use.

​Audits

Answer : 75%

​Two audits were performed before deployment. These audits were on private repositories. Each audit found multiple issues and the bulk were fixed. In both audits the code was considered a work in progress. It does not seem the audits were on the deployed code. As the repositories are private, we cannot know the difference between the audited code and the deployed code. This is a concern.

AAVE meets the standards for a 100% score as they have multiple audits with public results and fixes that were implemented. However, the auditor does not know what code was audited and how similar the deployed code is to the result of the audit. Therefore the score is 75%.

  1. Multiple Audits performed before deployment and results public and implemented or not required (100%)

  2. Single audit performed before deployment and results public and implemented or not required (90%)

  3. Audit(s) performed after deployment and no changes required. Audit report is public. (70%)

  4. No audit performed (20%)

  5. Audit Performed after deployment, existence is public, report is not public and no improvements deployed (0%)

Appendices

Author Details

The author of this audit is Rex of Caliburn Consulting.

Email : rex@caliburnc.com Twitter : @ShinkaRex

I started with Ethereum just before the DAO and that was a wonderful education. It showed the importance of code quality. The second Parity hack also showed the importance of good process. Here my aviation background offers some value. Aerospace knows how to make reliable code using quality processes.

I was coaxed to go to EthDenver 2017 and there I started SecuEth.org with Bryant and Roman. We created guidelines on good processes for blockchain code development. We got EthFoundation funding to assist in their development.

Process Quality Audits are an extension of the SecurEth guidelines that will further increase the quality processes in Solidity and Vyper development.

Career wise I am a business development for an avionics supplier.

Scoring Appendix

​Deployed Code Appendix

​Code Used Appendix

​Healthy Repository

Example Code Appendix

/**
* @title LendingPool contract
* @notice Implements the actions of the LendingPool, and exposes accessory methods to fetch the users and reserve data
* @author Aave
**/
contract LendingPool is ReentrancyGuard, VersionedInitializable {
using SafeMath for uint256;
using WadRayMath for uint256;
using Address for address;
LendingPoolAddressesProvider public addressesProvider;
LendingPoolCore public core;
LendingPoolDataProvider public dataProvider;
LendingPoolParametersProvider public parametersProvider;
IFeeProvider feeProvider;
/**
* @dev emitted on deposit
* @param _reserve the address of the reserve
* @param _user the address of the user
* @param _amount the amount to be deposited
* @param _referral the referral number of the action
* @param _timestamp the timestamp of the action
**/
event Deposit(
address indexed _reserve,
address indexed _user,
uint256 _amount,
uint16 indexed _referral,
uint256 _timestamp
);
/**
* @dev emitted during a redeem action.
* @param _reserve the address of the reserve
* @param _user the address of the user
* @param _amount the amount to be deposited
* @param _timestamp the timestamp of the action
**/
/**
* @dev this function is invoked by the proxy contract when the LendingPool contract is added to the
* AddressesProvider.
* @param _addressesProvider the address of the LendingPoolAddressesProvider registry
**/
function initialize(LendingPoolAddressesProvider _addressesProvider) public initializer {
addressesProvider = _addressesProvider;
core = LendingPoolCore(addressesProvider.getLendingPoolCore());
dataProvider = LendingPoolDataProvider(addressesProvider.getLendingPoolDataProvider());
parametersProvider = LendingPoolParametersProvider(
addressesProvider.getLendingPoolParametersProvider()
);
feeProvider = IFeeProvider(addressesProvider.getFeeProvider());
}
/**
* @dev deposits The underlying asset into the reserve. A corresponding amount of the overlying asset (aTokens)
* is minted.
* @param _reserve the address of the reserve
* @param _amount the amount to be deposited
* @param _referralCode integrators are assigned a referral code and can potentially receive rewards.
**/
function deposit(address _reserve, uint256 _amount, uint16 _referralCode)
external
payable
nonReentrant
onlyActiveReserve(_reserve)
onlyUnfreezedReserve(_reserve)
onlyAmountGreaterThanZero(_amount)
{
AToken aToken = AToken(core.getReserveATokenAddress(_reserve));
bool isFirstDeposit = aToken.balanceOf(msg.sender) == 0;
core.updateStateOnDeposit(_reserve, msg.sender, _amount, isFirstDeposit);
//minting AToken to user 1:1 with the specific exchange rate
aToken.mintOnDeposit(msg.sender, _amount);
//transfer to the core contract
core.transferToReserve.value(msg.value)(_reserve, msg.sender, _amount);
//solium-disable-next-line
emit Deposit(_reserve, msg.sender, _amount, _referralCode, block.timestamp);
}

SLOC Appendix

Solidity Contracts

Language

Files

Lines

Blanks

Comments

Code

Complexity

Solidity

34

6308

844

2159

3305

270

Comments to Code 2159/ 3305 = 65%

TypeScript Tests

Language

Files

Lines

Blanks

Comments

Code

Complexity

TypeScript

21

5816

1052

91

4673

371

JSON

11

2981

19

0

2962

0

Tests to Code (4673+2962)) / 3305 = 231%

Coverage Report Appendix

Testing Networks Appendix

Ropstein Network
Kovan Test Network