Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Md book #633

Merged
merged 6 commits into from
Oct 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
132 changes: 132 additions & 0 deletions .github/workflows/book.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
name: book

concurrency:
cancel-in-progress: true
group: ${{github.workflow}}-${{github.ref}}

on:
push:
branches: [main]
pull_request:
branches: [main]
merge_group:

jobs:
test:
runs-on: ubuntu-latest
name: test

steps:
- uses: actions/checkout@v3

- name: Install mdbook
run: |
mkdir mdbook
curl -sSL https://github.com/rust-lang/mdBook/releases/download/v0.4.14/mdbook-v0.4.14-x86_64-unknown-linux-gnu.tar.gz | tar -xz --directory=./mdbook
echo `pwd`/mdbook >> $GITHUB_PATH

- name: Install mdbook-template
run: |
mkdir mdbook-template
curl -sSL https://github.com/sgoudham/mdbook-template/releases/latest/download/mdbook-template-x86_64-unknown-linux-gnu.tar.gz | tar -xz --directory=./mdbook-template
echo `pwd`/mdbook-template >> $GITHUB_PATH

- name: Run tests
run: mdbook test

lint:
runs-on: ubuntu-latest
name: lint

steps:
- uses: actions/checkout@v3

- name: Install mdbook-linkcheck
run: |
mkdir mdbook-linkcheck
curl -sSL -o mdbook-linkcheck.zip https://github.com/Michael-F-Bryan/mdbook-linkcheck/releases/latest/download/mdbook-linkcheck.x86_64-unknown-linux-gnu.zip
unzip mdbook-linkcheck.zip -d ./mdbook-linkcheck
chmod +x `pwd`/mdbook-linkcheck/mdbook-linkcheck
echo `pwd`/mdbook-linkcheck >> $GITHUB_PATH

- name: Run linkcheck
run: mdbook-linkcheck --standalone

build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Install toolchain
uses: dtolnay/rust-toolchain@nightly
- uses: Swatinem/rust-cache@v2
with:
cache-on-failure: true

- name: Install mdbook
run: |
mkdir mdbook
curl -sSL https://github.com/rust-lang/mdBook/releases/download/v0.4.14/mdbook-v0.4.14-x86_64-unknown-linux-gnu.tar.gz | tar -xz --directory=./mdbook
echo `pwd`/mdbook >> $GITHUB_PATH

- name: Install mdbook-template
run: |
mkdir mdbook-template
curl -sSL https://github.com/sgoudham/mdbook-template/releases/latest/download/mdbook-template-x86_64-unknown-linux-gnu.tar.gz | tar -xz --directory=./mdbook-template
echo `pwd`/mdbook-template >> $GITHUB_PATH

- name: Build book
run: mdbook build documentation

- name: Build docs
run: RUSTDOCFLAGS="--enable-index-page -Zunstable-options" cargo +nightly doc --all --no-deps

- name: Move docs to book folder
run: |
mkdir -p target/book/docs
mv target/doc documentation/book/docs

- name: Archive artifact
shell: sh
run: |
chmod -c -R +rX "documentation/book" |
while read line; do
echo "::warning title=Invalid file permissions automatically fixed::$line"
done
tar \
--dereference --hard-dereference \
--directory "documentation/book" \
-cvf "$RUNNER_TEMP/artifact.tar" \
--exclude=.git \
--exclude=.github \
.

- name: Upload artifact
uses: actions/upload-artifact@v3
with:
name: github-pages
path: ${{ runner.temp }}/artifact.tar
retention-days: 1
if-no-files-found: error

deploy:
# Only deploy if a push to main
if: github.ref_name == 'main' && github.event_name == 'push'
runs-on: ubuntu-latest
needs: [test, lint, build]

# Grant GITHUB_TOKEN the permissions required to make a Pages deployment
permissions:
pages: write
id-token: write

environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}

steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v2
2 changes: 1 addition & 1 deletion book.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
authors = ["Sabnock01"]
language = "en"
multilingual = false
src = "docs/src"
src = "documentation/src"
title = "Arbiter"
1 change: 0 additions & 1 deletion docs/src/getting_started/agents.md

This file was deleted.

1 change: 0 additions & 1 deletion docs/src/getting_started/getting_started.md

This file was deleted.

1 change: 0 additions & 1 deletion docs/src/introduction/introduction.md

This file was deleted.

7 changes: 3 additions & 4 deletions docs/src/SUMMARY.md → documentation/src/SUMMARY.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
# Summary

