🧑‍💻

[Seed Gauge] How to Verify Deployed Code

Tags
💡
This guide was accurate when Beanstalk did not use any external libraries. For the latest

Smart contracts are represented as bytecode in the EVM. You get a brief intro to bytecode in this article.

The goal of “verifying deployed code” is to confirm that the source code in the GitHub pull request for a BIP is actually the same code that was deployed on-chain.

Verify locally

Due to various changes to the Seed Gauge codebase, the bytecode will need to be verified across different commit hashes. The facets will need to be checked from 3 different hashes.

  • daa0dd - original
  • cbef4ff - commit hash from updating LibWell to support twaReserves read at sunrise for subgraph purposes.
  • ac8e68 - commit hash from updating LibLockedUnderlying.

These can be cross checked on github:

Steps to verify:

  1. In the terminal, navigate to the Beanstalk repo.
  2. Run: git checkout bip39-seedGauge
  3. Download the below, and rename the file to hardhat.config.js. Alternatively, paste the contents of hardhat.txt to the existing hardhat.config.js . (Notion does not support .js files).
  4. hardhat.txt14.4KB
  5. Initialize a anvil local node, forked from mainnet (feel free to swap out the fork url for improved performance):
  6. anvil --fork-url https://eth-mainnet.g.alchemy.com/v2/<API-KEY> --chain-id 1337
  7. Switch to the daa0dd commit hash and compile:
  8. git checkout daa0dd && npx hardhat clean && npx hardhat compile
  9. Run the following script. Verify that the following facets are valid:
    • GaugePointFacet
    • ConvertFacet
    • ConvertGettersFacet
    • WhitelistFacet
    • BDVFacet
    • MigrationFacet
    • InitBipSeedGauge
npx hardhat verifySeedGauge --facet 2 --network localhost
  1. Switch to commit cbef4f, recompile, and verify the following facets are valid by running the following script (note that the command below is slightly different):
    • SiloFacet
    • MetadataFacet
    • SiloGettersFacet
    • LiquidityWeightFacet
    • EnrootFacet
    • UnripeFacet
git checkout cbef4f && npx hardhat compile && npx hardhat verifySeedGauge --facet 1 --network localhost
  1. Switch to commit bip39-seedGauge, recompile, and verify the following facets are valid by running the following script:
    • SeasonFacet
    • SeasonGettersFacet
git checkout bip39-seedGauge && npx hardhat compile && npx hardhat verifySeedGauge --facet 0 --network localhost

Additional manual verification can be done by comparing the deployedBytecode in diamondCuts/facetBytecode-x-y-facets.json to the Etherscan deployed bytecode.