-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Fix debugger for shanghai (push0 code) and double key clicks #5345
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -21,7 +21,7 @@ use forge::{ | |
| utils::h256_to_b256, | ||
| }; | ||
| use foundry_config::{find_project_root_path, Config}; | ||
| use foundry_evm::utils::evm_spec; | ||
| use foundry_evm::executor::SpecId; | ||
| use std::{collections::BTreeMap, str::FromStr}; | ||
| use tracing::trace; | ||
| use ui::{TUIExitReason, Tui, Ui}; | ||
|
|
@@ -103,7 +103,7 @@ impl RunArgs { | |
| // configures a bare version of the evm executor: no cheatcode inspector is enabled, | ||
| // tracing will be enabled only for the targeted transaction | ||
| let builder = | ||
| ExecutorBuilder::default().with_config(env).with_spec(evm_spec(&config.evm_version)); | ||
| ExecutorBuilder::default().with_config(env).with_spec(SpecId::SHANGHAI); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is not doing what's intended—it's expected for the debugger to trip up when it sees a @Code0x2 doesn't the debugger work with
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Hm, I'm not convinced, this is kind of tricky: #5345 (comment)
This could also be a good solution: in my example there you'd error on push0, explain to the user why, and suggest re-running with the above flag
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @Evalir Im using the debugger from Maybe the better way is to allow setting evm version from cast cli |
||
|
|
||
| let mut executor = builder.build(db); | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,7 +1,7 @@ | ||
| use crossterm::{ | ||
| event::{ | ||
| self, DisableMouseCapture, EnableMouseCapture, Event, KeyCode, KeyEvent, KeyModifiers, | ||
| MouseEvent, MouseEventKind, | ||
| MouseEvent, MouseEventKind, KeyEventKind, | ||
| }, | ||
| execute, | ||
| terminal::{disable_raw_mode, enable_raw_mode, EnterAlternateScreen, LeaveAlternateScreen}, | ||
|
|
@@ -1312,9 +1312,11 @@ enum Interrupt { | |
| impl Interrupt { | ||
| fn char_press(&self) -> Option<char> { | ||
| if let Self::KeyPressed(event) = &self { | ||
| if let KeyCode::Char(c) = event.code { | ||
| if c.is_alphanumeric() || c == '\'' { | ||
| return Some(c) | ||
| if matches!(event.kind, KeyEventKind::Press) { | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. On what occasions will this happen? This has never been reported before 😅 do you have any way to test this?
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This happens on windows, it happened to me and another searcher who reported it in flashbots discord the other day. |
||
| if let KeyCode::Char(c) = event.code { | ||
| if c.is_alphanumeric() || c == '\'' { | ||
| return Some(c) | ||
| } | ||
| } | ||
|
Comment on lines
+1315
to
1320
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this is independent of the change above?
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yea independent change
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'd like to merge this individually |
||
| } | ||
| } | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hmm, not sure about this because this bypasses the config
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm this is interesting, because the push0 can come from the user's code OR a forked network's code.
If building something multichain, they might have their EVM config set to paris so it can work on mainnet and optimism. They may debug a test/tx against mainnet which has a push0, and because their code will be deployed to mainnet (shanghai), that debug experience should work. Not changing this means it would fail, because live code had a push0. Which means we SHOULD change the EVM version to shanghai for that case, even locally they chose paris.
Since we can't know the user's intentions (about what chains they'll use), I think we have to change this to shanghai to support the above case? And then maybe we just show a warning explaining that it was changed and why it was changed
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The reasoning for this change is that since this is only for the debugger, shanghai enables push0 code but doesnt disable other codes. hardcoded it because couldnt figure out a way to set evm version from
cast run -d