- [Introduction](./introduction/introduction.md)
- [Anomaly Detection](./introduction/anomaly_detection.md)
<!-- - [Anomaly Detection](./introduction/anomaly_detection.md) -->
- [Getting Started / Installation](./getting_started/getting_started.md)
- [CLI Installation with Cargo](./getting_started/cargo_install.md)
- [Setting up Simulations](./getting_started/simulation.md)
- [Setting up Simulations](./getting_started/setting_up_simulations.md)
- [Configuring Agents](./getting_started/agents.md)
- [Examples](./getting_started/examples.md)
<!-- - [Examples](./getting_started/examples.md) -->
- [Auditing](./auditing/auditing.md)
- [Identifying your random variable](./auditing/random_variable.md)
- [Quantifying Economic Risk / Economic Audits](./economic_risk/economic_risk.md)
Expand Down
File renamed without changes.
3 changes: 3 additions & 0 deletions documentation/src/getting_started/agents.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Configuring agents

Once your contract state is initialized you can think about iterating over your stochastic process and designing your agents to react to certain changes in the systems and contracts. For example an arbitraguer will want to react to price changes in the system.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# CLI Installation with Cargo
# Getting Started

## Prerequisites

Expand All @@ -15,7 +15,7 @@ Once Rust is installed, you can install Arbiter from the package registry using
cargo install arbiter
```

You can now run `arbiter --help` to verify your installation and view the help menu.
You can now run `arbiter --version` to verify your installation.

### Building From Source
Install Git, if you haven't already. There are many online guides on how to install Git on different devices, including one from [Github](https://github.com/git-guides/install-git).
Expand Down Expand Up @@ -43,6 +43,13 @@ This initializes a new Arbiter project with a template. You can generate the bin
```bash
arbiter bind
```
Arbiter bind wraps `forge bind` and is configured from your cargo.toml. There are three optional fields you can add to your toml to configure arbiter bind.
```toml
[arbiter]
bindings_workspace = "simulation" # must be a valid workspace member
submodules = false # change to true if you want the submodule bindings to be generated
ignore_interfaces = false # change to true if you want to ignore interfaces contracts
```

The template is executable at this point and you can run it by running:

Expand Down
13 changes: 13 additions & 0 deletions documentation/src/getting_started/setting_up_simulations.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Setting up Simulations

At a high level it could be a good idea map out your simulation before you start writing it. Understand some key objectives of your simulation for example maybe you want to look for anomaly behavior and attempt to identify any critical failure points in the system. In this case you want to understand what a failure point is and how you can identify it. Another key thing to think about is what random process do you want to simulate over. Maybe you want to simulate over a random process that represents the price of a token with Geometric Brownian Motion or something more complex like a jump diffusion process, arbiter reexports rust quant and a binding for a liquid exchange that supports this. The last thing to consider is who are the agents in your simulation. Are they arbitrage bots, are they liquidity providers, are they random agents, or are they a combination of all of these. Identify key externally owned accounts and thing about what actions they can take in your simulation.

When deisigning a simulation the first thing you need to think about is what contracts are in your simulation systems. You can start with just a one like in the template repository and add them as you continue your development. Almost all simulation design will start like this.

## Set up Steps
- Identify key contracts
- Generate bindings for those contracts
- Deploy these contracts to the local in memory instance of revm (you can also skip this step in favor of using the forking feature)

After you have a system deployed in your in memory revm instance you are going to want to make sure your system state is correct. This could mean making sure you contracts hold enough balance of some specific tokens. Maybe you want to mint some tokens to a specific address, or you need to do token aprovals for your contracts.

10 changes: 10 additions & 0 deletions documentation/src/introduction/introduction.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Introduction

Arbiter is a free an open source EVM analysis tool for complex smart contract systems. At it's core it is an in memory EVM sanbox with a set of analysis tools built on top of it. It is designed to be modular, extensible and performant. Arbiter is capable of delivering an array of stachastic analysis toold with evm execution parity.

## Motivation
Smart contract engineers need to test their contracts against a wide array of potentially adversarial environments and contract parameters. The static stateless testing of contracts can only take you so far. To truly test the security of a contract, you need to test it against a wide array of dynamic environments that encompass the externalities of Ethereum mainnet. We wanted to do just that with Arbiter.

Both smart contract and financial engineers come together in Decentralized Finance (DeFi) to build and deploy a wide array of complex decentralized applications as well as fincancial strategies respectively. For the latter, a financial engineer may want to test their strategies against thousands of market conditions, contract settings, shocks, and autonomous or random or even AI agents all while making sure their strategy isn't vulnerable to bytecode-level exploits.

To configure such a rich simulation environment on a test or local network is also possible with Arbiter by a change in choice of middleware. The most efficient choice for getting robust, yet quick, simulations would bypass any networking and use a low level language's implementation of the EVM. Furthermore, we can gain control over the EVM worldstate by working directly on revm. We would like the user to have a choice in how they want to simulate their contracts and Arbiter provides that choice.
Loading