-
Notifications
You must be signed in to change notification settings - Fork 14
Conversation
* allocating a static Buffer on the heap * adding documentation
Adding `Commit` method to `svm_kv::traits::KVStore` is required in order to proceed.
* native rust (a.k.a `Builder`) * json * wasm
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.
Looks good. Had some minor comments.
}}; | ||
} | ||
|
||
/// Decodes a encoded function buffer back into a `sdk_values::Value` |
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.
a -> an
let mut values = Vec::new(); | ||
|
||
while next_byte != marker::ARRAY_END { | ||
let v = self.decode_value(cursor)?; |
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.
Looks like this supports infinite nesting of arrays. Is this intentional?
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've added a marker-trait to prohibit encoding of nested arrays
crates/svm-abi/encoder/src/lib.rs
Outdated
@@ -0,0 +1,96 @@ | |||
#![no_std] | |||
|
|||
//! This crate is responsible of encoding SVM types (its actuall type and their values to be precise), |
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.
actuall => actual
crates/svm-abi/encoder/src/lib.rs
Outdated
value::{Address, AddressOwned, PubKey256, PubKey256Owned}, | ||
}; | ||
|
||
/// A traits to be implemented by of types. |
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.
Something is wrong with this sentence.
Motivation
The purpose of this PR is to implement a well-defined ABI encoding & decoding specification for the blob data passed to the
func_buffer
. (calledctor_buf
in the context ofspawn app
- but it's the same mechanism).Since WASM MVP comes out-of-the-box only 2 types relevant for us (SVM don't work for
floats
for determinism concerns).We need to come up with an encoding method so that we can feed a function with composite data such as:
Tuple
Address
PublicKey
This
svm-codec
should extend its exposed WASM API and it'll do so by importing this crate.So when
smapp
(or any other future Wallet client) will want to dispatch a new SVM transaction ofspawn-app
(orexec-app
) to the network, it will do so in two steps:func_buf
andfunc_args
- using thesvm-abi
crate (implemented in this PR).func_buf
andfunc_args
with the results of step 1.In the future, we may add new ABI encoding schemes. But hopefully, we can get away with this one.
Also, this ABI encoding scheme should be leveraged by the future so-called SMESH language.
Important:
There will be high-level API exposed as JSON for each App. This data will contain variables names and types for each function. That's how
smapp
(or similar) will know that a function input expects in a high-level without caring about the low-level implementation details.Also, this data will be off-chain. This functionality is out of scope for this PR.