Skip to content

Commit

Permalink
fix: Avoid overflow
Browse files Browse the repository at this point in the history
By default `1` is assigned a 32-bit type, leading to overflow when
shifting left by 40 positions. Fixed with `u64` suffix, which forces
the expression to have type `u64` in which case shift left by 40
positions succeeds.

Co-authored-by: Ferdinand Sauer <ferdinand@neptune.cash>
Co-authored-by: Thorkil Schmidiger <thor@neptune.cash>
  • Loading branch information
3 people committed Nov 20, 2024
1 parent c4288ee commit 2175b1e
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/models/blockchain/transaction/validity/single_proof.rs
Original file line number Diff line number Diff line change
Expand Up @@ -878,7 +878,7 @@ mod test {
#[tokio::test]
async fn invalid_discriminant_crashes_execution() {
let pub_input = PublicInput::new(bfe_vec![0, 0, 0, 0, 0]);
for illegal_discriminant_value in bfe_array![-1, 3, 4, 1 << 40] {
for illegal_discriminant_value in bfe_array![-1, 3, 4, 1u64 << 40] {
let init_ram: HashMap<_, _> = [(
FIRST_NON_DETERMINISTICALLY_INITIALIZED_MEMORY_ADDRESS,
illegal_discriminant_value,
Expand Down

0 comments on commit 2175b1e

Please sign in to comment.