Skip to content
This repository has been archived by the owner on Aug 21, 2024. It is now read-only.

test(concurrency): test scenarios of validate_reads with unvalid reads #1955

Conversation

OriStarkware
Copy link
Contributor

@OriStarkware OriStarkware commented Jun 4, 2024

This change is Reviewable

@OriStarkware OriStarkware self-assigned this Jun 4, 2024
@OriStarkware OriStarkware force-pushed the ori/starknet/concurrency/versioned_state/remove_compiled_class_hashes_from_validate_reads branch from 50f7c2a to 28c3d6a Compare June 4, 2024 11:48
@OriStarkware OriStarkware force-pushed the ori/starknet/concurrency/versioned_state/add_test_false_validate_reads branch from 5e59c9d to c4f43f5 Compare June 4, 2024 11:52
@codecov-commenter
Copy link

codecov-commenter commented Jun 4, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 78.42%. Comparing base (6e06e79) to head (72c30b8).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #1955   +/-   ##
=======================================
  Coverage   78.42%   78.42%           
=======================================
  Files          62       62           
  Lines        8913     8913           
  Branches     8913     8913           
=======================================
  Hits         6990     6990           
  Misses       1476     1476           
  Partials      447      447           

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

@OriStarkware OriStarkware force-pushed the ori/starknet/concurrency/versioned_state/remove_compiled_class_hashes_from_validate_reads branch from 28c3d6a to 1a78830 Compare June 4, 2024 12:34
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: 0 of 2 files reviewed, 1 unresolved discussion (waiting on @barak-b-starkware, @noaov1, @OriStarkware, and @Yoni-Starkware)


crates/blockifier/src/concurrency/versioned_state_test.rs line 350 at r1 (raw file):

            declared_contracts: HashMap::from([(class_hash, true)]),
            ..Default::default()
        },

It's the same test as the one below. (7, 8)

@OriStarkware OriStarkware force-pushed the ori/starknet/concurrency/versioned_state/remove_compiled_class_hashes_from_validate_reads branch 3 times, most recently from fce92f2 to 24a7acb Compare June 5, 2024 13:55
@OriStarkware OriStarkware force-pushed the ori/starknet/concurrency/versioned_state/add_test_false_validate_reads branch from c4f43f5 to d7e6104 Compare June 5, 2024 13:57
Copy link
Contributor Author

@OriStarkware OriStarkware 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 2 files reviewed, 1 unresolved discussion (waiting on @barak-b-starkware, @meship-starkware, @noaov1, and @Yoni-Starkware)


crates/blockifier/src/concurrency/versioned_state_test.rs line 350 at r1 (raw file):

Previously, meship-starkware (Meshi Peled) wrote…

It's the same test as the one below. (7, 8)

Done.

@OriStarkware OriStarkware force-pushed the ori/starknet/concurrency/versioned_state/remove_compiled_class_hashes_from_validate_reads branch from 24a7acb to 314657b Compare June 5, 2024 14:20
@OriStarkware OriStarkware force-pushed the ori/starknet/concurrency/versioned_state/add_test_false_validate_reads branch from d7e6104 to 558c1a4 Compare June 5, 2024 14:21
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 2 of 2 files at r2, all commit messages.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @barak-b-starkware, @noaov1, @OriStarkware, and @Yoni-Starkware)


crates/blockifier/src/concurrency/versioned_state_test.rs line 365 at r2 (raw file):

        TransactionalState::create_transactional(&mut version_state_proxy_5);

    transactional_state_5.get_class_hash_at(contract_address).unwrap();

This line is to get the contract_address in the read set of transactional_state_5?

Copy link
Contributor Author

@OriStarkware OriStarkware 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 @barak-b-starkware, @meship-starkware, @noaov1, and @Yoni-Starkware)


crates/blockifier/src/concurrency/versioned_state_test.rs line 365 at r2 (raw file):

Previously, meship-starkware (Meshi Peled) wrote…

This line is to get the contract_address in the read set of transactional_state_5?

Exactly

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 @barak-b-starkware, @noaov1, and @Yoni-Starkware)

