Skip to content
This repository was archived by the owner on May 29, 2024. It is now read-only.

Commit d1ec230

Browse files
author
Ethen
authored
Update core logic to be less verbose & more simple in abstraction (#182)
1 parent 8c1d724 commit d1ec230

File tree

143 files changed

+4576
-5859
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

143 files changed

+4576
-5859
lines changed

README.md

+1-3
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ To use the template, run the following command(s):
6767
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
6868
```
6969

70-
**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
70+
**Note**: If you want to bootstrap the application and run specific heuristics/paths upon start, update config.env `BOOTSTRAP_PATH` value to the location of your genesis.json file then run
7171

7272
### Building and Running New Images
7373

@@ -143,7 +143,6 @@ A bootstrap config file is used to define the initial state of the pessimism ser
143143
[
144144
{
145145
"network": "layer1",
146-
"pipeline_type": "live",
147146
"type": "contract_event",
148147
"start_height": null,
149148
"alerting_params": {
@@ -157,7 +156,6 @@ A bootstrap config file is used to define the initial state of the pessimism ser
157156
},
158157
{
159158
"network": "layer1",
160-
"pipeline_type": "live",
161159
"type": "balance_enforcement",
162160
"start_height": null,
163161
"alerting_params": {

cmd/main.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ func RunPessimism(_ *cli.Context) error {
9595
return err
9696
}
9797

98-
logger.Info("Received bootstrapped session UUIDs", zap.Any(logging.SUUIDKey, ids))
98+
logger.Info("Received bootstrapped session UUIDs", zap.Any(logging.Session, ids))
9999

100100
logger.Debug("Application state successfully bootstrapped")
101101
}

config.env.template

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
L1_RPC_ENDPOINT=
33
L2_RPC_ENDPOINT=
44

5-
# Oracle Geth Block Poll Intervals (ms)
5+
# Chain
66
L1_POLL_INTERVAL=5000
77
L2_POLL_INTERVAL=5000
88

@@ -39,4 +39,4 @@ ENABLE_METRICS=1 # 0 to disable, 1 to enable
3939
METRICS_READ_HEADER_TIMEOUT=60
4040

4141
# Concurrency Management
42-
MAX_PIPELINE_COUNT=10
42+
MAX_PATH_COUNT=10

docs/Gemfile.lock

+3-3
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ GEM
8282
octokit (~> 4.0)
8383
public_suffix (>= 3.0, < 5.0)
8484
typhoeus (~> 1.3)
85-
html-pipeline (2.14.3)
85+
html-path (2.14.3)
8686
activesupport (>= 2)
8787
nokogiri (>= 1.4)
8888
http_parser.rb (0.8.0)
@@ -125,7 +125,7 @@ GEM
125125
jekyll-include-cache (0.2.1)
126126
jekyll (>= 3.7, < 5.0)
127127
jekyll-mentions (1.6.0)
128-
html-pipeline (~> 2.3)
128+
html-path (~> 2.3)
129129
jekyll (>= 3.7, < 5.0)
130130
jekyll-optional-front-matter (0.3.2)
131131
jekyll (>= 3.0, < 5.0)
@@ -194,7 +194,7 @@ GEM
194194
listen (~> 3.0)
195195
jemoji (0.12.0)
196196
gemoji (~> 3.0)
197-
html-pipeline (~> 2.2)
197+
html-path (~> 2.2)
198198
jekyll (>= 3.0, < 5.0)
199199
kramdown (2.3.2)
200200
rexml

docs/architecture/alerting.markdown

+3-4
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ end
2424

2525
subgraph AM["Alerting Manager"]
2626
alertingRelay --> |Alert|EL
27-
EL[eventLoop] --> |Alert SUUID|AS["AlertStore"]
27+
EL[eventLoop] --> |Alert UUID|AS["AlertStore"]
2828
AS --> |Alert Policy|EL
2929
EL --> |Submit alert|SR["SeverityRouter"]
3030
SR --> SH["Slack"]
@@ -48,7 +48,7 @@ An `Alert` type stores all necessary metadata for external consumption by a down
4848
The alert store is a persistent storage layer that is used to store alerting entries. As of now, the alert store only supports configurable alert destinations for each alerting entry. Ie:
4949

5050
```
51-
(SUUID) --> (AlertDestination)
51+
(UUID) --> (AlertDestination)
5252
```
5353

5454
### Alert Destinations
@@ -77,7 +77,7 @@ Done! You should now see any generated alerts being forwarded to your specified
7777

7878
#### PagerDuty
7979

80-
The PagerDuty alert destination is a configurable destination that allows alerts to be sent to a specific PagerDuty services via the use of integration keys. Pessimism also uses the SUUID associated with an alert as a deduplication key for PagerDuty. This is done to ensure that PagerDuty will not be spammed with duplicate or incidents.
80+
The PagerDuty alert destination is a configurable destination that allows alerts to be sent to a specific PagerDuty services via the use of integration keys. Pessimism also uses the UUID associated with an alert as a deduplication key for PagerDuty. This is done to ensure that PagerDuty will not be spammed with duplicate or incidents.
8181

8282
### Alert CoolDowns
8383

@@ -88,7 +88,6 @@ An example of this is shown below:
8888
```json
8989
{
9090
"network": "layer1",
91-
"pipeline_type": "live",
9291
"type": "balance_enforcement",
9392
"start_height": null,
9493
"alerting_params": {

docs/architecture/api.markdown

+3-3
Original file line numberDiff line numberDiff line change
@@ -12,17 +12,17 @@ Currently, interactive endpoint documentation is hosted via [Swagger UI](https:/
1212

1313
### Configuration
1414

15-
The API can be customly configured using environment variables stored in a `config.env` file. The following environment variables are used to configure the API:
15+
The API can be configured using environment variables stored in a `config.env` file. The following environment variables are used to configure the API:
1616

1717
- `SERVER_HOST`: The host address to serve the API on (eg. `localhost`)
1818
- `SERVER_PORT`: The port to serve the API on (eg. `8080`)
1919
- `SERVER_KEEP_ALIVE`: The keep alive second duration for the server (eg. `10`)
2020
- `SERVER_READ_TIMEOUT`: The read timeout second duration for the server (eg. `10`)
2121
- `SERVER_WRITE_TIMEOUT`: The write timeout second duration for the server (eg. `10`)
2222

23-
### Components
23+
### Processes
2424

25-
The Pessimism API is broken down into the following constituent components:
25+
The Pessimism API is broken down into the following constituent processes:
2626

2727
- `handlers`: The handlers package contains the HTTP handlers for the API. Each handler is responsible for handling a specific endpoint and is responsible for parsing the request, calling the appropriate service method, and renders a response.
2828
- `service`: The service package contains the business logic for the API. The service is responsible for handling calls to the core Pessimism subsystems and is responsible for validating incoming requests.

docs/architecture/architecture.markdown

+3-3
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ permalink: /architecture
88

99
There are *three subsystems* that drive Pessimism’s architecture:
1010

11-
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
12-
2. [Risk Engine](./engine.markdown) - Logical execution platform that runs a set of heuristics on the data funneled from the Pipeline DAG
11+
1. [ETL](./etl.markdown) - Modularized data extraction system for retrieving and processing external chain data in the form of a DAG known as the Path DAG
12+
2. [Risk Engine](./engine.markdown) - Logical execution platform that runs a set of heuristics on the data funneled from the Path DAG
1313
3. [Alerting](./alerting.markdown) - Alerting system that is used to notify users of heuristic failures
1414

1515
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.
@@ -23,7 +23,7 @@ The API will be supported to allow Pessimism users via client to:
2323
## Diagram
2424

2525
The following diagram illustrates the core interaction flow between the three primary subsystems, API, and external data sources:
26-
![high level component diagram](../assets/images/high_level_diagram.png)
26+
![high level process diagram](../assets/images/high_level_diagram.png)
2727

2828
## Shared State
2929

docs/architecture/engine.markdown

+8-23
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ graph LR;
2222
subgraph A["Engine Manager"]
2323
C(eventLoop) -.-> C;
2424
C --> |input|D("execute()")
25-
D --> |input.PUUID|E[SessionStore]
25+
D --> |input.PathID|E[SessionStore]
2626
E --> |"[]sessions"|D
2727
D --> |"[]sessions"|F[Risk Engine]
2828
F --> |"[]outcome"|D
@@ -45,28 +45,13 @@ The ETL publishes `Heuristic Input` to the Risk Engine using a relay channel. Th
4545

4646
## Heuristic Session
4747

48-
A heuristic session refers to the execution and representation of a single heuristic. A heuristic session is uniquely identified by a `SUUID` and is associated with a single `PUUID`. A heuristic session is created by the `EngineManager` when a user requests to run an active session. The `EngineManager` will create a new `HeuristicSession` and pass it to the `RiskEngine` to be executed. The `RiskEngine` will then execute the heuristic session and return an `InvalidationOutcome` to the `EngineManager`. The `EngineManager` will then create an `Alert` using the `InvalidationOutcome` and publish it to the Alerting system.
49-
50-
## Session UUID (SUUID)
51-
52-
The SUUID is a unique identifier that is used to identify a specific heuristic session. The SUUID is generated by the `EngineManager` when a user requests to run a new heuristic session. The SUUID is used to uniquely identify a specific heuristic session. This allows the `EngineManager` to perform operations on a specific heuristic session such as removing it or updating it.
53-
54-
A `SUUID` constitutes of both a unique `UUID` and a `PID`.
55-
56-
A `SessionPID` is encoded using the following 3 byte array sequence:
57-
58-
```
59-
0 1 2 3
60-
|-----------|-----------|-----------|
61-
network pipeline heuristic
62-
type type type
63-
```
48+
A heuristic session refers to the execution and representation of a single heuristic. A heuristic session is uniquely identified by a `UUID` and is associated with a single `PathID`. A heuristic session is created by the `EngineManager` when a user requests to run an active session. The `EngineManager` will create a new `HeuristicSession` and pass it to the `RiskEngine` to be executed. The `RiskEngine` will then execute the heuristic session and return an `InvalidationOutcome` to the `EngineManager`. The `EngineManager` will then create an `Alert` using the `InvalidationOutcome` and publish it to the Alerting system.
6449

6550
## Heuristic Input
6651

6752
The heuristic input is a struct that contains the following fields:
6853

69-
* `PUUID` - The ID of the heuristic that the input data is intended for
54+
* `PathID` - The ID of the heuristic that the input data is intended for
7055
* `Input` - Transit data that was generated by the ETL
7156

7257
## Heuristic
@@ -80,17 +65,17 @@ Every hardcoded heuristic must implement an `Heuristic` interface to be compatib
8065
```
8166
type Heuristic interface {
8267
Addressing() bool
83-
InputType() core.RegisterType
84-
Invalidate(core.TransitData) (*core.InvalOutcome, bool, error)
85-
SUUID() core.SUUID
86-
SetSUUID(core.SUUID)
68+
InputType() core.TopicType
69+
Invalidate(core.Event) (*core.InvalOutcome, bool, error)
70+
UUID() core.UUID
71+
SetUUID(core.UUID)
8772
}
8873
8974
```
9075

9176
### Heuristic Input Type
9277

93-
The heuristic input type is a `RegisterType` that defines the type of data that the heuristic will receive as input. The heuristic input type is defined by the `InputType()` method of the `Heuristic` interface. The heuristic input type is used by the `RiskEngine` to determine if the input data is compatible with the heuristic. If the input data is not compatible with the heuristic, the `RiskEngine` will not execute the heuristic and will return an error.
78+
The heuristic input type is a `TopicType` that defines the type of data that the heuristic will receive as input. The heuristic input type is defined by the `InputType()` method of the `Heuristic` interface. The heuristic input type is used by the `RiskEngine` to determine if the input data is compatible with the heuristic. If the input data is not compatible with the heuristic, the `RiskEngine` will not execute the heuristic and will return an error.
9479

9580
### Addressing
9681

0 commit comments

Comments
 (0)