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

chore(blockifier): add syscalls_gas_costs struct #2359

Merged

Conversation

Yonatan-Starkware
Copy link
Contributor

No description provided.

@reviewable-StarkWare
Copy link

This change is Reviewable

Copy link
Collaborator

@Yoni-Starkware Yoni-Starkware left a comment

Choose a reason for hiding this comment

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

Reviewable status: 0 of 3 files reviewed, 3 unresolved discussions (waiting on @avi-starkware, @meship-starkware, and @Yonatan-Starkware)


crates/blockifier/src/versioned_constants.rs line 566 at r1 (raw file):

#[derive(Debug, Default, Deserialize)]
pub struct SyscallsGasCosts {

Suggestion:

SyscallGasCosts

crates/blockifier/src/versioned_constants.rs line 662 at r1 (raw file):

    // OS gas costs.
    pub transaction_gas_cost: u64,
    pub syscalls_gas_costs: SyscallsGasCosts,

Suggestion:

syscall_gas_costs

crates/blockifier/resources/versioned_constants_0_13_4.json line 120 at r1 (raw file):

        },
        "validated": "VALID",
        "syscalls_gas_costs": {

We are going to remove these fields from the VC eventually, right?
so better to wait with this PR

Code quote:

        "syscalls_gas_costs": {

@Yonatan-Starkware Yonatan-Starkware force-pushed the yonatank/blockifier/add_keccak_builtin_gas_cost branch from 8537aae to e574b59 Compare December 1, 2024 09:19
@Yonatan-Starkware Yonatan-Starkware force-pushed the yonatank/blockifier/add_syscalls_gas_costs_struct branch from 7ab50eb to 2f6b4f1 Compare December 1, 2024 09:19
Copy link
Collaborator

@Yoni-Starkware Yoni-Starkware left a comment

Choose a reason for hiding this comment

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

Reviewable status: 0 of 3 files reviewed, 3 unresolved discussions (waiting on @avi-starkware, @meship-starkware, and @Yonatan-Starkware)


crates/blockifier/resources/versioned_constants_0_13_4.json line 121 at r2 (raw file):

        "validated": "VALID",
        "syscalls_gas_costs": {
            "call_contract_gas_cost": {

Now you can remove the _gas_cost suffix

Suggestion:

"call_contract"

Copy link
Collaborator

@Yoni-Starkware Yoni-Starkware left a comment

Choose a reason for hiding this comment

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

Reviewable status: 0 of 3 files reviewed, 4 unresolved discussions (waiting on @avi-starkware, @meship-starkware, and @Yonatan-Starkware)


crates/blockifier/src/versioned_constants.rs line 567 at r2 (raw file):

#[derive(Debug, Default, Deserialize)]
pub struct SyscallsGasCosts {
    pub call_contract_gas_cost: u64,

Now you can remove this suffix

Suggestion:

pub call_contract: u64,

Copy link
Collaborator

@Yoni-Starkware Yoni-Starkware left a comment

Choose a reason for hiding this comment

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

Reviewable status: 0 of 3 files reviewed, 5 unresolved discussions (waiting on @avi-starkware, @meship-starkware, and @Yonatan-Starkware)


crates/blockifier/src/versioned_constants.rs line 705 at r2 (raw file):

            BuiltinName::mul_mod => self.base_gas_costs.mul_mod_gas_cost,
            BuiltinName::segment_arena => return Err(GasCostsError::VirtualBuiltin),
            BuiltinName::output | BuiltinName::ecdsa => {

You should have a price for this builtin as well now

Code quote:

 BuiltinName::ecdsa 

Copy link
Collaborator

@Yoni-Starkware Yoni-Starkware left a comment

Choose a reason for hiding this comment

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

Reviewable status: 0 of 3 files reviewed, 6 unresolved discussions (waiting on @avi-starkware, @meship-starkware, and @Yonatan-Starkware)


crates/blockifier/src/versioned_constants.rs line 682 at r2 (raw file):

        }        
    }
}

Please remove this impl. This is only used in the parsing phase, so just do it there

Code quote:

impl BaseGasCosts {
    fn get(&self, key: &str) -> u64 {
        match key {
            "step_gas_cost" => self.step_gas_cost,
            "memory_hole_gas_cost" => self.memory_hole_gas_cost,
            "range_check_gas_cost" => self.range_check_gas_cost,
            "keccak_builtin_gas_cost" => self.keccak_builtin_gas_cost,
            "pedersen_gas_cost" => self.pedersen_gas_cost,
            "bitwise_builtin_gas_cost" => self.bitwise_builtin_gas_cost,
            "ecop_gas_cost" => self.ecop_gas_cost,
            "poseidon_gas_cost" => self.poseidon_gas_cost,
            "add_mod_gas_cost" => self.add_mod_gas_cost,
            "mul_mod_gas_cost" => self.mul_mod_gas_cost,
            "default_initial_gas_cost" => self.default_initial_gas_cost,
            "entry_point_initial_budget" => self.entry_point_initial_budget,
            "syscall_base_gas_cost" => self.syscall_base_gas_cost,
            "transaction_gas_cost" => self.transaction_gas_cost,
            _ => panic! ("unvalid key"),
        }
    }
}

@Yonatan-Starkware Yonatan-Starkware force-pushed the yonatank/blockifier/add_syscalls_gas_costs_struct branch from 2f6b4f1 to 20c662c Compare December 1, 2024 12:03
Copy link
Contributor

@meship-starkware meship-starkware left a comment

Choose a reason for hiding this comment

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

Reviewed 1 of 3 files at r1, 10 of 13 files at r3.
Reviewable status: 10 of 13 files reviewed, 9 unresolved discussions (waiting on @avi-starkware, @Yonatan-Starkware, and @Yoni-Starkware)


crates/blockifier/src/versioned_constants.rs line 705 at r2 (raw file):

Previously, Yoni-Starkware (Yoni) wrote…

You should have a price for this builtin as well now

The price should be 10561; it is not part of the VC for now. Should we add a PR like the keccak one to it?


crates/blockifier/resources/versioned_constants_0_13_4.json line 98 at r2 (raw file):

        "poseidon_gas_cost": 491,
        "add_mod_gas_cost": 230,
        "mul_mod_gas_cost": 604,

It does not have to be on this PR, but please extract the builtins to a sub-category as well

Suggestion:

        Builtins_l2_gas_cost: {
        "range_check": 70,
        "keccak_builtin": 136189,
        "pedersen": 4050,
        "bitwise_builtin": 583,
        "ecop": 4085,
        "poseidon": 491,
        "add_mod": 230,
        "mul_mod": 604,
    }

crates/blockifier/resources/versioned_constants_0_13_4.json line 120 at r2 (raw file):

        },
        "validated": "VALID",
        "syscalls_gas_costs": {

That would make Tzahi happy

Suggestion:

"syscalls_l2_gas_costs

crates/blockifier/src/versioned_constants_test.rs line 201 at r2 (raw file):

            "step_gas_cost": 3
        },
        "transaction_gas_cost": {

Can you add one nestes syscall to this test?

@Yonatan-Starkware Yonatan-Starkware force-pushed the yonatank/blockifier/add_keccak_builtin_gas_cost branch from e574b59 to 33c6748 Compare December 1, 2024 12:51
@Yonatan-Starkware Yonatan-Starkware force-pushed the yonatank/blockifier/add_syscalls_gas_costs_struct branch 3 times, most recently from 617ea6d to ddb025c Compare December 1, 2024 13:43
@Yonatan-Starkware
Copy link
Contributor Author

crates/blockifier/resources/versioned_constants_0_13_4.json line 98 at r2 (raw file):

Previously, meship-starkware (Meshi Peled) wrote…

It does not have to be on this PR, but please extract the builtins to a sub-category as well

next PR, this one is already big enough

@Yonatan-Starkware Yonatan-Starkware force-pushed the yonatank/blockifier/add_syscalls_gas_costs_struct branch from ddb025c to bb04196 Compare December 1, 2024 13:59
Copy link
Collaborator

@Yoni-Starkware Yoni-Starkware left a comment

Choose a reason for hiding this comment

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

Reviewed 4 of 7 files at r5.
Reviewable status: 11 of 19 files reviewed, 10 unresolved discussions (waiting on @avi-starkware, @meship-starkware, and @Yonatan-Starkware)


crates/blockifier/resources/versioned_constants_0_13_1_1.json line 651 at r6 (raw file):

        ]
    }
}

