-
Notifications
You must be signed in to change notification settings - Fork 545
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
Return Error if CKZG or BLS features are disabled, but are called #1448
Closed
Closed
Changes from 5 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
c878ea5
change ```PrecompileResult``` to enum
rupam-04 69b65f8
fixed tests and fmt
rupam-04 3380df7
define ```PrecompileResult``` as ```Result<PrecompileOutput, Precomp…
rupam-04 328ea25
replace ```PrecompileResult::err``` with ```PrecompileErrors::err```
rupam-04 953cff5
implement ```From<PrecompileError>``` for ```PrecompileErrors```
rupam-04 4bf5bb3
drop ```revm-precompile``` from dependencies
rupam-04 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,7 +6,7 @@ use super::{ | |
}; | ||
use crate::{u64_to_address, PrecompileWithAddress}; | ||
use blst::{blst_p1, blst_p1_affine, blst_p1_from_affine, blst_p1_to_affine, p1_affines}; | ||
use revm_primitives::{Bytes, Precompile, PrecompileError, PrecompileResult}; | ||
use revm_primitives::{Bytes, Precompile, PrecompileError, PrecompileErrors, PrecompileResult}; | ||
|
||
/// [EIP-2537](https://eips.ethereum.org/EIPS/eip-2537#specification) BLS12_G1MSM precompile. | ||
pub const PRECOMPILE: PrecompileWithAddress = | ||
|
@@ -29,13 +29,13 @@ pub(super) fn g1_msm(input: &Bytes, gas_limit: u64) -> PrecompileResult { | |
"G1MSM input length should be multiple of {}, was {}", | ||
g1_mul::INPUT_LENGTH, | ||
input_len | ||
))); | ||
)).into()); | ||
} | ||
|
||
let k = input_len / g1_mul::INPUT_LENGTH; | ||
let required_gas = msm_required_gas(k, g1_mul::BASE_GAS_FEE); | ||
if required_gas > gas_limit { | ||
return Err(PrecompileError::OutOfGas); | ||
return Err(PrecompileError::OutOfGas.into()); | ||
} | ||
|
||
let mut g1_points: Vec<blst_p1> = Vec::with_capacity(k); | ||
|
@@ -53,7 +53,7 @@ pub(super) fn g1_msm(input: &Bytes, gas_limit: u64) -> PrecompileResult { | |
// NB: Scalar multiplications, MSMs and pairings MUST perform a subgroup check. | ||
// | ||
// So we set the subgroup_check flag to `true` | ||
let p0_aff = &extract_g1_input(slice, true)?; | ||
let p0_aff = &extract_g1_input(slice, true).unwrap(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why unwrap? |
||
|
||
let mut p0 = blst_p1::default(); | ||
// SAFETY: p0 and p0_aff are blst values. | ||
|
@@ -64,14 +64,15 @@ pub(super) fn g1_msm(input: &Bytes, gas_limit: u64) -> PrecompileResult { | |
&extract_scalar_input( | ||
&input[i * g1_mul::INPUT_LENGTH + G1_INPUT_ITEM_LENGTH | ||
..i * g1_mul::INPUT_LENGTH + G1_INPUT_ITEM_LENGTH + SCALAR_LENGTH], | ||
)? | ||
) | ||
.unwrap() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. unwrap? |
||
.b, | ||
); | ||
} | ||
|
||
// return infinity point if all points are infinity | ||
if g1_points.is_empty() { | ||
return Ok((required_gas, [0; 128].into())); | ||
return PrecompileResult::ok(required_gas, [0; 128].into()); | ||
} | ||
|
||
let points = p1_affines::from(&g1_points); | ||
|
@@ -82,5 +83,5 @@ pub(super) fn g1_msm(input: &Bytes, gas_limit: u64) -> PrecompileResult { | |
unsafe { blst_p1_to_affine(&mut multiexp_aff, &multiexp) }; | ||
|
||
let out = encode_g1_point(&multiexp_aff); | ||
Ok((required_gas, out)) | ||
PrecompileResult::ok(required_gas, out) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
unwrap
here?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.
if I useexpect
, then what panic msg should I give? Or should I use something else altogether?