GithubHelp home page GithubHelp logo

kemartiti / pyth-client Goto Github PK

View Code? Open in Web Editor NEW

This project forked from pyth-network/pyth-client

0.0 0.0 0.0 660 KB

client API for on-chain pyth programs

License: Apache License 2.0

CMake 0.70% C++ 79.08% Makefile 0.01% C 12.70% Python 4.79% Shell 1.10% JavaScript 0.94% HTML 0.16% CSS 0.09% Dockerfile 0.44%

pyth-client's Introduction

pyth-client

client API for on-chain pyth programs

Build Instructions

# depends on openssl
apt install libssl-dev

# depends on libz
apt install zlib1g zlib1g-dev

# depends on libzstd
apt install libzstd-dev

# uses cmake to build
apt install cmake

# default is release build
./scripts/build.sh

You may want to build this repository inside a linux docker container for various reasons, e.g., if building on an M1 mac, or to run BPF binaries. You can run the following command to open a shell in a linux docker container with the pyth-client directory mounted:

export PYTH_REPO=/path/to/host/pyth-client
export IMAGE="docker.io/pythfoundation/pyth-client:devnet-v2.8.1"

docker run -it \
  --volume "${HOME}:/home/pyth/home" \
  --volume "${HOME}/.config:/home/pyth/.config" \
  --mount "type=bind,src=${PYTH_REPO},target=/home/pyth/pyth-client" \
  --userns=host \
  --user="$( id -ur ):$( id -gr )" \
  --platform linux/amd64 \
  $IMAGE \
  /bin/bash -l

This command runs a recent pyth-client docker image that already has the necessary dependencies installed. Therefore, once the container is running, all you have to do is run cd pyth-client && ./scripts/build.sh. Note that updates to the pyth-client directory made inside the docker container will be persisted to the host filesystem (which is probably desirable).

Fuzzing

Build a docker image for running fuzz tests:

docker build . --platform linux/amd64 -f docker/fuzz/Dockerfile -t pyth-fuzz

Each fuzz test is invoked via an argument to the fuzz command-line program, and has a corresponding set of test cases in the subdirectory with the same name as the test. You can run these tests using a command like:

docker run -t \
  --platform linux/amd64 \
  -v "$(pwd)"/findings:/home/pyth/pyth-client/findings \
  pyth-fuzz \
  sh -c "./afl/afl-fuzz -i ./pyth-client/pyth/tests/fuzz/add/testcases -o ./pyth-client/findings ./pyth-client/build/fuzz add"

This command will run the add fuzz test on the tests cases in pyth/tests/fuzz/add/testcases, saving any outputs to findings/. Note that findings/ is shared between the host machine and the docker container, so you can inspect any error cases by looking in that subdirectory on the host.

If you find an error case that you want to investigate further, you can run the program on the failing input using something like:

docker run -t \
  --platform linux/amd64 \
  -v "$(pwd)"/findings:/home/pyth/pyth-client/findings \
  pyth-fuzz \
  sh -c "./pyth-client/build/fuzz add < ./pyth-client/findings/crashes/id\:000000\,sig\:06\,src\:000000\,op\:flip1\,pos\:0"

in this example, id\:000000\,sig\:06\,src\:000000\,op\:flip1\,pos\:0 is the file containing the failing input.

pyth-client's People

Contributors

daviesalex avatar dragonfrond avatar drozdziak1 avatar evan-gray avatar jayantk avatar jbezaire avatar jhunsaker avatar mass avatar richardbrooks2000 avatar rtilder avatar sejeff avatar tina1998612 avatar tony-ricciardi 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.