Skip to content

Commit a385ff5

Browse files
committed
Add study notes for 2025-08-21
1 parent dd9daac commit a385ff5

1 file changed

Lines changed: 37 additions & 0 deletions

File tree

0xMiloAI.md

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,43 @@ web3初学者
1515
## Notes
1616

1717
<!-- Content_START -->
18+
# 2025-08-21
19+
20+
今日总结:
21+
Gas 优化
22+
23+
核心原则:减少 Storage 读写、多用 memory、降低循环和函数调用开销。
24+
25+
常见技巧:
26+
27+
缓存存储值:避免重复 SLOAD。
28+
29+
减少 Storage 写:一次写入成本高达 20,000 gas。
30+
31+
位压缩:多个变量打包进一个 uint256。
32+
33+
循环优化:先缓存 arr.length。
34+
35+
函数可见性:external 比 public 更省 gas(仅外部调用场景)。
36+
37+
合约安全
38+
39+
设计原则:最小权限、模块化、显式错误与事件。
40+
41+
常见漏洞与防护:
42+
43+
重入攻击:先改状态再转账,使用 Checks-Effects-Interactions 模式。
44+
45+
预言机操纵:使用 Chainlink、多源价格、TWAP。
46+
47+
整数溢出/下溢:Solidity 0.8+ 内建检查,或 unchecked 慎用。
48+
49+
权限缺失:关键函数加 onlyOwner 或 AccessControl。
50+
51+
未初始化代理:确保初始化函数仅能调用一次。
52+
53+
前置交易/三明治攻击:滑点控制、MEV 保护措施。
54+
1855
# 2025-08-19
1956

2057
今日总结:

0 commit comments

Comments
 (0)