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

[WIP] Stateful statediff #1509

Open
wants to merge 4 commits into
base: nightly
Choose a base branch
from
Open

[WIP] Stateful statediff #1509

wants to merge 4 commits into from

Conversation

kpp
Copy link
Contributor

@kpp kpp commented Nov 22, 2024

Description

Now instead of storing [address balance nonce code_hash] we store [address diff(balance) diff(nonce) diff(code_hash)]. When nonce/code_hash are not changed, they take 1 byte. And some heuristics to find a diff are implemented.So for a transfer tx we went from [20 + 32 + 8 + 33] + [20 + 32 + 8 + 33] bytes to [20 diff 2 1] + [20 diff 1 1], where diff for balance e.g. (before 4283200000, after 1232308282) is packed into 5 bytes. So 93+93 bytes went to 28+27.

Easy to implement (see #1132):

  • parse into typed: SetL1Hash
  • parse into typed: SetLatestBlockHash
  • parse into typed: RemoveLatestBlockHashRange
  • parse into typed: SetHead(Block)
  • parse into typed: SetScreData(RuleEnforcerData)
  • parse into typed: SetSovAccountPublicKey([u8; 32], [u8; 32])
  • parse into typed: RemoveSovAccountPublicKey([u8; 32])
  • parse into typed: SetSovAccount([u8; 32], SovAcc)
  • parse into typed: RemoveSovAccount([u8; 32])

To implement RepeatedWrites we need to scan writes, if:

  • there is no write in Db -> assign unique u32 id and store it in db
  • there was a write and it has a u32 id -> provide that id into compute_state_update

Linked Issues

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.

Implement a PoW stateful statediff
1 participant