-
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
Conversation
mattsse
left a comment
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.
ptal @Evalir
| // 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); |
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
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
| if matches!(event.kind, KeyEventKind::Press) { | ||
| if let KeyCode::Char(c) = event.code { | ||
| if c.is_alphanumeric() || c == '\'' { | ||
| return Some(c) | ||
| } | ||
| } |
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.
this is independent of the change above?
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.
yea independent change
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.
I'd like to merge this individually
can you split these changes into two, the spec/env changes needs some investigation
| // 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); |
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.
This is not doing what's intended—it's expected for the debugger to trip up when it sees a PUSH0 opcode if the evm version is not set to shanghai.
@Code0x2 doesn't the debugger work with --evm-version shanghai on the cli or evm_version=shanghai on your foundry.toml? I believe we do not need this change at all—you just need to set the appropiate evm version.
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.
it's expected for the debugger to trip up when it sees a PUSH0 opcode if the evm version is not set to shanghai.
Hm, I'm not convinced, this is kind of tricky: #5345 (comment)
doesn't the debugger work with
--evm-version shanghaion the cli orevm_version=shanghaion yourfoundry.toml? I believe we do not need this change at all—you just need to set the appropiate evm version.
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
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.
@Evalir Im using the debugger from cast run -d -r <rpc> <txhash>, and there is no option there to set evm version
Maybe the better way is to allow setting evm version from cast cli
| if let KeyCode::Char(c) = event.code { | ||
| if c.is_alphanumeric() || c == '\'' { | ||
| return Some(c) | ||
| if matches!(event.kind, KeyEventKind::Press) { |
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.
On what occasions will this happen? This has never been reported before 😅 do you have any way to test this?
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.
This happens on windows, it happened to me and another searcher who reported it in flashbots discord the other day.
Works fine on linux though, dunno why
mattsse
left a comment
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.
since the interrupt changes are valid on it's own it'd like to have these changes in two separate prs
|
agree w/ mattsse—let's split this pr please 🙏 |
|
superseded by #5547 cc @iFrostizz |
Motivation
The debugger bricks up when it hits push0 opcode
Additionally, the debugger will run keystrokes twice
Solution
Set the default evm version to shanghai and only trigger keystrokes on press