bZx Network Process Quality Review

Score 17%

This is a bZx Network Process Quality Audit completed on July 21, 2020. It was performed using the Process Audit process (version 0.3) but then updated to 0.4 on 27 July due to new scoring weights. Version 0.4 is documented here. The audit was performed by ShinkaRex of Caliburn Consulting. Check out our Telegram.

This audit is special for a few reasons. I picked this company for an audit as it had lost funds several months before. I wanted to test if my process executed after the fact would detect an underlying area of concern. The answer of this question is Yes.

The final score of the audit is 17%, very low. 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 deployed code address(s) readily available? (Y/N)

Answer: No

There is no contract address visible on the website, gitbook or the GitHub. I found some address's for Fulcrum on State of the Dapps but I could not correlate the contracts with those on the GiitHub.

How to improve this score

Make the ethereum addresses of the smart contract utilized by your application available on either your website or your github (in the README for instance). Ensure the address is up to date. This is a very important question wrt to the final score.

Is the code actively being used? (%)

Answer: 0%

This is low for a few reasons. First I do not have the address so I cannot get the analytics. Second the contract was paused after funds were drained.

Activity is 0 transactions a day.

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: No

Since we have no address, we cannot determine if it is Verfified.

How to improve this score

Ensure that the deployed code is verified as described in this article for Etherscan or ETHPM. Improving this score may require redeployment.

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

Answer: 0%

Since we have no code, we cannot perform a match.

GitHub address : https://github.com/bZxNetwork/bZx-monorepo

Deployed contracts in the following file (Not available)

Matching Repository:

How to improve this score

Ensure there is a clearly labelled repository holding all the contracts, documentation and tests for the deployed code. Ensure an appropriately labeled tag exists corresponding to deployment dates. Release tags are clearly communicated.

Is development software repository healthy? (%)

Answer: 100%

With over 2000 commits and 17 branches, the repository is healthy, as indicated in the Appendix.

GitHub address : https://github.com/bZxNetwork/bZx-monorepo

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: No

While the whitepaper is mentioned in the history description on the website, with the date. I could not find the actual text.

How to improve this score

Ensure the white paper is available for download from your website or at least the software repository. Ideally update the whitepaper to meet the capabilities of your present application.

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

Answer: No

The location in the docs.bzx.network is being updated with the new contracts, so the previous content was overwritten. However there is a docs directory in the repo which should have the old docs. Instead it is empty.

How to improve this score

Write the document based on the deployed code. For guidance, refer to the SecurEth System Description Document.

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

Answer: 0%

See answer above.

How to improve this score

This score can improve by adding content to the requirements document such that it comprehensively covers the requirements. For guidance, refer to the SecurEth System Description Document . Using tools that aid traceability detection will help.

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

Answer: 40%

There is good documentation of the function definitions of bZx.sol but many other functions have no commenting. Code examples are in the Appendix. As per the SLOC, there is 30% commenting to code.

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: 0%

With no requirements and minimal commenting, tracing is impossible.

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: 80%

There is strong evidence of a largely complete test regime. There is a 278% test to code ratio as per the Appendix.

How to improve this score

This score can improve by adding tests to fully cover the code. Document what is covered by traceability or test results in the software repository.

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

Answer: 0%

There is no evidence that code coverage was tracked or used as a goal

How to improve this score

This score can improve by adding tests achieving full code coverage. A clear report and scripts in the software repository will guarantee a high score.

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

Answer: Yes

In bZx\bZx-monorepo-development\scripts there is evidence of test scripts with build scripts

Packaged with the deployed code (Y/N)

Answer: Yes

The tests are in the repository with the code that appeared to be deployed.

Report of the results (%)

Answer: 0%

There is no evidence of a test report. The Github repository does not have tools to track coverage active.

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%

There is no evidence of Formal Verification. But in their defense, this is still a rare test.

Stress Testing environment (%)

Answer: 0%

There is no evidence of an active test network on Kovan or Ropstein or elsewhere.

Audits

Answer: 0%

As the code address is not available, we cannot verify if the audits are relevant to the code being executed by the users. For this reason, the audit score is 0.

There is am audit, done by ZK Labs. The audit took place in Sept 2018, a few months before the initial deployment in Feb 2019. The audit did not find any major bugs requiring updates though it did caution them in updating their contracts.

  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. No address for executing code available or 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

GitHub Healthy Appendix

Example Code Appendix

Example of Good commenting (.BZx.sol)

