Skip to content
This repository has been archived by the owner on Aug 14, 2023. It is now read-only.

Extend the SDK + CLI to support Immutable Storage #473

Open
YaronWittenstein opened this issue Dec 21, 2021 · 0 comments
Open

Extend the SDK + CLI to support Immutable Storage #473

YaronWittenstein opened this issue Dec 21, 2021 · 0 comments
Assignees
Labels
AA Related to the Accounts Abstraction codec Related to the Codec sdk Related to the SVM SDK simple-coin-iteration-3 svm svm-core SVM core change

Comments

@YaronWittenstein
Copy link
Contributor

YaronWittenstein commented Dec 21, 2021

Here is an example of how it could look like:

use svm_sdk_mock::template;

#[template]
mod Template {
  #[storage]
  struct Storage {
    #[immutable]
    pub_keys: [svm_sdk::Blob32; 3],
    started: bool,
    #[immutable]
    master_key: svm_sdk::Blob64,
    word: [u16; 3],
  }
}

The Var under svm-sdk-macros crate should have is_mutable: bool field added:
https://github.com/spacemeshos/svm/blob/master/crates/sdk-macros/src/struct/var.rs

This piecse of code should determine for each var whether it's mutable or not:

pub fn storage_vars(strukt: &Struct) -> Result<Vec<Var>> {

pub fn storage_vars(strukt: &Struct) -> Result<Vec<Var>> {

The generated code should gather variables pub_keys and master_key to sit together under the Immutable Storage Section (which is enforced to be at index #0 - see) and variables to be under Storage Section #1.

The emitted Storage Schema should reflect that and then the CLI should be updated as well:
https://github.com/spacemeshos/svm/blob/22fb1cf627d5c82d20c285744dd9ee708e9c7c08/crates/cli/src/subcmd_craft_deploy/meta.rs

The Data Section should always include the Immutable Storage under Section #0 and the Mutable Storage under Section #1 (both will be of type Fixed-Layout)

@YaronWittenstein YaronWittenstein added AA Related to the Accounts Abstraction sdk Related to the SVM SDK simple-coin-iteration-3 svm svm-core SVM core change codec Related to the Codec labels Dec 21, 2021
@YaronWittenstein YaronWittenstein changed the title Extend the SVM SDK + SVM CLI to support Immutable Storage Extend theSDK + SVM CLI to support Immutable Storage Dec 21, 2021
@YaronWittenstein YaronWittenstein changed the title Extend theSDK + SVM CLI to support Immutable Storage Extend the SDK + CLI to support Immutable Storage Dec 21, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
AA Related to the Accounts Abstraction codec Related to the Codec sdk Related to the SVM SDK simple-coin-iteration-3 svm svm-core SVM core change
Projects
None yet
Development

No branches or pull requests

2 participants