-
Notifications
You must be signed in to change notification settings - Fork 48
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
Deploy panic_data
handling
#2157
Conversation
97f2edd
to
4da575a
Compare
4da575a
to
adbe3f1
Compare
fn felt_from_short_string(short_str: &str) -> Felt252 { | ||
return Felt252::from_bytes_be(short_str.as_bytes()); | ||
} |
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 add some simple unit test for that
fn try_extract_panic_data(err: &str) -> Option<Vec<Felt252>> { | ||
let re = Regex::new(r#"(?m)^Got an exception while executing a hint: Custom Hint Error: Execution failed. Failure reason: "(.*)"\.$"#) | ||
.expect("Could not create panic_data matching regex"); | ||
|
||
if let Some(captures) = re.captures(err) { | ||
if let Some(panic_data_match) = captures.get(1) { | ||
let panic_data_felts: Vec<Felt252> = panic_data_match | ||
.as_str() | ||
.split(", ") | ||
.map(felt_from_short_string) | ||
.collect(); | ||
|
||
return Some(panic_data_felts); | ||
} | ||
} | ||
None | ||
} |
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 could be unit tested
insert_value_to_cellref!(vm, deployed_contract_address, contract_address)?; | ||
insert_value_to_cellref!(vm, panic_data_end, ptr)?; |
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.
Why are we inserting an address and panic data end here? Shouldn't it be panic data start end and?
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.
Keep in mind this will change anyways after merging #2163 - we will just return plain Span<felt252>
every time and extract panic_data
in cairo code.
You can look at the draft for handling errors in deploy
cheatcode, but feel free to do it however you feel like is the best.
I think we should try to not change the user interface too much while reimplementing it using general cheatcode.
panic_data.append('PANIK'); | ||
panic_data.append('DEJTA'); |
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.
😆
Please can we wait with merging for general cheatcode impl? 🥺 |
Make sure to remove the TODO after implementing it |
Checklist