Skip to content
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

Handle additional panics #1250

Merged
merged 13 commits into from
Sep 26, 2023
Merged

Handle additional panics #1250

merged 13 commits into from
Sep 26, 2023

Conversation

Nashtare
Copy link
Collaborator

This PR partly addresses #1247. More specifically, it handles (on the EVM crate):

  • all risky as_usize() calls
  • all risky expect() calls
  • U256 methods with implicit internal panic (from_big_endian / from_big_endian / div_mod).

I haven't changed (unless required from cascade changes) the kernel / tests + interpreter files as those don't matter as much (panic in testing is fine, and the kernel risks of panic would arise during the offline preprocessing phase which would be caught ahead).

@Nashtare Nashtare self-assigned this Sep 22, 2023
Copy link
Contributor

@wborgeaud wborgeaud left a comment

Choose a reason for hiding this comment

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

Looks good to me!

Comment on lines 220 to 221
let mut state = GenerationState::<F>::new(inputs.clone(), &KERNEL.code)
.map_err(|_| anyhow!("Failed to parse all the initial prover inputs"))?;
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: Could also do

.map_err(|err| anyhow!("Failed to parse all the initial prover inputs: {:?}", err))?;

to get more info on which ProgramError was thrown. Also applies elsewhere in this PR.

evm/src/util.rs Outdated
Comment on lines 75 to 79
if TryInto::<usize>::try_into(u256).is_err() {
return Err(ProgramError::IntegerTooLarge);
}

Ok(u256.as_usize())
Copy link
Contributor

Choose a reason for hiding this comment

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

nit

Suggested change
if TryInto::<usize>::try_into(u256).is_err() {
return Err(ProgramError::IntegerTooLarge);
}
Ok(u256.as_usize())
u256.try_into().map_err(|_| ProgramError::IntegerTooLarge)

@Nashtare Nashtare merged commit 03a9558 into 0xPolygonZero:main Sep 26, 2023
2 checks passed
@Nashtare Nashtare deleted the panics branch September 26, 2023 15:14
@Nashtare Nashtare mentioned this pull request Oct 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants