Allow using a different serialization format for the initial state and the Rust WASM<->JS bridge #302
Allow using a different serialization format for the initial state and the Rust WASM<->JS bridge #302noomly wants to merge 9 commits intowarp-contracts:mainfrom
Conversation
240f6b9 to
c5fbd07
Compare
c5fbd07 to
60de8c7
Compare
60de8c7 to
ddeabf4
Compare
|
I've briefly reviewed the PR and I really like the implementation. The only thing that bothers me is the c/p of the rust-wasm-imports..it will be a bit painful to maintain... |
|
Yeah I agree, there's definitely something to be done here. I'm still not sure what though; some functions implementations clash between the original json and the msgpack version... There are definitely some common parts that could be shared but honestly, it's probably still going to be a pain to maintain even if we try to merge the two rust-wasm-imports. Maybe we could think of another strategy for the way this is handled (at least for Rust contracts, I haven't taken a close look at how it's handled for Go & AS). As I understand it, the only reason the glue code is reconstructed is to expose JS functions to WASM like the various SmartWeave functions & log, right? Have you considered trying to inject these functions by doing some light parsing on the glue code and leaving everything else intact for example? |
But now that I read again the wasm-bindgen/wasm-bindgen#1128 (comment) issue (which is the exact same issue we're facing in the SDK) - maybe there's some better way (e.g. wasm-bindgen/wasm-bindgen#1128 (comment)). We're open for PRs! |
Do you consider this issue of glue code handling critical for this PR or could it be researched and addressed in separate one at a later time? |
|
ad. 2 - this should be done/refactored within a separate issue. |
|
#309, @rpiszczatowski will try to refactor this crap :-) |
|
@noomly , I believe we could merge this PR as is...the only thing missing is an integration test for the new format... |
|
hey @ppedziwiatr , I'll be back from vacation on the 9th, I'll be able to add the tests then. |
no rush :-) |
|
btw. @noomly I've released the Feel free to test it out. I'll try to return to the #288 this week. |
|
Great! I'll get to this when I'm done with this PR :) By the way, while running the typechecker I've realized that I made the What do you think? Should we make it an optional field that defaults to JSON or should we leave it as a required field? |
We can't break backwards compatibility here (also - probably 99.9% of the users will still use the json), so please set the default value to JSON. Thanks! |
|
@rpiszczatowski we need to return to this :-) |
Implements the idea discussed here #284 (comment).
It allows the usage of alternative serialization formats to JSON for the initial state and the communication between WASM & JS. It implements Messagepack as a first alternative and is currently only focused on bringing this to Rust contracts but it lays the foundations for other formats & contracts.
This PR is still a WIP but I thought I'd submit a PR so that we can discuss the implementation details.