Top Tweets for #GasTip
#GasTip
在 modifier 中编写尽可能少的逻辑或者将部分逻辑抽象到一个单独的函数里面有助于减少 contract size.
原因是 modifier 修饰方法的本质是 solidity 编译器将 modifier 中的代码复制了到函数前后, 感觉有点类似宏展开的意思, 所以 modifier 里面代码越多, 被修饰的时候展开重复的部分也就越多...
不过个人感觉这种应该也可以在编译器层面上优化? 可能需要在函数的首尾多几个 jump ?
出处:
https://t.co/RxbYndV3au
#GasTip
solidity 中函数参数使用 calldata 一定比 memory 更省 gas 吗?
很多人觉得只要数据结构不用修改, 无脑使用 callback 就完事了, 其实不一定的, 某些情况下 memory 甚至会比 calldata 更省 gas. 这里关键看2点:
1. memory 之于 callback 的开销来自将 https://t.co/zwnVxltjHy 解析并复制到到 evm 内存.
2. 但是可以看到 memory 后续访问的开销实际是要低于 callback的, 我个人的理解是因为每次访问 calldata 内部变量其实都需要做一次 abi.decode.
所以这里其实隐含了这样一条原则: 针对参数需要频繁访问的情况, 即使不需要修改, 使用 memory 的 gas 性能也会好于 callback.
可以看到在 UniswapV4 中所有的 PoolKey 都是用的 memory 而不是 callback, 其实就是这个原因.

#GasTip
一直以为 EVM memory 中前 64 bytes (memory scratch space) 作为哈希函数的保留空间没什么卵用, 其实不然, 今天在 solady 的 ERC20 实现中看到一个很骚的操作. 它使用 memory scratch space 来替代 abi.encodePacked 进行数据拼接然后将结果传给 keccak256 来计算哈希值.
节约 gas 的原因是避免了不必要的空间分配 ( 使用 abi.encodePacked 的话默认会分配 0x40 指向的空间 ), 虽然说 scratch space 的值可能会被覆盖(主要是调用哈希函数后), 但我们这里对于该空间的使用在具体进行哈希前就结束了, 所以原则上我们完全可以在一次内联汇编内自由地使用该空间.
solady 中大量使用了该技巧, 把合约的 gas 性能压榨到了极致.

It's #GasTip Wednesday 😊
What to do when you smell gas in the house?
Close valve to stop gas flow, ventilate the house by opening doors, Identify the leakage using water with Liquid dish wash, then hire a qualified contractor to fit it 😊 Save a life #whenyouthinkofgasthinkofus

#GasTip para estudiantes en verano, hagan hielo en latas (birra, gaseosa, etc) cortadas, la pones 5 segundos abajo del agua y sale al toque el hielo. Aaa de nada por sus futuros teres.
Shell #GasTip: In case you sense a gas leak, don’t panic. Close the regulator knob on your gas tank & on your cooker.

Shell #GasTip: Use an apron or cotton clothes while cooking with gas, and not synthetic clothes like silk or Chiffon that easily catch fire.


#Gastip: Don't gun your engine! Rapid acceleration and breaking increases your fuel consumption by 37%!

#GasTip: Every year, loose or damaged gas caps cause 147 million gallons of #gas to evaporate! #ThingsYouShouldKnow

8 ways to save on gas -- 1: Make sure your tires are inflated http://t.co/dxVO1Smy #gastip
8 ways to save on gas -- 5: Be smart about your air conditioner. http://t.co/oerQBKya #gastip
8 ways to save on gas -- 8: Don't drive more than 4 miles for gas if you're looking to save $.10/gallon http://t.co/ex96ShrB #gastip
8 ways to save on gas -- 3: Alter your driving style. http://t.co/kWCn8I88 #gastip
8 ways to save on gas -- 6: Forget about brand loyalty and points. http://t.co/GRsJSCWq #gastip
8 ways to save on gas -- 2: Never let your gas tank go below the halfway mark. http://t.co/lr4NNNvV #gastip
8 ways to save on gas -- 7: Certain credit card rewards might be worth it. http://t.co/WK7PW5d0 #gastip
8 ways to save on gas -- 4: Drive at a moderate speed. http://t.co/rGM0dn5r #gastip
Last Seen Hashtags on Sotwe
brosis()******** filter:videos
Seen from Brazil
grup sex
Seen from Turkey
hidden #voyeur
Seen from Turkey
minichat
Seen from United States
minichatt()()()()()()()()()()()()()()()********************** +filter:native_video
Seen from Turkey
caesaraugustus
Seen from United States
ديوت_بدوي
Seen from Bahrain
امل_سالم
Seen from United Kingdom
kira5000
minichatt(**)* filter:native_video
Seen from Brazil
Most Popular Users

Elon Musk 
@elonmusk
241.5M followers

Barack Obama 
@barackobama
118.8M followers

Cristiano Ronaldo 
@cristiano
114.5M followers

Donald J. Trump 
@realdonaldtrump
111.9M followers

Narendra Modi 
@narendramodi
107.1M followers

Rihanna 
@rihanna
98.7M followers

NASA 
@nasa
92.3M followers

Justin Bieber 
@justinbieber
91.8M followers

KATY PERRY 
@katyperry
90M followers

Taylor Swift 
@taylorswift13
84M followers

Lady Gaga 
@ladygaga
75.5M followers

Virat Kohli 
@imvkohli
73.4M followers

Kim Kardashian 
@kimkardashian
70.8M followers

YouTube 
@youtube
68.8M followers

Neymar Jr 
@neymarjr
66.5M followers

Bill Gates 
@billgates
65.2M followers

Selena Gomez 
@selenagomez
63.1M followers

The Ellen Show
@theellenshow
62.2M followers

CNN 
@cnn
61.7M followers

X 
@x
60.7M followers







