โ›ณ

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-38.
  8. task('bip38enc', async function () {
      const bcm = await impersonateBeanstalkOwner()
      await mintEth(bcm.address)
      await bcm.sendTransaction({to: BEANSTALK, value: 0, data: 'TBD'})
    })
  9. Run the following command in the same terminal window as step (3). Again, bip38enc is just an example from BIP-38โ€”see the respective
    ๐Ÿ“–
    BIP Runbooks
    . This will execute the diamondCut.
  10. npx hardhat bip38enc --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 view the diff and confirm that the expected facet addresses from the
    ๐Ÿ“–
    BIP Runbooks
    are correspondingly added, changed or removed.