This repository was archived by the owner on Aug 14, 2023. It is now read-only.
Merged
Conversation
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.
d2e35d6 to
a7d270a
Compare
a7d270a to
55028a3
Compare
Contributor
|
Reviewing this now, let's see what I can learn. |
fdd76fb to
682d2c6
Compare
neysofu
suggested changes
Jul 7, 2021
Contributor
neysofu
left a comment
There was a problem hiding this comment.
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); | ||
| /// ``` | ||
| /// |
Contributor
There was a problem hiding this comment.
I think we should keep this if possible. It'd still be relevant after updating it with the appropriate naming changes, right?
This file contains hidden or 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
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
Templateis 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, anameand atype(primitive orcomposite`) 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
Layoutof raw variables.A raw variable has an
id,offsetandbyte size. It has neithernamenor atype.Each raw variable represents a
primitive. For example, an 5-items Array defined under theSchemawill be translatedinto 5 raw variables under the
Layout.API
Similarly, SVM's core doesn't need to hold the high-level API of a
Templatein order to execute a transaction.It already has the
Exportsdefined under aWasmprogram.Of course, an
Exportfunction is very low-level but that info is a non-concern for a user usingsmapp / similarAdditionally, each deployed
Templateshould store its deployment content.Details such as the
layerof the deployment or the Account that sent the transaction.This kind of information is a must-have for
Transactions Historical Explorersbut 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
CoreandNon-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
Templateeasy to evolve in the future.The solution introduced in this PR is called the
Template Sections.Instead of looking at a
Templateas a single unit - from now on, we'll consider aTemplateas a collection of independent
Section. EachSectionwill serve as single purpose and belong to either theCoreorNon-Corecategory.The
Templateis an evolving entity. There is thepre-deploystage andpost-deploystages.Instead of having something such as
PreDeployTemplateandPostDeployTemplatein the code base - deploying aTemplatemeans adding aDeploy Sectionto a collection ofSection.If in the future we'll add a removal feature for a Template - we could come up with a new
Removal Sectionor similar.Moving into the
Sectionsdesign, we can now go further and store groups ofSectionsin different indexes very naturally.Upon fetch, we should query the required indexes and get the corresponding
Sectionsback.This PR also implements a
skip Sectionfunctionality when loading data.Each
Sectionis prefixed with aSection Preview, so when decoding the raw fetched data, we can ask to skipSectionsthat we don't want and only decode the ones we want.To summarize, we get 2 persistence optimizations:
Sectionsunder the samekeyof the underlying key-value databaseSectionswe 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 Sectionsas 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
Templatewill store each optionalSection.A Future PR might be using the
Sectionsbuilding blocks for anAppas well.@avive @lrettig This PR is the outcome of our previous Node API changes talks