matter-labs / foundry-zksync

Fork of Foundry tailored for zkSync environment

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Empty forked state for `vm.createSelectFork`

spengrah opened this issue · comments

Component

Forge

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

  • Foundry
  • Foundryup

What version of Foundry are you on?

forge 0.0.2 (bde6d97 2024-08-05T00:25:00.218693000Z)

What command(s) is the bug in?

forge test

Operating System

macOS (Apple Silicon)

Describe the bug

I am attempting to run some forked tests based on zkSync Sepolia. I'm using the standard fork test procedure I've used numerous times in og foundry, with the public RPC (https://sepolia.era.zksync.dev) and a very recent block number (3574400), but addresses of existing contracts are coming up in the forked state as having no code deployed, including the ZK token itself:

Here is my repo, including where I'm initiating the fork test (code snippet below) and where I'm logging the code size for the existing contracts.

Here is how I'm initiating the fork

string public network;
uint256 public BLOCK_NUMBER;
uint256 public fork;

function setUp() public virtual {
    network = "zkSyncSepolia"; // https://sepolia.era.zksync.dev
    BLOCK_NUMBER = 3_574_400;
    fork = vm.createFork(vm.rpcUrl(network), BLOCK_NUMBER);
}

I suppose the above is not surprising upon inspecting the forked state itself, which doesn't include any data for accounts or storage.

{
  "meta": {
    "cfg_env": {
      "chain_id": 300,
      "perf_analyse_created_bytecodes": "Analyse",
      "limit_contract_code_size": 18446744073709551615,
      "memory_limit": 134217728,
      "disable_block_gas_limit": false,
      "disable_eip3607": true,
      "disable_base_fee": false
    },
    "block_env": {
      "number": "0x368a80",
      "coinbase": "0x0000000000000000000000000000000000000000",
      "timestamp": "0x66b14480",
      "gas_limit": "0x4000000000000",
      "basefee": "0x17d7840",
      "difficulty": "0x0",
      "prevrandao": "0x0000000000000000000000000000000000000000000000000000000000000000",
      "blob_excess_gas_and_price": {
        "excess_blob_gas": 0,
        "blob_gasprice": 1
      }
    },
    "hosts": [
      "sepolia.era.zksync.dev"
    ]
  },
  "accounts": {},
  "storage": {},
  "block_hashes": {}
}

Closing. User error 😅

I was using vm.createFork, not vm.createSelectFork