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

refactor(blockifier): replace WORD_WIDTH w FELT_WIDTH in contract_class #1967

Conversation

avivg-starkware
Copy link
Contributor

No description provided.

@reviewable-StarkWare
Copy link

This change is Reviewable

Copy link
Contributor Author

This stack of pull requests is managed by Graphite. Learn more about stacking.

Join @avivg-starkware and the rest of your teammates on Graphite Graphite

@avivg-starkware avivg-starkware changed the title avivg/blockifier/use_api_WORD_WIDTH_and_remove_blockifier_WORD_WIDTH refactor(blockifier): remove WORD_WIDTH from blockifier, use starkn et_api instead Nov 12, 2024
@avivg-starkware avivg-starkware marked this pull request as ready for review November 12, 2024 06:41
Copy link

Artifacts upload triggered. View details here

Copy link

Artifacts upload triggered. View details here

@avivg-starkware avivg-starkware force-pushed the avivg/blockifier/remove_WORD_WIDTH_from_blockifier_use_starknet_api_instead branch from cb06e92 to de3c5c0 Compare November 12, 2024 06:52
Copy link

Artifacts upload triggered. View details here

Copy link

codecov bot commented Nov 12, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 75.67%. Comparing base (e3165c4) to head (2aa0c56).
Report is 358 commits behind head on main.

Additional details and impacted files
@@             Coverage Diff             @@
##             main    #1967       +/-   ##
===========================================
+ Coverage   40.10%   75.67%   +35.56%     
===========================================
  Files          26      103       +77     
  Lines        1895    13827    +11932     
  Branches     1895    13827    +11932     
===========================================
+ Hits          760    10463     +9703     
- Misses       1100     2909     +1809     
- Partials       35      455      +420     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@avivg-starkware avivg-starkware force-pushed the avivg/blockifier/remove_WORD_WIDTH_from_blockifier_use_starknet_api_instead branch from de3c5c0 to 170a607 Compare November 12, 2024 07:32
Copy link

Artifacts upload triggered. View details here

Copy link
Contributor

@ArniStarkware ArniStarkware left a comment

Choose a reason for hiding this comment

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

Reviewed 2 of 3 files at r1.
Reviewable status: 2 of 3 files reviewed, 1 unresolved discussion (waiting on @avivg-starkware and @Yoni-Starkware)


crates/blockifier/src/fee/eth_gas_constants.rs line 5 at r1 (raw file):

pub const GAS_PER_MEMORY_ZERO_BYTE: usize = 4;
pub const GAS_PER_MEMORY_BYTE: usize = 16;
pub const GAS_PER_MEMORY_WORD: usize = GAS_PER_MEMORY_BYTE * WORD_WIDTH;
  1. Be consistent.
  2. Imports come before everything.

Suggestion:

pub const GAS_PER_MEMORY_ZERO_BYTE: usize = 4;
pub const GAS_PER_MEMORY_BYTE: usize = 16;
pub const GAS_PER_MEMORY_WORD: usize = GAS_PER_MEMORY_BYTE * starknet_api::core::WORD_WIDTH;

@avivg-starkware avivg-starkware force-pushed the avivg/blockifier/remove_WORD_WIDTH_from_blockifier_use_starknet_api_instead branch from 170a607 to 4632773 Compare November 12, 2024 07:58
Copy link

Artifacts upload triggered. View details here

Copy link
Contributor Author

@avivg-starkware avivg-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: 1 of 3 files reviewed, 1 unresolved discussion (waiting on @ArniStarkware and @Yoni-Starkware)


crates/blockifier/src/fee/eth_gas_constants.rs line 5 at r1 (raw file):

Previously, ArniStarkware (Arnon Hod) wrote…
  1. Be consistent.
  2. Imports come before everything.

1- by consistent, you're referring to the use of "starknet_api::core::WORD_WIDTH" in the other files?
(that is used without 'use' but rather explicitly? )

