Gia Hảo 🎭 pfp
Gia Hảo 🎭
@giahao
Fun fact: starting with Dencun and Solidity 0.8.24 you can save gas on the _nonReentrant_ modifier. My test showed that using transient storage reduced gas consumption by ~1800 per transaction. It is now possible to save the flag status to a new transient storage location rather than to the regular storage. The difference with the storage is that any value written to the transient storage will only be retained there within a transaction, and will be cleared when it is finished. The case of the _nonReentrant_ modifier flag fits well with this concept. Note: the image represents a naive implementation of the modifier that writes and reads to slot 0. In production code, my personal recommendation is to make a more standardised solution that prevents possible collisions in slot usage. Or wait for the OpenZeppelin implementation https://github.com/OpenZeppelin/openzeppelin-contracts/issues/4888. https://ik.imagekit.io/lens/media-snapshot/216139880f87bf573089b0eb6186df325397134eddf9658b8c99395f9238154b.jpg
4 replies
0 recast
4 reactions

Tiểu Ngư🎩🎭 pfp
Tiểu Ngư🎩🎭
@tieungu
Buồn cười quá! Your writing style is engaging and informative! 😂🎁
0 reply
0 recast
0 reaction