@OriStarkware OriStarkware force-pushed the ori/starknet/concurrency/versioned_state/remove_compiled_class_hashes_from_validate_reads branch from 314657b to 10bba60 Compare June 5, 2024 14:45
@OriStarkware OriStarkware force-pushed the ori/starknet/concurrency/versioned_state/add_test_false_validate_reads branch 2 times, most recently from e36c1f2 to b68e77f Compare June 5, 2024 14:48
@OriStarkware OriStarkware force-pushed the ori/starknet/concurrency/versioned_state/remove_compiled_class_hashes_from_validate_reads branch from 10bba60 to 323444c Compare June 6, 2024 13:28
@OriStarkware OriStarkware changed the base branch from ori/starknet/concurrency/versioned_state/remove_compiled_class_hashes_from_validate_reads to main June 6, 2024 13:52
@OriStarkware OriStarkware dismissed meship-starkware’s stale review June 6, 2024 13:52

The base branch was changed.

@OriStarkware OriStarkware force-pushed the ori/starknet/concurrency/versioned_state/add_test_false_validate_reads branch from b68e77f to 6ff9a45 Compare June 6, 2024 13:54
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 2 of 2 files at r4, all commit messages.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on @barak-b-starkware, @noaov1, and @Yoni-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.

:lgtm:

Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on @barak-b-starkware, @noaov1, and @Yoni-Starkware)

Copy link
Collaborator

@barak-b-starkware barak-b-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 2 files at r1, 1 of 2 files at r4, all commit messages.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on @noaov1 and @Yoni-Starkware)

Copy link
Collaborator

@barak-b-starkware barak-b-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 @noaov1, @OriStarkware, and @Yoni-Starkware)


crates/blockifier/src/concurrency/versioned_state_test.rs line 331 at r4 (raw file):

    contract_address: ContractAddress,
    safe_versioned_state: ThreadSafeVersionedState<CachedState<DictStateReader>>,
) {

Can you try applying different cases with arg1 for the state maps and arg2 for the contract class mapping and maintain the body of the test something like:

let proxy_for_writing = safe_versioned_State.pin_version(0);
let proxy_for_reading = safe_versioned_State.pin_version(1);
let transactional_state_for_reading = ...;

proxy_for_writing.state().apply_writes(0, &arg1, &arg2);
assert(!proxy_for_reading.validate_reads(&state_maps);

Suggestion:

#[rstest]
#[case::get_storage_at(...)]
#[case::get_nonce(...)]
.
.
.
fn test_false_validate_reads(
    contract_address: ContractAddress,
    safe_versioned_state: ThreadSafeVersionedState<CachedState<DictStateReader>>,
    #[case] arg1,
    #[case] arg2,
) {

@OriStarkware OriStarkware force-pushed the ori/starknet/concurrency/versioned_state/add_test_false_validate_reads branch from 6ff9a45 to 61f2af1 Compare June 10, 2024 07:40
Copy link
Contributor Author

@OriStarkware OriStarkware 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 2 files reviewed, 1 unresolved discussion (waiting on @barak-b-starkware, @meship-starkware, @noaov1, and @Yoni-Starkware)


crates/blockifier/src/concurrency/versioned_state_test.rs line 331 at r4 (raw file):

Previously, barak-b-starkware wrote…

Can you try applying different cases with arg1 for the state maps and arg2 for the contract class mapping and maintain the body of the test something like:

let proxy_for_writing = safe_versioned_State.pin_version(0);
let proxy_for_reading = safe_versioned_State.pin_version(1);
let transactional_state_for_reading = ...;

proxy_for_writing.state().apply_writes(0, &arg1, &arg2);
assert(!proxy_for_reading.validate_reads(&state_maps);

Done.

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 r5, all commit messages.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @barak-b-starkware, @noaov1, and @Yoni-Starkware)

Copy link
Collaborator

@barak-b-starkware barak-b-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 r5, all commit messages.
Reviewable status: all files reviewed, 2 unresolved discussions (waiting on @noaov1, @OriStarkware, and @Yoni-Starkware)


crates/blockifier/src/concurrency/versioned_state_test.rs line 328 at r5 (raw file):

#[rstest]
#[case::check_declared_contracts(

In all cases:

Suggestion:

#[case::declared_contracts(

crates/blockifier/src/concurrency/versioned_state_test.rs line 372 at r5 (raw file):

    }
)]
fn test_false_validate_reads(

What about the "compiled contract classes validation"? Can it be added as another case here? Maybe adding another test for that?

Code quote:

fn test_false_validate_reads(

@OriStarkware OriStarkware force-pushed the ori/starknet/concurrency/versioned_state/add_test_false_validate_reads branch from 61f2af1 to 9916468 Compare June 13, 2024 07:51
Copy link
Contributor Author

@OriStarkware OriStarkware 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 2 files reviewed, 2 unresolved discussions (waiting on @barak-b-starkware, @meship-starkware, @noaov1, and @Yoni-Starkware)


crates/blockifier/src/concurrency/versioned_state_test.rs line 328 at r5 (raw file):

Previously, barak-b-starkware wrote…

In all cases:

Done.


crates/blockifier/src/concurrency/versioned_state_test.rs line 372 at r5 (raw file):

Previously, barak-b-starkware wrote…

What about the "compiled contract classes validation"? Can it be added as another case here? Maybe adding another test for that?

Done.

Copy link
Collaborator

@barak-b-starkware barak-b-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 r6, all commit messages.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @noaov1, @OriStarkware, and @Yoni-Starkware)


crates/blockifier/src/concurrency/versioned_state_test.rs line 381 at r6 (raw file):

        ..Default::default()
    }
)]

