Skip to content

Commit

Permalink
Changed invariant Abstraction to Heuristic (base-org#128)
Browse files Browse the repository at this point in the history
Co-authored-by: Adrian Smith <[email protected]>
  • Loading branch information
Ethen Pociask and adrain-cb authored Aug 1, 2023
1 parent 4fd93ad commit c2e99fd
Show file tree
Hide file tree
Showing 73 changed files with 1,288 additions and 1,230 deletions.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,4 @@ EXPOSE 8080
EXPOSE 7300

# Run app
CMD ["./pessimism"]
CMD ["./pessimism"]
13 changes: 6 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# pessimism
__Because you can't always be optimistic__

_Pessimism_ is a public good monitoring service that allows for [Op-Stack](https://stack.optimism.io/) and EVM compatible blockchains to be continuously assessed for real-time threats using custom defined user invariant rule sets. To learn about Pessimism's architecture, please advise the documentation.
_Pessimism_ is a public good monitoring service that allows for [OP Stack](https://stack.optimism.io/) and EVM compatible blockchains to be continuously assessed for real-time threats using custom defined user heuristic rule sets. To learn about Pessimism's architecture, please advise the documentation.

<!-- Badge row 1 - status -->

Expand Down Expand Up @@ -53,7 +53,7 @@ To use the template, run the following command(s):
docker run -p 8080:8080 -p 7300:7300 --env-file=config.env -it -v ${PWD}/genesis.json:/app/genesis.json ghcr.io/base-org/pessimism:latest
```

**Note**: If you want to bootstrap the application and run specific invariants/pipelines upon start, update config.env `BOOTSTRAP_PATH` value to the location of your genesis.json file then run
**Note**: If you want to bootstrap the application and run specific heuristics/pipelines upon start, update config.env `BOOTSTRAP_PATH` value to the location of your genesis.json file then run

### Building and Running New Images
- Run `make docker-build` at the root of the repository to build a new docker image.
Expand Down Expand Up @@ -96,7 +96,7 @@ A bootstrap config file is used to define the initial state of the pessimism ser
"type": "contract_event",
"start_height": null,
"alert_destination": "slack",
"invariant_params": {
"heuristic_params": {
"address": "0xfC0157aA4F5DB7177830ACddB3D5a9BB5BE9cc5e",
"args": ["Transfer(address, address, uint256)"]
}
Expand All @@ -107,7 +107,7 @@ A bootstrap config file is used to define the initial state of the pessimism ser
"type": "balance_enforcement",
"start_height": null,
"alert_destination": "slack",
"invariant_params": {
"heuristic_params": {
"address": "0xfC0157aA4F5DB7177830ACddB3D5a9BB5BE9cc5e",
"lower": 1,
"upper": 2
Expand All @@ -117,6 +117,5 @@ A bootstrap config file is used to define the initial state of the pessimism ser
```



## Spawning an invariant session
To learn about the currently supported invariants and how to spawn them, please advise the [invariants' documentation](./docs/invariants.markdown).
## Spawning a heuristic session
To learn about the currently supported heuristics and how to spawn them, please advise the [heuristics' documentation](./docs/heuristics.markdown).
11 changes: 5 additions & 6 deletions config.env.template
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# GETH compliant RPC APIs for layer 1 & 2 blockchains
L1_RPC_ENDPOINT=
L2_RPC_ENDPOINT=
L1_RPC_ENDPOINT=""
L2_RPC_ENDPOINT=""

# Oracle Geth Block Poll Intervals (ms)
L1_POLL_INTERVAL=5000
Expand All @@ -15,19 +15,18 @@ BOOTSTRAP_PATH=genesis.json

# Server configurations

SERVER_HOST=localhost
SERVER_HOST="localhost"
SERVER_PORT=8080
SERVER_KEEP_ALIVE_TIME=10
SERVER_READ_TIMEOUT=10
SERVER_WRITE_TIMEOUT=10
SERVER_SHUTDOWN_TIME=10

# Output Configs
SLACK_ENDPOINT=
SLACK_CHANNEL=
SLACK_ENDPOINT=""

# Metrics configurations
METRICS_HOST=localhost
METRICS_HOST="localhost"
METRICS_PORT=7300
ENABLE_METRICS=1 # 0 to disable, 1 to enable
METRICS_READ_HEADER_TIMEOUT=60
Expand Down
52 changes: 52 additions & 0 deletions docs/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# Pessimism Documentation

This directory contains the english specs for the Pessimism application.

## Contents
- [Architecture](architecture/architecture.markdown)
- [JSON-RPC API](swaggerdoc.html)
- [ETL Subsystem](architecture/etl.markdown)
- [Engine Subsystem](architecture/engine.markdown)
- [Alerting Subsystem](architecture/alerting.markdown)
- [Heuristics](heuristics.markdown)
- [Telemetry](telemetry.markdown)

## GitHub Pages
The Pessimism documentation is hosted on GitHub Pages. To view the documentation, please visit [https://base-org.github.io/pessimism](https://base-org.github.io/pessimism/architecture).


## Contributing
If you would like to contribute to the Pessimism documentation, please advise the guidelines stipulated in the [CONTRIBUTING.md](../CONTRIBUTING.md) file __before__ submitting a pull request.


## Running Docs Website Locally

### Prerequisites
- Ensure that you have installed the latest version of ruby on your machine following steps located [here](https://www.ruby-lang.org/en/documentation/installation/).
- Installing ruby should also install the ruby bundler which is used to install dependencies located in the [Gemfile](Gemfile)

### Local Testing
To run the documentation website locally, ensure you have followed the prerequisite steps, then do the following
1. Install dependencies via `bundle install`
2. Run `bundle exec jekyll serve`
3. You should now see a localhost version of documentation for the website!

## Creating Diagrams in GitHub Pages

It is important to note that you cannot simply write a mermaid diagram as you normally would with markdown and expect the diagram to be properly rendered via GitHub pages. To enable proper GitHub pages rendering, follow the recommended steps below:
1. Implement your diagram in markdown using the ` ```mermaid\n` key
2. Once done with implementing the diagram, ff you have not already, import the mermaid.js library via the following
```
{% raw %}
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/mermaid.min.js"></script>
{% endraw %}
```
3. Delete the ` ```mermaid ` key and replace it with
```
{% raw %}
<div class="mermaid">
--- diagram implementation here ---
</div>
{% endraw %}
4. Done! To make sure this renders correctly, you can run `bundle exec jekyll serve` to view your changes.
4 changes: 2 additions & 2 deletions docs/architecture/alerting.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ permalink: /architecture/alerting
{% endraw %}

## Overview
The alerting subsystem will receive alerts from the `EngineManager` and publish them to the appropriate alerting destinations. The alerting subsystem will also be responsible for managing the lifecycle of alerts. This includes creating, updating, and removing alerting entries for invariant sessions.
The alerting subsystem will receive alerts from the `EngineManager` and publish them to the appropriate alerting destinations. The alerting subsystem will also be responsible for managing the lifecycle of alerts. This includes creating, updating, and removing alerting entries for heuristic sessions.

## Diagram

Expand Down Expand Up @@ -53,4 +53,4 @@ The Slack alert destination is a configurable destination that allows alerts to

### Cooldown
**NOTE: This is currently unimplemented**
To ensure that alerts aren't spammed to destinations once invoked, a time based cooldown value should exist that specifies how long an invariantSession must wait before it can propagate a trigged alert again. This value should be configurable by the user via a JSON-RPC request.
To ensure that alerts aren't spammed to destinations once invoked, a time based cooldown value should exist that specifies how long an heuristicSession must wait before it can propagate a trigged alert again. This value should be configurable by the user via a JSON-RPC request.
12 changes: 6 additions & 6 deletions docs/architecture/architecture.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,16 @@ permalink: /architecture

## Overview
There are *three subsystems* that drive Pessimism’s architecture:
1. [ETL](etl.markdown) - Modularized data extraction system for retrieving and processing external chain data in the form of a DAG known as the Pipeline DAG
2. [Risk Engine](engine.markdown) - Logical execution platform that runs a set of invariants on the data funneled from the Pipeline DAG
3. [Alerting](alerting.markdown) - Alerting system that is used to notify users of invariant failures
1. [ETL](./etl.md) - Modularized data extraction system for retrieving and processing external chain data in the form of a DAG known as the Pipeline DAG
2. [Risk Engine](./engine.md) - Logical execution platform that runs a set of heuristics on the data funneled from the Pipeline DAG
3. [Alerting](./alerting.md) - Alerting system that is used to notify users of heuristic failures

These systems will be accessible by a client through the use of a JSON-RPC API that has unilateral access to all three primary subsystems.

The API will be supported to allow Pessimism users via client to:
1. Start invariant sessions
2. Update existing invariant sessions
3. Remove invariant sessions
1. Start heuristic sessions
2. Update existing heuristic sessions
3. Remove heuristic sessions

## Diagram
The following diagram illustrates the core interaction flow between the three primary subsystems, API, and external data sources:
Expand Down
Loading

0 comments on commit c2e99fd

Please sign in to comment.