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

Extract storage creation from State Transition Function #1103

Merged
merged 12 commits into from
Oct 26, 2023

Conversation

citizen-stig
Copy link
Member

@citizen-stig citizen-stig commented Oct 24, 2023

Description

This is the first step for implementing reorgs support.

This PR includes:

  • Change in rollup-interface StateTransitionFunction, by adding extra types that will needed
  • App template does not hold storage anymore, but it still does commit. Extracting commit functionality is under discussion
  • ProverStorage only writes to underlying db in commit, and not in compute_state_update. Except for empty JMT case. Added todo for this.
  • Adding new StorageManager to rollup-interface which is temporary placeholder before ForkManager arrives:
pub trait StorageManager {
    type NativeStorage;
    type NativeChangeSet;

    fn get_native_storage(&self) -> Self::NativeStorage;
}

Decision to keep AppTemplate committing to database is made for 2 reasons:

  • When ProverStorage will be transformed to work over snapshots, then it won't be actual commit to database, but to Snapshot.
  • To minimize changes done in this PR. But technically, Storage can become read-only over underlying storage. This is up to discussion. But it will simplify Storage trait a little bit.

Minor changes

  • Rename variables app and demo to stf
  • Rename generic ST to Stf according to generics naming convention.
  • Remove ProverStorage::db() method, as it is used only in tests
  • Make runtime attribute from AppTemplate to be crate public instead of completely public, as it was only used for tests.

Linked Issues

Testing

All existing tests are passing.

Docs

Documentation has been updated

@citizen-stig citizen-stig self-assigned this Oct 24, 2023
@citizen-stig citizen-stig changed the title Extract storage persistence from State Transition Function Extract storage creation from State Transition Function Oct 25, 2023
@citizen-stig citizen-stig force-pushed the nikolai/extract_persistence_from_stf branch from 506001b to a96221c Compare October 25, 2023 10:49
@codecov
Copy link

codecov bot commented Oct 25, 2023

Codecov Report

Merging #1103 (5fa223c) into nightly (9995ada) will decrease coverage by 0.1%.
Report is 2 commits behind head on nightly.
The diff coverage is 92.8%.

Files Coverage Δ
...tions/integration-tests/src/chain_state/helpers.rs 89.8% <ø> (-0.9%) ⬇️
...tations/integration-tests/src/chain_state/tests.rs 97.0% <100.0%> (+<0.1%) ⬆️
module-system/sov-modules-api/src/state/mod.rs 100.0% <100.0%> (ø)
...dule-system/sov-modules-rollup-template/src/lib.rs 91.5% <100.0%> (-0.3%) ⬇️
module-system/sov-modules-stf-template/src/lib.rs 89.8% <100.0%> (+0.2%) ⬆️
module-system/sov-state/src/lib.rs 84.2% <ø> (ø)
module-system/sov-state/src/prover_storage.rs 93.7% <100.0%> (-1.4%) ⬇️
module-system/sov-state/src/storage.rs 94.3% <ø> (ø)
module-system/sov-state/src/storage_manager.rs 100.0% <100.0%> (ø)
rollup-interface/src/state_machine/stf.rs 85.7% <ø> (ø)
... and 4 more

... and 10 files with indirect coverage changes

@citizen-stig citizen-stig marked this pull request as ready for review October 25, 2023 12:01
Copy link
Member

@bkolad bkolad left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After this is merged, can you please update https://github.com/Sovereign-Labs/sov-rollup-starter as well?

@citizen-stig citizen-stig added this pull request to the merge queue Oct 26, 2023
Merged via the queue into nightly with commit 8b4eb37 Oct 26, 2023
15 checks passed
@citizen-stig citizen-stig deleted the nikolai/extract_persistence_from_stf branch October 26, 2023 11:35
@citizen-stig citizen-stig linked an issue Oct 26, 2023 that may be closed by this pull request
20 tasks
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.

Data Availability re-orgs handling tracking issue
2 participants