// This interface is meant to used with the deployed BZxProxy contract (proxy/BZxProxy.sol) address.
// js example: const bZx = await BZx.at(BZxProxy.address);
contract BZx is BZxStorage {
/// @dev Takes the order as trader
/// @param orderAddresses Array of order's makerAddress, loanTokenAddress, interestTokenAddress, collateralTokenAddress, feeRecipientAddress, oracleAddress, takerAddress, tradeTokenToFillAddress.
/// @param orderValues Array of order's loanTokenAmount, interestAmount, initialMarginAmount, maintenanceMarginAmount, lenderRelayFee, traderRelayFee, maxDurationUnixTimestampSec, expirationUnixTimestampSec, makerRole (0=lender, 1=trader), withdrawOnOpen, and salt.
/// @param oracleData An arbitrary length bytes stream to pass to the oracle.
/// @param collateralTokenFilled Desired address of the collateralTokenAddress the trader wants to use.
/// @param loanTokenAmountFilled Desired amount of loanToken the trader wants to borrow.
/// @param tradeTokenToFillAddress If non-zero address, will swap the loanToken for this asset using the oracle.
/// @param withdrawOnOpen If true, will overcollateralize the loan and withdraw the position token to the trader's wallet. If set, tradeTokenToFillAddress is ignored.
/// @param signature ECDSA signature in raw bytes (rsv).
/// @return Total amount of loanToken borrowed (uint256).
/// @dev Traders can take a portion of the total coin being lent (loanTokenAmountFilled).
/// @dev Traders also specify the token that will fill the margin requirement if they are taking the order.
function takeLoanOrderAsTrader(
address[8] calldata orderAddresses,
uint256[11] calldata orderValues,
bytes calldata oracleData,
address collateralTokenFilled,
uint256 loanTokenAmountFilled,
address tradeTokenToFillAddress,
bool withdrawOnOpen,
bytes calldata signature)
external
returns (uint256);
/// @dev Takes the order as lender
/// @param orderAddresses Array of order's makerAddress, loanTokenAddress, interestTokenAddress, collateralTokenAddress, feeRecipientAddress, oracleAddress, takerAddress, tradeTokenToFillAddress.
/// @param orderValues Array of order's loanTokenAmount, interestAmount, initialMarginAmount, maintenanceMarginAmount, lenderRelayFee, traderRelayFee, maxDurationUnixTimestampSec, expirationUnixTimestampSec, makerRole (0=lender, 1=trader), withdrawOnOpen, and salt.
/// @param oracleData An arbitrary length bytes stream to pass to the oracle.
/// @param signature ECDSA signature in raw bytes (rsv).
/// @return Total amount of loanToken borrowed (uint256).
/// @dev Lenders have to fill the entire desired amount the trader wants to borrow.
/// @dev This makes loanTokenAmountFilled = loanOrder.loanTokenAmount.
function takeLoanOrderAsLender(
address[8] calldata orderAddresses,
uint256[11] calldata orderValues,
bytes calldata oracleData,
bytes calldata signature)
external
returns (uint256);
/// @dev Pushes an order on chain
/// @param orderAddresses Array of order's makerAddress, loanTokenAddress, interestTokenAddress, collateralTokenAddress, feeRecipientAddress, oracleAddress, takerAddress, tradeTokenToFillAddress.
/// @param orderValues Array of order's loanTokenAmount, interestAmount, initialMarginAmount, maintenanceMarginAmount, lenderRelayFee, traderRelayFee, maxDurationUnixTimestampSec, expirationUnixTimestampSec, makerRole (0=lender, 1=trader), withdrawOnOpen, and salt.
/// @param oracleData An arbitrary length bytes stream to pass to the oracle.
/// @param signature ECDSA signature in raw bytes (rsv).
/// @return A unique hash representing the loan order.
function pushLoanOrderOnChain(
address[8] calldata orderAddresses,
uint256[11] calldata orderValues,
bytes calldata oracleData,
bytes calldata signature)
external
returns (bytes32);

Example of minimal commenting (BZxVault.sol)

ontract BZxVault is EIP20Wrapper, BZxOwnable {
// Only the bZx contract can directly deposit ether
function() external payable onlyBZx {}
function withdrawEther(
address payable to,
uint256 value)
public
onlyBZx
returns (bool)
{
uint256 amount = value;
if (amount > address(this).balance) {
amount = address(this).balance;
}
return (to.send(amount)); // solhint-disable-line check-send-result, multiple-sends
}
function depositToken(
address token,
address from,
uint256 tokenAmount)
public
onlyBZx
returns (bool)
{
if (tokenAmount == 0) {
return false;
}
eip20TransferFrom(
token,
from,
address(this),
tokenAmount);
return true;
}

SLOC Appendix

Solidity Contracts

Language

Files

Lines

Blanks

Comments

Code

Complexity

Solidity

23

2,952

360

600

1,992

83

Comments to Code 600/1992 = 30%

JavcaScript Tests

Language

Files

Lines

Blanks

Comments

Code

Complexity

JavaScript

10

6,720

837

338

5545

141

Tests to Code 5545 / 1992 = 278%