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

perf(native_blockifier): transaction execution info add serialize #1315

Merged

Conversation

MohammadNassar1
Copy link
Contributor

@MohammadNassar1 MohammadNassar1 commented Jan 7, 2024

This change is Reviewable

@codecov-commenter
Copy link

codecov-commenter commented Jan 7, 2024

Codecov Report

Attention: 33 lines in your changes are missing coverage. Please review.

Comparison is base (bb30f51) 70.69% compared to head (3179a58) 70.95%.
Report is 2 commits behind head on main-v0.13.1.

Files Patch % Lines
...ates/native_blockifier/src/transaction_executor.rs 0.00% 17 Missing ⚠️
crates/blockifier/src/execution/call_info.rs 0.00% 1 Missing and 6 partials ⚠️
crates/native_blockifier/src/py_validator.rs 0.00% 3 Missing ⚠️
crates/blockifier/src/execution/entry_point.rs 0.00% 0 Missing and 2 partials ⚠️
crates/blockifier/src/transaction/objects.rs 0.00% 0 Missing and 2 partials ⚠️
...es/blockifier/src/transaction/transaction_types.rs 0.00% 0 Missing and 1 partial ⚠️
crates/native_blockifier/src/py_block_executor.rs 0.00% 1 Missing ⚠️
Additional details and impacted files
@@               Coverage Diff                @@
##           main-v0.13.1    #1315      +/-   ##
================================================
+ Coverage         70.69%   70.95%   +0.25%     
================================================
  Files                60       62       +2     
  Lines              7794     7980     +186     
  Branches           7794     7980     +186     
================================================
+ Hits               5510     5662     +152     
- Misses             1856     1898      +42     
+ Partials            428      420       -8     

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

@MohammadNassar1 MohammadNassar1 force-pushed the mohammad/TransactionExecutionInfo/Add_serialize branch from adb3ecc to 82e76fc Compare January 7, 2024 10:30
Copy link
Collaborator

@elintul elintul left a comment

Choose a reason for hiding this comment

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

Reviewed 10 of 14 files at r1, 4 of 4 files at r2, all commit messages.
Reviewable status: all files reviewed, 7 unresolved discussions (waiting on @giladchase and @MohammadNassar1)


crates/blockifier/src/execution/call_info.rs line 16 at r2 (raw file):

use crate::transaction::objects::TransactionExecutionResult;

#[derive(Clone, Debug, Default, Eq, PartialEq, Serialize)]

What is the default impl. of this trait?

Code quote:

Serialize

crates/blockifier/src/execution/call_info.rs line 59 at r2 (raw file):

#[derive(Debug, Default, Eq, PartialEq)]
pub struct VmExecutionResourcesWrapper(pub VmExecutionResources);

As VmExecutionResources is already an alias, consider renaming it to VmExecutionResourcesInner and then you won't have to change the type in CallInfo.
If in the future LC adds the trait to their struct, we'd have less changes.

Code quote:

VmExecutionResourcesWrapper

crates/blockifier/src/execution/call_info.rs line 59 at r2 (raw file):

#[derive(Debug, Default, Eq, PartialEq)]
pub struct VmExecutionResourcesWrapper(pub VmExecutionResources);

Consider adding new and implementing Deref for less changes throughout the code. Perhaps Gilad will have a good suggestion.

Code quote:

pub struct VmExecutionResourcesWrapper

crates/blockifier/src/execution/call_info.rs line 62 at r2 (raw file):

impl Serialize for VmExecutionResourcesWrapper {
    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>

Can we ask LC to add this trait to their repo.?
Also, while currently implementing here, why can't we add Serialize to the wrapper? Is repeating the inner structure necessary?

Code quote:

fn serialize

crates/blockifier/src/execution/call_info.rs line 75 at r2 (raw file):

        // Finish serializing the struct
        state.end()

Suggestion:

        // Create a serialize struct with the appropriate number of fields.
        let mut state = serializer.serialize_struct("ExecutionResourcesWrapper", 3)?;

        // Serialize each field individually.
        state.serialize_field("builtin_instance_counter", &self.0.builtin_instance_counter)?;
        state.serialize_field("n_memory_holes", &self.0.n_memory_holes)?;
        state.serialize_field("n_steps", &self.0.n_steps)?;

        // Finish serializing the struct.
        state.end()

crates/blockifier/src/execution/call_info.rs line 93 at r2 (raw file):

impl Serialize for CallInfo {
    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>

Why implement manually?

Code quote:

fn serialize<

crates/blockifier/src/execution/entry_point_execution.rs line 14 at r2 (raw file):

use starknet_api::stark_felt;

use super::call_info::VmExecutionResourcesWrapper;

Suggestion:

crate::...

Copy link
Collaborator

@elintul elintul 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 @giladchase and @MohammadNassar1)

a discussion (no related file):
Just to make sure: only the structs required to allow serialization of TransactionExecutionInfo now implement Serialize, right?


@MohammadNassar1 MohammadNassar1 force-pushed the mohammad/TransactionExecutionInfo/Add_serialize branch from 82e76fc to 38eb891 Compare January 7, 2024 12:56
Copy link
Contributor Author

@MohammadNassar1 MohammadNassar1 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 14 files reviewed, 6 unresolved discussions (waiting on @elintul and @giladchase)

a discussion (no related file):

Previously, elintul (Elin) wrote…

Just to make sure: only the structs required to allow serialization of TransactionExecutionInfo now implement Serialize, right?

Goal: to enable serialization for TransactionExecutionInfo.
I've derived serialize to all the inner structs, and implemented Serialize for the VmExecutionResources as it's an LC struct.



crates/blockifier/src/execution/call_info.rs line 16 at r2 (raw file):

Previously, elintul (Elin) wrote…

What is the default impl. of this trait?

something like:
self.0.serialize(...)
Which is the same like my below implementation for VmExecutionResourcesWrapper.


crates/blockifier/src/execution/call_info.rs line 59 at r2 (raw file):

Previously, elintul (Elin) wrote…

As VmExecutionResources is already an alias, consider renaming it to VmExecutionResourcesInner and then you won't have to change the type in CallInfo.
If in the future LC adds the trait to their struct, we'd have less changes.

In all the files?
Many files are using this alias. example


crates/blockifier/src/execution/call_info.rs line 59 at r2 (raw file):

Previously, elintul (Elin) wrote…

Consider adding new and implementing Deref for less changes throughout the code. Perhaps Gilad will have a good suggestion.

Done.


crates/blockifier/src/execution/call_info.rs line 62 at r2 (raw file):

Previously, elintul (Elin) wrote…

Can we ask LC to add this trait to their repo.?
Also, while currently implementing here, why can't we add Serialize to the wrapper? Is repeating the inner structure necessary?

Adding Serialize to the Wrapper requires an implementation in the inner fields.


crates/blockifier/src/execution/call_info.rs line 93 at r2 (raw file):

Previously, elintul (Elin) wrote…

Why implement manually?

You are right; no need for it.

@MohammadNassar1 MohammadNassar1 force-pushed the mohammad/TransactionExecutionInfo/Add_serialize branch from 38eb891 to 551706a Compare January 7, 2024 13:00
Copy link
Collaborator

@elintul elintul 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: 13 of 14 files reviewed, 4 unresolved discussions (waiting on @giladchase)

Copy link
Collaborator

@giladchase giladchase left a comment

Choose a reason for hiding this comment

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

Reviewed 8 of 14 files at r1, 3 of 4 files at r2, 1 of 3 files at r3, 2 of 2 files at r4, all commit messages.
Reviewable status: all files reviewed, 6 unresolved discussions (waiting on @elintul and @MohammadNassar1)


crates/blockifier/src/execution/call_info.rs line 16 at r2 (raw file):

Previously, MohammadNassar1 (mohammad-starkware) wrote…

something like:
self.0.serialize(...)
Which is the same like my below implementation for VmExecutionResourcesWrapper.

It'll ignore the wrapper types and just print the primitives in json format, so in this case, an array of [u8;32] arrays.

Example: https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=569bdb8b3bc4d77d369b1e591ae83a7d


crates/blockifier/src/execution/call_info.rs line 68 at r4 (raw file):