if so, I did so in this file as well. Otherwise, I'm sorry not sure i understand.

2- I see, I thought comments are excluded.

Copy link
Contributor

@ArniStarkware ArniStarkware 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, 1 of 1 files at r2.
Reviewable status: all files reviewed (commit messages unreviewed), 1 unresolved discussion (waiting on @avivg-starkware and @Yoni-Starkware)


crates/blockifier/src/fee/eth_gas_constants.rs line 5 at r1 (raw file):

Previously, avivg-starkware wrote…

1- by consistent, you're referring to the use of "starknet_api::core::WORD_WIDTH" in the other files?
(that is used without 'use' but rather explicitly? )

if so, I did so in this file as well. Otherwise, I'm sorry not sure i understand.

2- I see, I thought comments are excluded.

  1. Yes - this is what I meant.

a discussion (no related file):
I apologize - because this is contradictory to my latest comment. Please import the const in each file using: starknet_api::core::WORD_WIDTH.

Copy link
Contributor

@ArniStarkware ArniStarkware 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 (commit messages unreviewed), 1 unresolved discussion (waiting on @avivg-starkware and @Yoni-Starkware)


a discussion (no related file):

Previously, ArniStarkware (Arnon Hod) wrote…

I apologize - because this is contradictory to my latest comment. Please import the const in each file using: starknet_api::core::WORD_WIDTH.

use starknet_api::core::WORD_WIDTH;

@avivg-starkware avivg-starkware force-pushed the avivg/blockifier/remove_WORD_WIDTH_from_blockifier_use_starknet_api_instead branch from 4632773 to 595fcf0 Compare November 12, 2024 09:08
Copy link

Artifacts upload triggered. View details here

Copy link
Contributor Author

@avivg-starkware avivg-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, 1 unresolved discussion (waiting on @ArniStarkware and @Yoni-Starkware)


a discussion (no related file):

Previously, ArniStarkware (Arnon Hod) wrote…

use starknet_api::core::WORD_WIDTH;

all good, Done :)

Copy link
Contributor

@ArniStarkware ArniStarkware 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 @Yoni-Starkware)

@avivg-starkware avivg-starkware force-pushed the avivg/blockifier/remove_WORD_WIDTH_from_blockifier_use_starknet_api_instead branch from 595fcf0 to 0bd4c0d Compare November 12, 2024 12:27
Copy link

Artifacts upload triggered. View details here

@avivg-starkware avivg-starkware force-pushed the avivg/blockifier/remove_WORD_WIDTH_from_blockifier_use_starknet_api_instead branch from 0bd4c0d to e759d81 Compare November 12, 2024 12:36
Copy link

Artifacts upload triggered. View details here

Copy link
Contributor

@ArniStarkware ArniStarkware 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 r4, all commit messages.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on @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.

Blocking

Reviewed all commit messages.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on @avivg-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 @avivg-starkware)


crates/blockifier/src/fee/eth_gas_constants.rs line 1 at r4 (raw file):

use starknet_api::core::WORD_WIDTH;

Remove this const, and instead define FELT_WIDTH = 32 in contract_class.rs
WORD_WIDTH is the size of a word in ethereum.
In code_size, we approximate the code size by adding the max size of each element, which is felt, which is accidentally 32. Felt width could have been different.

Code quote:

use starknet_api::core::WORD_WIDTH;

@avivg-starkware avivg-starkware force-pushed the avivg/blockifier/remove_WORD_WIDTH_from_blockifier_use_starknet_api_instead branch 2 times, most recently from 30842e9 to 7c22e27 Compare November 13, 2024 08:22
Copy link

Artifacts upload triggered. View details here

Copy link

Artifacts upload triggered. View details here

Copy link
Contributor Author

@avivg-starkware avivg-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: 3 of 5 files reviewed, 1 unresolved discussion (waiting on @ArniStarkware and @Yoni-Starkware)