Revert this on all files

Copy link
Collaborator

@Yoni-Starkware Yoni-Starkware left a comment

Choose a reason for hiding this comment

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

Reviewable status: 11 of 19 files reviewed, 9 unresolved discussions (waiting on @avi-starkware, @meship-starkware, and @Yonatan-Starkware)


crates/blockifier/src/versioned_constants.rs line 705 at r2 (raw file):

Previously, meship-starkware (Meshi Peled) wrote…

The price should be 10561; it is not part of the VC for now. Should we add a PR like the keccak one to it?

Yes


crates/blockifier/src/versioned_constants.rs line 667 at r6 (raw file):

pub struct GasCosts {
    pub base_gas_costs: BaseGasCosts, 
    pub syscall_gas_costs: SyscallGasCosts,

Suggestion:

    pub base: BaseGasCosts,
    pub syscalls: SyscallGasCosts,

Copy link
Contributor

@meship-starkware meship-starkware left a comment

Choose a reason for hiding this comment

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

Reviewed 1 of 13 files at r3, 7 of 11 files at r4, 6 of 7 files at r5, 1 of 1 files at r6.
Reviewable status: all files reviewed (commit messages unreviewed), 9 unresolved discussions (waiting on @avi-starkware and @Yonatan-Starkware)

@Yonatan-Starkware Yonatan-Starkware force-pushed the yonatank/blockifier/add_syscalls_gas_costs_struct branch from bb04196 to 760b8b7 Compare December 1, 2024 15:58
@Yonatan-Starkware Yonatan-Starkware force-pushed the yonatank/blockifier/add_syscalls_gas_costs_struct branch from ad4e1f9 to a3d5e5a Compare December 5, 2024 10:03
@Yonatan-Starkware Yonatan-Starkware force-pushed the yonatank/blockifier/add_keccak_builtin_gas_cost branch from 18c0d49 to cafa73f Compare December 5, 2024 11:13
@Yonatan-Starkware Yonatan-Starkware force-pushed the yonatank/blockifier/add_syscalls_gas_costs_struct branch from a3d5e5a to d4e2e1f Compare December 5, 2024 11:46
Copy link
Contributor

@meship-starkware meship-starkware left a comment

Choose a reason for hiding this comment

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

Reviewed 5 of 5 files at r11, 2 of 2 files at r12, all commit messages.
Reviewable status: all files reviewed, 4 unresolved discussions (waiting on @avi-starkware and @Yonatan-Starkware)

@Yonatan-Starkware Yonatan-Starkware force-pushed the yonatank/blockifier/add_keccak_builtin_gas_cost branch from cafa73f to 8d7c3a5 Compare December 5, 2024 15:12
@Yonatan-Starkware Yonatan-Starkware force-pushed the yonatank/blockifier/add_syscalls_gas_costs_struct branch from d4e2e1f to 9d8115f Compare December 5, 2024 15:12
@Yonatan-Starkware
Copy link
Contributor Author

crates/blockifier/src/versioned_constants.rs line 705 at r2 (raw file):

Previously, Yoni-Starkware (Yoni) wrote…

Yes

should the price be 0 in the old jsons? or the above?

@Yonatan-Starkware Yonatan-Starkware changed the base branch from yonatank/blockifier/add_keccak_builtin_gas_cost to graphite-base/2359 December 5, 2024 16:15
@Yonatan-Starkware Yonatan-Starkware force-pushed the yonatank/blockifier/add_syscalls_gas_costs_struct branch from 9d8115f to 44a4a6f Compare December 5, 2024 16:16
@Yonatan-Starkware Yonatan-Starkware changed the base branch from graphite-base/2359 to main December 5, 2024 16:16
@Yonatan-Starkware Yonatan-Starkware force-pushed the yonatank/blockifier/add_syscalls_gas_costs_struct branch from 44a4a6f to 82b0083 Compare December 5, 2024 16:16
Copy link
Contributor

@meship-starkware meship-starkware left a comment

Choose a reason for hiding this comment

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

Reviewed 1 of 1 files at r13, all commit messages.
Reviewable status: all files reviewed, 4 unresolved discussions (waiting on @avi-starkware, @Yonatan-Starkware, and @Yoni-Starkware)

Copy link
Collaborator

@Yoni-Starkware Yoni-Starkware 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 4 of 4 files at r14, all commit messages.
Reviewable status: all files reviewed, 2 unresolved discussions (waiting on @avi-starkware and @Yonatan-Starkware)

Copy link
Collaborator

@Yoni-Starkware Yoni-Starkware left a comment

Choose a reason for hiding this comment

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

Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @avi-starkware)

