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...
github.com
Steps to verify:
- In the terminal, navigate to the Beanstalk repo.
- Run:
git checkout bip39-seedGauge - Download the below, and rename the file to
hardhat.config.js. Alternatively, paste the contents ofhardhat.txtto the existinghardhat.config.js. (Notion does not support .js files). - Initialize a anvil local node, forked from mainnet (feel free to swap out the fork url for improved performance):
- Switch to the
daa0ddcommit hash and compile: - Run the following script. Verify that the following facets are valid:
- GaugePointFacet
- ConvertFacet
- ConvertGettersFacet
- WhitelistFacet
- BDVFacet
- MigrationFacet
- InitBipSeedGauge
anvil --fork-url https://eth-mainnet.g.alchemy.com/v2/<API-KEY> --chain-id 1337git checkout daa0dd && npx hardhat clean && npx hardhat compilenpx hardhat verifySeedGauge --facet 2 --network localhost- 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- 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 localhostAdditional manual verification can be done by comparing the deployedBytecode in diamondCuts/facetBytecode-x-y-facets.json to the Etherscan deployed bytecode.