Skip to content

Commit d15c7b1

Browse files
authored
Adding new monitor (Safe Liveness Expiration) (#44)
* feat: add liveness expiration base * chore: clean up metrics + lib + name * chore: remove the comment address * chore: add new address * feat: add the `livenessGuard` + `livenessModule` * feat: add the missing metrics * refactor: change some minor and rename variables. * clean: clean the CLI.go before sending it. * feat: add `README.md` * chore: fix the test. * chore: fix readme. * feat: add new readme and clean the readme of the projects * chore: readme fix * Update README.md * chore: fix typo and links * chore: fix typos
1 parent acdc61e commit d15c7b1

File tree

14 files changed

+4865
-86
lines changed

14 files changed

+4865
-86
lines changed

README.md

Lines changed: 64 additions & 83 deletions
Original file line numberDiff line numberDiff line change
@@ -1,121 +1,102 @@
11
# Monitorism
2+
23
A blockchain surveillance tool that supports monitoring for the OP Stack and EVM-compatible chains.
34

4-
⚠️ Caution: *Monitorism* is currently in its beta phase and is under active migration 🔨. This implies that *Monitorism* is presently not fully stable. ⚠️
5+
## Monitors Component
56

6-
## Development
7-
After cloning, please run `./bootstrap.sh` to set up the development environment correctly.
7+
The list of all the monitors currently built into monitorism is below.
88

9-
## Intro
10-
The cli has the ability to spin up a monitor for varying activities, each emmitting metrics used to setup alerts.
11-
```
12-
COMMANDS:
13-
multisig Monitors OptimismPortal pause status, Safe nonce, and Pre-Signed nonce stored in 1Password
14-
fault Monitors output roots posted on L1 against L2
15-
withdrawals Monitors proven withdrawals on L1 against L2
16-
balances Monitors account balances
17-
secrets Monitors secrets revealed in the CheckSecrets dripcheck
18-
```
9+
### Global Events Monitor
1910

20-
Each monitor has some common configuration, configurable both via cli or env with defaults.
21-
```
22-
OPTIONS:
23-
--log.level value [$MONITORISM_LOG_LEVEL] The lowest log level that will be output (default: INFO)
24-
--log.format value [$MONITORISM_LOG_FORMAT] Format the log output. Supported formats: 'text', 'terminal', 'logfmt', 'json', 'json-pretty', (default: text)
25-
--log.color [$MONITORISM_LOG_COLOR] Color the log output if in terminal mode (default: false)
26-
--metrics.enabled [$MONITORISM_METRICS_ENABLED] Enable the metrics server (default: false)
27-
--metrics.addr value [$MONITORISM_METRICS_ADDR] Metrics listening address (default: "0.0.0.0")
28-
--metrics.port value [$MONITORISM_METRICS_PORT] Metrics listening port (default: 7300)
29-
--loop.interval.msec value [$MONITORISM_LOOP_INTERVAL_MSEC] Loop interval of the monitor in milliseconds (default: 60000)
30-
```
11+
![df2b94999628ce8eee98fb60f45667e54be9b13db82add6aa77888f355137329](https://github.com/ethereum-optimism/monitorism/assets/23560242/b8d36a0f-8a17-4e22-be5a-3e9f3586b3ab)
12+
13+
The Global Events Monitor is made for to taking YAML rules as configuration and monitoring the events that are emitted on the chain.
3114

32-
## Monitors
15+
| `op-monitorism/global_events` | [README](https://github.com/ethereum-optimism/monitorism/blob/main/op-monitorism/global_events/README.md) |
16+
| ----------------------------- | --------------------------------------------------------------------------------------------------------- |
3317

34-
In addition the common configuration, each monitor also has their specific configuration
18+
### Liveness Expiration Monitor
3519

36-
* **Note**: The environment variable prefix for monitor-specific configuration is different than the global monitor config described above.
20+
![ab27497cea05fbd51b7b1c2ecde5bc69307ac0f27349f6bba4f3f21423116071](https://github.com/ethereum-optimism/monitorism/assets/23560242/af7a7e29-fff5-4df3-82f0-94c2f28fde84)
21+
22+
The Liveness Expiration Monitor is made for monitoring the liveness expiration on Safes.
23+
24+
| `op-monitorism/liveness_expiration` | [README](https://github.com/ethereum-optimism/monitorism/blob/main/op-monitorism/liveness_expiration/README.md) |
25+
| ----------------------------------- | --------------------------------------------------------------------------------------------------------------- |
3726

3827
### Fault Monitor
3928

40-
The fault monitor checks for changes in output roots posted to the `L2OutputOracle` contract. On change, reconstructing the output root from a trusted L2 source and looking for a match
41-
```
42-
OPTIONS:
43-
--l1.node.url value [$FAULT_MON_L1_NODE_URL] Node URL of L1 peer (default: "127.0.0.1:8545")
44-
--l2.node.url value [$FAULT_MON_L2_NODE_URL] Node URL of L2 peer (default: "127.0.0.1:9545")
45-
--start.output.index value [$FAULT_MON_START_OUTPUT_INDEX] Output index to start from. -1 to find first unfinalized index (default: -1)
46-
--optimismportal.address value [$FAULT_MON_OPTIMISM_PORTAL] Address of the OptimismPortal contract
47-
```
29+
The fault monitor checks for changes in output roots posted to the `L2OutputOracle` contract.
30+
On change, reconstructing the output root from a trusted L2 source and looking for a match.
4831

49-
On mismatch the `isCurrentlyMismatched` metrics is set to `1`.
32+
| `op-monitorism/fault` | [README](https://github.com/ethereum-optimism/monitorism/blob/main/op-monitorism/fault/README.md) |
33+
| --------------------- | ------------------------------------------------------------------------------------------------- |
5034

5135
### Withdrawals Monitor
5236

53-
The withdrawals monitor checks for new withdrawals that have been proven to the `OptimismPortal` contract. Each withdrawal is checked against the `L2ToL1MessagePasser` contract
54-
```
55-
OPTIONS:
56-
--l1.node.url value [$WITHDRAWAL_MON_L1_NODE_URL] Node URL of L1 peer (default: "127.0.0.1:8545")
57-
--l2.node.url value [$WITHDRAWAL_MON_L2_NODE_URL] Node URL of L2 peer (default: "127.0.0.1:9545")
58-
--event.block.range value [$WITHDRAWAL_MON_EVENT_BLOCK_RANGE] Max block range when scanning for events (default: 1000)
59-
--start.block.height value [$WITHDRAWAL_MON_START_BLOCK_HEIGHT] Starting height to scan for events
60-
--optimismportal.address value [$WITHDRAWAL_MON_OPTIMISM_PORTAL] Address of the OptimismPortal contract
61-
```
37+
The withdrawals monitor checks for new withdrawals that have been proven to the `OptimismPortal` contract.
38+
Each withdrawal is checked against the `L2ToL1MessagePasser` contract.
6239

63-
If a proven withdrawal is missing from L2, the `isDetectingForgeries` metrics is set to `1`.
40+
| `op-monitorism/withdrawals` | [README](https://github.com/ethereum-optimism/monitorism/blob/main/op-monitorism/withdrawals/README.md) |
41+
| --------------------------- | ------------------------------------------------------------------------------------------------------- |
6442

6543
### Balances Monitor
6644

6745
The balances monitor simply emits a metric reporting the balances for the configured accounts.
68-
```
69-
OPTIONS:
70-
--node.url value [$BALANCE_MON_NODE_URL] Node URL of a peer (default: "127.0.0.1:8545")
71-
--accounts address:nickname [ --accounts address:nickname ] [$BALANCE_MON_ACCOUNTS] One or accounts formatted via address:nickname
72-
```
46+
47+
| `op-monitorism/balances` | [README](https://github.com/ethereum-optimism/monitorism/blob/main/op-monitorism/balances/README.md) |
48+
| ------------------------ | ---------------------------------------------------------------------------------------------------- |
7349

7450
### Multisig Monitor
7551

76-
The multisig monitor reports the paused status of the `OptimismPortal` contract. If set, the latest nonce of the configued `Safe` address. And also if set, the latest presigned nonce stored in One Password. The latest presigned nonce is identifyed by looking for items in the configued vault that follow a `ready-<nonce>.json` name. The highest nonce of this item name format is reported.
52+
The multisig monitor reports the paused status of the `OptimismPortal` contract.
53+
If set, the latest nonce of the configued `Safe` address. And also if set, the latest presigned nonce stored in One Password.
54+
The latest presigned nonce is identifyed by looking for items in the configued vault that follow a `ready-<nonce>.json` name.
55+
The highest nonce of this item name format is reported.
7756

78-
* **NOTE**: In order to read from one password, the `OP_SERVICE_ACCOUNT_TOKEN` environment variable must be set granting the process permission to access the specified vault.
79-
80-
```
81-
OPTIONS:
82-
--l1.node.url value [$MULTISIG_MON_L1_NODE_URL] Node URL of L1 peer (default: "127.0.0.1:8545")
83-
--optimismportal.address value [$MULTISIG_MON_OPTIMISM_PORTAL] Address of the OptimismPortal contract
84-
--nickname value [$MULTISIG_MON_NICKNAME] Nickname of chain being monitored
85-
--safe.address value [$MULTISIG_MON_SAFE] Address of the Safe contract
86-
--op.vault value [$MULTISIG_MON_1PASS_VAULT_NAME] 1Pass Vault name storing presigned safe txs following a 'ready-<nonce>.json' item name format
87-
```
57+
| `op-monitorism/multisig` | [README](https://github.com/ethereum-optimism/monitorism/blob/main/op-monitorism/multisig/README.md) |
58+
| ------------------------ | ---------------------------------------------------------------------------------------------------- |
8859

8960
### Drippie Monitor
9061

9162
The drippie monitor tracks the execution and executability of drips within a Drippie contract.
9263

93-
```
94-
OPTIONS:
95-
--l1.node.url value Node URL of L1 peer (default: "127.0.0.1:8545") [$DRIPPIE_MON_L1_NODE_URL]
96-
--drippie.address value Address of the Drippie contract [$DRIPPIE_MON_DRIPPIE]
97-
--log.level value The lowest log level that will be output (default: INFO) [$MONITORISM_LOG_LEVEL]
98-
--log.format value Format the log output. Supported formats: 'text', 'terminal', 'logfmt', 'json', 'json-pretty', (default: text) [$MONITORISM_LOG_FORMAT]
99-
--log.color Color the log output if in terminal mode (default: false) [$MONITORISM_LOG_COLOR]
100-
--metrics.enabled Enable the metrics server (default: false) [$MONITORISM_METRICS_ENABLED]
101-
--metrics.addr value Metrics listening address (default: "0.0.0.0") [$MONITORISM_METRICS_ADDR]
102-
--metrics.port value Metrics listening port (default: 7300) [$MONITORISM_METRICS_PORT]
103-
--loop.interval.msec value Loop interval of the monitor in milliseconds (default: 60000) [$MONITORISM_LOOP_INTERVAL_MSEC]
104-
```
64+
| `op-monitorism/drippie` | [README](https://github.com/ethereum-optimism/monitorism/blob/main/op-monitorism/multisig/README.md) |
65+
| ----------------------- | ---------------------------------------------------------------------------------------------------- |
10566

10667
### Secrets Monitor
10768

10869
The secrets monitor takes a Drippie contract as a parameter and monitors for any drips within that contract that use the CheckSecrets dripcheck contract. CheckSecrets is a dripcheck that allows a drip to begin once a specific secret has been revealed (after a delay period) and cancels the drip if a second secret is revealed. It's important to monitor for these secrets being revealed as this could be a sign that the secret storage platform has been compromised and someone is attempting to exflitrate the ETH controlled by that drip.
10970

71+
| `op-monitorism/secrets` | [README](https://github.com/ethereum-optimism/monitorism/blob/main/op-monitorism/multisig/README.md) |
72+
| ----------------------- | ---------------------------------------------------------------------------------------------------- |
73+
74+
## CLI and Docs
75+
76+
## Development
77+
After cloning, please run `./bootstrap.sh` to set up the development environment correctly.
78+
79+
## Intro
80+
The cli has the ability to spin up a monitor for varying activities, each emmitting metrics used to setup alerts.
81+
82+
```
83+
COMMANDS:
84+
multisig Monitors OptimismPortal pause status, Safe nonce, and Pre-Signed nonce stored in 1Password
85+
fault Monitors output roots posted on L1 against L2
86+
withdrawals Monitors proven withdrawals on L1 against L2
87+
balances Monitors account balances
88+
secrets Monitors secrets revealed in the CheckSecrets dripcheck
89+
```
90+
91+
Each monitor has some common configuration, configurable both via cli or env with defaults.
92+
11093
```
11194
OPTIONS:
112-
--l1.node.url value Node URL of L1 peer (default: "127.0.0.1:8545") [$SECRETS_MON_L1_NODE_URL]
113-
--drippie.address value Address of the Drippie contract [$SECRETS_MON_DRIPPIE]
114-
--log.level value The lowest log level that will be output (default: INFO) [$MONITORISM_LOG_LEVEL]
115-
--log.format value Format the log output. Supported formats: 'text', 'terminal', 'logfmt', 'json', 'json-pretty', (default: text) [$MONITORISM_LOG_FORMAT]
116-
--log.color Color the log output if in terminal mode (default: false) [$MONITORISM_LOG_COLOR]
117-
--metrics.enabled Enable the metrics server (default: false) [$MONITORISM_METRICS_ENABLED]
118-
--metrics.addr value Metrics listening address (default: "0.0.0.0") [$MONITORISM_METRICS_ADDR]
119-
--metrics.port value Metrics listening port (default: 7300) [$MONITORISM_METRICS_PORT]
120-
--loop.interval.msec value Loop interval of the monitor in milliseconds (default: 60000) [$MONITORISM_LOOP_INTERVAL_MSEC]
95+
--log.level value [$MONITORISM_LOG_LEVEL] The lowest log level that will be output (default: INFO)
96+
--log.format value [$MONITORISM_LOG_FORMAT] Format the log output. Supported formats: 'text', 'terminal', 'logfmt', 'json', 'json-pretty', (default: text)
97+
--log.color [$MONITORISM_LOG_COLOR] Color the log output if in terminal mode (default: false)
98+
--metrics.enabled [$MONITORISM_METRICS_ENABLED] Enable the metrics server (default: false)
99+
--metrics.addr value [$MONITORISM_METRICS_ADDR] Metrics listening address (default: "0.0.0.0")
100+
--metrics.port value [$MONITORISM_METRICS_PORT] Metrics listening port (default: 7300)
101+
--loop.interval.msec value [$MONITORISM_LOOP_INTERVAL_MSEC] Loop interval of the monitor in milliseconds (default: 60000)
121102
```

op-monitorism/balances/README.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
### Balances Monitor
2+
3+
The balances monitor simply emits a metric reporting the balances for the configured accounts.
4+
5+
```
6+
OPTIONS:
7+
--node.url value [$BALANCE_MON_NODE_URL] Node URL of a peer (default: "127.0.0.1:8545")
8+
--accounts address:nickname [ --accounts address:nickname ] [$BALANCE_MON_ACCOUNTS] One or accounts formatted via address:nickname
9+
```

op-monitorism/cmd/monitorism/cli.go

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@ import (
99
"github.com/ethereum-optimism/monitorism/op-monitorism/drippie"
1010
"github.com/ethereum-optimism/monitorism/op-monitorism/fault"
1111
"github.com/ethereum-optimism/monitorism/op-monitorism/global_events"
12+
"github.com/ethereum-optimism/monitorism/op-monitorism/liveness_expiration"
1213
"github.com/ethereum-optimism/monitorism/op-monitorism/multisig"
1314
"github.com/ethereum-optimism/monitorism/op-monitorism/secrets"
1415
"github.com/ethereum-optimism/monitorism/op-monitorism/withdrawals"
15-
1616
"github.com/ethereum-optimism/optimism/op-service/cliapp"
1717
oplog "github.com/ethereum-optimism/optimism/op-service/log"
1818
opmetrics "github.com/ethereum-optimism/optimism/op-service/metrics"
@@ -82,7 +82,14 @@ func newCli(GitCommit string, GitDate string) *cli.App {
8282
Usage: "Monitors global events with YAML configuration",
8383
Description: "Monitors global events with YAML configuration",
8484
Flags: append(global_events.CLIFlags("GLOBAL_EVENT_MON"), defaultFlags...),
85-
Action: cliapp.LifecycleCmd(global_eventsMain),
85+
Action: cliapp.LifecycleCmd(GlobalEventMain),
86+
},
87+
{
88+
Name: "liveness_expiration",
89+
Usage: "Monitor the liveness expiration on Gnosis Safe.",
90+
Description: "Monitor the liveness expiration on Gnosis Safe.",
91+
Flags: append(liveness_expiration.CLIFlags("LIVENESS_EXPIRATION_MON"), defaultFlags...),
92+
Action: cliapp.LifecycleCmd(LivenessExpirationMain),
8693
},
8794
{
8895
Name: "version",
@@ -97,7 +104,22 @@ func newCli(GitCommit string, GitDate string) *cli.App {
97104
}
98105
}
99106

100-
func global_eventsMain(ctx *cli.Context, closeApp context.CancelCauseFunc) (cliapp.Lifecycle, error) {
107+
func LivenessExpirationMain(ctx *cli.Context, closeApp context.CancelCauseFunc) (cliapp.Lifecycle, error) {
108+
log := oplog.NewLogger(oplog.AppOut(ctx), oplog.ReadCLIConfig(ctx))
109+
cfg, err := liveness_expiration.ReadCLIFlags(ctx)
110+
if err != nil {
111+
return nil, fmt.Errorf("failed to parse LivenessExpiration config from flags: %w", err)
112+
}
113+
114+
metricsRegistry := opmetrics.NewRegistry()
115+
monitor, err := liveness_expiration.NewMonitor(ctx.Context, log, opmetrics.With(metricsRegistry), cfg)
116+
if err != nil {
117+
return nil, fmt.Errorf("failed to create LivenessExpiration monitor: %w", err)
118+
}
119+
120+
return monitorism.NewCliApp(ctx, log, metricsRegistry, monitor)
121+
}
122+
func GlobalEventMain(ctx *cli.Context, closeApp context.CancelCauseFunc) (cliapp.Lifecycle, error) {
101123
log := oplog.NewLogger(oplog.AppOut(ctx), oplog.ReadCLIConfig(ctx))
102124
cfg, err := global_events.ReadCLIFlags(ctx)
103125
if err != nil {

op-monitorism/drippie/README.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
### Drippie Monitor
2+
3+
The drippie monitor tracks the execution and executability of drips within a Drippie contract.
4+
5+
```
6+
OPTIONS:
7+
--l1.node.url value Node URL of L1 peer (default: "127.0.0.1:8545") [$DRIPPIE_MON_L1_NODE_URL]
8+
--drippie.address value Address of the Drippie contract [$DRIPPIE_MON_DRIPPIE]
9+
--log.level value The lowest log level that will be output (default: INFO) [$MONITORISM_LOG_LEVEL]
10+
--log.format value Format the log output. Supported formats: 'text', 'terminal', 'logfmt', 'json', 'json-pretty', (default: text) [$MONITORISM_LOG_FORMAT]
11+
--log.color Color the log output if in terminal mode (default: false) [$MONITORISM_LOG_COLOR]
12+
--metrics.enabled Enable the metrics server (default: false) [$MONITORISM_METRICS_ENABLED]
13+
--metrics.addr value Metrics listening address (default: "0.0.0.0") [$MONITORISM_METRICS_ADDR]
14+
--metrics.port value Metrics listening port (default: 7300) [$MONITORISM_METRICS_PORT]
15+
--loop.interval.msec value Loop interval of the monitor in milliseconds (default: 60000) [$MONITORISM_LOOP_INTERVAL_MSEC]
16+
```

op-monitorism/fault/README.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
### Fault Monitor
2+
3+
The fault monitor checks for changes in output roots posted to the `L2OutputOracle` contract. On change, reconstructing the output root from a trusted L2 source and looking for a match
4+
5+
```
6+
OPTIONS:
7+
--l1.node.url value [$FAULT_MON_L1_NODE_URL] Node URL of L1 peer (default: "127.0.0.1:8545")
8+
--l2.node.url value [$FAULT_MON_L2_NODE_URL] Node URL of L2 peer (default: "127.0.0.1:9545")
9+
--start.output.index value [$FAULT_MON_START_OUTPUT_INDEX] Output index to start from. -1 to find first unfinalized index (default: -1)
10+
--optimismportal.address value [$FAULT_MON_OPTIMISM_PORTAL] Address of the OptimismPortal contract
11+
```
12+
13+
On mismatch the `isCurrentlyMismatched` metrics is set to `1`.

0 commit comments

Comments
 (0)