Giter Club home page Giter Club logo

scout's Introduction

Scout

Scout is a Ethereum 2.0 Phase 2 execution prototyping engine.

Warning: this is super experimental

Goals

  1. Create a (black boxed) execution prototyping engine
  2. Create some example contracts ("execution scripts")
  3. Enable "easy" onboarding for creating scripts
  4. By having actual real world use cases in scripts, we can benchmark the design and identify bottlenecks

What is this?

This engine intentionally avoids a lot of details and therefore it is not usable as a Eth 2.0 client. Instead of being a client, it should support reading and outputting shard/beacon states in a YAML format.

How to use this?

Need Rust first. Then install chisel using cargo:

cargo install chisel

There is a Makefile to make building easy:

  • build will build all components (the runner and the example scripts)
  • test will run tests using the YAML test files
  • all will do both

The runner is called scout and is available at target/release/phase2-scout after being built.

The runner expects a YAML test file:

beacon_state:
  execution_scripts:
    - scripts/helloworld/target/wasm32-unknown-unknown/release/phase2_helloworld.wasm
shard_pre_state:
  exec_env_states:
    - "0000000000000000000000000000000000000000000000000000000000000000"
shard_blocks:
  - env: 0
    data: ""
  - env: 0
    data: ""
shard_post_state:
  exec_env_states:
    - "0000000000000000000000000000000000000000000000000000000000000000"

The runner expects a filename pointing to the test file or will default to test.yaml in the local directory if nothing was specified.

How to code scripts?

An example script is located in scripts/helloworld. It uses ewasm-rust-api with the experimental eth2 feature.

extern crate ewasm_api;

use ewasm_api::*;

#[cfg(not(test))]
#[no_mangle]
pub extern "C" fn main() {
    let pre_state_root = eth2::load_pre_state_root();

    assert!(eth2::block_data_size() == 0);

    // No updates were made to the state
    let post_state_root = pre_state_root;

    eth2::save_post_state_root(post_state)
}

A better example is located in scripts/bazaar which is in essence a stateless contract. It uses SSZ serialisation. A test case is included in bazaar.yaml.

It should be possible to import any Rust crate as long as it can be compiled to the wasm32 target.

Maintainer

  • Alex Beregszaszi

License

Apache 2.0

scout's People

Contributors

axic avatar

Watchers

James Cloos avatar  avatar

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.