You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Aug 14, 2023. It is now read-only.
Before implementing the Immutable Storage, we need to prepare for that.
As explained in the SVM Code Reuse between Templates adding another dimension called Section Index should simplify things (regardless of the code reuse).
Storage Host Functions
In order to introduce the Section Index we need to adjust each storage-related host function to require a section_idx parameter in addition to the current var_id one.
Instead of reading a variable by an absolute index, we'd turn the index local and add a section index.
For example get32(var_id) would turn into get32(var_id, section_idx) etc.
Later, in order to enforce an Immutable Only policy when required, the host function will just have to check that the section_index given is zero (see future issue: #472).
AccountStorage
Similarly, the interface of the AccountStorage should ask for a section_idx alongside the current var_id.
The key formula should take use the Section Index now since the var_id becomes a local value with its Storage Section.
SVM SDK
For the scope of this issue, as a stopgap to make the tests pass, I'd recommend to hardcode the value 1 as the section index used in the generated code.
Before implementing the
Immutable Storage,
we need to prepare for that.As explained in the SVM Code Reuse between Templates adding another dimension called
Section Index
should simplify things (regardless of the code reuse).Storage Host Functions
In order to introduce the
Section Index
we need to adjust each storage-related host function to require asection_idx
parameter in addition to the currentvar_id
one.Instead of reading a variable by an absolute index, we'd turn the index local and add a section index.
For example
get32(var_id)
would turn intoget32(var_id, section_idx)
etc.Later, in order to enforce an
Immutable Only
policy when required, the host function will just have to check that thesection_index
given is zero (see future issue: #472).AccountStorage
Similarly, the interface of the
AccountStorage
should ask for asection_idx
alongside the currentvar_id
.The key formula should take use the
Section Index
now since thevar_id
becomes a local value with itsStorage Section
.SVM SDK
For the scope of this issue, as a stopgap to make the tests pass, I'd recommend to hardcode the value
1
as thesection index
used in the generated code.The
svm-sdk-macros
crate should change under this file:https://github.com/spacemeshos/svm/blob/master/crates/sdk-macros/src/struct/storage.rs
For example:
This line
svm/crates/sdk-macros/src/struct/storage.rs
Line 165 in 6edb73d
will be changed to:
The
sdk-storage
will change theStorage
trait to requiresection_idx
as well:svm/crates/sdk-storage/src/lib.rs
Line 17 in 6edb73d
(and consequently, the
sdk-storage-mock
andsdk-storage-ffi
crates will have to be updated)For the long-term SDK changes - see issue: #473
The resulting code should probably look similar to this:
The text was updated successfully, but these errors were encountered: