Skip to content

Add gas_reserve_create libfunc. #7756

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

Merged
merged 1 commit into from
May 21, 2025

Conversation

liorgold2
Copy link
Collaborator

@liorgold2 liorgold2 commented May 16, 2025

Stack:

⚠️ Part of a stack created by spr. Do not merge manually using the UI - doing so may have unexpected results.

@reviewable-StarkWare
Copy link

This change is Reviewable

@liorgold2 liorgold2 force-pushed the pr/liorgold2/lior/gas-coupon/464dc795 branch from 95df5ef to 05267a7 Compare May 16, 2025 12:02
@liorgold2 liorgold2 force-pushed the pr/liorgold2/lior/gas-coupon/464dc795 branch 2 times, most recently from eb40216 to 0606f46 Compare May 16, 2025 13:23
@liorgold2 liorgold2 mentioned this pull request May 16, 2025
@liorgold2 liorgold2 requested a review from orizi May 16, 2025 13:24
@liorgold2 liorgold2 changed the title Add gas_coupon_buy libfunc. Add gas_reserve_create libfunc. May 20, 2025
@liorgold2 liorgold2 force-pushed the pr/liorgold2/lior/gas-coupon/464dc795 branch from 0606f46 to eb55e23 Compare May 20, 2025 14:33
Copy link
Collaborator

@orizi orizi left a comment

Choose a reason for hiding this comment

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

Reviewed 13 of 13 files at r2, all commit messages.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @liorgold2)


crates/cairo-lang-sierra-to-casm/src/invocations/gas_reserve.rs line 49 at r2 (raw file):

        HasEnoughGas:
        assert gas_minus_amount = *(range_check++);
    };

consider extracting and reusing at build_small_diff

Code quote:

    add_input_variables! {casm_builder,
        buffer(1) range_check;
        deref gas_counter;
        deref amount;
    };

    casm_build_extend! {casm_builder,
        let orig_range_check = range_check;
        tempvar has_enough_gas;
        tempvar gas_minus_amount = gas_counter - amount;
        hint TestLessThanOrEqual {lhs: amount, rhs: gas_counter} into {dst: has_enough_gas};
        jump HasEnoughGas if has_enough_gas != 0;

        // Failure. Prove that gas_minus_amount < 0.
        const u128_bound = (BigInt::from(u128::MAX) + 1) as BigInt;
        tempvar tmp = gas_minus_amount + u128_bound;
        assert tmp = *(range_check++);
        jump Failure;

        HasEnoughGas:
        assert gas_minus_amount = *(range_check++);
    };

@liorgold2 liorgold2 force-pushed the pr/liorgold2/lior/gas-coupon/464dc795 branch from eb55e23 to 0b78dc4 Compare May 21, 2025 10:52
Copy link
Collaborator

@orizi orizi left a comment

Choose a reason for hiding this comment

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

:lgtm:

Reviewed 3 of 3 files at r3, all commit messages.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on @liorgold2)

@liorgold2 liorgold2 added this pull request to the merge queue May 21, 2025
Merged via the queue into main with commit 20fcab6 May 21, 2025
96 checks passed
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.

3 participants