Missing state updates or optimizable state variables
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức phù hợp với người mới
- 25/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Cần làm rõ
- Mức độ hoạt động
- Đình trệ
- Công nghệ
- solidity
- Lĩnh vực
- blockchain
Hướng nghiên cứu
Start by reading dynamic-nft-3-services/SuperDynamicNFT.sol and ultimate-nft-repo/contracts/RandomIpfsNft.sol. Trace every use and assignment of callbackGasLimit, requestConfirmations, numWords, and s_tokenIdToBreed, then compare their roles with Solidity constant and immutable documentation. Done means each reported variable has a documented decision about whether it needs updates or a modifier change.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Hi, we are a research group on programming languages and software engineering. We recently conducted a systematic study on the causes, effects, and fixes of the inconsistent state update vulnerability in solidity. We are attempting to build a tool to detect bugs about state updates based on our findings. We have tried our prototype tool on some popular Github solidity repositories, and for your repository, we found that there are missing state updates or gas consumption that can be optimized.
The point is that when we declare a state variable in the contract, if the variable is not reassigned throughout the project, it may be a missed state update, including balance, order number, counter, contract status flag, etc. Of course, it may also be a state variable with special purposes that does not need to be changed, such as maximum supply, contract administrator address, configuration information, etc. When declaring these state variables that do not need to be changed, the constant or immutable modifier should be used as required, which will save gas.
For your repository, we found the following state variables that may need attention. If you are not forgetting to update them, perhaps you should declare them with the constant or immutable modifier:
SuperDynamicNFT.sol
State variable: callbackGasLimit, requestConfirmations, numWords
uint32 private callbackGasLimit = 2500000;
uint16 private requestConfirmations = 3;
uint32 private numWords = 6;
RandomIpfsNft.sol
State variable: s_tokenIdToBreed
mapping(uint256 => Breed) private s_tokenIdToBreed;
Do you find our results useful? Your reply and invaluable suggestions would be greatly appreciated, and are vital for improving our tool. Thanks a lot for your time!
(The reason why constant and immutable modifiers can save gas is that they do not consume storage space within the EVM. Their values are compiled directly into smart contract bytecode, which reduces the gas cost of storage. This storage method also avoids the SLOAD operation that reads EVM storage (costs about 100 gas in EVM). The main difference between constant and immutable variables is that the value of immutable variables can be set in the constructor, and immutable variables may cost more gas than constant variables. In addition, there is a slight difference in the variable types they support. The official documentation describes more details: https://docs.soliditylang.org/en/latest/contracts.html)
- Ngôn ngữ chính
- Solidity
- Star
- 243
- Fork
- 116
- Chỉ số merge pull request
- Không có pull request nào được merge trong 30 ngày
Chuẩn bị môi trường
Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của smartcontractkit/smart-contract-examples
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 72/100
smartcontractkit/smart-contract-examples#10 · 1 bình luận · 1 reaction ·
-
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 15/100
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 50/100
smartcontractkit/smart-contract-examples#91 · 1 bình luận · 1 reaction ·
-
WioowĐang mở
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 1/100
-
Update the Functions example README to use the new .env.encCó thể làm lại được @buddhiraz đã nhận 957 ngày trước và không có pull request nào đang mở. Đang mở
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 45/100
smartcontractkit/smart-contract-examples#22 · 1 bình luận ·
Tất cả issue của smartcontractkit/smart-contract-examples
Issue tương tự
-
[Integration]: eRPCĐang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 62/100
ava-labs/builders-hub#4826 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 62/100
Chia-Network/chia-blockchain#21573 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 84/100
erigontech/erigon#25432 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
performance
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
Hamplard-Hub/Hamplard--contracts#706 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 2 ngày