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

Meta: Stateful StateDiff (tracking issue) #1237

Open
3 of 10 tasks
Tracked by #1281
kpp opened this issue Sep 27, 2024 · 0 comments
Open
3 of 10 tasks
Tracked by #1281

Meta: Stateful StateDiff (tracking issue) #1237

kpp opened this issue Sep 27, 2024 · 0 comments
Labels
DECISION-NEEDED the issue should be carefully evaluated for inclusion into the repo P-low Low priority T - enhancement New feature or request
Milestone

Comments

@kpp
Copy link
Contributor

kpp commented Sep 27, 2024

Let's define:

  • stateless statediff - is a diff with full information about all state changes in the batch.
  • stateful statediff - is a diff with full information about all state changes in the batch given the previous state.

In other words:

prev_state: {K -> V} = ...
inputs = ...
new_state: {K -> V} = STF(prev_state, inputs)

stateless_state_diff: {K -> V} = new_state \ prev_state
stateful_state_diff: {K -> V} = [difference(key, stateless_state_diff[key], prev_state[key]))
                                                    for key in stateless_state_diff]

Where difference is defined as:

difference key new null = (key, NoCompression(x))
difference key new prev
  | new < prev = (index(key), Sub(prev - new))
  | new > prev = (index(key), Add(new - prev))
  | new <<< prev = (index(key), Transform(prev))
  | new >>> prev = (index(key), Transform(prev))
  | new == prev = unreachable

See https://docs.zksync.io/build/developer-reference/handling-pubdata-in-boojum for more details.

See https://github.com/code-423n4/2024-03-zksync/blob/main/docs/Smart%20contract%20Section/Handling%20pubdata.md#state-diffs-after-boojum-upgrade for more technical details.

See https://github.com/matter-labs/zksync-era/blob/main/core/lib/types/src/storage/writes/compression.rs.

See https://github.com/matter-labs/zksync-era/blob/main/core/lib/types/src/storage/writes/mod.rs.

Linked issues:

@kpp kpp added T - enhancement New feature or request P-low Low priority labels Sep 27, 2024
This was referenced Oct 2, 2024
@kpp kpp changed the title Statefull StateDiff Meta: Statefull StateDiff Oct 3, 2024
@eyusufatik eyusufatik added the DECISION-NEEDED the issue should be carefully evaluated for inclusion into the repo label Oct 9, 2024
@kpp kpp changed the title Meta: Statefull StateDiff Meta: Stateful StateDiff Nov 22, 2024
@eyusufatik eyusufatik modified the milestones: Fork 1, Mainnet Must Nov 28, 2024
@kpp kpp changed the title Meta: Stateful StateDiff Meta: Stateful StateDiff (tracking issue) Feb 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
DECISION-NEEDED the issue should be carefully evaluated for inclusion into the repo P-low Low priority T - enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants