Git Product home page Git Product logo

gramine-andromeda-revm's Introduction

Warning

This repository is a work in progress, and for now only functions as a showcase. This code is not intended to secure any valuable information.

Andromeda MEVM in Gramine

This is a gramine environment for running Andromeda REVM in a TEE.

The TEE service (gramine-sirrah) uses stdin and stdout for passing data in and out of the REVM, which currently supports two commands:

  • advance [height], which advances the suave chain to requested height (or to latest if no height provided)
  • execute tx_data, which executes the requested data. For data format see Andromeda REVM.

The TEE service is stateless, so make sure that you have suave-geth running. TEE will connect to http://localhost:8545 by default, which you can override by passing --rpc flag. The RPC is used for fetching chain data along with their proofs.

We also provide a simple http and tpc server for handling requests to and from the TEE service, for example usage see andromeda-sirrah-contracts.

Current measurement

mr_signer: f0365ce7081fda379914c703fe08648db1cce3747e8c10f74ff742926399f15a
mr_enclave: cd4a0af69a811a223a92379b08a84b2e3ecdd7a199bb0656ebd1cd689df8c402

Run locally

The Andromeda revm-andromeda relies on gramine features for the precompiles, specifically /dev/attestation/quote and /dev/urandom/.
Running outside of an enclave, we can still simulate this. For example /dev/urandom works anyway. The other Andromeda precompiles, volatile{Get/Set} are directly managed in-memory by suave-andromeda-revm.

cargo build
cargo run

Replicate build using Docker (no SGX Required)

To build and print the MRENCLAVE:

docker build --tag gramine-andromeda-revm .
docker run --rm gramine-andromeda-revm

Extract reproducible binaries built using docker

docker build --output=. -f=binaries.Dockerfile .

Alternatively, run make docker-binaries which does the same. Note that the binaries will be pulled from dockerhub as opposed to local image. This ensures the MRSIGNER is matching.

The above will output sgx-revm.sig, sgx-revm.manifest, sgx-revm.manifest.sgx into the main directory, and gramine-sirrah into target/release directory. Continue as if you just ran SGX=1 make all. Since we are outputing the binaries, you might encounter errors if you are not using the same OS as the docker target (ubuntu 22.04).

For now we are still checking the mr_signer, if you want to connect to one of the predeployed Andromeda contracts without configuring your mr_signer you can pull binaries from ruteri/gramine-andromeda-revm:latest.

How to replicate the execution on an SGX-enabled environment (still using Docker)

docker run -it --device /dev/sgx_enclave \
       -v /var/run/aesmd/aesm.socket:/var/run/aesmd/aesm.socket \
       gramine-andromeda-revm "gramine-sgx ./sgx-revm"

License

The code in this project is free software under the MIT license.

gramine-andromeda-revm's People

Contributors

ruteri avatar amiller avatar

Stargazers

banri avatar Shun Kakinoki avatar  avatar  avatar

Watchers

Ryan Schneider avatar  avatar Chris Hager avatar Scott Bigelow avatar  avatar Moe Mahhouk avatar  avatar Taarush Vemulapalli avatar  avatar

gramine-andromeda-revm's Issues

Automate docker reproducible build process

Currently building docker image with binaries is done manually.
Since we do not rely on the signer any more, but rather on mr_enclave, it doesn't matter who builds the binaries -- it should now be done from CI.

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.