Skip to content

Commit

Permalink
[KGA-70] fix: handle_l1_message gas price set to 0 (#1584)
Browse files Browse the repository at this point in the history
<!--- Please provide a general summary of your changes in the title
above -->

<!-- Give an estimate of the time you spent on this PR in terms of work
days.
Did you spend 0.5 days on this PR or rather 2 days?  -->

Time spent on this PR:

## Pull request type

<!-- Please try to limit your pull request to one type,
submit multiple pull requests if needed. -->

Please check the type of change your PR introduces:

- [x] Bugfix
- [ ] Feature
- [ ] Code style update (formatting, renaming)
- [ ] Refactoring (no functional changes, no api changes)
- [ ] Build related changes
- [ ] Documentation content changes
- [ ] Other (please describe):

## What is the current behavior?

<!-- Please describe the current behavior that you are modifying,
or link to a relevant issue. -->

Resolves #<Issue number>

## What is the new behavior?

<!-- Please describe the behavior or changes that are being added by
this PR. -->

Fees are payed on L1 in the starknet messaging contract.
Users should not pay a second time.

<!-- Reviewable:start -->
- - -
This change is [<img src="https://reviewable.io/review_button.svg"
height="34" align="absmiddle"
alt="Reviewable"/>](https://reviewable.io/reviews/kkrt-labs/kakarot/1584)
<!-- Reviewable:end -->
  • Loading branch information
obatirou authored Nov 7, 2024
1 parent 3b4553f commit e791ac1
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
3 changes: 3 additions & 0 deletions cairo_zero/kakarot/constants.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ namespace Constants {
// FIELD PRIME
const FELT252_PRIME_HIGH = 0x8000000000000110000000000000000;
const FELT252_PRIME_LOW = 0x1;

// Infinite gas handle_l1_message
const INFINITE_GAS = 2 ** 64 - 1;
}

// See model.Opcode:
Expand Down
7 changes: 6 additions & 1 deletion cairo_zero/kakarot/library.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -395,6 +395,11 @@ namespace Kakarot {
return l1_messaging_contract_address;
}

// @notice Handle an L1 message
// Gas is paid on L1 through the starknet messaging system hence this should not
// revert due to OOG.
// The gas limit is set to Constants.INFINITE_GAS.
// The gas price is set to 0 so no gas is paid and no refund is given.
func handle_l1_message{
syscall_ptr: felt*,
pedersen_ptr: HashBuiltin*,
Expand All @@ -410,7 +415,7 @@ namespace Kakarot {
let (access_list) = alloc();

return eth_call(
0, l1_sender, to, 2100000000, 1, value_u256, data_len, data, 0, access_list
0, l1_sender, to, Constants.INFINITE_GAS, 0, value_u256, data_len, data, 0, access_list
);
}

Expand Down

0 comments on commit e791ac1

Please sign in to comment.