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

feat: whitelist 'compute_starknet_address' from reentrancy #1254

Merged
merged 2 commits into from
Jul 5, 2024
Merged
Changes from 1 commit
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
Prev Previous commit
update revert status of precompiles
  • Loading branch information
enitrat committed Jul 5, 2024
commit cd022186aabbb93b3bd819cc9881ebe97795dce7
14 changes: 6 additions & 8 deletions src/kakarot/precompiles/kakarot_precompiles.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,7 @@
let is_input_invalid = is_le(input_len, 99);
if (is_input_invalid != 0) {
let (revert_reason_len, revert_reason) = Errors.outOfBoundsRead();
return (
revert_reason_len, revert_reason, CAIRO_PRECOMPILE_GAS, Errors.EXCEPTIONAL_HALT
);
return (revert_reason_len, revert_reason, CAIRO_PRECOMPILE_GAS, TRUE);
}

// Input is formatted as:
Expand Down Expand Up @@ -102,7 +100,7 @@
);
if (success == FALSE) {
// skip formatting to bytes32 array and return revert reason directly
return (retdata_len, retdata, CAIRO_PRECOMPILE_GAS, TRUE);

Check warning on line 103 in src/kakarot/precompiles/kakarot_precompiles.cairo

View check run for this annotation

Codecov / codecov/patch

src/kakarot/precompiles/kakarot_precompiles.cairo#L103

Added line #L103 was not covered by tests
}

let (output) = alloc();
Expand All @@ -118,11 +116,11 @@
let (output) = alloc();
let output_len = retdata_len * 32;
Helpers.felt_array_to_bytes32_array(retdata_len, retdata, output);
return (output_len, output, CAIRO_PRECOMPILE_GAS, 0);
return (output_len, output, CAIRO_PRECOMPILE_GAS, FALSE);
}

let (revert_reason_len, revert_reason) = Errors.invalidCairoSelector();
return (revert_reason_len, revert_reason, CAIRO_PRECOMPILE_GAS, Errors.EXCEPTIONAL_HALT);
return (revert_reason_len, revert_reason, CAIRO_PRECOMPILE_GAS, TRUE);

Check warning on line 123 in src/kakarot/precompiles/kakarot_precompiles.cairo

View check run for this annotation

Codecov / codecov/patch

src/kakarot/precompiles/kakarot_precompiles.cairo#L123

Added line #L123 was not covered by tests
}

// @notice Sends a message to a message to L1.
Expand All @@ -143,7 +141,7 @@
let is_input_invalid = is_le(input_len, 95);
if (is_input_invalid != 0) {
let (revert_reason_len, revert_reason) = Errors.outOfBoundsRead();
return (revert_reason_len, revert_reason, CAIRO_MESSAGE_GAS, Errors.EXCEPTIONAL_HALT);
return (revert_reason_len, revert_reason, CAIRO_MESSAGE_GAS, TRUE);
}

// Input is formatted as:
Expand All @@ -156,7 +154,7 @@
let data_fits_in_input = is_le(data_bytes_len, input_len - 3 * 32);
if (data_fits_in_input == 0) {
let (revert_reason_len, revert_reason) = Errors.outOfBoundsRead();
return (revert_reason_len, revert_reason, CAIRO_MESSAGE_GAS, Errors.EXCEPTIONAL_HALT);
return (revert_reason_len, revert_reason, CAIRO_MESSAGE_GAS, TRUE);
}
let data_ptr = input + 3 * 32;

Expand All @@ -165,6 +163,6 @@

send_message_to_l1(target_address, data_bytes_len, data_ptr);
let (output) = alloc();
return (0, output, CAIRO_MESSAGE_GAS, 0);
return (0, output, CAIRO_MESSAGE_GAS, FALSE);
}
}
Loading