crates/blockifier/src/fee/eth_gas_constants.rs line 1 at r4 (raw file):

Previously, Yoni-Starkware (Yoni) wrote…

Remove this const, and instead define FELT_WIDTH = 32 in contract_class.rs
WORD_WIDTH is the size of a word in ethereum.
In code_size, we approximate the code size by adding the max size of each element, which is felt, which is accidentally 32. Felt width could have been different.

Done (please tell me if I missed something) .
are the comments clear enough?

Copy link
Contributor

@ArniStarkware ArniStarkware left a comment

Choose a reason for hiding this comment

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

Reviewed 2 of 2 files at r5, all commit messages.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @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.

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


crates/blockifier/src/fee/eth_gas_constants.rs line 1 at r4 (raw file):

Previously, avivg-starkware wrote…

Done (please tell me if I missed something) .
are the comments clear enough?

Move starknet_api::core::WORD_WIDTH back to this file.

Please rename the commit and PR message

@avivg-starkware avivg-starkware changed the title refactor(blockifier): remove WORD_WIDTH from blockifier, use starkn et_api instead refactor(blockifier): replace WORD_WIDTH w FELT_WIDTH in contract_class Nov 13, 2024
Copy link

Artifacts upload triggered. View details here

@avivg-starkware avivg-starkware force-pushed the avivg/blockifier/remove_WORD_WIDTH_from_blockifier_use_starknet_api_instead branch 2 times, most recently from d8064e7 to bdf6489 Compare November 13, 2024 10:06
Copy link

Artifacts upload triggered. View details here

Copy link
Contributor Author

@avivg-starkware avivg-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: 2 of 5 files reviewed, 1 unresolved discussion (waiting on @ArniStarkware and @Yoni-Starkware)


crates/blockifier/src/fee/eth_gas_constants.rs line 1 at r4 (raw file):

Previously, Yoni-Starkware (Yoni) wrote…

Move starknet_api::core::WORD_WIDTH back to this file.

Please rename the commit and PR message

Done.

Copy link

Artifacts upload triggered. View details here

@avivg-starkware avivg-starkware changed the title refactor(blockifier): replace WORD_WIDTH w FELT_WIDTH in contract_class refactor(blockifier): replace WORD_WIDTH w FELT_WIDTH in contract_class Nov 13, 2024
Copy link

Artifacts upload triggered. View details here

@avivg-starkware avivg-starkware force-pushed the avivg/blockifier/remove_WORD_WIDTH_from_blockifier_use_starknet_api_instead branch from bdf6489 to 2aa0c56 Compare November 13, 2024 10:10
Copy link

Artifacts upload triggered. View details here

Copy link
Contributor

@ArniStarkware ArniStarkware 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 3 files at r6, all commit messages.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @Yoni-Starkware)

Copy link

Benchmark movements:
tree_computation_flow performance improved 😺
tree_computation_flow time: [34.359 ms 34.415 ms 34.504 ms]
change: [-3.8995% -2.3566% -1.0151%] (p = 0.00 < 0.05)
Performance has improved.
Found 6 outliers among 100 measurements (6.00%)
2 (2.00%) high mild
4 (4.00%) high severe

Copy link
Contributor

@ArniStarkware ArniStarkware 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 @Yoni-Starkware)

Copy link
Contributor

@ArniStarkware ArniStarkware 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 @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 1 of 2 files at r5, 3 of 3 files at r6, all commit messages.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on @avivg-starkware)

Copy link
Contributor

@ArniStarkware ArniStarkware 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 @avivg-starkware)

@avivg-starkware avivg-starkware merged commit 6e3cb93 into main Nov 13, 2024
14 checks passed
@avivg-starkware avivg-starkware deleted the avivg/blockifier/remove_WORD_WIDTH_from_blockifier_use_starknet_api_instead branch November 13, 2024 14:45
@github-actions github-actions bot locked and limited conversation to collaborators Nov 15, 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