Cudos contest - Funen's results

Decentralised cloud computing for Web3.

General Information

Platform: Code4rena

Start Date: 03/05/2022

Pot Size: $75,000 USDC

Total HM: 6

Participants: 55

Period: 7 days

Judge: Albert Chon

Total Solo HM: 2

Id: 116

League: COSMOS

Cudos

Findings Distribution

Researcher Performance

Rank: 26/55

Findings: 2

Award: $226.38

🌟 Selected for report: 0

🚀 Solo Findings: 0

Awards

113.5998 USDC - $113.60

Labels

bug
QA (Quality Assurance)

External Links

  1. Title : Inconsistent Versioning

The library versions used and the version indicated in CosmoToken.sol are inconsistent. The libraries are using OpenZeppelin v3 for solidity versions ^0.8.0, however, the contract uses version ^0.6.6.

Contracts should be deployed with the same compiler version and flags that they have been tested the most with. Locking the pragma helps ensure that contracts do not accidentally get deployed using, for example, the latest compiler which may have higher risks of undiscovered bugs. Contracts may also be deployed by others and the pragma indicates the compiler version intended by the original authors.

##Tool Used Manual Review

##Recommended Mitigation recommend maintaining consistent versioning throughout the entire contract.

Awards

112.7769 USDC - $112.78

Labels

bug
G (Gas Optimization)

External Links

  1. Title : Saving gas by removing = 0

This code can be saving more gas by removing = 0, it because If a variable was not set/initialized, it is assumed to have default value to 0

##TOOLS USED Manual Review

##Mitigation Step Remove = 0

  1. Title : using ++i than i++ for saving more gas

Using i++ instead ++i for all the loops, the variable i is incremented using i++. It is known that implementation by using ++i costs less gas per iteration than i++.

Tools Used

Manual Review

Occurances

Gravity.sol#L128 Gravity.sol#L233 Gravity.sol#L263 Gravity.sol#L453 Gravity.sol#L569 Gravity.sol#L579 Gravity.sol#L660

  1. Title : Title : change uint256 i = 0 into uint256 i for saving more gas

using this implementation can saving more gas for each loops.

##Tool Used Manual Review

##Recommended Mitigation Change it

##Occurances

Gravity.sol#L128 Gravity.sol#L233 Gravity.sol#L263 Gravity.sol#L453 Gravity.sol#L569 Gravity.sol#L579 Gravity.sol#L660

  1. Title : Caching array length can saving more gas

This implementation can be saving more gas, since if caching the array length is more gas efficient. just because access to a local variable in solidity is more efficient.

##Tool Used Manual Review

##Occurances

Gravity.sol#L128 Gravity.sol#L233 Gravity.sol#L263 Gravity.sol#L453 Gravity.sol#L569 Gravity.sol#L579 Gravity.sol#L660

  1. Title : Code can be shorter for saving more gas

This cumulativePowerImplementation can be used for saving more gas, instead of doube caching, it can be changed by using += instead.

##POC https://www.tutorialspoint.com/solidity/solidity_operators.htm

##Tool Used Manual Review, Remix

##Recommended Mitigation

cumulativePower = cumulativePower + _powers[i];

change to :

cumulativePower += _powers[i];

##Another Occurances Gravity.sol#L244

  1. Title : Using short reason string can be used for saving more gas

Every reason string takes at least 32 bytes. Use short reason strings that fits in 32 bytes or it will become more expensive.

##Tool Used Manual Review

##Occurances Gravity.sol#L119 Gravity.sol#L256 Gravity.sol#L386 Gravity.sol#L492 Gravity.sol#L407 Gravity.sol#L496 Gravity.sol#L655 Gravity.sol#L668

  1. Value can be set as immutable for saving more gas

The linked variables assigned in the constructor can be declared as immutable. Immutable state variables can be assigned during contract creation but will remain constant throughout the lifetime of a deployed contract. A big advantage of immutable variables is that reading them is significantly cheaper than reading from regular state variables since they will not be stored in storage.

##Tool Used Manual Review

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