Commit 0c659f0
feat(cheatcode):
* 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/foundry#8571 (comment)
* doc: remove legacy comment in test
* style: reuse empty initialized var on return val
---------
Co-authored-by: zerosnacks <[email protected]>startDebugTraceRecording and stopDebugTraceRecording for ERC4337 testing (#8571)1 parent 5101a32 commit 0c659f0
File tree
15 files changed
+626
-119
lines changed- crates
- cheatcodes
- assets
- spec/src
- src
- evm
- debugger
- src/tui
- evm/core/src
- testdata
- cheats
- default/cheats
15 files changed
+626
-119
lines changedSome generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
58 | 58 | | |
59 | 59 | | |
60 | 60 | | |
| 61 | + | |
61 | 62 | | |
62 | 63 | | |
63 | 64 | | |
| |||
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
85 | 85 | | |
86 | 86 | | |
87 | 87 | | |
| 88 | + | |
88 | 89 | | |
89 | 90 | | |
90 | 91 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
261 | 261 | | |
262 | 262 | | |
263 | 263 | | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
264 | 286 | | |
265 | 287 | | |
266 | 288 | | |
| |||
287 | 309 | | |
288 | 310 | | |
289 | 311 | | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
290 | 323 | | |
291 | 324 | | |
292 | 325 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
4 | | - | |
5 | | - | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
6 | 7 | | |
7 | 8 | | |
8 | 9 | | |
| |||
14 | 15 | | |
15 | 16 | | |
16 | 17 | | |
| 18 | + | |
17 | 19 | | |
18 | 20 | | |
19 | 21 | | |
20 | 22 | | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
21 | 26 | | |
22 | 27 | | |
23 | 28 | | |
| |||
715 | 720 | | |
716 | 721 | | |
717 | 722 | | |
| 723 | + | |
| 724 | + | |
| 725 | + | |
| 726 | + | |
| 727 | + | |
| 728 | + | |
| 729 | + | |
| 730 | + | |
| 731 | + | |
| 732 | + | |
| 733 | + | |
| 734 | + | |
| 735 | + | |
| 736 | + | |
| 737 | + | |
| 738 | + | |
| 739 | + | |
| 740 | + | |
| 741 | + | |
| 742 | + | |
| 743 | + | |
| 744 | + | |
| 745 | + | |
| 746 | + | |
| 747 | + | |
| 748 | + | |
| 749 | + | |
| 750 | + | |
| 751 | + | |
| 752 | + | |
| 753 | + | |
| 754 | + | |
| 755 | + | |
| 756 | + | |
| 757 | + | |
| 758 | + | |
| 759 | + | |
| 760 | + | |
| 761 | + | |
| 762 | + | |
| 763 | + | |
| 764 | + | |
| 765 | + | |
| 766 | + | |
| 767 | + | |
| 768 | + | |
| 769 | + | |
| 770 | + | |
| 771 | + | |
| 772 | + | |
| 773 | + | |
| 774 | + | |
| 775 | + | |
| 776 | + | |
| 777 | + | |
| 778 | + | |
| 779 | + | |
| 780 | + | |
718 | 781 | | |
719 | 782 | | |
720 | 783 | | |
| |||
0 commit comments