        &self.0
    }
}

The derive generates the code you wrote

Suggestion:

#[derive(Debug, Default, Eq, PartialEq, derive_more::Deref)]
pub struct VmExecutionResourcesWrapper(pub VmExecutionResources);

crates/blockifier/src/execution/deprecated_entry_point_execution.rs line 256 at r4 (raw file):

            gas_consumed: 0,
        },
        vm_resources: VmExecutionResourcesWrapper(full_call_vm_resources.filter_unused_builtins()),

nit: Consider adding derive_more::From to this type and replacing it with full_call_vm_resources.filter_unused_builtins().into(), this hides the newtype which is generally a good thing, since it only exists due to technical constraints and doesn't have any significance on its own.
(DItto for other constructors in other files.)

But totally not critical, can stay as is.

Code quote:

VmExecutionResourcesWrapper(full_call_vm_resources.filter_unused_builtins())

@MohammadNassar1 MohammadNassar1 force-pushed the mohammad/TransactionExecutionInfo/Add_serialize branch from 551706a to 2c9b698 Compare January 9, 2024 10:41
Copy link
Contributor Author

@MohammadNassar1 MohammadNassar1 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: 8 of 14 files reviewed, 5 unresolved discussions (waiting on @elintul and @giladchase)


crates/blockifier/src/execution/call_info.rs line 68 at r4 (raw file):

Previously, giladchase wrote…

The derive generates the code you wrote

Done.


crates/blockifier/src/execution/deprecated_entry_point_execution.rs line 256 at r4 (raw file):

Previously, giladchase wrote…

nit: Consider adding derive_more::From to this type and replacing it with full_call_vm_resources.filter_unused_builtins().into(), this hides the newtype which is generally a good thing, since it only exists due to technical constraints and doesn't have any significance on its own.
(DItto for other constructors in other files.)

But totally not critical, can stay as is.

Liked it.
Code was updated accordingly.

giladchase
giladchase previously approved these changes Jan 10, 2024
Copy link
Collaborator

@giladchase giladchase 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 6 files at r5, 3 of 3 files at r6, all commit messages.
Reviewable status: all files reviewed, 3 unresolved discussions (waiting on @elintul)

@MohammadNassar1 MohammadNassar1 force-pushed the mohammad/TransactionExecutionInfo/Add_serialize branch from faa2ade to fc0195f Compare January 11, 2024 10:44
Copy link
Collaborator

@elintul elintul 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: 15 of 17 files reviewed, 5 unresolved discussions (waiting on @giladchase and @MohammadNassar1)


crates/blockifier/src/execution/call_info.rs line 16 at r2 (raw file):

Previously, giladchase wrote…

It'll ignore the wrapper types and just print the primitives in json format, so in this case, an array of [u8;32] arrays.

Example: https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=569bdb8b3bc4d77d369b1e591ae83a7d

Thanks!


crates/blockifier/src/execution/call_info.rs line 58 at r7 (raw file):

}

#[derive(Debug, Default, Eq, PartialEq, derive_more::Deref, derive_more::From)]

Do we still need .0-s throughout the code?

Code quote:

derive_more::Deref

