SewUp

Rust Engineer

Antonio

yanganto@github

2021/06/19 Rust meetup @Beijin

What is SewUp

  • Rust
  • Open source at Github
  • Contract Dev as Backend

Is contract good enough

forĀ  Web 3?

Where is the gap

  • Security
  • Too low level
  • Too many domain knowledge

How to Sew Up

  • Security
  • Too low level
  • Too many domain knowledge

Rust

Contract Dev as Backend

Rust in Contract

  • ewasm-rust-api
  • Version 0.11.0 (2019 Nov 27)

eWasm

Executor

.rs

Pain point eWasm with Rust

eWasm

Executor

.rs

  • Not really Rusty API
    • Result

    • Option

  • Operating in low-level
    • operate on Bytes32

    • Manually handle functional signature
  • Not easy to test with cargo test

This is C

pub enum CallResult {
    Successful,
    Failure,
    Revert,
    Unknown,
}

This is Rust

pub enum CallError {
    Failure,
    Revert,
    Unknown,
}

fn call() -> CallResult;

fn call() -> Result<(), CallError>;

Please read things behind the wordings!

The goal of Sewup

eWasm

WasmEdge

.rs

ewasm-rust-api

sewup

  • Rusty API
    • Result

    • Option

    • Error

  • high level operation
    • like handle KV db

    • functional signature macro
    • no more byte operation
  • Easy to test with cargo test

Error

  • Customize error
  • Good error message
  • Easy to use

match your funtion

Rust style result

Rust Style

structure

bytes

Easy for

Developing

string

store without touching Bytes32

Keep working

  • Function Inputs (v0.0.2)
  • Function outputs (v0.0.2)
  • Update mutated Bytes32(Raw) only

Inputs

  • from contract caller
    • runtime inputs
  • from contract developer
    • compile time inputs
  • tools for generate input data

Outputs

  • Rusty
    • return a Result
  • Non-Rusty
    • return T for Result<T>
  • Return
    • from main
    • from handler

Last but not least

Blockchain bring TRUST to the world

Rust is the stem of TRUST

Thanks for listening

Star the project if you like it

There are also help want issues and good first issues

Interested in VM?

WasmEdge is welcom to contribute

WeChat

SewUp

By Antonio Yang

SewUp

Secondstate EWasm Utility Program, a library to help you sew up your Ethereum project with Rust and just like develop in a common backend.

  • 1,070