Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions cli/src/cmd/cast/run.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down Expand Up @@ -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);
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

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


let mut executor = builder.build(db);

Expand Down
10 changes: 6 additions & 4 deletions ui/src/lib.rs
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},
Expand Down Expand Up @@ -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) {
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

if let KeyCode::Char(c) = event.code {
if c.is_alphanumeric() || c == '\'' {
return Some(c)
}
}
Comment on lines +1315 to 1320
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

}
}
Expand Down