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("0xD1A0060ba708BC4BCD3DA6C37EFa8deDF015FB70")
      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. 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 tasks in the 📖BIP Runbooks that corresponds to the diamondCut call to the hardhat.config.js file. The following is an example from BIP-50.
  8. task('bip50part1enc', 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, bip50enc is just an example from BIP-50—see the respective 📖BIP Runbooks. This will execute the diamondCut.
  10. npx hardhat bip50part1enc --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.