crates/blockifier/src/execution/call_info.rs line 73 at r7 (raw file):

    {
        // Create a serialize struct with the appropriate number of fields.
        let mut state = serializer.serialize_struct("ExecutionResourcesWrapper", 3)?;

What does this name represent?

Code quote:

"ExecutionResourcesWrapper"

Copy link
Contributor Author

@MohammadNassar1 MohammadNassar1 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 17 files reviewed, 5 unresolved discussions (waiting on @elintul and @giladchase)


crates/blockifier/src/execution/call_info.rs line 58 at r7 (raw file):

Previously, elintul (Elin) wrote…

Do we still need .0-s throughout the code?

I used .0 in one case when using PyVmExecutionResources::from, which doesn't call deref automatically. The other option is to call it explicitly with .deref() instead of .0. I prefer the second option.


crates/blockifier/src/execution/call_info.rs line 73 at r7 (raw file):

Previously, elintul (Elin) wrote…

What does this name represent?

It's the name of the struct.
It's not used during the serialization. An example of an output:

"vm_resources":{"builtin_instance_counter":{"range_check_builtin":1},"n_memory_holes":0,"n_steps":62}

Copy link
Collaborator

@giladchase giladchase 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 17 files reviewed, 5 unresolved discussions (waiting on @elintul and @MohammadNassar1)


crates/blockifier/src/execution/call_info.rs line 62 at r2 (raw file):

Previously, MohammadNassar1 (mohammad-starkware) wrote…

Adding Serialize to the Wrapper requires an implementation in the inner fields.

More specifically, adding derive(Serialize) requires that all fields also implement Serialize, but since LC don't implement it and it's their type, we are forced to wrap it in a newType.

However, like you said, if LC adds derive(Serialize) it'll render this wrapper unnecessary.


crates/blockifier/src/execution/call_info.rs line 58 at r7 (raw file):

Previously, MohammadNassar1 (mohammad-starkware) wrote…

I used .0 in one case when using PyVmExecutionResources::from, which doesn't call deref automatically. The other option is to call it explicitly with .deref() instead of .0. I prefer the second option.

Deref is only for method calls unfortunately, so it doesn't apply for field accessors unless they are via getters :(

A common solution for this is to add an inner() method which returns self.0 (we haven't done this alot thus far but it's idiomatic).

This allows you to make the inner field private and communicates the NewType'iness of the instance better than .0 does (because the reader can't tell for certain if this is a newtype or a larger tuple struct with .1,.2,... .

(BTW performance-wise this method will likely get inlined anyway)


crates/blockifier/src/execution/call_info.rs line 73 at r7 (raw file):

Previously, MohammadNassar1 (mohammad-starkware) wrote…

It's the name of the struct.
It's not used during the serialization. An example of an output:

"vm_resources":{"builtin_instance_counter":{"range_check_builtin":1},"n_memory_holes":0,"n_steps":62}

I think she meant the syntax, it's the serialization API that serde exposes for defining a custom serialization scheme for a struct that doesn't derive(Serialize) in the normal way.
I think a better api for it could have been let mut custom_serializer = serializer.begin_custom_serialization_for("NameOfStructYouWantToSerializeNow",...)

Copy link
Contributor Author

@MohammadNassar1 MohammadNassar1 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 17 files reviewed, 4 unresolved discussions (waiting on @elin, @elintul, and @giladchase)


crates/blockifier/src/execution/call_info.rs line 58 at r7 (raw file):

Previously, giladchase wrote…

Deref is only for method calls unfortunately, so it doesn't apply for field accessors unless they are via getters :(

A common solution for this is to add an inner() method which returns self.0 (we haven't done this alot thus far but it's idiomatic).

This allows you to make the inner field private and communicates the NewType'iness of the instance better than .0 does (because the reader can't tell for certain if this is a newtype or a larger tuple struct with .1,.2,... .

(BTW performance-wise this method will likely get inlined anyway)

@elin, what so you think?


crates/blockifier/src/execution/call_info.rs line 73 at r7 (raw file):

Previously, giladchase wrote…

I think she meant the syntax, it's the serialization API that serde exposes for defining a custom serialization scheme for a struct that doesn't derive(Serialize) in the normal way.
I think a better api for it could have been let mut custom_serializer = serializer.begin_custom_serialization_for("NameOfStructYouWantToSerializeNow",...)

@giladchase, can you please tell me how to use this API?
I couldn't find such a method in the serializer.

@MohammadNassar1 MohammadNassar1 force-pushed the mohammad/TransactionExecutionInfo/Add_serialize branch from d01d35b to 65c8568 Compare January 18, 2024 08:29
Copy link
Collaborator

@giladchase giladchase 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: 6 of 17 files reviewed, 4 unresolved discussions (waiting on @elin and @elintul)


crates/blockifier/src/execution/call_info.rs line 73 at r7 (raw file):

Previously, MohammadNassar1 (mohammad-starkware) wrote…

@giladchase, can you please tell me how to use this API?
I couldn't find such a method in the serializer.

Ahh this doesn't exist, i was just giving an example for a better name for this that would have made this action more obvious that "serialize_struct" (which doesn't imply that it is opening a state).

@MohammadNassar1 MohammadNassar1 force-pushed the mohammad/TransactionExecutionInfo/Add_serialize branch 2 times, most recently from 386cef1 to d42b9ff Compare January 18, 2024 14:32
Copy link
Collaborator

@elintul elintul 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 r10, all commit messages.
Reviewable status: 7 of 17 files reviewed, 7 unresolved discussions (waiting on @elin, @giladchase, and @MohammadNassar1)


crates/native_blockifier/src/py_block_executor.rs line 88 at r10 (raw file):

        tx: &PyAny,
        raw_contract_class: Option<&str>,
    ) -> NativeBlockifierResult<(Vec<u8>, PyBouncerInfo)> {

Please define an alias: RawTransactionExecutionInfo.

Code quote:

Vec<u8>

crates/native_blockifier/src/py_validator.rs line 74 at r10 (raw file):

        // so they are skipped here.
        if let AccountTransaction::DeployAccount(_deploy_account_tx) = account_tx {
            let (_bytes_tx_execution_info, _py_bouncer_info) =

In other locations as well.

Suggestion:

_raw_tx_execution_info

crates/native_blockifier/src/transaction_executor.rs line 90 at r10 (raw file):

                tx_visited_storage_entries.extend(tx_execution_info.get_visited_storage_entries());
                let bytes_tx_execution_info =
                    serde_json::to_string(&tx_execution_info).unwrap().into_bytes();

Please return SerdeError instead of unwraping.

Code quote:

unwrap()

@MohammadNassar1 MohammadNassar1 force-pushed the mohammad/TransactionExecutionInfo/Add_serialize branch from d42b9ff to 62e0f0f Compare January 21, 2024 11:18
Copy link
Contributor Author

@MohammadNassar1 MohammadNassar1 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 17 files reviewed, 6 unresolved discussions (waiting on @elin, @elintul, and @giladchase)


crates/native_blockifier/src/py_block_executor.rs line 88 at r10 (raw file):

Previously, elintul (Elin) wrote…

Please define an alias: RawTransactionExecutionInfo.

Done.


crates/native_blockifier/src/transaction_executor.rs line 90 at r10 (raw file):

Previously, elintul (Elin) wrote…

Please return SerdeError instead of unwraping.

Done.

Copy link
Collaborator

@giladchase giladchase 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 @MohammadNassar1)


crates/blockifier/src/execution/call_info.rs line 89 at r18 (raw file):

        wrapper.0
    }
}

The name is somewhat confusing, it doens't generate an "Into", it generates the exact from you wrote.
The derive_more::From before it genreates the reverse From (bad api on their part...)

Suggestion:

#[derive(Debug, Default, derive_more::Deref, derive_more::From, derive_more::Into Eq, PartialEq)]
pub struct VmExecutionResourcesWrapper(pub VmExecutionResources);

Copy link
Collaborator

@giladchase giladchase 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 @MohammadNassar1)


crates/blockifier/src/execution/call_info.rs line 58 at r7 (raw file):

Previously, MohammadNassar1 (mohammad-starkware) wrote…

For using inner method, we still need to add .inner in the code.
I implement from, to be able to use .into().
However, I still need to use .0 in one place in the code.

You mean in calculate_tx_weights which ownership on the inner vlaue?
I think the function can be changed to get the value by ref (doens't seem to do anything with the ownership), and then Deref can be used.

Copy link
Collaborator

@giladchase giladchase left a comment

Choose a reason for hiding this comment

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

For future reference: i found this serde trick which allows you to implement [De]Serialize on extetrnal types (which side steps the need for a wrapper), but i'm not sure it's worth it to scrap your work thus far for that
https://serde.rs/remote-derive.html#deriving-deserialize-for-type-in-a-different-crate.

:lgtm:

Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @MohammadNassar1)

