Skip to content

Conversation

@Code0x2
Copy link

@Code0x2 Code0x2 commented Jul 10, 2023

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

Copy link
Member

@mattsse mattsse left a 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);
Copy link
Member

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

Copy link
Collaborator

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

Copy link
Author

@Code0x2 Code0x2 Jul 12, 2023

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

Comment on lines +1315 to 1320
if matches!(event.kind, KeyEventKind::Press) {
if let KeyCode::Char(c) = event.code {
if c.is_alphanumeric() || c == '\'' {
return Some(c)
}
}
Copy link
Member

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?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yea independent change

Copy link
Member

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

@mattsse mattsse added the A-debugger Area: debugger label Jul 10, 2023
// 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);
Copy link
Member

@Evalir Evalir Jul 10, 2023

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.

Copy link
Collaborator

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 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.

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

Copy link
Author

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) {
Copy link
Member

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?

Copy link
Author

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

Copy link
Member

@mattsse mattsse left a 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

@Evalir
Copy link
Member

Evalir commented Jul 15, 2023

agree w/ mattsse—let's split this pr please 🙏

@Evalir
Copy link
Member

Evalir commented Aug 21, 2023

superseded by #5547 cc @iFrostizz

@Evalir Evalir closed this Aug 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-debugger Area: debugger

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants