🧑‍💻

[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.

  • The deployed code can be viewed on Etherscan (or by calling a trusted RPC locally via CLI).
    • Example: https://etherscan.io/address/0xc1e088fc1323b20bcbee9bd1b9fc9546db5624c5#code
  • The source code can be viewed on the GitHub site or by pulling the GitHub repository locally (always double you check you are on the correct branch).
    • Example: https://github.com/BeanstalkFarms/beanstalk/tree/wells-integration

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:

BIP-45: Seed Gauge System by Brean0 · Pull Request #722 · BeanstalkFarms/Beanstalk

BIP-45: Seed Gauge System Proposer Safisynai Proposer Wallet: 0x43a9da9bade357843fbe7e5ee3eedd910f9fac1e Summary Implement the Seed Gauge System; Implement the ability to set a target number of S...

BIP-45: Seed Gauge System by Brean0 · Pull Request #722 · BeanstalkFarms/Beanstalk

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.