I would expect this case to panic for the assertion:

            assert_eq!(
                is_declared,
                self.compiled_contract_classes.read(tx_index + 1, class_hash).is_some()
            );

what do I miss here?

Code quote:

#[case::declared_contracts(
    StateMaps {
        declared_contracts: HashMap::from([(class_hash!(1_u8), false)]),
        ..Default::default()
    },
    StateMaps {
        declared_contracts: HashMap::from([(class_hash!(1_u8), true)]),
        ..Default::default()
    }
)]

@OriStarkware OriStarkware force-pushed the ori/starknet/concurrency/versioned_state/add_test_false_validate_reads branch from 9916468 to 4b7fe21 Compare June 13, 2024 11:39
Copy link
Contributor Author

@OriStarkware OriStarkware 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 2 files reviewed, 1 unresolved discussion (waiting on @barak-b-starkware, @noaov1, and @Yoni-Starkware)


crates/blockifier/src/concurrency/versioned_state_test.rs line 381 at r6 (raw file):

Previously, barak-b-starkware wrote…

I would expect this case to panic for the assertion:

            assert_eq!(
                is_declared,
                self.compiled_contract_classes.read(tx_index + 1, class_hash).is_some()
            );

what do I miss here?

The code will not panic because the state is ok.

@OriStarkware OriStarkware force-pushed the ori/starknet/concurrency/versioned_state/add_test_false_validate_reads branch 2 times, most recently from 21157f7 to 184d7ef Compare June 13, 2024 13:53
Copy link
Collaborator

@barak-b-starkware barak-b-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 r8, all commit messages.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @noaov1, @OriStarkware, and @Yoni-Starkware)


-- commits line 5 at r1:
Two commits by mistake?

Code quote:

- 50f7c2a: fix(concurrency): remove compiled_class_hashes check from validate_reads

- c4f43f5: test(concurrency): test scenarios of validate_reads with unvalid reads

@OriStarkware OriStarkware force-pushed the ori/starknet/concurrency/versioned_state/add_test_false_validate_reads branch from 184d7ef to e5a3d38 Compare June 16, 2024 06:31
Copy link
Contributor Author

@OriStarkware OriStarkware 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 @barak-b-starkware, @noaov1, and @Yoni-Starkware)


-- commits line 5 at r1:

Previously, barak-b-starkware wrote…

Two commits by mistake?

I don't see 2 commits.

Copy link
Collaborator

@barak-b-starkware barak-b-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:

Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on @noaov1 and @Yoni-Starkware)

@OriStarkware OriStarkware force-pushed the ori/starknet/concurrency/versioned_state/add_test_false_validate_reads branch from e5a3d38 to 937ae88 Compare June 16, 2024 09:51
@OriStarkware OriStarkware force-pushed the ori/starknet/concurrency/versioned_state/add_test_false_validate_reads branch from 937ae88 to 72c30b8 Compare June 16, 2024 10:18
@OriStarkware OriStarkware merged commit 67fbebe into main Jun 16, 2024
9 checks passed
@OriStarkware OriStarkware deleted the ori/starknet/concurrency/versioned_state/add_test_false_validate_reads branch June 16, 2024 10:24
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