Giter Site home page Giter Site logo

ewasm-rust-api's People

Contributors

axic avatar hugo-dc avatar jakelang avatar s1na avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

ewasm-rust-api's Issues

Turn ewasm_api into a trait

And provide two implementations:

  • native
  • scaffolded (* maybe look for a better name)

The native one wraps around the C functions, while the scaffolded can be used for testing.

Use no_std

Building binaries with funcs that return stdlib structs get really big, really fast.

Alternatively, we can either use pwasm's lib or write something similar for our purpose.
edit: and use a smaller allocator

consider adding a `main` function to `src\main.rs`

use ewasm_api::prelude::*;

fn entry() {
let a: Hash = block_hash(1);
finish_data(&a.bytes);
}

ewasm_entry_point!(entry);

error[E0601]: main function not found in crate myrust
|
= note: consider adding a main function to src\main.rs

error: aborting due to previous error

For more information about this error, try rustc --explain E0601.

Create a macro for the entry point

Maybe #5 will solve this or we could iteratively add smaller features.

The suggestion is that we add a macro, which generates the right signature (main()) as a C function on the wasm32 target and generates a stub or a warning/error on other targets.

Such as:

ewasm!({
  ewasm_api::abort()
})

eei return: Trap condition: unreachable

Getting error: Trap condition: unreachable

To compare, I imported the return function manually and tried to return the same data, while calling the manually imported function the test pass without errors, I realized the only difference between the manually imported function and the ewasm-rust-api function is that ewasm-api function specifies that the function never returns (using return type -> !).

fn ethereum_return(dataOffset: *const u32, length: u32) -> !;

Introduce higher level data types

For the types:

  • Address (160 bit)
  • EtherValue (128 bit)
  • StorageKey (256 bit)
  • StorageValue (256 bit)
  • Hash (256 bit)

It should not pull in any big dependency and there's no need to have an operators on these, only to wrap the underlying data type and expose some basic traits (as_slice, to_vec).

Documentation

Documentation can be written and automatically generated using cargo doc. It is handled in-source using triple-slash comments, for example:

/// this trait does trait stuff
Would be helpful to document this for contract devs.

Cleaning up "features"

Right now we have:

  • std/no_std
  • wee_alloc/qimalloc/stdalloc
  • one feature for each optional EEI: debug, experimental, bignum, eth2 (these would be merged into master once stable)

This is spawning this build hell as seen in #56.

Perhaps bignum could go under experimental. With time as these features mature, they wouldn't need to be conditionally enabled.

Maybe debug doesn't even need to be a feature, just made available. Idea by @jakelang to only enable the debug module when compiling in debug mode. Extending on that: how about making them macros which are compiled to nop in release mode?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.