crytic / medusa

Parallelized, coverage-guided, mutational Solidity smart contract fuzzing, powered by go-ethereum
https://secure-contracts.com/program-analysis/medusa/docs/src/
GNU Affero General Public License v3.0
304 stars 40 forks source link

enable loading state from forge script ran against anvil #469

Open 0xalpharush opened 2 months ago

0xalpharush commented 2 months ago

I think we should be able to run Anvil, run a deploy script against its RPC, and load the output of anvil_dumpState https://github.com/ethereum-optimism/optimism/blob/develop/op-chain-ops/foundry/allocs.go#L26

0xalpharush commented 1 month ago

https://github.com/crytic/medusa/tree/feat/replay-crash2

0xalpharush commented 1 month ago

The primitive of loading alloc's produced by forge test is done e.g. https://github.com/0xalpharush/foundry-dumpstate/blob/e18fe00b9d783ae99f4b0777a4491cf8e950c6d5/test/Counter.t.sol#L15

You can also use anvil for rmm-core as shown here. First, start anvil: anvil --dump-state dump-state.json. Then run npx hardhat test test/unit/unit_test_seed.test.ts --network localhost

What remains to be done is some way to map the ABI to the deployed address since the contract created event likely won't register the right ABI given the code is included in the genesis block