Tags
This guide was accurate when Beanstalk did not use any external libraries.
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
- Follow How to Setup Environment — after running
npx hardhat compile
, aartifacts
directory will be created in theprotocol
directory. - Double check that you are on the correct branch listed in the BIP Runbooks.
- Navigate to
artifacts/contracts/beanstalk
. - For each facet being added or changed (and
_init
address if applicable—these will be in theinit/
directory), do the following: - Navigate to the corresponding Beanstalk module (like
field/
, orinit/
for the_init
contract)—eachXFacet.sol
file should have a correspondingXFacet.json
file. - At the bottom of each JSON file, find the corresponding bytecode under the
bytecode
key (second to the bottom). - Open a site like https://www.diffchecker.com/text-compare/ and copy the local bytecode into the first field.
- Fetch the on-chain bytecode for the respective facet address—this can be done via CLI or by visiting the Contract tab on Etherscan and scrolling down. At the bottom, you can see the on-chain bytecode for the given contract in the Contract Creation Code field.
- Copy this on-chain bytecode into the second field on Diffchecker.
- Note that you may have to prepend this bytecode with
0x
. - Click “Find Difference” on Diffchecker. If they are identical then the source code on GitHub matches the on-chain deployed bytecode. Repeat for each facet being added or changed in the BIP.