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: dump_declared_classes can dump for a specific block range #1283

Merged
merged 1 commit into from
Oct 19, 2023

Conversation

Yael-Starkware
Copy link
Contributor

@Yael-Starkware Yael-Starkware commented Oct 17, 2023

Pull Request type

Please check the type of change your PR introduces:

  • 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?

Issue Number: N/A

What is the new behavior?

Does this introduce a breaking change?

  • Yes
  • No

Other information


This change is Reviewable

Copy link
Contributor

@OmriEshhar1 OmriEshhar1 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 4 files at r1, all commit messages.
Reviewable status: all files reviewed, 4 unresolved discussions (waiting on @Yael-Starkware)


crates/dump_declared_classes/src/main.rs line 11 at r1 (raw file):

/// The file path can be passed as an argument, otherwise it will be dumped to
/// "dump_declared_classes.json".
/// A starting block and an ending block can also be passed as optional arguments, otherwise the

A start block and an end block

Code quote:

A starting block and an ending block

crates/dump_declared_classes/src/main.rs line 14 at r1 (raw file):

/// entire table will be dumped.
fn main() {
    let matches = Command::new("Dump declared classes")

move the part of parsing the command-line parameters to a separate function.


crates/dump_declared_classes/src/main.rs line 14 at r1 (raw file):

/// entire table will be dumped.
fn main() {
    let matches = Command::new("Dump declared classes")

Add a validation that start_block value exists iff end_block value exists.
And validate that stark_block<=end_block.
(Is it possible to validate that end_block < last block ?)


crates/dump_declared_classes/src/main.rs line 37 at r1 (raw file):

    let file_path = matches.get_one::<String>("file_path").unwrap().as_str();
    let res: StorageResult<()> =

Maybe call dump_declared_classes_table_to_file() function for both cases (with / without block-range) and inside it separate it to 2 functions (instead of doing it here).

@Yael-Starkware Yael-Starkware force-pushed the yael/dump_declared_class_block_range branch from 2ff9ce9 to fe9d358 Compare October 18, 2023 07:54
@codecov
Copy link

codecov bot commented Oct 18, 2023

Codecov Report

Merging #1283 (024b1db) into main (c318b66) will decrease coverage by 0.50%.
Report is 1 commits behind head on main.
The diff coverage is 23.40%.

@@            Coverage Diff             @@
##             main    #1283      +/-   ##
==========================================
- Coverage   72.99%   72.50%   -0.50%     
==========================================
  Files          84       84              
  Lines        7972     8059      +87     
  Branches     7972     8059      +87     
==========================================
+ Hits         5819     5843      +24     
- Misses       1229     1284      +55     
- Partials      924      932       +8     
Files Coverage Δ
crates/papyrus_storage/src/lib.rs 58.40% <ø> (ø)
crates/papyrus_storage/src/utils.rs 55.26% <47.82%> (-0.99%) ⬇️
crates/dump_declared_classes/src/main.rs 0.00% <0.00%> (ø)

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@Yael-Starkware Yael-Starkware force-pushed the yael/dump_declared_class_block_range branch 2 times, most recently from a60d5e5 to 0a67776 Compare October 18, 2023 11:52
Copy link
Contributor Author

@Yael-Starkware Yael-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, 4 unresolved discussions (waiting on @OmriEshhar1)


crates/dump_declared_classes/src/main.rs line 11 at r1 (raw file):

Previously, OmriEshhar1 wrote…

A start block and an end block

Done.


crates/dump_declared_classes/src/main.rs line 14 at r1 (raw file):

Previously, OmriEshhar1 wrote…

Add a validation that start_block value exists iff end_block value exists.
And validate that stark_block<=end_block.
(Is it possible to validate that end_block < last block ?)

added now that both start_block and end_block are required.
added a check that start_block< end_block
also possible to check end_block < last block, done


crates/dump_declared_classes/src/main.rs line 37 at r1 (raw file):

Previously, OmriEshhar1 wrote…

Maybe call dump_declared_classes_table_to_file() function for both cases (with / without block-range) and inside it separate it to 2 functions (instead of doing it here).

not relevant anymore

Copy link
Contributor

@OmriEshhar1 OmriEshhar1 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 r2, all commit messages.
Reviewable status: all files reviewed, 8 unresolved discussions (waiting on @Yael-Starkware)


crates/dump_declared_classes/src/main.rs line 10 at r2 (raw file):

/// The start_block and end_block arguments are mandatory and define the block range to dump,
/// start_block is inclusive and end_block is exclusive. The file_path is an optional parameter,
/// otherwise the data will be dumped to "dump_declared_classes.json".

Maybe move this part of the documentation to fn get_cli_params()

Code quote:

/// The start_block and end_block arguments are mandatory and define the block range to dump,
/// start_block is inclusive and end_block is exclusive. The file_path is an optional parameter,
/// otherwise the data will be dumped to "dump_declared_classes.json".

crates/dump_declared_classes/src/main.rs line 14 at r2 (raw file):

    let cli_params = get_cli_params();
    match dump_declared_classes_table_by_block_range(cli_params.start_block, cli_params.end_block, &cli_params.file_path) {
        Ok(_) => println!("Dumped declared_classes table to file: {}", cli_params.file_path),

add . at end of sentenece (x2)


crates/dump_declared_classes/src/main.rs line 64 at r2 (raw file):

        panic!("start_block must be smaller than end_block");
    }
    let compile_class_marker =

compiled_class_marker

Code quote:

compile_class_marker

crates/dump_declared_classes/src/main.rs line 65 at r2 (raw file):

    }
    let compile_class_marker =
        get_compiled_class_marker().expect("couldn't get compiled class marker");

Couldn't get compiled_class marker.

Code quote:

couldn't get compiled class marker

crates/dump_declared_classes/src/main.rs line 66 at r2 (raw file):

    let compile_class_marker =
        get_compiled_class_marker().expect("couldn't get compiled class marker");
    if start_block > compile_class_marker.0 || end_block > compile_class_marker.0 {

it's enough to check end_block


crates/papyrus_storage/src/utils_test.rs line 16 at r2 (raw file):

#[test]
fn test_dump_table_to_file() {

change the name of the test
test_dump_declared_classes() ?

Code quote:

test_dump_table_to_file

crates/papyrus_storage/src/utils_test.rs line 49 at r2 (raw file):

            .unwrap();
    }
    let txn = reader.begin_ro_txn().unwrap();

add empty line


crates/papyrus_storage/src/utils_test.rs line 50 at r2 (raw file):

    }
    let txn = reader.begin_ro_txn().unwrap();
    // Test dump_declared_classes_to_file

// Test dump_table_to_file for declared_clases table.

Code quote:

// Test dump_declared_classes_to_file

@Yael-Starkware Yael-Starkware force-pushed the yael/dump_declared_class_block_range branch from 0a67776 to 878aac1 Compare October 18, 2023 12:27
Copy link
Contributor Author

@Yael-Starkware Yael-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, 8 unresolved discussions (waiting on @OmriEshhar1)


crates/dump_declared_classes/src/main.rs line 10 at r2 (raw file):

Previously, OmriEshhar1 wrote…

Maybe move this part of the documentation to fn get_cli_params()

Done


crates/dump_declared_classes/src/main.rs line 14 at r2 (raw file):

Previously, OmriEshhar1 wrote…

add . at end of sentenece (x2)

done


crates/dump_declared_classes/src/main.rs line 64 at r2 (raw file):

Previously, OmriEshhar1 wrote…

compiled_class_marker

fixed and moved this code to utils.rs


crates/dump_declared_classes/src/main.rs line 65 at r2 (raw file):

Previously, OmriEshhar1 wrote…

Couldn't get compiled_class marker.

this code was deleted


crates/dump_declared_classes/src/main.rs line 66 at r2 (raw file):

Previously, OmriEshhar1 wrote…

it's enough to check end_block

right done , now in utils.rs


crates/papyrus_storage/src/utils_test.rs line 16 at r2 (raw file):

Previously, OmriEshhar1 wrote…

change the name of the test
test_dump_declared_classes() ?

done


crates/papyrus_storage/src/utils_test.rs line 49 at r2 (raw file):

Previously, OmriEshhar1 wrote…

add empty line

Done.


crates/papyrus_storage/src/utils_test.rs line 50 at r2 (raw file):

Previously, OmriEshhar1 wrote…

// Test dump_table_to_file for declared_clases table.

Done.

Copy link
Contributor Author

@Yael-Starkware Yael-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 6 files reviewed, 8 unresolved discussions (waiting on @OmriEshhar1)


crates/dump_declared_classes/src/main.rs line 14 at r1 (raw file):

Previously, OmriEshhar1 wrote…

move the part of parsing the command-line parameters to a separate function.

Done.

@Yael-Starkware Yael-Starkware force-pushed the yael/dump_declared_class_block_range branch from 878aac1 to 9108b6b Compare October 18, 2023 12:36
OmriEshhar1
OmriEshhar1 previously approved these changes Oct 18, 2023
Copy link
Contributor

@OmriEshhar1 OmriEshhar1 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 4 files at r3, 1 of 1 files at r4, all commit messages.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on @Yael-Starkware)

Copy link
Contributor

@OmriEshhar1 OmriEshhar1 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 2 of 2 files at r5, all commit messages.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on @Yael-Starkware)

@Yael-Starkware Yael-Starkware added this pull request to the merge queue Oct 19, 2023
Merged via the queue into main with commit d116ae4 Oct 19, 2023
20 checks passed
@Yael-Starkware Yael-Starkware deleted the yael/dump_declared_class_block_range branch October 19, 2023 05:37
@github-actions github-actions bot locked and limited conversation to collaborators Oct 20, 2023
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.

2 participants