-
Notifications
You must be signed in to change notification settings - Fork 28
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(blockifier): add struct StateChangesCountForFee #2175
Conversation
Artifacts upload triggered. View details here |
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 8 of 8 files at r1, all commit messages.
Reviewable status: all files reviewed, 8 unresolved discussions (waiting on @yoavGrs)
crates/blockifier/src/transaction/transactions_test.rs
line 0 at r1 (raw file):
same as above: does it make sense to have nonzero values for n_allocations in this test?
crates/blockifier/src/state/cached_state.rs
line 731 at r1 (raw file):
n_modified_contracts: modified_contracts.len(), }, n_allocated_keys: if enable_stateful_compression {
hmmm... maybe this flag is a bit confusing...
I would expect enable_stateful_compression
to indicate whether or not contract 0x2
appears in the state diff,
not whether or not we charge for allocations (which is what is happening here).
should we have two separate flags for this? @Yoni-Starkware
Code quote:
n_allocated_keys: if enable_stateful_compression {
crates/blockifier/src/state/cached_state.rs
line 755 at r1 (raw file):
pub struct StateChangesCountForFee { pub state_changes_count: StateChangesCount, pub n_allocated_keys: usize,
just to be clear: this field will be computed, regardless of the enable_stateful_compression
flag, correct?
Code quote:
pub n_allocated_keys: usize,
crates/blockifier/src/fee/resources.rs
line 153 at r1 (raw file):
sender_address: Option<ContractAddress>, fee_token_address: ContractAddress, enable_stateful_compression: bool,
consider this rename, everywhere (see below - maybe a separate flag for stateful compression?)
Suggestion:
charge_for_allocations: bool,
crates/blockifier/src/fee/resources.rs
line 181 at r1 (raw file):
// TODO(Nimrod, 29/3/2024): delete `get_da_gas_cost` and move it's logic here. // TODO(Yoav): Add the cost of allocating keys. get_da_gas_cost(&self.state_changes_for_fee.state_changes_count, use_kzg_da)
did we decide the allocation should be part of DA gas?
we show DA gas separately in the receipt, we want to charge for allocation but not necessarily make it show up as part of the DA gas vector
@Yoni-Starkware WDYT?
Code quote:
// TODO(Yoav): Add the cost of allocating keys.
get_da_gas_cost(&self.state_changes_for_fee.state_changes_count, use_kzg_da)
crates/blockifier/src/fee/receipt_test.rs
line 0 at r1 (raw file):
any coverage benefit from making some of these values non-zero?
if so, please make some non-zero
(if tests fail: why?)
crates/blockifier/src/transaction/account_transactions_test.rs
line 1385 at r1 (raw file):
block_context.versioned_constants.enable_stateful_compression, ) .state_changes_count;
why take this field, and not compare the entire object?
X3 (same Q twice below)
Code quote:
.state_changes_count
crates/blockifier/src/state/cached_state_test.rs
line 351 at r1 (raw file):
n_modified_contracts: 2, }, n_allocated_keys: 0,
can you update create_state_changes_for_test
to create some allocations and use some nonzero X
here?
Suggestion:
n_allocated_keys: if enable_stateful_compression { X } else { 0 },
539d545
to
4832a87
Compare
46a6da2
to
868b6b6
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: 5 of 8 files reviewed, 9 unresolved discussions (waiting on @dorimedini-starkware)
crates/blockifier/src/fee/receipt_test.rs
line at r1 (raw file):
Previously, dorimedini-starkware wrote…
any coverage benefit from making some of these values non-zero?
if so, please make some non-zero
(if tests fail: why?)
Done, where it makes sense.
Some tests will fail when we include the allocations in the gas computation.
crates/blockifier/src/state/cached_state.rs
line 755 at r1 (raw file):
Previously, dorimedini-starkware wrote…
just to be clear: this field will be computed, regardless of the
enable_stateful_compression
flag, correct?
No.
Under a ForFee
struct, this field will be 0 if not enable_stateful_compression
.
crates/blockifier/src/state/cached_state_test.rs
line 351 at r1 (raw file):
Previously, dorimedini-starkware wrote…
can you update
create_state_changes_for_test
to create some allocations and use some nonzeroX
here?
It will create allocations when we implement the allocation logic. Look at this test here:
https://reviewable.io/reviews/starkware-libs/sequencer/2150
crates/blockifier/src/transaction/account_transactions_test.rs
line 1385 at r1 (raw file):
Previously, dorimedini-starkware wrote…
why take this field, and not compare the entire object?
X3 (same Q twice below)
Changing it.
I'll set the correct number of allocations when we implement the allocation logic (2150).
crates/blockifier/src/transaction/transactions_test.rs
line at r1 (raw file):
Previously, dorimedini-starkware wrote…
same as above: does it make sense to have nonzero values for n_allocations in this test?
No allocations in invoke return_result
/ declare tx.
This is the expected value.
crates/blockifier/src/state/cached_state.rs
line 732 at r1 (raw file):
}, n_allocated_keys: if enable_stateful_compression { self.allocated_keys.count()
Sorry, moving this to the next PR.
Code quote:
self.allocated_keys.count()
Artifacts upload triggered. View details here |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #2175 +/- ##
===========================================
+ Coverage 40.10% 68.70% +28.60%
===========================================
Files 26 108 +82
Lines 1895 13936 +12041
Branches 1895 13936 +12041
===========================================
+ Hits 760 9575 +8815
- Misses 1100 3950 +2850
- Partials 35 411 +376 ☔ 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.
Reviewed 3 of 3 files at r2, all commit messages.
Reviewable status: all files reviewed, 3 unresolved discussions (waiting on @yoavGrs)
crates/blockifier/src/state/cached_state.rs
line 755 at r1 (raw file):
Previously, yoavGrs wrote…
No.
Under aForFee
struct, this field will be 0 ifnot enable_stateful_compression
.
ah, right.
but the StateChanges will count this? just not the ForFee
flavor?
4832a87
to
f799e59
Compare
868b6b6
to
d7d90ca
Compare
Artifacts upload triggered. View details here |
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: 1 of 8 files reviewed, 3 unresolved discussions (waiting on @dorimedini-starkware and @yoavGrs)
crates/blockifier/src/state/cached_state.rs
line 731 at r1 (raw file):
Previously, dorimedini-starkware wrote…
hmmm... maybe this flag is a bit confusing...
I would expectenable_stateful_compression
to indicate whether or not contract0x2
appears in the state diff,
not whether or not we charge for allocations (which is what is happening here).
should we have two separate flags for this? @Yoni-Starkware
We should count the allocated keys here regardless of this flag - only charge according to it.
And yes, more readable to have two flags.
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: 1 of 8 files reviewed, 3 unresolved discussions (waiting on @dorimedini-starkware and @yoavGrs)
crates/blockifier/src/state/cached_state.rs
line 731 at r1 (raw file):
Previously, Yoni-Starkware (Yoni) wrote…
We should count the allocated keys here regardless of this flag - only charge according to it.
And yes, more readable to have two flags.
Even better - let the second config be the cost of an allocated key, and set it to 0 for old VCs. That way we save a flag.
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: 1 of 8 files reviewed, 3 unresolved discussions (waiting on @dorimedini-starkware and @yoavGrs)
crates/blockifier/src/fee/resources.rs
line 181 at r1 (raw file):
Previously, dorimedini-starkware wrote…
did we decide the allocation should be part of DA gas?
we show DA gas separately in the receipt, we want to charge for allocation but not necessarily make it show up as part of the DA gas vector
@Yoni-Starkware WDYT?
Hmmm yes but I don't want to split this part into another struct. And soon we will have L2 cost for state changes, so I think putting this under StateResources makes sense.
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 7 of 7 files at r3, all commit messages.
Reviewable status: all files reviewed, 4 unresolved discussions (waiting on @yoavGrs)
crates/blockifier/src/fee/gas_usage_test.rs
line 82 at r3 (raw file):
}, 19, >>>>>>> 868b6b68c (feat(blockifier): add struct StateChangesCountForFee)
oops
Code quote:
>>>>>>> 868b6b68c (feat(blockifier): add struct StateChangesCountForFee)
Artifacts upload triggered. View details here |
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, 3 unresolved discussions (waiting on @yoavGrs)
crates/blockifier/src/fee/resources.rs
line 181 at r1 (raw file):
Previously, Yoni-Starkware (Yoni) wrote…
Hmmm yes but I don't want to split this part into another struct. And soon we will have L2 cost for state changes, so I think putting this under StateResources makes sense.
unblocking here, but I'm saying that get_da_gas_cost
should ignore allocations even in future PRs.
this function should return get_da_gas_cost(...).checked_add(get_allocations_gas_cost(...)).expect(...)
, so we can still use get_da_gas_cost
to represent the cost of data availability (and not starknet state allocation costs)
f799e59
to
aa0115b
Compare
d7d90ca
to
3cf36e7
Compare
3cf36e7
to
bb121ba
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: 1 of 9 files reviewed, 4 unresolved discussions (waiting on @dorimedini-starkware and @yoavGrs)
crates/blockifier/src/state/cached_state.rs
line 731 at r5 (raw file):
}, // TODO: Set number of allocated keys. n_allocated_keys: { 0 },
What's the plan?
Code quote:
// TODO: Set number of allocated keys.
n_allocated_keys: { 0 },
bb121ba
to
d3b22a0
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: 1 of 9 files reviewed, 4 unresolved discussions (waiting on @dorimedini-starkware)
crates/blockifier/src/fee/gas_usage_test.rs
line 82 at r3 (raw file):
Previously, dorimedini-starkware wrote…
oops
:(
crates/blockifier/src/fee/resources.rs
line 153 at r1 (raw file):
Previously, dorimedini-starkware wrote…
consider this rename, everywhere (see below - maybe a separate flag for stateful compression?)
removed.
crates/blockifier/src/fee/resources.rs
line 181 at r1 (raw file):
Previously, dorimedini-starkware wrote…
unblocking here, but I'm saying that
get_da_gas_cost
should ignore allocations even in future PRs.
this function should returnget_da_gas_cost(...).checked_add(get_allocations_gas_cost(...)).expect(...)
, so we can still useget_da_gas_cost
to represent the cost of data availability (and not starknet state allocation costs)
👍
crates/blockifier/src/state/cached_state.rs
line 731 at r1 (raw file):
Previously, Yoni-Starkware (Yoni) wrote…
Even better - let the second config be the cost of an allocated key, and set it to 0 for old VCs. That way we save a flag.
https://reviewable.io/reviews/starkware-libs/sequencer/2200
crates/blockifier/src/state/cached_state.rs
line 755 at r1 (raw file):
Previously, dorimedini-starkware wrote…
ah, right.
but the StateChanges will count this? just not theForFee
flavor?
Sorry, even in theForFee
struct, the real amount will appear.
d3b22a0
to
391bf4b
Compare
391bf4b
to
2838afb
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: 1 of 9 files reviewed, 4 unresolved discussions (waiting on @dorimedini-starkware and @Yoni-Starkware)
crates/blockifier/src/state/cached_state.rs
line 731 at r5 (raw file):
Previously, Yoni-Starkware (Yoni) wrote…
What's the plan?
I changed the order of the branches, and removed the TODO.
2838afb
to
2c19800
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 4 files at r4, 1 of 6 files at r5, 4 of 5 files at r6, 2 of 2 files at r7, all commit messages.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @Yoni-Starkware)
crates/blockifier/src/fee/resources.rs
line 17 at r7 (raw file):
}; #[cfg(any(test, feature = "testing"))] use crate::state::cached_state::StateChangesCount;
delete (see below)
non-blocking, it's a question of style
Code quote:
#[cfg(any(test, feature = "testing"))]
use crate::state::cached_state::StateChangesCount;
crates/blockifier/src/fee/resources.rs
line 183 at r7 (raw file):
) -> Self { Self { state_changes_for_fee: StateChangesCountForFee {
I suggest this, looks better than gating the use
(see above)
Suggestion:
state_changes_for_fee: crate::state::cached_state::StateChangesCountForFee
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 4 files at r4, 1 of 6 files at r5, 1 of 5 files at r6, 1 of 2 files at r7, all commit messages.
Reviewable status: complete! all files reviewed, all discussions resolved (waiting on @yoavGrs)
2c19800
to
9a147b1
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 r8, all commit messages.
Reviewable status: complete! all files reviewed, all discussions resolved (waiting on @yoavGrs)
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 @yoavGrs)
9a147b1
to
99c2be9
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 r9, all commit messages.
Reviewable status: complete! all files reviewed, all discussions resolved (waiting on @yoavGrs)
No description provided.