Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(cmd-api-server): web assembly plugin modules #1281

Closed
petermetz opened this issue Aug 30, 2021 · 0 comments · Fixed by #1463
Closed

feat(cmd-api-server): web assembly plugin modules #1281

petermetz opened this issue Aug 30, 2021 · 0 comments · Fixed by #1463
Assignees
Labels
API_Server dependencies Pull requests that update a dependency file enhancement New feature or request Security Related to existing or potential security vulnerabilities Significant_Change Applying this label triggers the more stringent review of the maintainers and the 2+1 PR rule.
Milestone

Comments

@petermetz
Copy link
Member

Description

As a user of Cactus I want to be able to load plugins that are WASM modules, not just vanilla JS ones.

Acceptance Criteria

  1. A PoC of a Rust wasm-pack based plugin that can be loaded into the NodeJS process of the API server
  2. Tests verify that the above works as intended at runtime
@petermetz petermetz added enhancement New feature or request API_Server dependencies Pull requests that update a dependency file Security Related to existing or potential security vulnerabilities Significant_Change Applying this label triggers the more stringent review of the maintainers and the 2+1 PR rule. labels Aug 30, 2021
@petermetz petermetz added this to the v0.10.0 milestone Aug 30, 2021
@petermetz petermetz self-assigned this Oct 1, 2021
petermetz added a commit to petermetz/cacti that referenced this issue Oct 19, 2021
Adding a new keychain in-memory plugin that has it's implementation
written in Rust that is then compiled down to WebAssmebly via wasm-pack
and used by the wrapper Typescript code.

This is NOT meant for production because it stores everything in plain
text and also provides zero durability/persistence guarantees given that
it's only storing everything in memory.

The actual news here is that we have a plugin now written in Rust which
is the pre-cursor to us being able to do something similar with the
Weaver relay component as the next phase of a bigger PoC.

The reason why not the entire plugin is implemented in Rust is because
we are unable to hook up ExpressJS request handlers from the Rust code
as far as I could determine. See this link for further details on this:
https://rustwasm.github.io/book/reference/js-ffi.html#from-the-rust-side

Because of the above, the way it works is this:

        +--------+ API Request   +----------+
        | HTTP   |-------------->| ExpressJS|
        | Client |               +----------+
        +--------+               Method|
                                 Call  |
                                       v
        +---------+ Method Call  +----------+
        | Calling |------------->|JS Plugin |
        | Module  |              |Module    |
        +---------+              +----------+
                                   |get()
                                   |set()
                                   |has()
                                   |delete()
                +-------------+    |
                | Wasm Plugin |<---+
                | Module      |
                +-------------+
                        ^
                        |
                        |
                        v
           +------------------------+
           |Rust Native             |
           |HashMap<String, String> |
           +------------------------+

Resolves hyperledger#1281

Signed-off-by: Peter Somogyvari <peter.somogyvari@accenture.com>
petermetz added a commit that referenced this issue Oct 25, 2021
Adding a new keychain in-memory plugin that has it's implementation
written in Rust that is then compiled down to WebAssmebly via wasm-pack
and used by the wrapper Typescript code.

This is NOT meant for production because it stores everything in plain
text and also provides zero durability/persistence guarantees given that
it's only storing everything in memory.

The actual news here is that we have a plugin now written in Rust which
is the pre-cursor to us being able to do something similar with the
Weaver relay component as the next phase of a bigger PoC.

The reason why not the entire plugin is implemented in Rust is because
we are unable to hook up ExpressJS request handlers from the Rust code
as far as I could determine. See this link for further details on this:
https://rustwasm.github.io/book/reference/js-ffi.html#from-the-rust-side

