Code Monkey home page Code Monkey logo

crust-sworker's Introduction

Crust sWorker · Build Status GitHub license

sWorker(storage worker) is an offchain storage work inspector of Crust MPoW protocol running inside TEE enclave.

Funded by web3 foundation                                         

Prerequisites:

  • Hardware requirements: CPU must contain SGX module, and make sure the SGX function is turned on in the bios, please click this page to check if your machine supports SGX

  • Other configurations

    • Secure Boot in BIOS needs to be turned off
    • Need use ordinary account, cannot support root account
  • Ensure that you have one of the following required operating systems:

    • Ubuntu* 16.04 LTS Desktop 64bits (just for docker mode)
    • Ubuntu* 16.04 LTS Server 64bits (just for docker mode)
    • Ubuntu* 18.04 LTS Desktop 64bits
    • Ubuntu* 18.04 LTS Server 64bits
  • Install git-lfs:

    curl -s https://packagecloud.io/install/repositories/github/git-lfs/script.deb.sh | sudo bash
    sudo apt-get install git-lfs
    git lfs install
    
  • Clone project

    git clone https://github.com/crustio/crust-sworker.git
    

Build

Build from docker

Please refer to Crust sWorker docker mode

Build from source code

  • Prerequisites:

    sudo apt-get update
    sudo apt-get install -y wget expect kmod unzip libboost-all-dev libleveldb-dev build-essential linux-headers-`uname -r` libssl-dev curl libprotobuf-dev libcurl4-openssl-dev
    

    Note: This mode is just for Ubuntu* 16.04

  • Install crust sworker

    sudo ./stripts/install.sh
    

How to use

Configure

In /opt/crust/crust-sworker/etc/Config.json file you can configure your sworker application.

{
    "base_path" : "/opt/crust/crust-sworker/2.0.0/sworker_base_path",    # sWorker key information location, must be absolute path
    "base_url" : "http://127.0.0.1:12222/api/v0",                        # your sWorker node api address
    "data_path" : ["/data1"],                                            # If this item is not set, srd and sealing function cannot be applied
    
    "ipfs_url" : "http://0.0.0.0:5001/api/v0",                           # the IPFS node url
    "dcap" : {
        "base_url" : "https://dcap-attestation.crust.network",
        "report_path" : "/attestation/report"
    },
    "chain" : {                 
        "base_url" : "http://127.0.0.1:56666/api/v1",
        "address" : "cTGVGrFB8suPunnTNEYzDaRdQNPC9QeAGeJDHzs9KXWcM7Wkb",  # the address of crust api
        "account_id" : "069686d23c8e0170553dddca0c36a659c6fc39fa0d5148f1ba1cc95ec4d4c414",
        "password" : "123456",
        "backup" : "{\"encoded\":\"G6l6RC1kWmpIPMgMiUNc9psNwdC7ej0AprgcK6MfJOUAgAAAAQAAAAgAAAD+yayzRW06k1rj4mdPq1KciRiXCItbJucJWanamLURB1PfIcOuxol6zZX6jaKjFFCPAjD6eriU1ZioVaji5KW5VLNRo4V6r03kFYp68tAX7EOl1X5O/sMyu/9+2n6/qMuilIF5knw6mgJC5ajCGmEbPIMVnOXytc//dgHN0z2sVhTtnKZxHYvKCk/143UFo0tv8dFh3oTXbZKR908A\",\"encoding\":{\"content\":[\"pkcs8\",\"sr25519\"],\"type\":[\"scrypt\",\"xsalsa20-poly1305\"],\"version\":\"3\"},\"address\":\"cTGVGrFB8suPunnTNEYzDaRdQNPC9QeAGeJDHzs9KXWcM7Wkb\",\"meta\":{\"genesisHash\":\"0x8b404e7ed8789d813982b9cb4c8b664c05b3fbf433309f603af014ec9ce56a8c\",\"isHardware\":false,\"name\":\"yo\",\"tags\":[],\"whenCreated\":1626234897533}}"
    }
}

Run

/opt/crust/crust-sworker/2.0.0/bin/crust-sworker -c /opt/crust/crust-sworker/2.0.0/etc/Config.json