@Yonatan-Starkware Yonatan-Starkware force-pushed the yonatank/blockifier/add_syscalls_gas_costs_struct branch 2 times, most recently from a4e9622 to b6948ba Compare December 8, 2024 09:56
@Yonatan-Starkware Yonatan-Starkware force-pushed the yonatank/blockifier/add_syscalls_gas_costs_struct branch from b6948ba to 347b59e Compare December 8, 2024 10:28
@Yonatan-Starkware
Copy link
Contributor Author

crates/blockifier/resources/versioned_constants_0_13_4.json line 120 at r1 (raw file):

Previously, Yoni-Starkware (Yoni) wrote…

We are going to remove these fields from the VC eventually, right?
so better to wait with this PR

Done.

Copy link
Contributor Author

@Yonatan-Starkware Yonatan-Starkware left a comment

Choose a reason for hiding this comment

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

Reviewable status: 11 of 21 files reviewed, 1 unresolved discussion (waiting on @avi-starkware, @meship-starkware, and @Yoni-Starkware)


crates/blockifier/src/versioned_constants_test.rs line 141 at r9 (raw file):

Previously, Yoni-Starkware (Yoni) wrote…

Is this necessary?

Done.


crates/blockifier/src/versioned_constants.rs line 755 at r9 (raw file):

            syscalls : syscalls,
        };
        Ok(gas_costs)

Done.

Copy link
Collaborator

@Yoni-Starkware Yoni-Starkware left a comment

Choose a reason for hiding this comment

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

Reviewed 6 of 10 files at r15, 4 of 4 files at r16, all commit messages.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @avi-starkware)

Copy link
Contributor

@meship-starkware meship-starkware left a comment

Choose a reason for hiding this comment

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

Reviewed 3 of 4 files at r14, 6 of 10 files at r15, 4 of 4 files at r16, all commit messages.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @avi-starkware)

Copy link
Contributor

@meship-starkware meship-starkware left a comment

Choose a reason for hiding this comment

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

Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @avi-starkware)

Copy link
Contributor

@meship-starkware meship-starkware left a comment

Choose a reason for hiding this comment

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

Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on @avi-starkware)

@Yonatan-Starkware Yonatan-Starkware merged commit a0dd2fb into main Dec 8, 2024
13 checks passed
@github-actions github-actions bot locked and limited conversation to collaborators Dec 10, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants