-
Notifications
You must be signed in to change notification settings - Fork 26
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
chore(blockifier): derive serde for transaction_execution_info #379
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed 5 of 5 files at r1, all commit messages.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @aner-starkware, @meship-starkware, and @noaov1)
a discussion (no related file):
why?
what's the use case?
Previously, dorimedini-starkware wrote…
🤷, it's the assignment from github issues... |
There was a problem hiding this 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 @aner-starkware, @meship-starkware, and @noaov1)
a discussion (no related file):
Previously, aner-starkware wrote…
🤷, it's the assignment from github issues...
ah
ok then, please gate it behind a feature, so we verify we don't use this internally
There was a problem hiding this 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 @aner-starkware and @noaov1)
a discussion (no related file):
In all open issues PRs, Ariel asked us to add @tdelabro
Previously, dorimedini-starkware wrote…
What does that mean? |
Previously, meship-starkware (Meshi Peled) wrote…
Thanks. |
There was a problem hiding this 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, 2 unresolved discussions (waiting on @aner-starkware, @noaov1, and @tdelabro)
a discussion (no related file):
Previously, aner-starkware wrote…
What does that mean?
- add a feature (call it, say,
transaction_serde
in thefeatures
section of the blockifier's cargo.toml - use
cfg_attr
to conditionally derive (De)Serialize if the feature is active (seecfg_attr
examples in the repo)
@aner-starkware you can take a look to widely used crate like: https://github.com/rust-num/num-bigint/blob/master/Cargo.toml The Cargo.toml has a Then instead of having #[derive(Copy, Clone)]
#[cfg_attr(feature = "serde", derive(serde::Serizalize, serde::Deserialize)]
pub struct MyStruct {} |
12a029c
to
67b490b
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed 5 of 5 files at r1.
Reviewable status: 0 of 7 files reviewed, 3 unresolved discussions (waiting on @aner-starkware, @dorimedini-starkware, @noaov1, and @tdelabro)
crates/blockifier/Cargo.toml
line 15 at r2 (raw file):
concurrency = [] jemalloc = ["dep:tikv-jemallocator"] transaction_serde = []
AFAIU, no need for explicit dependencies as serde is a non-optional dependency already.
67b490b
to
5c2652a
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed 1 of 7 files at r2, 6 of 6 files at r3, all commit messages.
Reviewable status: all files reviewed, 8 unresolved discussions (waiting on @aner-starkware, @noaov1, and @tdelabro)
crates/blockifier/src/execution/call_info.rs
line 32 at r3 (raw file):
#[cfg_attr(test, derive(Clone))] #[cfg_attr(feature = "transaction_serde", derive(Deserialize))] #[derive(Debug, Default, Eq, PartialEq, Serialize)]
this is cleaner IMO; WDYT?
this way you only need to name the feature once
Suggestion:
use cairo_vm::vm::runners::cairo_runner::ExecutionResources;
use serde::Serialize;
use starknet_api::core::{ClassHash, ContractAddress, EthAddress, PatriciaKey};
use starknet_api::state::StorageKey;
use starknet_api::transaction::{EventContent, L2ToL1Payload};
use starknet_api::{felt, patricia_key};
use starknet_types_core::felt::Felt;
use crate::execution::entry_point::CallEntryPoint;
use crate::fee::gas_usage::get_message_segment_length;
use crate::state::cached_state::StorageEntry;
#[cfg_attr(feature = "transaction_serde", derive(serde::Deserialize))]
#[derive(Clone, Debug, Default, Eq, PartialEq, Serialize)]
pub struct Retdata(pub Vec<Felt>);
#[macro_export]
macro_rules! retdata {
( $( $x:expr ),* ) => {
Retdata(vec![$($x),*])
};
}
#[cfg_attr(test, derive(Clone))]
#[cfg_attr(feature = "transaction_serde", derive(Deserialize))]
#[derive(Debug, Default, Eq, PartialEq, Serialize)]
crates/blockifier/src/execution/entry_point.rs
line 8 at r3 (raw file):
use num_traits::{Inv, Zero}; #[cfg(feature = "transaction_serde")] use serde::Deserialize;
see above
Code quote:
#[cfg(feature = "transaction_serde")]
use serde::Deserialize;
crates/blockifier/src/fee/actual_cost.rs
line 3 at r3 (raw file):
use cairo_vm::vm::runners::cairo_runner::ExecutionResources; #[cfg(feature = "transaction_serde")] use serde::{Deserialize, Serialize};
see above
Code quote:
#[cfg(feature = "transaction_serde")]
use serde::{Deserialize, Serialize};
crates/blockifier/src/state/cached_state.rs
line 7 at r3 (raw file):
use indexmap::IndexMap; #[cfg(feature = "transaction_serde")] use serde::{Deserialize, Serialize};
see above
Code quote:
#[cfg(feature = "transaction_serde")]
use serde::{Deserialize, Serialize};
crates/blockifier/src/transaction/objects.rs
line 7 at r3 (raw file):
use num_traits::Pow; #[cfg(feature = "transaction_serde")] use serde::Deserialize;
see above
Code quote:
#[cfg(feature = "transaction_serde")]
use serde::Deserialize;
5c2652a
to
54b4df3
Compare
There was a problem hiding this 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 7 files reviewed, 8 unresolved discussions (waiting on @aner-starkware, @dorimedini-starkware, @noaov1, and @tdelabro)
crates/blockifier/src/execution/call_info.rs
line 32 at r3 (raw file):
Previously, dorimedini-starkware wrote…
this is cleaner IMO; WDYT?
this way you only need to name the feature once
Agree
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed 5 of 5 files at r4, all commit messages.
Reviewable status: complete! all files reviewed, all discussions resolved (waiting on @noaov1)
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #379 +/- ##
==========================================
+ Coverage 76.51% 76.59% +0.07%
==========================================
Files 329 348 +19
Lines 34931 36771 +1840
Branches 34931 36771 +1840
==========================================
+ Hits 26729 28165 +1436
- Misses 5909 6283 +374
- Partials 2293 2323 +30 ☔ View full report in Codecov by Sentry. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewable status: complete! all files reviewed, all discussions resolved (waiting on @noaov1)
54b4df3
to
194066d
Compare
There was a problem hiding this 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.
Reviewable status: all files reviewed (commit messages unreviewed), all discussions resolved (waiting on @noaov1)
There was a problem hiding this 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: complete! all files reviewed, all discussions resolved (waiting on @noaov1)
There was a problem hiding this 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: complete! all files reviewed, all discussions resolved (waiting on @noaov1)
This change is