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).
- 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).
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:
- 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.txt
to 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
daa0dd
commit hash and compile: - Run the following script. Verify that the following facets are valid:
- GaugePointFacet
- ConvertFacet
- ConvertGettersFacet
- WhitelistFacet
- BDVFacet
- MigrationFacet
- InitBipSeedGauge
hardhat.txt14.4KB
anvil --fork-url https://eth-mainnet.g.alchemy.com/v2/<API-KEY> --chain-id 1337
git checkout daa0dd && npx hardhat clean && npx hardhat compile
npx 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 localhost
Additional manual verification can be done by comparing the deployedBytecode
in diamondCuts/facetBytecode-x-y-facets.json
to the Etherscan deployed bytecode.