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

test(starknet_consensus_orchestrator): central transaction execution info object test #3337

Merged
merged 1 commit into from
Jan 22, 2025

Conversation

Yael-Starkware
Copy link
Contributor

No description provided.

@reviewable-StarkWare
Copy link

This change is Reviewable

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: 0 of 4 files reviewed, 1 unresolved discussion (waiting on @dafnamatsry and @DvirYo-starkware)


crates/sequencing/papyrus_consensus_orchestrator/src/cende/central_objects_test.rs line 261 at r1 (raw file):

/// Recursively traverse a transaction execution info json and sort the HashSet fields.
fn sort_execution_info_hashset_fields(json: &Value) -> Value {

This is a pretty ugly solution but I couldn't find another way to compare the jsons. please let me know if you have a better idea.

@Yael-Starkware Yael-Starkware force-pushed the yael/central_execution_info branch from 1a9a65b to 223d45c Compare January 15, 2025 13:21
Copy link
Contributor

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


crates/sequencing/papyrus_consensus_orchestrator/Cargo.toml line 12 at r1 (raw file):

assert_matches.workspace = true
async-trait.workspace = true
blockifier= { workspace = true, features = ["transaction_serde"] }

What does this feature do?
Do you need to change something here?

# transaction_serde is not activated by any workspace crate; test the build.

Code quote:

blockifier= { workspace = true, features = ["transaction_serde"] }

crates/sequencing/papyrus_consensus_orchestrator/src/cende/central_objects_test.rs line 268 at r1 (raw file):

                if key == "accessed_storage_keys" || key == "accessed_contract_addresses" {
                    if let Value::Array(array) = value {
                        let mut sorted_array = array.clone();

What happens if the inner values in the array also have HashSet? I think this function will not work. The items will be serialized using serde_json::to_string, and the order of this serialization is not deterministic.
It may work fine for this case, but comment and explain this explicitly.


crates/sequencing/papyrus_consensus_orchestrator/src/cende/central_objects_test.rs line 301 at r1 (raw file):

    let python_json = read_json_file(python_json_path);

    assert_json_eq(&rust_json, &python_json, "serialize_central_objects test".to_string());

Can you add the test name to the error message?

Code quote:

 "serialize_central_objects test".to_string()

crates/sequencing/papyrus_consensus_orchestrator/resources/central_transaction_execution_info.json line 1 at r1 (raw file):

{

Don't use default values here, like in the previous PR.


crates/sequencing/papyrus_consensus_orchestrator/src/cende/central_objects.rs line 364 at r1 (raw file):

/// A mapping from a transaction execution resource to its actual usage.
#[derive(Debug, Eq, PartialEq, Serialize, Deserialize)]

This is needed only for tests? I think it is fine to not compile only for tests, but just to make sure.

Code quote:

Deserialize

@Yael-Starkware Yael-Starkware force-pushed the yael/central_execution_info_testing2 branch from 4f3849b to a42a94f Compare January 16, 2025 10:42
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: 0 of 5 files reviewed, 6 unresolved discussions (waiting on @dafnamatsry and @DvirYo-starkware)


crates/sequencing/papyrus_consensus_orchestrator/Cargo.toml line 12 at r1 (raw file):

Previously, DvirYo-starkware wrote…

What does this feature do?
Do you need to change something here?

# transaction_serde is not activated by any workspace crate; test the build.

will check with Dori


crates/sequencing/papyrus_consensus_orchestrator/resources/central_transaction_execution_info.json line 1 at r1 (raw file):

Previously, DvirYo-starkware wrote…

Don't use default values here, like in the previous PR.

Done.


crates/sequencing/papyrus_consensus_orchestrator/src/cende/central_objects_test.rs line 268 at r1 (raw file):

Previously, DvirYo-starkware wrote…

What happens if the inner values in the array also have HashSet? I think this function will not work. The items will be serialized using serde_json::to_string, and the order of this serialization is not deterministic.
It may work fine for this case, but comment and explain this explicitly.

code was deleted.


crates/sequencing/papyrus_consensus_orchestrator/src/cende/central_objects_test.rs line 301 at r1 (raw file):

Previously, DvirYo-starkware wrote…

Can you add the test name to the error message?

the test name is the only thing in the error message .
or maybe I misunderstood you.


crates/sequencing/papyrus_consensus_orchestrator/src/cende/central_objects.rs line 364 at r1 (raw file):

Previously, DvirYo-starkware wrote…

This is needed only for tests? I think it is fine to not compile only for tests, but just to make sure.

yes

Copy link
Collaborator

@dafnamatsry dafnamatsry left a comment

Choose a reason for hiding this comment

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

Reviewed all commit messages.
Reviewable status: 0 of 5 files reviewed, 7 unresolved discussions (waiting on @DvirYo-starkware and @Yael-Starkware)


crates/sequencing/papyrus_consensus_orchestrator/src/cende/central_objects_test.rs line 282 at r2 (raw file):

// the entire object, we fill only one CallInfo with non-default values and the other CallInfos are
// None.
fn central_transaction_execution_info() -> Value {

Split to several functions:

  • test_call_info()with empty inner_calls - which can be used for all the CallInfo mebers. And maybe this would work:
CallInfo {
    inner_calls: vec![test_call_info()]
    ...test_call_info()
}
  • test_transaction_receipt()

You can also add test_execution_resources() which is repeated here.

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: 0 of 5 files reviewed, 6 unresolved discussions (waiting on @dafnamatsry and @DvirYo-starkware)


crates/sequencing/papyrus_consensus_orchestrator/src/cende/central_objects_test.rs line 282 at r2 (raw file):

Previously, dafnamatsry wrote…

Split to several functions:

  • test_call_info()with empty inner_calls - which can be used for all the CallInfo mebers. And maybe this would work:
CallInfo {
    inner_calls: vec![test_call_info()]
    ...test_call_info()
}
  • test_transaction_receipt()

You can also add test_execution_resources() which is repeated here.

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: 0 of 5 files reviewed, 6 unresolved discussions (waiting on @dafnamatsry and @DvirYo-starkware)


crates/sequencing/papyrus_consensus_orchestrator/Cargo.toml line 12 at r1 (raw file):

Previously, Yael-Starkware (YaelD) wrote…

will check with Dori

this is not relevant anymore.

Copy link
Contributor

@DvirYo-starkware DvirYo-starkware left a comment

Choose a reason for hiding this comment

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

I think I see changes also from different PRs, for example, the function fn central_sierra_contract_class_json() -> Value. please remove them

Reviewed 4 of 5 files at r3, all commit messages.
Reviewable status: 4 of 5 files reviewed, 3 unresolved discussions (waiting on @dafnamatsry and @Yael-Starkware)


crates/sequencing/papyrus_consensus_orchestrator/src/cende/central_objects_test.rs line 301 at r1 (raw file):

Previously, Yael-Starkware (YaelD) wrote…

the test name is the only thing in the error message .
or maybe I misunderstood you.

I mean, for example, for execution info, print the case name transaction_execution_info. Not very important

@Yael-Starkware Yael-Starkware force-pushed the yael/central_execution_info_testing2 branch from 73a72a0 to 009aef5 Compare January 19, 2025 10:06
@Yael-Starkware Yael-Starkware changed the base branch from yael/central_execution_info to main January 19, 2025 10:06
@Yael-Starkware Yael-Starkware force-pushed the yael/central_execution_info_testing2 branch 2 times, most recently from 5e8456b to c48a6ac Compare January 19, 2025 13:56
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: 3 of 5 files reviewed, 3 unresolved discussions (waiting on @dafnamatsry and @DvirYo-starkware)


crates/sequencing/papyrus_consensus_orchestrator/src/cende/central_objects_test.rs line 301 at r1 (raw file):

Previously, DvirYo-starkware wrote…

I mean, for example, for execution info, print the case name transaction_execution_info. Not very important

the test name always appears in the title anyway, so I change the string to describe the failure.

Copy link
Collaborator

@dafnamatsry dafnamatsry 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 5 files at r3, 3 of 3 files at r5, all commit messages.
Reviewable status: 4 of 5 files reviewed, 5 unresolved discussions (waiting on @DvirYo-starkware and @Yael-Starkware)


crates/sequencing/papyrus_consensus_orchestrator/src/cende/central_objects_test.rs line 377 at r5 (raw file):

            counter.insert(BuiltinName::pedersen, 4);
            counter
        },

Suggestion:

        builtin_instance_counter: HashMap::from([
            (BuiltinName::range_check, 31),
            (BuiltinName::pedersen, 4),
        ]),

crates/sequencing/papyrus_consensus_orchestrator/src/cende/central_objects_test.rs line 437 at r5 (raw file):

        validate_call_info: Some(CallInfo { inner_calls: vec![call_info()], ..call_info() }),
        execute_call_info: None,
        fee_transfer_call_info: None,

and update the comment...

Suggestion:

        execute_call_info: Some(CallInfo { inner_calls: vec![call_info()], ..call_info() }),,
        fee_transfer_call_info: Some(CallInfo { inner_calls: vec![call_info()], ..call_info() }),,

crates/sequencing/papyrus_consensus_orchestrator/src/cende/central_objects_test.rs line 460 at r5 (raw file):

                starknet_resources: StarknetResources {
                    // The archival_data has private fields so it cannot be assigned, however, it is
                    // not being used in the central object anyway so it can be default.

This is true for the whole resources filed. Consider using TransactionResources::default().

Code quote:

                    // The archival_data has private fields so it cannot be assigned, however, it is
                    // not being used in the central object anyway so it can be default.

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: 4 of 5 files reviewed, 5 unresolved discussions (waiting on @dafnamatsry and @DvirYo-starkware)


crates/sequencing/papyrus_consensus_orchestrator/src/cende/central_objects_test.rs line 437 at r5 (raw file):

Previously, dafnamatsry wrote…

and update the comment...

no need to test the same object again and again.
it also makes the json file more complex to create and maintain.


crates/sequencing/papyrus_consensus_orchestrator/src/cende/central_objects_test.rs line 460 at r5 (raw file):

Previously, dafnamatsry wrote…

This is true for the whole resources filed. Consider using TransactionResources::default().

I think this suggestion makes the test cover less edge cases.


crates/sequencing/papyrus_consensus_orchestrator/src/cende/central_objects_test.rs line 377 at r5 (raw file):

            counter.insert(BuiltinName::pedersen, 4);
            counter
        },

Done.

@Yael-Starkware Yael-Starkware force-pushed the yael/central_execution_info_testing2 branch from c48a6ac to 23a612e Compare January 21, 2025 07:25
Copy link
Collaborator

@dafnamatsry dafnamatsry 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, 5 unresolved discussions (waiting on @DvirYo-starkware and @Yael-Starkware)


crates/sequencing/papyrus_consensus_orchestrator/src/cende/central_objects_test.rs line 437 at r5 (raw file):

Previously, Yael-Starkware (YaelD) wrote…

no need to test the same object again and again.
it also makes the json file more complex to create and maintain.

Putting None here doesn't test the serialisation of the field at all.
It would be enough to change the type of the field to Optional<SomeOtherType> and the test would not catch that.

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: 0 of 8 files reviewed, 5 unresolved discussions (waiting on @dafnamatsry and @DvirYo-starkware)


crates/sequencing/papyrus_consensus_orchestrator/src/cende/central_objects_test.rs line 437 at r5 (raw file):

Previously, dafnamatsry wrote…

Putting None here doesn't test the serialisation of the field at all.
It would be enough to change the type of the field to Optional<SomeOtherType> and the test would not catch that.

Done.

@Yael-Starkware Yael-Starkware force-pushed the yael/central_execution_info_testing2 branch from 69f7a21 to 6c5a4af Compare January 21, 2025 14:02
@Yael-Starkware Yael-Starkware force-pushed the yael/central_execution_info_testing2 branch from 6c5a4af to 5e1b2c6 Compare January 22, 2025 06:02
Copy link
Collaborator

@dafnamatsry dafnamatsry 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 8 files at r7, 5 of 5 files at r9, all commit messages.
Reviewable status: all files reviewed, 2 unresolved discussions (waiting on @DvirYo-starkware)

@Yael-Starkware Yael-Starkware changed the title test(sequencing): central transaction execution info object test test(starknet_consensus_orchestrator): central transaction execution info object test Jan 22, 2025
Copy link
Contributor

@DvirYo-starkware DvirYo-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 r4.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @Yael-Starkware)

@Yael-Starkware Yael-Starkware added this pull request to the merge queue Jan 22, 2025
Merged via the queue into main with commit 6bf101f Jan 22, 2025
36 of 38 checks passed
@github-actions github-actions bot locked and limited conversation to collaborators Jan 24, 2025
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