Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(cheatcode):
startDebugTraceRecording
and `stopDebugTraceRecord…
…ing` for ERC4337 testing (foundry-rs#8571) * feat: add record opcode cheat code feat: capture stack inputs as part of the opcode feat: record opcode -> record debug trace fix: memory OOG, need to only use needed stack, mem input fix: missing op code, instruction results fix: accessing out-of-bound idx memory When running on some project, we noticed that it sometimes try to access memory with out of bound index and panics. This commit fix it by: 1. Enfore reset to Nonce after stopDebugTraceRecording(), this ensures the `some(..) = ...` part will not be triggered 2. Change how opcode_utils.rs accesses memory. Return empty vector if trying access out-of-bound memory. * test: add DebugTrace.t.sol for the debug trace cheatcode * fix: rebase errors * feat: use tracer for debug trace instead of recording during inspector This commit also cleans up the previous implementaiton on inspector. And then change the cheatcode interface to be of three steps: 1. start recording debug trace 2. stop recording 3. get the debug trace by index The reason is to avoid out-of-memory issue by returning the whole traces at once. * fix: rebase duplication * feat: replace instruction result with isOutOfGas * fix: CI issues * fix: remove DebugTrace wrapper in inspector * fix: revert to original tracer config when stops * chore: reuse existing opcode functions * chore: refactor, fmt, clippy run * chore: use ref instead of clone, returning Error when not able to access * chore: move buffer to evm_core from debugger * fix: disable dummy tracer by default, return explicit error Since enabling dummy tracer still come with performance impact, remove the auto dummy tracer initiation. The cheatcode will return explicit error and require the test to be run in -vvv mode to have the tracer enabled by default. * fix: return all traces, turn on necessary tracer config There was OOM concern but using the get-by-index style, despite improved, does not solve the root cause. The main issue is that the tracer config did not turn off after the stop recording cheatcode being called. It seems too much burden for the tracer to record the returned traces inside forge tests as the tests will also pass around the debug traces, causing memory boost. This commit also only turns on necessary tracer config instead of using all(). * chore: cleanup comments, typo * fix: use bytes for memory, remove flattern function, fix get_slice_from_memory * fix: style fmt * fix: ensure steps in the order of node when flatten A node can have steps that calls to another node, so the child node's step might occur before some steps of its parent node. This introduce the flatten_call_trace function back using recursive call to ensure the steps are in correct order despite not in the same order of the node index. see PR comment: foundry-rs#8571 (comment) * doc: remove legacy comment in test * style: reuse empty initialized var on return val --------- Co-authored-by: zerosnacks <95942363+zerosnacks@users.noreply.github.com>
- Loading branch information