diamond-2-hardhat icon indicating copy to clipboard operation
diamond-2-hardhat copied to clipboard

refactor(DiamondCutFacet.sol): use diamondCut from library

Open ubinatus opened this issue 3 years ago • 1 comments

Motivation

Since this repo, just like the diamond-1-hardhat and diamond-3-hardhat are for reference implementations, was thinking reusing the diamondCut from the LibDiamond in the DiamondCutFacet.sol would be helpful for new readers to understand how the cut logic differs from the other implementations (instead of duplicating the same pre logic for addReplaceRemoveFacetSelectors).

I totally understand that diamond-2-hardhat should be the most efficient in terms of diamond cutting. Even so, using the library instead uses more gas (not that significant) 😅. Is this worth doing this to help demonstrate how the cutting logic works?

Gas report for the current repo test

Current:

  • diamondCut method: avg gas for 22 calls 348444
  • DiamondCutFacet deployment method: avg gas for 22 calls 1952190

Proposed:

  • diamondCut method: avg gas for 22 calls 349019
  • DiamondCutFacet deployment method: avg gas for 22 calls 1974592

ubinatus avatar Sep 10 '22 03:09 ubinatus

You are right, it really isn't much more gas. Will consider it.

mudgen avatar Dec 16 '22 14:12 mudgen