elintul
elintul previously approved these changes Jan 30, 2024
Copy link
Collaborator

@elintul elintul 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 @MohammadNassar1)

@MohammadNassar1 MohammadNassar1 force-pushed the mohammad/TransactionExecutionInfo/Add_serialize branch 2 times, most recently from 69a0655 to 5f7a672 Compare January 31, 2024 09:12
Copy link
Contributor Author

@MohammadNassar1 MohammadNassar1 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: 6 of 18 files reviewed, 1 unresolved discussion (waiting on @elintul and @giladchase)


crates/blockifier/src/execution/call_info.rs line 58 at r7 (raw file):

Previously, giladchase wrote…

You mean in calculate_tx_weights which ownership on the inner vlaue?
I think the function can be changed to get the value by ref (doens't seem to do anything with the ownership), and then Deref can be used.

Following @giladchase suggestion, I removed the wrapper and used Serde to derive Serialize as explained here.


crates/blockifier/src/execution/call_info.rs line 89 at r18 (raw file):

Previously, giladchase wrote…

The name is somewhat confusing, it doens't generate an "Into", it generates the exact from you wrote.
The derive_more::From before it genreates the reverse From (bad api on their part...)

This code was removed.
See the above comment.

@MohammadNassar1 MohammadNassar1 changed the title TransactionExecutionInfo: add serialize perf(native_blockifier): transaction execution info add serialize Jan 31, 2024
@MohammadNassar1 MohammadNassar1 force-pushed the mohammad/TransactionExecutionInfo/Add_serialize branch from 5f7a672 to 5fc61f2 Compare January 31, 2024 13:12
elintul
elintul previously approved these changes Jan 31, 2024
Copy link
Collaborator

@elintul elintul left a comment

Choose a reason for hiding this comment

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

Reviewed 12 of 12 files at r19, all commit messages.
Reviewable status: all files reviewed, 3 unresolved discussions (waiting on @giladchase and @MohammadNassar1)


crates/blockifier/src/execution/call_info.rs line 83 at r19 (raw file):

// This struct is just a copy of the remote `VmExecutionResources` Struct.
// The remote attribute gives the path to the actual type we intend to derive
// Serialize and Deserialize for.

I think it's enough to say it is used to implement serde functionality on VmExecutionResources which is not defined inside the crate.

Code quote:

// This struct is just a copy of the remote `VmExecutionResources` Struct.
// The remote attribute gives the path to the actual type we intend to derive
// Serialize and Deserialize for.

crates/blockifier/src/execution/call_info.rs line 98 at r19 (raw file):

    pub execution: CallExecution,
    // It gives the path to the definition for the remote type.
    #[serde(with = "VmExecutionResourcesDef")]

I think the comment doesn't add information.

Suggestion:

    #[serde(with = "VmExecutionResourcesDef")]

@MohammadNassar1 MohammadNassar1 force-pushed the mohammad/TransactionExecutionInfo/Add_serialize branch 3 times, most recently from 4d61fae to 3179a58 Compare January 31, 2024 16:07
Copy link
Collaborator

@giladchase giladchase 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: 9 of 18 files reviewed, 1 unresolved discussion (waiting on @elintul and @MohammadNassar1)


crates/native_blockifier/src/transaction_executor.rs line 39 at r20 (raw file):

    #[serde(flatten)]
    info: TransactionExecutionInfo,
    tx_type: String,

Can this be TransactionType?

Code quote:

    tx_type: String,

crates/native_blockifier/src/transaction_executor.rs line 153 at r20 (raw file):

                };
                let raw_tx_execution_info = serde_json::to_vec(&typed_tx_execution_info)
                    .map_err(NativeBlockifierError::SerdeError)?;

I think this will still work, the ? runs into behind the scenes on the error

Suggestion:

                let raw_tx_execution_info = serde_json::to_vec(&typed_tx_execution_info)?;

giladchase
giladchase previously approved these changes Jan 31, 2024
Copy link
Collaborator

@giladchase giladchase 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 10 files at r9, 1 of 6 files at r12, 1 of 9 files at r13, 5 of 12 files at r19, 9 of 9 files at r20, all commit messages.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @elintul and @MohammadNassar1)

elintul
elintul previously approved these changes Jan 31, 2024
Copy link
Collaborator

@elintul elintul left a comment

Choose a reason for hiding this comment

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

Reviewed 9 of 9 files at r20, all commit messages.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @MohammadNassar1)

@MohammadNassar1 MohammadNassar1 force-pushed the mohammad/TransactionExecutionInfo/Add_serialize branch from 3179a58 to cb0632f Compare January 31, 2024 16:34
Copy link
Contributor Author

@MohammadNassar1 MohammadNassar1 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: 17 of 18 files reviewed, 1 unresolved discussion (waiting on @elintul and @giladchase)


crates/native_blockifier/src/transaction_executor.rs line 39 at r20 (raw file):

Previously, giladchase wrote…

Can this be TransactionType?

It doesn't work.

Copy link
Collaborator

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

Copy link
Collaborator

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

@MohammadNassar1 MohammadNassar1 merged commit f16fa89 into main-v0.13.1 Jan 31, 2024
8 checks passed
rodrigo-pino added a commit to NethermindEth/blockifier that referenced this pull request Mar 7, 2024
* Run cargo update

Signed-off-by: Dori Medini <[email protected]>

* Detach native_blockifier

* Bump cairo-vm and cairo compiler

New cairo-vm version includes performance optimizations.
New cairo version only includes the new vm version.

* Release 0.4.1-rc.0

* Re-attach native_blockifier, bump papyrus_storage

