code4rena-2022-08-nounsdao-n03

[N‑03] 2^n - 1 should be re-written as type(uintn).max

보고서

Summary

2**<n> - 1 형식으로 최대값을 이용하는 대신 type(uint<n>).max 코드로 대체하라 제안했다.

Keyword

readability, clean code

Vulnerability

File: contracts/base/ERC721Checkpointable.sol
 
254:          require(n < 2**32, errorMessage);
 
259:          require(n < 2**96, errorMessage);

과거 컴파일러는 type(uint<n>).max 가 없어 uint<n>(-1)2**<n> - 1 를 이용했지만, 이제는 그러지 않아도 된다.

Impact

코드 읽기 힘들다.

Mitigation

type(uint<n>).max 를 이용한다.


tags: bughunting, nouns dao, readability, clean code, smart contract, solidity, severity none