โ›ณ

How to Verify Facet Changes

Tags

The following is a guide on verifying that the expected facet addresses are added/changed/removed upon the execution of a diamondCut call.

  1. Follow
    ๐Ÿ—๏ธ
    How to Setup Environment
    .
  2. Add the following code to the hardhat.config.js file in the protocol directory of the cloned repository.
  3. Note that you may have to add the import for getBeanstalk on line 10 from .utils.

    task('facet', async function () {
      const bs = await getBeanstalk()
      console.log(await bs.facets())
    })

    You may have to add an import for getBeanstalk from utils.js.

  4. Run the following command in a separate terminal window (in the same directory) to the mainnet fork that you started per
    ๐Ÿ—๏ธ
    How to Setup Environment
    .
  5. npx hardhat facet --network localhost | pbcopy

    This command will get a list of all the facet addresses and their function selectors at BLOCK_NUMBER (set in the .env file). pbcopy copies the output to your clipboard.

  6. Go to a site like https://www.diffchecker.com/text-compare/ and paste the output in the first text field.
  7. Add the hardhat task in the
    ๐Ÿ“–
    BIP Runbooks
    that corresponds to the diamondCut call to the hardhat.config.js file. The following is an example from BIP-32.
  8. const { impersonateSeraph } = require("./scripts/impersonate");
    
    task('bip32enc', async function () {
      const bcm = await impersonateBeanstalkOwner()
    	await impersonateSeraph()
      await mintEth(bcm.address)
      await bcm.sendTransaction({to: BEANSTALK, value: 0, data: '0x1f931c1c00000000000000000000000000000000000000000000000000000000000000600000000000000000000000003b0eb84510739833896148f689eb938daa9d060900000000000000000000000000000000000000000000000000000000000009e0000000000000000000000000000000000000000000000000000000000000000700000000000000000000000000000000000000000000000000000000000000e000000000000000000000000000000000000000000000000000000000000001800000000000000000000000000000000000000000000000000000000000000240000000000000000000000000000000000000000000000000000000000000030000000000000000000000000000000000000000000000000000000000000003a000000000000000000000000000000000000000000000000000000000000004a00000000000000000000000000000000000000000000000000000000000000800000000000000000000000000b1238014b5bbd945760451f8ed38401e5c3dc2f40000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000011f931c1c00000000000000000000000000000000000000000000000000000000000000000000000000000000c8ac12fe3ba9426e35c746d3ce95f31e38f10d5c00000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000060000000000000000000000000000000000000000000000000000000000000000286b40a1b00000000000000000000000000000000000000000000000000000000d8a6aafe0000000000000000000000000000000000000000000000000000000000000000000000000000000077c8442af4ff144a5570c96f39030ae2f16fc6390000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000028456cb59000000000000000000000000000000000000000000000000000000003f4ba83a0000000000000000000000000000000000000000000000000000000000000000000000000000000077827e4d9d483848952c96503d2f49635317ee7b0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000016929145b0000000000000000000000000000000000000000000000000000000000000000000000000000000077827e4d9d483848952c96503d2f49635317ee7b0000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000044e71e0c8000000000000000000000000000000000000000000000000000000008da5cb5b000000000000000000000000000000000000000000000000000000005f504a8200000000000000000000000000000000000000000000000000000000f2fde38b00000000000000000000000000000000000000000000000000000000000000000000000000000000f14224733b3fc90433ce7d831746f8835d664ec10000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000178cd31ca000000000000000000000000000000000000000000000000000000000304ec65d00000000000000000000000000000000000000000000000000000000b6f42085000000000000000000000000000000000000000000000000000000001799b3b2000000000000000000000000000000000000000000000000000000001edb6be1000000000000000000000000000000000000000000000000000000009bb4e35a0000000000000000000000000000000000000000000000000000000083e0888800000000000000000000000000000000000000000000000000000000dc6ba285000000000000000000000000000000000000000000000000000000003944880200000000000000000000000000000000000000000000000000000000c85951a1000000000000000000000000000000000000000000000000000000009c45a1d50000000000000000000000000000000000000000000000000000000034af5416000000000000000000000000000000000000000000000000000000001e2231430000000000000000000000000000000000000000000000000000000029130a66000000000000000000000000000000000000000000000000000000004d62283100000000000000000000000000000000000000000000000000000000f4a057e2000000000000000000000000000000000000000000000000000000006ae1c014000000000000000000000000000000000000000000000000000000000bfca7e300000000000000000000000000000000000000000000000000000000d47aee59000000000000000000000000000000000000000000000000000000004a16607c000000000000000000000000000000000000000000000000000000004f9a967800000000000000000000000000000000000000000000000000000000f9c4ebde00000000000000000000000000000000000000000000000000000000a3ef48c9000000000000000000000000000000000000000000000000000000000000000000000000000000002f1d8929ade28664343bd8b99988386961731e580000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000074b4e8d9a0000000000000000000000000000000000000000000000000000000043c5198e00000000000000000000000000000000000000000000000000000000c869c1eb00000000000000000000000000000000000000000000000000000000ce133450000000000000000000000000000000000000000000000000000000006299a9af000000000000000000000000000000000000000000000000000000000d1a844c000000000000000000000000000000000000000000000000000000006ee66ddf000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004e1c7392a00000000000000000000000000000000000000000000000000000000'})
    })
  9. Run the following command in the same terminal window as step (3). Again, bip32enc is just an example from BIP-32โ€”see the respective
    ๐Ÿ“–
    BIP Runbooks
    . This will execute the diamondCut.
  10. npx hardhat bip32enc --network localhost
  11. Run the facet task again.
  12. npx hardhat facet --network localhost | pbcopy
  13. Go back to https://www.diffchecker.com/text-compare/ and paste the new output in the second text field.
  14. Click โ€œFind Differenceโ€ to generate the diff.
  15. Manually parse the diff and confirm that the expected facet addresses and function selectors from the
    ๐Ÿ“–
    BIP Runbooks
    are correspondingly added, changed or removed.