* native_blockifier: Allow querying for `Blockifier` version. (starkware-libs#1249)

This allows one to do:
```
import native_blockifier
native_blockifier.blockifier_version()
```
And get the version the native was compiled with.

Co-Authored-By: Gilad Chase <[email protected]>

* Add updated version of estimate_casm_hash_computation_resources(). (starkware-libs#1314)

* Resolve conflicts.

* Reconnect nnative-blockifier

Signed-off-by: Dori Medini <[email protected]>

* Add the field kzg_resources to PyBouncerInfo. (starkware-libs#1321)

* Add use_kzg_da flag to PyBlockInfo. (starkware-libs#1319)

* Merge `main-v0.13.0` into `main` (resolve conflicts).

* Remove gas price bounds from general config (starkware-libs#1329)

Signed-off-by: Dori Medini <[email protected]>

* Bump cairo-vm version (starkware-libs#1330)

Signed-off-by: Dori Medini <[email protected]>

* Update cairo compiler version and fix related TODOs. (starkware-libs#1332)

* Small fix in into_block_context. (starkware-libs#1337)

* Data gas prices in block context (starkware-libs#1336)

Signed-off-by: Dori Medini <[email protected]>

* Use try_from instead of as (starkware-libs#1322)

* Use into instead of as (starkware-libs#1333)

* Add MAX_L1_GAS_AMOUNT_U128 (starkware-libs#1335)

* Refactor calculate_tx_gas_usage (starkware-libs#1320)

* Change additional as to try_from and try_to (starkware-libs#1342)

* Remove PyKzgResources. Reveal the state diff size. (starkware-libs#1341)

* Make `BlockContext` a newtype around `BlockInfo` (starkware-libs#1323)

The crux of this commit is the change in `block_context.rs`, which
converts `BlockContext` into a wrapper around `BlockInfo` (which used to be
`BlockContext`).

Everything else is just delegating the accessors to the internal block_info, made
by search-and-replace (no other changes).

Motivation:
- This change the groundwork for future refactor and consolidation of
contexts.
- Subsequent commits will extract non block-specific constants from
`BlockInfo` into separate `ChainInfo` and `VersionedConstants` structs,
which will be siblings of `block_info` inside `BlockContext`.

Co-Authored-By: Gilad Chase <[email protected]>

* Extract from `BlockInfo` into `ChainInfo` (starkware-libs#1344)

`BlockInfo` should only contain block-level info, whereas chain-level
information should be held at the `BlockContext` level, encapsulated in
a dedicated `ChainInfo` struct.

Changes:
Only extract from `BlockInfo` and store in `BlockContext.chain_info:
ChainInfo`. All other changes are search-replace + moving the
fee_token_address getter into `ChainInfo`.

TODO: extract more stuff from BlockInfo: version-dependant constants should
be extracted into a dedicated VersionedConstants, which will be a member of BlockContext

Co-Authored-By: Gilad Chase <[email protected]>

* Revert changes of 776d7a5 (starkware-libs#1352)

* fix(native_blockifier): Remove `PyGasPrices` (starkware-libs#1353)

`PyX` types are intended to represent (a subset) of the real
structure of object in Python.
Currently Python is broken do to PyBlockInfo's FromPyObject expecting
there to be a `PyGasPrices`, which doesn't exist in Ptyhon

Co-Authored-By: Gilad Chase <[email protected]>

* Rename `{into,to}_actual_cost_builder` (starkware-libs#1355)

`into` implies `owned -> owned` cast, whereas `to` can imply `borrowed
-> owned`.

See this reference for naming convention: https://rust-lang.github.io/api-guidelines/naming.html#ad-hoc-conversions-follow-as_-to_-into_-conventions-c-conv

Co-Authored-By: Gilad Chase <[email protected]>

* add missing internal panic in cairo1 (starkware-libs#1340)

* add missing internal panic in cairo1

* update `test_stack_trace` and make it work with Cairo1 as well as Cairo0

* Align block info fields (starkware-libs#1358)

Signed-off-by: Dori Medini <[email protected]>

* ci: add commitlint in CI (starkware-libs#1313)

Signed-off-by: Dori Medini <[email protected]>

* Create the function calculate_tx_blob_gas_usage. (starkware-libs#1346)

* Add direct cast from PyFelt into ContractAddress + Deref (starkware-libs#1345)

Co-Authored-By: Gilad Chase <[email protected]>

* fix: revert "Add direct cast from PyFelt into ContractAddress + Deref (starkware-libs#1345)" (starkware-libs#1364)

This reverts commit 6b524c9.

Python is fussy about derive_more, will TAL at it again later

Co-Authored-By: Gilad Chase <[email protected]>

* refactor(fee): split tx l1 gas computation to da and non-da sum, add fee test for empty transaction (starkware-libs#1339)

* test: add stack trace regressions tests in Cairo1 for various call chains (starkware-libs#1367)

* feat(fee): preparation-add the calldata length to the resource calcaultion (starkware-libs#1361)

* build(fee): added new struct and field in preparation for using blob_gas (starkware-libs#1356)

* feat(fee): modified calculate_tx_l1_gas_usage(s) added calculate_tx_gas_and_blob_gas_usage (starkware-libs#1357)

* style: remove some unnecessary variables (starkware-libs#1366)

* feat(fee): modified calculate_tx_l1_gas_usage(s), added calculate_tx_gas_and_blob_gas_usage (starkware-libs#1370)

* refactor(state): replace GlobalContractCache default with GlobalContractCache new (starkware-libs#1368)

* feat(fee): check gas amount including discounted data gas (starkware-libs#1374)

Signed-off-by: Dori Medini <[email protected]>

* test: add cairo0 variants to the new stack trace regression tests (starkware-libs#1371)

* feat(fee): calculates messages size field (starkware-libs#1290)

* fix(native_blockifier): change failure_flag type to bool (starkware-libs#1334)

* fix(execution): convert all local errors to stack trace (starkware-libs#1378)

Signed-off-by: Dori Medini <[email protected]>

* fix(execution): change additional as to from (starkware-libs#1373)

* Merge `main-v0.13.1` into `main` (resolve conflicts).

* fix(native_blockifier): use PyCallType and PyEntryPointType instead of as (starkware-libs#1383)

* ci: prevent PR title check on merges

Signed-off-by: Dori Medini <[email protected]>

* ci: ignore merge PRs when linting PR titles (starkware-libs#1388)

Signed-off-by: Dori Medini <[email protected]>

* refactor(native_blockifier): pybouncerinfo tx_weights field (starkware-libs#1347)

* style(fee): fix error handle unpack (starkware-libs#1390)

* feat(fee): add linear combination for gas and blob_gas (starkware-libs#1360)

* refactor: change CustomHint error usage into VirtualMachineError::Other(anyhow::Error) (starkware-libs#1397)

* refactor(state): use get_nonce_updates (starkware-libs#1398)

* refactor: make the BlockContext constructor private as preparation for pre_process_block changes (starkware-libs#1385)

* refactor: change variable and function names for gas_vector (starkware-libs#1400)

* fix(fee): modified estimate_minimal_gas_vector, extracted compute_discounted_gas_from_gas_vector (starkware-libs#1401)

* refactor: modified extraction in extract_l1_blob_gas_usage (from unwrap_or(0) to expect) (starkware-libs#1402)

* test: update test_call_contract to new infra (starkware-libs#1404)

Signed-off-by: Dori Medini <[email protected]>

* feat: add VersionedConstants

- Currently only covers the constants previously contained in `BlockInfo`.
TODO: Add check if this covers all chain ids, which might have different
contstants
- Remove `BlockContextArgs`: no longer needed now that BlockContext can
  be initialized by 3 args of public types.

* test: update test_replace_class to new infra (starkware-libs#1405)

Signed-off-by: Dori Medini <[email protected]>

* refactor: restructure old_block_number_and_hash as a struct (starkware-libs#1403)

* chore(fee): gas computation refactor (starkware-libs#1408)

Changes:
1. Implemented get_da_gas_cost, which returns a GasVector (depending on
   use_kzg_da flag).
2. Deleted calculate_tx_gas_usage_vector, because
   calculate_tx_l1_gas_usage does the same thing.
3. Derived derive_more::Add for GasVector to easily sum up gas costs.

Signed-off-by: Dori Medini <[email protected]>

* chore(fee): use GasVector as a return type for gas computations (starkware-libs#1409)

Signed-off-by: Dori Medini <[email protected]>

* refactor: rename context modules

- Rename block_context.rs -> context.rs. This will hold all context
  types.
- Rename block_execution.rs -> block.rs and move `BlockInfo` and
  `GasPrices` there (`GasPrices` is only used inside `BlockInfo`).

No other changes.

* chore(fee): integer VM gas usage (starkware-libs#1410)

* chore(fee): use GasVector as a return type for gas computations

Signed-off-by: Dori Medini <[email protected]>

* chore(fee): integer VM gas usage

Signed-off-by: Dori Medini <[email protected]>

* perf(native_blockifier): transaction execution info add serialize (starkware-libs#1315)

* feat(fee): adding a slope paramters to the os resources (starkware-libs#1362)

* feat(fee): set the resources slope values (starkware-libs#1363)

* refactor: make `AccountTransactionContext` hold BlockContext

- Rename `AccountTransactionContext` into `TransactionInfo`: i want to
  use `Context` for something else, and `Account` is a misnomer, since
  L1Transactions also generate this instance.
- Create a new `AccountTransactionContext`, which holds `BlockContext`
  and `TransactionInfo`: This mirrors `BlockContext`, which holds
  `BlockInfo` as well as higher level contexts.
- Remove all unnecessary `get_account_tx` calls.
- Replace all functions that take both `block_context` and `tx_info` with
a single `TransactionContext`.
- Make `EntryPointExecutionContext` hold an `Arc<TransactionContext>`
  instead of both a block_context and `tx_info`: previously every entry
  point cloned the blockContext and generated a new tx_info, now they
  all share the same (identical) one.

* feat: add more constants to`VersionedConstants`

- Add gateway constants, these are only for transparency, and aren't
  used directly by the Blockifier whatsoever.
- Pass `validate_max_n_steps` into the blockifier via native_blockifier,
  to override versioned constants defaults.
- Sort json

* fix: remove dead code `block_context.rs` (starkware-libs#1423)

The module has already taken out of lib.rs in
`8ba2662f93999b526ef7fd0a7fc49d1314657184` (making this module
dead-code), but the file wasn't actually deleted there.

Co-Authored-By: Gilad Chase <[email protected]>

* fix: delete dead code block_execution.rs (starkware-libs#1425)

Was already removed from lib.rs.

Co-Authored-By: Gilad Chase <[email protected]>

* chore(execution): enforce nonzero gas prices (starkware-libs#1391)

Signed-off-by: Dori Medini <[email protected]>

* refactor(execution)!: pre_process_block refactor for full_nodes simulate transaction (starkware-libs#1387)

* refactor(native_blockifier): flat fields in bouncerinfo (starkware-libs#1394)

* feat: add Starknet OS constants to `VersionedConstants` - unused

1. Currently not using the new consts, just adding
the deserialization logic and tests.
In upcoming commits this will replace the gas costs in `constants.rs`.

The idea is that values inside `cairo_constants` that are json objects,
that is, have the form:
```json
"step_gas_cost": {
  foo_cost: x,
  bar_cost: y,
  ...
}
```
should be parsed as:
```
step_gas_cost = foo_cost*x + bar_cost*y + ...,
```
where {x,y} must be unsigned integers (otherwise an error is thrown),
and where {foo_cost, bar_cost,...} must correspond to keys that
have already* been parsed in the JSON.

Note: JSON standard doesn't enforce order on the keys, but our
implementation does; we should consider using a format that ensures
order, rather than relying on serde's implementation and `IndexMap`.

2. validate the os costs on creation (except for in tests): under
this assumption `get_gas_cost` will _panic_ if given a non-whitelisted
gas cost name.

3. hide the two hashmaps inside `VersionedConstants`, they have
invariants, set accessors accordingly.

* chore(execution): saturate step bound on overflow (starkware-libs#1429)

Signed-off-by: Dori Medini <[email protected]>

* feat(fee): add signature length to ActualCostBuilder (starkware-libs#1431)

* feat(execution): use gas costs only from `VersionedConstants`

- Remove from constants module and replace all usages with
  `VersionedConstants#gas_cost(..)`
  - Move all comments from the constants module into the const whitelist
    in `VersionedConstants`.
- Add gas cost getter to `EntryPointExecutionContext`, for readability
  - enclose in closure inside hint_processor.rs for even more brevity.
- Move `Transaction::Initial_gas` into `VersionedConstants`: it is now
  derived from the constants json.
- No other logic changes.

* feat(fee): add os resources to versioned constants

- Move hardcoded os resources json into the versioned constants json,
  move `OsResources` into into `OsResources` module.
- Indent versioned_constants.json at 4.
- Delete os_usage.rs: all logic is now called from methods in
  `VersionedConstants`(todo: extract into submodules, currently
  just a big module).
- Delete os_usage_test.rs: these are not post-deserialize validations of
  `OsResources`.
- sorted versioned_constants (where possible, which is everywhere except
  for inside os_constants keys).

* chore(execution): fix the tests using create_state_changes_for_test for readability and correctness (starkware-libs#1430)

* refactor(execution, native_blockifier): make TransactionExecutor.execute() work w/o Py objects (starkware-libs#1414)

* refactor(execution, native_blockifier): make TransactionExecutor.finalize() work without Py objects (starkware-libs#1418)

* refactor(execution, native_blockifier): decouple BouncerInfo from Python (starkware-libs#1428)

* refactor: split InnerCallExecutionError into CallContractExecutionError & LibraryCallExecutionError.
Add storage_address to both new types and class_hash to LibraryCallExecutionError (starkware-libs#1432)

* feat(execution): moved global max step limit to input validation (starkware-libs#1415)

Signed-off-by: Dori Medini <[email protected]>

* test(execution): improve covrage of test_count_actual_storage_changes (starkware-libs#1436)

* refactor(execution): the struct state changes and state changes count (starkware-libs#1417)

* chore(fee): update os resources and fix expected

* fix(native_blockifier): fix unused imports (starkware-libs#1442)

* chore(execution): consume state_changes on state_changes_count from (starkware-libs#1443)

* feat(execution): calculate the syscall resources for every entry point (starkware-libs#1437)

* feat(execution): add entry_point_syscall_counter (starkware-libs#1407)

* refactor(execution): split get_additional_os_resources (starkware-libs#1411)

* feat(execution): add the syscall resources to vm_resources (starkware-libs#1412)

* fix(fee): fix doc of usize u128 conversions (starkware-libs#1446)

* fix: memory holes tests (starkware-libs#1451)

Co-Authored-By: Gilad Chase <[email protected]>

* fix: remove unused dep ctor (starkware-libs#1455)

Co-Authored-By: Gilad Chase <[email protected]>

* refactor(execution): replace StateChangesCount::from with state_changes.count() (starkware-libs#1452)

* refactor(transaction): make DeclareTransaction fields public (starkware-libs#1441)

* refactor: remove enum VirtualMachineExecutionError (starkware-libs#1453)

* fix(native_blockifier): fix build for mac + unused import (starkware-libs#1406)

* feat(fee): add ClassInfo struct (starkware-libs#1434)

* Merge `main-v0.13.1` into `main` (resolve conflicts).

* feat(fee): add GasVector to TransactionExecutionInfo (starkware-libs#1399)

* feat(fee): add DA GasVector to TransactionExecutionInfo

Signed-off-by: Dori Medini <[email protected]>

* chore(fee): rename blob_gas to l1_data_gas

Signed-off-by: Dori Medini <[email protected]>

* chore(fee): delete unused PyGasVector

Signed-off-by: Dori Medini <[email protected]>

* refactor(execution): remove syscall_counter from ExecutionResources (starkware-libs#1424)

* Update syscall resources (starkware-libs#1459)

* fix: os resources (starkware-libs#1465)

Co-Authored-By: Gilad Chase <[email protected]>

* feat(state): bouncer DA count: define StateWriteKeys (starkware-libs#1461)

* chore: alphabetize top level keys in versioned constants (starkware-libs#1466)

Co-authored-by: Gilad Chase <[email protected]>

* feat(state): bouncer DA count: use StateWriteKeys to count state diff size (starkware-libs#1462)

* refactor(execution, native_blockifier): move Bouncer to blockifier crate (starkware-libs#1445)

* refactor(transaction): use ClassInfo in Declare transaction (starkware-libs#1456)

* feat(fee): add gas cost for calldata bytes (starkware-libs#1426)

* chore: bump CI versions (starkware-libs#1473)

- Remove the deprecated `actions-rs/toolchain@v1` wherever it is still
  used.
- Bump everything to latest versions.

Co-Authored-By: Gilad Chase <[email protected]>

* refactor(execution): delete enrty point ExecutionResources (starkware-libs#1447)

* fix: limit the syscall emit_event resources, keys, data and number of events (starkware-libs#1463)

* fix(transaction): set l1 hanlder payload size to None for non-l1 hanlder txs (bouncer count) (starkware-libs#1470)

* feat(fee): charge for signatures per byte (starkware-libs#1474)

* Merge `main-v0.13.0-hotfix` into `main-v0.13.1` (resolve conflicts).

* feat(execution): round block_number and timestamp for the execution info syscall in validate_mode (starkware-libs#1467)

* feat(fee): add gas cost for code bytes (starkware-libs#1475)

* feat(fee): add events gas cost (starkware-libs#1458)

* chore(execution): increase invoke_tx_max_n_steps (starkware-libs#1477)

Co-Authored-By: Gilad Chase <[email protected]>

* chore(fee): update vm resource and l2 resource costs (starkware-libs#1479)

* chore: upgrade cairo and sn-api versions (starkware-libs#1454)

* chore: upgrade cairo and sn-api versions

* chore: upgrade cairo and sn-api versions (starkware-libs#1460)

* fix: fix cargo.lock - remove cargo update (starkware-libs#1481)

* fix: undo cargo update from previous commit 984431a

* fix: update cargo.lock to take into account changes in 984431a

they wered reverted in previous commit.

Co-Authored-By: Gilad Chase <[email protected]>

* fix: fix versioned_constants.json

* chore(fee): small fixes (starkware-libs#1484)

* refactor(fee): moving calculate_tx_gas_usage_vector to ActualCostBuilder (starkware-libs#1478)

* Release v0.5.0-rc.1

* refactor(execution): remove fee weights from config (starkware-libs#1487)

* fix: update the event limit constants (starkware-libs#1483)

* Merge `main-v0.13.0-hotfix` into `main-v0.13.1` (resolve conflicts).

* refactor(execution, native_blockifier): move TransactionExecutor to blockifier (starkware-libs#1497)

* refactor(state): remove unnecessary derive (starkware-libs#1505)

* refactor(execution): move bouncer, block and block_test to blockifier dir (starkware-libs#1502)

* feat(fee): add n_events field to BouncerInfo (starkware-libs#1489)

* refactor: move the event size limit constants into versioned_constants (starkware-libs#1490)

* refactor(transaction): remove public fields, add new function (starkware-libs#1480)

* refactor(execution): type of additional_data in test_validate_accounts_tx (starkware-libs#1485)

* refactor: move validate_block_number_rounding and validate_timestamp_rounding to versioned_constants (starkware-libs#1506)

* test(execution): add get_execution_info scenario to test_validate_accounts_tx (starkware-libs#1486)

* test(execution): get_sequencer_address in test_validate_accounts_tx (starkware-libs#1496)

* refactor: use versioned_constants function when possible (starkware-libs#1508)

* test(execution): get_block_number and get_block_timestamp in test_validate_accounts_tx for Cairo0 (starkware-libs#1512)

* chore(fee): Update os resources to include 4844 calculations (starkware-libs#1498)

* refactor: replaced default_invoke_tx_args with macro that enforces to explicitly define max_fee (starkware-libs#1510)

* feat(fee): calculate n_events field for BouncerInfo in a naive way (starkware-libs#1499)

* fix: state trait does not require &mut self (starkware-libs#1325)

* fix: state trait does not require &mut self

fix: sachedState use interior mutability

* chore: remove clippy allow

* fix: small review fix

* fix: remove to_state_diff from StateApi (starkware-libs#1326)

* chore: merge branch main-v0.13.1 into main (resolve conflicts)

* feat: add merge_branches script (starkware-libs#1513)

* chore: bump compiler version to 2.6.0-rc.1 (starkware-libs#1525)

Signed-off-by: Dori Medini <[email protected]>

* chore: move validate consts into os constants (starkware-libs#1523)

* chore: move validate consts into os constants

Had to bump serde_json due to some apparent bug with the recent stable
rust.

* feat: make 13_1 consts backwards compatible

Assign the following defaults for keys missing in versioned_constants
files (for example, they are missing in versioned_constants_13_0.json).

- EventSizeLimit => max values
- L2ResourceGasCosts => 0 values
- validate rounding numbers => 1 (to preserve past no-rounding
  behavior). This required bundling them up in a specialized struct in
  order to define a custom default as 1 (rather than 0).
- Add test for default values: required extracting validation logic of
  `OsResources` so it won't trigger automatically in tests.

Co-Authored-By: Gilad Chase <[email protected]>

* chore!: limit pointer width in both crates (starkware-libs#1527)

Signed-off-by: Dori Medini <[email protected]>

* feat: backwards compatibility for calldata_factor

If os resources' inner tx is missing `constant` and `calldata_factor`
keys, then:
- assume it is a flat `ExecutionResources` instance, and put its
  contents inside a `constant` key.
- initialize calldata_factor as default (all zeros).

* feat: add versioned_constants_13_0.json (starkware-libs#1520)

Changes between this and the current versioned_constants:
- no `event_size_limit`
- invoke_tx_max_n_steps is 3_000_000 instead of 4_000_000
- no `l2_resource_gas_costs`
- multiple value changes in os_resources
- `vm_resource_fee_cost` is X2 for all values
- no constants for validate's block number and timestamp rounding

No other changes (in particular, os constants is indeed _unchanged_)

Co-Authored-By: Gilad Chase <[email protected]>

* Merge `main-v0.13.1` into `main` (resolve conflicts).

* fix: versioned constants validate (starkware-libs#1537)

- validate invocation had a syntax error, which was hidden by the cfg
- remove `testing` from the cfg, since we all compile with `testing`
  during development, and it's just not what we want.

Co-Authored-By: Gilad Chase <[email protected]>

* fix: update the tx event limit constants (starkware-libs#1517)

* chore: release 0.5.0-rc.2: 13_0.json support

* fix: generate_starknet_os_resources python target fix (starkware-libs#1541)

* No conflicts in main-v0.13.1 -> main merge, this commit is for any change needed to pass the CI.

* fix: generate_starknet_os_resources python target fix (starkware-libs#1548)

* refactor: remove some magic numbers from tests (starkware-libs#1547)

* fix!: update max_contract_bytecode_size to 81k (starkware-libs#1549)

* chore: add merge_status.py script (starkware-libs#1543)

Signed-off-by: Dori Medini <[email protected]>

* chore: merge branch main-v0.13.1 into main (resolve conflicts)

* ci: advance setup-python action version (starkware-libs#1555)

* refactor(native_blockifier): rename l1_gas_amount to gas_weight in bouncerInfo (starkware-libs#1524)

* chore: release v0.5.0-rc.3

* chore: panic if u128_from_usize fails (starkware-libs#1522)

Signed-off-by: Dori Medini <[email protected]>

* refactor: make StateError::UndeclaredClassHash a one-line error (starkware-libs#1563)

Change previous error which prints out as:
```
Class with hash ClassHash(
    StarkFelt(
        "0x00000000000000000000000000000000000000000000000000000000000004d2",
    ),
) is not declared.
```
into:
```
Class with hash 0x00000000000000000000000000000000000000000000000000000000000004d2 is not declared.
```

* test(fee): test get_message_segment_length function (starkware-libs#1471)

* refactor: add BlockWeights for the future bouncer (starkware-libs#1444)

* refactor: remove f64 usage at blockifier (starkware-libs#1519)

* fix: unwrap called on u128 (starkware-libs#1570)

Signed-off-by: Dori Medini <[email protected]>

* test: use FeatureContract in create_test_state and tests which uses it (starkware-libs#1556)

* No conflicts in main-v0.13.1 -> main merge, this commit is for any change needed to pass the CI.

* chore: remove final f64s (starkware-libs#1574)

Signed-off-by: Dori Medini <[email protected]>

* chore: remove some 'as' conversions and enforce no 'as' conversions (starkware-libs#1575)

* chore: remove final f64s

Signed-off-by: Dori Medini <[email protected]>

* chore: remove some 'as' conversions and enforce no 'as' conversions

Signed-off-by: Dori Medini <[email protected]>

* Restore workflow

* Rename ci

* Add commit lint rules

* nightly format

* update .env

* Test global env and composite action

* attemp fix to composite action

* Minor fix

* Modify .github structure

* Add composite action to jobs?

* Minor yaml fix

* Fix compilation errors

* WIP

* Storage_read_write_gas

* add tests for vm & native

* modify test_get_execution_info

* Review tests

* rename syscalls_test.rs -> syscall_tests.rs

* Fix minor compilation bug

* Update dependencies

---------

Signed-off-by: Dori Medini <[email protected]>
Co-authored-by: Dori Medini <[email protected]>
Co-authored-by: Gilad Chase <[email protected]>
Co-authored-by: giladchase <[email protected]>
Co-authored-by: Lior Goldberg <[email protected]>
Co-authored-by: liorgold2 <[email protected]>
Co-authored-by: Arnon Hod <[email protected]>
Co-authored-by: Elin Tulchinsky <[email protected]>
Co-authored-by: OriStarkware <[email protected]>
Co-authored-by: Ayelet Zilber <[email protected]>
Co-authored-by: zuphitf <[email protected]>
Co-authored-by: aner-starkware <[email protected]>
Co-authored-by: Noa Oved <[email protected]>
Co-authored-by: Yoni <[email protected]>
Co-authored-by: YaelD <[email protected]>
Co-authored-by: mohammad-starkware <[email protected]>
Co-authored-by: barak-b-starkware <[email protected]>
Co-authored-by: Lucas @ StarkWare <[email protected]>
Co-authored-by: dafnamatsry <[email protected]>
Co-authored-by: avi-starkware <[email protected]>
Co-authored-by: Tzahi <[email protected]>
Co-authored-by: nimrod-starkware <[email protected]>
Co-authored-by: Timothée Delabrouille <[email protected]>
Co-authored-by: Barak <[email protected]>
Co-authored-by: Yonatan Iluz <[email protected]>
Co-authored-by: Rodrigo <[email protected]>
gswirski pushed a commit to reilabs/blockifier that referenced this pull request Jun 26, 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