Canto Identity Subprotocols contest - Awesome's results

Subprotocols for Canto Identity Protocol.

General Information

Platform: Code4rena

Start Date: 17/03/2023

Pot Size: $36,500 USDC

Total HM: 10

Participants: 98

Period: 3 days

Judge: leastwood

Total Solo HM: 5

Id: 223

League: ETH

Canto Identity Subprotocols

Findings Distribution

Researcher Performance

Rank: 56/98

Findings: 1

Award: $22.77

QA:
grade-b

🌟 Selected for report: 0

🚀 Solo Findings: 0

Awards

22.7749 USDC - $22.77

Labels

bug
grade-b
QA (Quality Assurance)
Q-12

External Links

1. Lines too long

In general, it is a good practice to keep lines of source code within 80 characters in length. Although, some flexibility is allowed and it is reasonable to let lines be up to 120 characters in some instances.

On modern screens, it is even possible to go beyond this limit. However, it is recommended to split lines when they reach a length of 164 characters or more, as this is the point at which GitHub will introduce a scroll bar to view the code.

This can help to make the code more readable and easier to work with.

Affected line of code:

2. Follow function order of solidity style guide

The Solidity style guide recommends the following function order:

  • constructor

  • receive function (if exists)

  • fallback function (if exists)

  • external

  • public

  • internal

  • private

Within a grouping, place the view and pure functions last.

This is because "Ordering helps readers identify which functions they can call and to find the constructor and fallback definitions easier." -solidity style guide

Affected line of code:

3. Use the delete operator to clear variables, rather than assigning a value of 0/false.

To clear variables, consider using the delete operator rather than assigning to false or zero, because this conveys the intention more clearly and is more idiomatic.

As an example on line 92-93 you can refactor the code like so:

Line 92:    delete prevByteWasContinuation;
Line 93:    delete bytesOffset;

Affected line of code:

4. Fix typos to improve readability

File: canto-namespace-protocol/src/Namespace.sol
line 72:    /// @param _revenueAddress Adress to send the revenue to

...

line  82:    // Register CSR on Canto mainnnet

...

line 152:    // We keep track of the unique trays NFTs (for burning them) and only check the owner once for the last occurence of the tray

Consider making the following changes to Namespace.sol:

File: canto-pfp-protocol/src/ProfilePicture.sol
line 61:    // Register CSR on Canto mainnnet

File: canto-bio-protocol/src/Bio.sol
line 34:    // Register CSR on Canto mainnnet

File: canto-namespace-protocol/src/Tray.sol
line 111:    // Register CSR on Canto mainnnet

Consider making the following changes to ProfilePicture.sol, Tray.sol, and Bio.sol:

5. Use newer versions of solidity

Consider using the latest version of solidity as newer versions have bug fixes, as well as new features.

The latest versions provide things like using for(0.8.13 and above.), string.concat() instead of abi.encodePacked()(0.8.12 and above.), and bytes.concat() instead of abi.encodePacked()(0.8.4 and above.)

Affected lines of code:

6. Add whitespace between comment

To increase the readability of comment codes add at least 1 space at the beginning of single-line comments. If you are using multi-line comments add at least 1 space/newline at the beginning and end.

Here are a few examples of lousy comment spacing:

//This is a comment with no whitespace at the beginning

/*This is a comment with no whitespace at the beginning */

/* This is a comment with a whitespace at the beginning but not the end*/

Here are a few examples of good comment spacing:

// This is a comment with a whitespace at the beginning

/* This is a comment with a whitespace at the beginning */

/*
 * This is a comment with a whitespace at the beginning
 */

/*
This comment has a newline
*/

Affected lines of code:

7. Use _safeMint() instead of _mint()

_safeMint() includes additional safety checks that are not present in _mint.

Affected lines of code:

#0 - c4-judge

2023-04-11T05:52:30Z

0xleastwood marked the issue as grade-b

AuditHub

A portfolio for auditors, a security profile for protocols, a hub for web3 security.

Built bymalatrax © 2024

Auditors

Browse

Contests

Browse

Get in touch

ContactTwitter