Because of the above, the way it works is this:

        +--------+ API Request   +----------+
        | HTTP   |-------------->| ExpressJS|
        | Client |               +----------+
        +--------+               Method|
                                 Call  |
                                       v
        +---------+ Method Call  +----------+
        | Calling |------------->|JS Plugin |
        | Module  |              |Module    |
        +---------+              +----------+
                                   |get()
                                   |set()
                                   |has()
                                   |delete()
                +-------------+    |
                | Wasm Plugin |<---+
                | Module      |
                +-------------+
                        ^
                        |
                        |
                        v
           +------------------------+
           |Rust Native             |
           |HashMap<String, String> |
           +------------------------+

Resolves #1281

Signed-off-by: Peter Somogyvari <peter.somogyvari@accenture.com>
Leeyoungone pushed a commit to Leeyoungone/cactus that referenced this issue Oct 26, 2021
Adding a new keychain in-memory plugin that has it's implementation
written in Rust that is then compiled down to WebAssmebly via wasm-pack
and used by the wrapper Typescript code.

This is NOT meant for production because it stores everything in plain
text and also provides zero durability/persistence guarantees given that
it's only storing everything in memory.

The actual news here is that we have a plugin now written in Rust which
is the pre-cursor to us being able to do something similar with the
Weaver relay component as the next phase of a bigger PoC.

The reason why not the entire plugin is implemented in Rust is because
we are unable to hook up ExpressJS request handlers from the Rust code
as far as I could determine. See this link for further details on this:
https://rustwasm.github.io/book/reference/js-ffi.html#from-the-rust-side

Because of the above, the way it works is this:

        +--------+ API Request   +----------+
        | HTTP   |-------------->| ExpressJS|
        | Client |               +----------+
        +--------+               Method|
                                 Call  |
                                       v
        +---------+ Method Call  +----------+
        | Calling |------------->|JS Plugin |
        | Module  |              |Module    |
        +---------+              +----------+
                                   |get()
                                   |set()
                                   |has()
                                   |delete()
                +-------------+    |
                | Wasm Plugin |<---+
                | Module      |
                +-------------+
                        ^
                        |
                        |
                        v
           +------------------------+
           |Rust Native             |
           |HashMap<String, String> |
           +------------------------+

Resolves hyperledger#1281

Signed-off-by: Peter Somogyvari <peter.somogyvari@accenture.com>
RafaelAPB pushed a commit to RafaelAPB/blockchain-integration-framework that referenced this issue Mar 9, 2022
Adding a new keychain in-memory plugin that has it's implementation
written in Rust that is then compiled down to WebAssmebly via wasm-pack
and used by the wrapper Typescript code.

This is NOT meant for production because it stores everything in plain
text and also provides zero durability/persistence guarantees given that
it's only storing everything in memory.

The actual news here is that we have a plugin now written in Rust which
is the pre-cursor to us being able to do something similar with the
Weaver relay component as the next phase of a bigger PoC.

The reason why not the entire plugin is implemented in Rust is because
we are unable to hook up ExpressJS request handlers from the Rust code
as far as I could determine. See this link for further details on this:
https://rustwasm.github.io/book/reference/js-ffi.html#from-the-rust-side

Because of the above, the way it works is this:

        +--------+ API Request   +----------+
        | HTTP   |-------------->| ExpressJS|
        | Client |               +----------+
        +--------+               Method|
                                 Call  |
                                       v
        +---------+ Method Call  +----------+
        | Calling |------------->|JS Plugin |
        | Module  |              |Module    |
        +---------+              +----------+
                                   |get()
                                   |set()
                                   |has()
                                   |delete()
                +-------------+    |
                | Wasm Plugin |<---+
                | Module      |
                +-------------+
                        ^
                        |
                        |
                        v
           +------------------------+
           |Rust Native             |
           |HashMap<String, String> |
           +------------------------+

Resolves hyperledger#1281

Signed-off-by: Peter Somogyvari <peter.somogyvari@accenture.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
API_Server dependencies Pull requests that update a dependency file enhancement New feature or request Security Related to existing or potential security vulnerabilities Significant_Change Applying this label triggers the more stringent review of the maintainers and the 2+1 PR rule.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant