Cudos contest - delfin454000'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: 37/55

Findings: 2

Award: $179.65

🌟 Selected for report: 0

🚀 Solo Findings: 0

Awards

113.5088 USDC - $113.51

Labels

bug
QA (Quality Assurance)

External Links

Awards

66.1426 USDC - $66.14

Labels

bug
G (Gas Optimization)

External Links

Issue: Require message is to long Explanation: The messages below can be shortened to 32 characters or fewer (as shown) to save gas

https://github.com/code-423n4/2022-05-cudos/blob/de39cf3cd1f1e1cf211819b06d4acf6a043acda0/solidity/contracts/Gravity.sol#L119

            "The caller is not whitelisted for this operation"

Change message to Caller is not whitelisted for op

https://github.com/code-423n4/2022-05-cudos/blob/de39cf3cd1f1e1cf211819b06d4acf6a043acda0/solidity/contracts/Gravity.sol#L240

					"Validator signature does not match."

Change message to Validator sig does not match

There are additional long require messages below that might be hard to cut back while preserving their meaning:

https://github.com/code-423n4/2022-05-cudos/blob/de39cf3cd1f1e1cf211819b06d4acf6a043acda0/solidity/contracts/Gravity.sol#L291

			"New valset nonce must be greater than the current nonce"

https://github.com/code-423n4/2022-05-cudos/blob/de39cf3cd1f1e1cf211819b06d4acf6a043acda0/solidity/contracts/Gravity.sol#L386

				"New batch nonce must be greater than the current nonce"

https://github.com/code-423n4/2022-05-cudos/blob/de39cf3cd1f1e1cf211819b06d4acf6a043acda0/solidity/contracts/Gravity.sol#L392

				"Batch timeout must be greater than the current block height"

https://github.com/code-423n4/2022-05-cudos/blob/de39cf3cd1f1e1cf211819b06d4acf6a043acda0/solidity/contracts/Gravity.sol#L496

				"New invalidation nonce must be greater than the current nonce"

https://github.com/code-423n4/2022-05-cudos/blob/de39cf3cd1f1e1cf211819b06d4acf6a043acda0/solidity/contracts/Gravity.sol#L655

		require(address(_cudosAccessControls) != address(0), "Access control contract address is incorrect");

The same long require message occurs in both lines below:

https://github.com/code-423n4/2022-05-cudos/blob/de39cf3cd1f1e1cf211819b06d4acf6a043acda0/solidity/contracts/Gravity.sol#L256

https://github.com/code-423n4/2022-05-cudos/blob/de39cf3cd1f1e1cf211819b06d4acf6a043acda0/solidity/contracts/Gravity.sol#L668

			"Submitted validator set signatures do not have enough power."

The same long require message occurs in all three lines below:

https://github.com/code-423n4/2022-05-cudos/blob/de39cf3cd1f1e1cf211819b06d4acf6a043acda0/solidity/contracts/Gravity.sol#L312

https://github.com/code-423n4/2022-05-cudos/blob/de39cf3cd1f1e1cf211819b06d4acf6a043acda0/solidity/contracts/Gravity.sol#L407

https://github.com/code-423n4/2022-05-cudos/blob/de39cf3cd1f1e1cf211819b06d4acf6a043acda0/solidity/contracts/Gravity.sol#L511

				"Supplied current validators and powers do not match checkpoint."

The same long require message occurs in all three lines below:

https://github.com/code-423n4/2022-05-cudos/blob/de39cf3cd1f1e1cf211819b06d4acf6a043acda0/solidity/contracts/Gravity.sol#L317

https://github.com/code-423n4/2022-05-cudos/blob/de39cf3cd1f1e1cf211819b06d4acf6a043acda0/solidity/contracts/Gravity.sol#L418

https://github.com/code-423n4/2022-05-cudos/blob/de39cf3cd1f1e1cf211819b06d4acf6a043acda0/solidity/contracts/Gravity.sol#L527

				"The sender of the transaction is not validated orchestrator"

Issue: Use of '&&' within a require function Explanation: Dividing the require into separate require messages instead of using '&&' will save gas

https://github.com/code-423n4/2022-05-cudos/blob/de39cf3cd1f1e1cf211819b06d4acf6a043acda0/solidity/contracts/Gravity.sol#L411-L414

			require(
				_amounts.length == _destinations.length && _amounts.length == _fees.length,
				"Malformed batch of transactions"
			);

Recommended:

			require(_amounts.length == _destinations.length, "Malformed batch of transactions)";
			require(_amounts.length == _fees.length, "Malformed batch of transactions)";

The same require function with embedded '&&' occurs in all three sets of lines below:

https://github.com/code-423n4/2022-05-cudos/blob/de39cf3cd1f1e1cf211819b06d4acf6a043acda0/solidity/contracts/Gravity.sol#L301-L307

https://github.com/code-423n4/2022-05-cudos/blob/de39cf3cd1f1e1cf211819b06d4acf6a043acda0/solidity/contracts/Gravity.sol#L396-L402

https://github.com/code-423n4/2022-05-cudos/blob/de39cf3cd1f1e1cf211819b06d4acf6a043acda0/solidity/contracts/Gravity.sol#L500-L506

			require(
				_currentValset.validators.length == _currentValset.powers.length &&
					_currentValset.validators.length == _v.length &&
					_currentValset.validators.length == _r.length &&
					_currentValset.validators.length == _s.length,
				"Malformed current validator set"
			);

Recommended:

			require(_currentValset.validators.length == _currentValset.powers.length, "Malformed current validator set");
			require(_currentValset.validators.length == _v.length, "Malformed current validator set");
			require(_currentValset.validators.length == _r.length, "Malformed current validator set");
			require(_currentValset.validators.length == _s.length, "Malformed current validator set");

Issue: Variables should not be initialized to their default values Explanation: Initializing uint variables to their default value of 0 is unnecessary and costs gas

https://github.com/code-423n4/2022-05-cudos/blob/de39cf3cd1f1e1cf211819b06d4acf6a043acda0/solidity/contracts/Gravity.sol#L54

	uint256 public state_lastValsetNonce = 0;

Recommended:

	uint256 public state_lastValsetNonce;

uint256 cumulativePower is initialized to zero in both lines below:

https://github.com/code-423n4/2022-05-cudos/blob/de39cf3cd1f1e1cf211819b06d4acf6a043acda0/solidity/contracts/Gravity.sol#L231

https://github.com/code-423n4/2022-05-cudos/blob/de39cf3cd1f1e1cf211819b06d4acf6a043acda0/solidity/contracts/Gravity.sol#L659

		uint256 cumulativePower = 0;

Recommended:

		uint256 cumulativePower;
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