This repository has been archived by the owner on Aug 14, 2023. It is now read-only.
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Implemented the `svm_allocate` host function. adding some debugging printing to the new `svm_allocate` host function. WIP: computing the `returns` byte-size for a function (sdk-macros) * `calldata` is allocated on instance only when non-empty. The `svm-sdk` relies on the host function for Wasm targeted code and on the default global allocator otherwise. adding `svm_sdk_std::panic` (aborts for Wasm and unwinds otherwise) WIP: adding an explicit feature flag for the host static allocation. svm-codec is using the default global-alloactor (not the "static allocation") codec - js tests pass (commenting the `verify_data` for now) tests pass CI - running only on Windows + running the tests 10 times (there seems to be a sporadic failures) CI - skipping the build stage svm-sdk-std: exposing Rust `Vec` svm-sdk-std: using `panic!` running only the `svm-runtime` crate tests. Removing `wabt` (using only `wat`) - it takes much less time to build. using cache action v2 Adding GitHub Action for LLVM Adding caching to the llvm LLVM 10 Returning back the original LLVM action for Windows adding feature-flags `default-cranelift` and `default-llvm` trying to run CI against `llvm` running tests with a single thread runtime - removing two ignored tests related to gas-metering Commenting a test runtime: ignoring all tests except one running tests in dev-mode Building on Linux and macOS svm-sdk-std: returning back Rust `Vec` Commenting part of the problematic test Commenting another part of the problematic test uncomment part of the problematic test cbindgen version bump problemtic test - wasm input file "runtime_calldata.wasm" isn't using the "static-alloc" problemtic test: input wasm is being compiled with less code and no `.cargo/config` file Uncommenting all the problematic test Trying to locate the bug Trying again to pinpoint the bug Adding asserts against setting explicitly empty `returndata` WIP: debugging WIP: debugging... WIP: debugging... skipping the last CI stages for now... WIP: trying to locate the cause of the bug... WIP commenting the "static-alloc" related code from `svm-sdk-alloc` WIP Trying again to make the test fail Trying to figure out whether the #[endpoint] return-type has anything to do with the bug... Commenting "Storage" from the wasm input of the failing test... More debugging the root cause of the problem debugging... adding "Cache workspace" step Splitting cargo caching into isloated steps. adding "Dump GitHub context" step. CI: changing to `crates/runtime` before running the tests Try again to run CI... Try again CI: disabling LLVM installation for now (Windows) Trying again to reproduce a broken CI on Windows... Checking whether the bug has something to do with `svm_sdk::Address` Trying to find a minimal failing input using `Amount` WIP: Debugging... WIP: removing the parameter from the problematic endpoint This should pass (not using `endpoint`) This should fail again... `ExtHost#get_calldata` - returning a static data Re-compile the wasm input Empty `endpoint` prologue. debugging debugging... Trying to narrow the bug WIP Narrowing the epilogue part should fail... Uncommenting part of the epilogue WIP
… the endpoint's macro.
YaronWittenstein
force-pushed
the
template-sections
branch
2 times, most recently
from
July 4, 2021 14:36
d2e35d6
to
a7d270a
Compare
YaronWittenstein
force-pushed
the
template-sections
branch
from
July 5, 2021 05:41
a7d270a
to
55028a3
Compare
Reviewing this now, let's see what I can learn. |
YaronWittenstein
force-pushed
the
template-sections
branch
from
July 6, 2021 07:40
fdd76fb
to
682d2c6
Compare
neysofu
suggested changes
Jul 7, 2021
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome to see these many comments. I haven't looked at everything as it deals with a lot of stuff that I'm not familiar with, but it seems good to me
Comment on lines
16
to
50
/// | ||
/// # Example | ||
/// | ||
/// ```rust | ||
/// use std::io::Cursor; | ||
/// | ||
/// use svm_types::Template; | ||
/// use svm_codec::api::builder::DeployTemplateBuilder; | ||
/// use svm_codec::template; | ||
/// | ||
/// let layout = vec![5, 10].into(); | ||
/// let ctors = vec!["init".to_string()]; | ||
/// | ||
/// let bytes = DeployTemplateBuilder::new() | ||
/// .with_version(0) | ||
/// .with_name("My Template") | ||
/// .with_code(&[0xC, 0x0, 0xD, 0xE]) | ||
/// .with_layout(&layout) | ||
/// .with_ctors(&ctors) | ||
/// .build(); | ||
/// | ||
/// let mut cursor = Cursor::new(&bytes[..]); | ||
/// let actual = template::decode_deploy_template(&mut cursor).unwrap(); | ||
/// | ||
/// let expected = Template { | ||
/// version: 0, | ||
/// name: "My Template".to_string(), | ||
/// code: vec![0xC, 0x0, 0xD, 0xE], | ||
/// layout, | ||
/// ctors: vec!["init".to_string()] | ||
/// }; | ||
/// | ||
/// assert_eq!(expected, actual); | ||
/// ``` | ||
/// |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should keep this if possible. It'd still be relevant after updating it with the appropriate naming changes, right?
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Motivation
This PR rewrites the way a
Template
is represented and being used.The main trigger for that change was the decision to store pieces of data that could have been otherwise stored off-chain.
Here are 2 examples:
Schema
Contains the high-level definitions of the persistent storage of a
Template
.Each variable has an
id
, aname
and atype
(primitive or
composite`) associated with it.The Schema isn't required for the execution of a transaction.
From SVM's Runtime perspective - it only cares about the raw data.
This data contains the raw
Layout
of raw variables.A raw variable has an
id
,offset
andbyte size
. It has neithername
nor atype
.Each raw variable represents a
primitive
. For example, an 5-items Array defined under theSchema
will be translatedinto 5 raw variables under the
Layout
.API
Similarly, SVM's core doesn't need to hold the high-level API of a
Template
in order to execute a transaction.It already has the
Exports
defined under aWasm
program.Of course, an
Export
function is very low-level but that info is a non-concern for a user usingsmapp / similar
Additionally, each deployed
Template
should store its deployment content.Details such as the
layer
of the deployment or the Account that sent the transaction.This kind of information is a must-have for
Transactions Historical Explorers
but in theory part of this can be also used for core processes inside SVM (in future versions upon arithmetical changes).Sections
Generally, SVM needs to retrieves different pieces of data in different contexts.
We can roughly categorize the content as
Core
andNon-Core
.It's pivotal to be able to fetch only the required data as fast as we can.
Secondly, it's crucial to make the format of a
Template
easy to evolve in the future.The solution introduced in this PR is called the
Template Sections
.Instead of looking at a
Template
as a single unit - from now on, we'll consider aTemplate
as a collection of independent
Section
. EachSection
will serve as single purpose and belong to either theCore
orNon-Core
category.The
Template
is an evolving entity. There is thepre-deploy
stage andpost-deploy
stages.Instead of having something such as
PreDeployTemplate
andPostDeployTemplate
in the code base - deploying aTemplate
means adding aDeploy Section
to a collection ofSection
.If in the future we'll add a removal feature for a Template - we could come up with a new
Removal Section
or similar.Moving into the
Sections
design, we can now go further and store groups ofSections
in different indexes very naturally.Upon fetch, we should query the required indexes and get the corresponding
Sections
back.This PR also implements a
skip Section
functionality when loading data.Each
Section
is prefixed with aSection Preview
, so when decoding the raw fetched data, we can ask to skipSections
that we don't want and only decode the ones we want.To summarize, we get 2 persistence optimizations:
Sections
under the samekey
of the underlying key-value databaseSections
we can ask to decode only what the ones we're interested in and skip the rest.Last notes:
SVM will probably consider the
Non-Core Sections
as optional when retrieving them.It means that the client asking for them will have to support a fallback for obtaining that data (from some off-chain service).
However, for Genesis it's seems fair that each
Template
will store each optionalSection
.A Future PR might be using the
Sections
building blocks for anApp
as well.@avive @lrettig This PR is the outcome of our previous Node API changes talks