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

mirror jms timeless history2 a9acf2741f6ddb1ed431d8143e0f1ed41672173d #123

Conversation

shahar4
Copy link
Collaborator

@shahar4 shahar4 commented Oct 2, 2023

Changes VM internal rollbacks to work differently: you now call snapshot to push a snapshot onto a stack. Later you can rollback or forget_snapshot.

This enables many optimizations. For example, in the old model an integer had to remember all its old values. In the new model, remembering the value it had at the time of the snapshot suffices. The snapshots can be used in place of the forwards and rollbacks lists in storage and event_sink and doing so will fix a pubdata refund bug.

Bytes paid for storage writes are computed in a new much simpler way because the old way relied on reading history, which is bad as it is tightly coupled to how history is implemented. Same thing with the number of contracts decommitted.

VM memory statistics are no longer published because nobody seems to care about them and I don't want to have to change them all the time during the history optimizations that I'm going to do. A more maintainable version could be developed but I'd suggest using massif for memory statistics instead.

  • Mirrors branch main from private at 37c38b2
  • Mirrors branch nix-zlib from private at c3c4d32a91904f31a879e72e001fb6d6d96259e7
  • Mirrors branch jms-timeless-history2 from private at 1620fd8fdce2761fe76c2eb637d8b0e6b500cd9e
  • Mirrors branch jms-timeless-history2 from private at a9acf2741f6ddb1ed431d8143e0f1ed41672173d

This is a mirror of this private PR.

@shahar4 shahar4 requested a review from a team as a code owner October 2, 2023 06:23
@codecov
Copy link

codecov bot commented Oct 2, 2023

Codecov Report

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

Comparison is base (427f654) 31.49% compared to head (5b951c2) 31.91%.
Report is 3 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #123      +/-   ##
==========================================
+ Coverage   31.49%   31.91%   +0.42%     
==========================================
  Files         477      480       +3     
  Lines       25429    25135     -294     
==========================================
+ Hits         8010     8023      +13     
+ Misses      17419    17112     -307     
Files Coverage Δ
core/lib/multivm/src/glue/init_vm.rs 7.69% <ø> (+0.19%) ⬆️
core/lib/vm/src/implementation/bytecode.rs 53.84% <ø> (+1.99%) ⬆️
core/lib/vm/src/implementation/gas.rs 14.28% <ø> (ø)
core/lib/vm/src/implementation/logs.rs 40.00% <ø> (ø)
core/lib/vm/src/implementation/statistics.rs 27.27% <ø> (+18.18%) ⬆️
core/lib/vm/src/old_vm/memory.rs 88.31% <100.00%> (+34.63%) ⬆️
core/lib/vm/src/old_vm/utils.rs 67.21% <100.00%> (+15.96%) ⬆️
core/lib/vm/src/tracers/storage_invocations.rs 0.00% <ø> (ø)
core/lib/vm/src/tracers/utils.rs 90.90% <100.00%> (+34.45%) ⬆️
core/lib/vm/src/tracers/validation/mod.rs 0.00% <ø> (ø)
... and 29 more

... and 27 files with indirect coverage changes

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

@Deniallugo Deniallugo force-pushed the mirror-jms-timeless-history2-a9acf2741f6ddb1ed431d8143e0f1ed41672173d branch from e806bf5 to 5b951c2 Compare October 2, 2023 06:41
@github-actions
Copy link
Contributor

github-actions bot commented Oct 2, 2023

Detected VM performance changes

Benchmark name Difference in runtime
call_far -10.4%
event_spam -3.5%
decode_shl_sub -3.5%
write_and_decode -4.0%
finish_eventful_frames -8.9%
access_memory -3.2%
slot_hash_collision -4.6%

mr-teikst pushed a commit to mr-teikst/zksync-era that referenced this pull request Mar 6, 2024
This commit addresses the issue of an unbounded loop in the `writes` function of the `WritesAndMessages` contract. The unbounded loop could potentially lead to out-of-gas errors and transaction failures if the `iterations` parameter is set too high.

The fix introduces a `LOOP_LIMIT` constant that sets the maximum number of iterations allowed in a single transaction. If the desired `iterations` exceed the loop limit, the function now splits the iterations into multiple batches, executing the loop for the `LOOP_LIMIT` iterations in each batch.

The `writes` function has been modified as follows:

- Introduce a `LOOP_LIMIT` constant set to 1000 (adjustable based on gas limits and requirements)
- Use a `while` loop to handle remaining iterations
- Calculate the `batchSize` as the minimum of `LOOP_LIMIT` and the remaining iterations
- Execute the loop for the calculated `batchSize`
- Update the remaining iterations and start index for the next batch

By splitting the operation into multiple transactions, the function ensures that the loop never exceeds the `LOOP_LIMIT`, preventing potential out-of-gas issues. However, this approach may introduce additional complexity and potential for inconsistencies if transactions fail or are reordered.

Resolves: matter-labs#123 (replace with the actual issue number, if applicable)
@Deniallugo Deniallugo deleted the mirror-jms-timeless-history2-a9acf2741f6ddb1ed431d8143e0f1ed41672173d branch March 12, 2024 16:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants