foundry icon indicating copy to clipboard operation
foundry copied to clipboard

Partial verify-bytecode not working as expected

Open blmalone opened this issue 8 months ago • 0 comments

Component

Forge

Have you ensured that all of these are up to date?

  • [X] Foundry
  • [X] Foundryup

What version of Foundry are you on?

forge verify-bytecode "$address" "$contract_name" --rpc-url "$MAINNET_RPC_URL" --json

What command(s) is the bug in?

forge verify-bytecode

Operating System

macOS (Apple Silicon)

Describe the bug

Steps to reproduce

# Clone optimism repo and compile the contracts 
git clone https://github.com/ethereum-optimism/optimism
cd optimism
git checkout op-contracts/v1.3.0
pnpm clean
pnpm install
pnpm build
cd packages/contracts-bedrock
rm -rf lib/
forge clean
forge install
forge build

# This should have matched=true on a partial verification
forge verify-bytecode 0xba2492e52F45651B60B8B38d4Ea5E2390C64Ffb1 SystemConfig --rpc-url "$MAINNET_RPC_URL" --json

git checkout op-contracts/v1.2.0
rm -rf lib/
forge clean
forge install
forge build
# This should have matched=false on a partial verification - but it returns 'true'. 
forge verify-bytecode 0xba2492e52F45651B60B8B38d4Ea5E2390C64Ffb1 SystemConfig --rpc-url "$MAINNET_RPC_URL" --json

Notice that SystemConfig has completely different source code at each of these optimism repo tagged commits:

  • v1.2.0: https://github.com/ethereum-optimism/optimism/blob/op-contracts/v1.2.0/packages/contracts-bedrock/src/L1/SystemConfig.sol
  • v1.3.0: https://github.com/ethereum-optimism/optimism/blob/op-contracts/v1.3.0/packages/contracts-bedrock/src/L1/SystemConfig.sol

Actual Results

First forge verify-bytecode command output with tag op-contracts/v1.3.0:


[{"bytecode_type":"creation","matched":true,"verification_type":"partial"},{"bytecode_type":"runtime","matched":true,"verification_type":"partial"}]

Second forge verify-bytecode command output with tag op-contracts/v1.2.0:

[{"bytecode_type":"creation","matched":false,"verification_type":"full","message":"Creation code did not match - this may be due to varying compiler settings"},{"bytecode_type":"runtime","matched":true,"verification_type":"partial"}]
v1.2.0 v1.3.0
Actual Creation Code Match No Yes
Actual Runtime Code Match Yes Yes

Expected Results

v1.2.0 v1.3.0
Expected Creation Code Match No Yes
Expected Runtime Code Match No Yes

blmalone avatar Jun 25 '24 16:06 blmalone