cowdao-grants / cow-shed

A gas-efficient, address-bound account abstraction for permissioned hooks on CoW Protocol
GNU General Public License v3.0
8 stars 1 forks source link

Nonce gas efficiency #4

Closed mfw78 closed 3 months ago

mfw78 commented 3 months ago

Problem

This mapping results in a new slot being initialiased from bytes32(0) on every nonce being executed. This results in more gas consumption as opposed to using a bitmap (mapping(uint256 => uint256)) per https://github.com/Vectorized/solady/blob/183a5c9cc3ca982492ae5fcca9e7ed6668ddb6ac/src/utils/LibBitmap.sol.

Line reference:

https://github.com/meetmangukiya/cow-shed/blob/d67e97dd501d2fec42ab7d3e511bc3f9a2d87a8a/src/COWShedStorage.sol#L12

Solution

Implement nonce using bitmaps.