Crust sWorker executable file

  1. Run 'bin/crust-sworker -h, --help' to show how to use crust-sworker.
  2. Run 'bin/crust-sworker -c, --config <config_file_path>' to use customized configure file, you can get your own configure file by referring etc/Config.json.
  3. Run 'bin/crust-sworker -v, --version', program will output version information.
  4. Run 'bin/crust-sworker --offline', program will not interact with the chain.
  5. Run 'bin/crust-sworker --debug', program will output debug logs.
  6. Run 'bin/crust-sworker --ecdsa', program will use ECDSA DCAP attestation, default is EPID IAS attestation.

APIs

Crust sWorker provides plenty of getting and controlling interfaces, please refer to Crust sWorker APIs

Contribution

Thank you for considering to help out with the source code! We welcome contributions from anyone on the internet, and are grateful for even the smallest of fixes! If you'd like to contribute to crust, please fork, fix, commit and send a pull request for the maintainers to review and merge into the main codebase.

Rules

Please make sure your contribution adhere to our coding guideliness:

  • No --force pushes or modifying the master branch history in any way. If you need to rebase, ensure you do it in your own repo.
  • Pull requests need to be based on and opened against the master branch.
  • A pull-request must not be merged until CI has finished successfully.
  • Make sure your every commit is signed

Merge process

Merging pull requests once CI is successful:

  • A PR needs to be reviewed and approved by project maintainers;
  • PRs that break the external API must be tagged with breaksapi;
  • No PR should be merged until all reviews' comments are addressed.

License

GPL v3

crust-sworker's People

Contributors

lowentropybody avatar pangwa avatar tonycode2012 avatar wanglie1986 avatar wuhaixian1984 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

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

crust-sworker's Issues

Fail to install SGX SSL by using root account

Error: /opt/sgxsdk/bin/x64/sgx_sign: error while loading shared libraries: libcrypto.so.1.1: cannot open shared object file: No such file or directory. (ps: Preliminary research finds correlation with environmental variables for different user types)

Httplib' bug will cause the log to be logged after the authentication is passed.

Log like:
[Mar 26 2020 16:11:25] [INFO] -----Meaningful Validation-----
[Mar 26 2020 16:11:25] [INFO] -----Empty Validation-----
[Mar 26 2020 16:11:25] [INFO] -----Validation Waiting-----
[Mar 26 2020 16:11:25] [INFO] Empty root hash: 7b231d786cbd17124fc0619bd51cf75b4b1ef10ab708b052b55154a97c8f35ee
[Mar 26 2020 16:11:25] [INFO] Empty capacity: 4G
[Mar 26 2020 16:11:25] [INFO] Meaningful work is:
[Mar 26 2020 16:11:25] [INFO] Store enclave data successfully!
[Mar 26 2020 16:11:25] [ERROR] Send to IAS failed! Trying again...(1)
[Mar 26 2020 16:11:27] [INFO] Block height:84622 is not enough!
[Mar 26 2020 16:11:30] [INFO] Sending quote to IAS service successfully!
[Mar 26 2020 16:11:30] [INFO] Verify IAS report in enclave successfully!

Todo list in testing v1

  • Environment setup and operation logic
    • Dependent installation script (sgx, cpprest, sgx-ssl, ipfs etc.)
    • Realize '.app init' command (create base config, start ipfs)
  • Signature report and network access information
  • Deal http error
  • Readme, help documentation and command
  • Use log file
  • Call the post interface to send information to chain
    • Network access information
    • Root of empty disk and meaningful files
  • Multi-node logic test

Offline mode is needed

'Development launch' needs to cooperate with the crust chain to start all processes, this is not convenient for testing, we need offline mode.

[ForklessUp] Restart TEE should report works

Currently, If TEE restart at 340 block, it won't report 300-slot work report anymore(because it only recognize the 300n block).
However, if we need do the TEE forkless-upgrade, it should report works anyway to avoid fake offline.

Seal empty disk information into disk/chain (after test v1)

To ensure that users do not cheat, the current restart implementation mode is re-plot empty disk. This will have a huge impact on performance and program startup time.
Now consider a scheme that allows the empty disk information to be continuously and reliably stored in a certain location.

Tee work report should add randomness

Now TEE report workloads all in same pace, this will cause N validators num reports in 1 block, add randomness in N ~ N*100 to reduce this performance issue

The TEE work report is too big

Currently work report include all the file root hash. If one node stores 10000 files. Them the work report will be very big

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.