Skip to content

Latest commit

 

History

History
195 lines (145 loc) · 9.05 KB

README.md

File metadata and controls

195 lines (145 loc) · 9.05 KB

Sentinel

Indexing, monitoring and alerting solution for MetaMorpho vaults time-locked operations.

Table of Contents

Introduction

If you're a user of the MetaMorpho vaults, Sentinel is interesting for you.

As stated in the official MetaMorpho's README:

All actions that may be against users' interests (e.g. enabling a market with a high exposure) are subject to a timelock of minimum 24 hours. The owner, or the guardian if set, can revoke the action during the timelock. After the timelock, the action can be executed by anyone.

This is the reason we decided to build Sentinel: a tool that will monitor the vaults, look for any timelocked actions and notify the users via Discord, Telegram, Slack and more.

Features

Sentinel is currently able to monitor the vaults and send notifications.

But for now, indexing is not ready and notifications are limited to Discord. We are actively working on both features, with more notifications integrations as our first priority.

See more in the Contributing section.

Configuration

Many aspects of Sentinel are managed by a configuration file that will be loaded during its startup.

An example configuration file can be found in ./etc/config.example.yaml. It contains the default values for each parameter and their corresponding explanation.

Notification Connectors

Each notification connector requires a specific configuration. For example, Discord requires the following fields in the configuration file:

notifier:
  discord-notification-connector:
    webhook-url: "https://your-webhook-url"

Architecture

Coming soon.

Getting Started

This section is dedicated to help you run Sentinel both locally for testing purposes and in a more "production-ready" setup.

Prerequisites

  • Docker
  • Forge
  • Go

Locally - From Source

You can run Sentinel locally by first forking the network where the MetaMorpho Vault is deployed, and then run it.

First, you need to fork the network using anvil:

# Feel free to use another block-number, we choose this one for the sake of this example.
anvil -f $RPC_URL --auto-impersonate --fork-block-number 21429070

Then, you can start Sentinel.:

go run main.go -c etc/config.example.yaml

Note that you can tweak the configuration to fit your needs, for example if you want to add the Discord notifier, add the following:

# etc/config.discord.yaml
notifier:
  discord-notification-connector:
    webhook-url: "https://your-webhook-url"

Finally, you need to impersonate the administrator of the vault to perform an action that is timelocked:

# Sends ETH to the account to impersonate
cast send 0x2566f66f68ed438726AD904524FB306A03FdB80B --value 1ether --private-key 0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80

# Perform the action - Here decreasing the timelock from 96h to 95h59m59s
cast send 0x38989BBA00BDF8181F4082995b3DEAe96163aC5D --from 0x2566f66f68ed438726AD904524FB306A03FdB80B "submitTimelock(uint256)" 345599 --unlocked

And you should see a log similar to the following appear in your terminal:

INFO[2024-12-19T19:51:54+01:00]
INFO[2024-12-19T19:51:54+01:00]      _____            __  _            __
INFO[2024-12-19T19:51:54+01:00]     / ___/___  ____  / /_(_)___  ___  / /
INFO[2024-12-19T19:51:54+01:00]     \__ \/ _ \/ __ \/ __/ / __ \/ _ \/ /
INFO[2024-12-19T19:51:54+01:00]    ___/ /  __/ / / / /_/ / / / /  __/ /
INFO[2024-12-19T19:51:54+01:00]   /____/\___/_/ /_/\__/_/_/ /_/\___/_/
INFO[2024-12-19T19:51:54+01:00]
INFO[2024-12-19T19:51:54+01:00]
INFO[2024-12-19T19:51:54+01:00] All services initialized, starting sentinel..
INFO[2024-12-19T19:51:54+01:00] Fetched new block from EL Client              block_number=21429072
INFO[2024-12-19T19:51:54+01:00] Capturing events logs emitted by contracts at block  block_number=21429072 contract_addresses="[0xA9c3D3a366466Fa809d1Ae982Fb2c46E5fC41101 0x38989BBA00BDF8181F4082995b3DEAe96163aC5D]"
INFO[2024-12-19T19:51:54+01:00] Captured events logs emitted at block         block_number=21429072 captured_events_logs=1
INFO[2024-12-19T19:51:54+01:00] Decoding captured event log emitted by contract  event_contract_address=0x38989BBA00BDF8181F4082995b3DEAe96163aC5D
INFO[2024-12-19T19:51:54+01:00] Decoded timelocked action                     kind="Timelock Decrease"
INFO[2024-12-19T19:51:54+01:00] A new timelocked-action has been detected!    block_number=21429072 chain=mainnet current_timelock=96h0m0s description="Timelock decreased to 95h59m59s" kind="Timelock Decrease" valid_at="2024-12-22 12:25:06 +0100 CET" vault=0x38989BBA00BDF8181F4082995b3DEAe96163aC5D

Locally - Using Docker

We provide a Docker configuration to help you run Sentinel more easily.

First, you need to fork the network using anvil:

anvil -f $RPC_URL --auto-impersonate --fork-block-number 21429070

Then, you can start Sentinel in Docker using docker compose:

docker compose up

This will use the dedicated Sentinel configuration for Docker, which you can find in ./etc/config.example.docker.yaml.

Finally, you need to impersonate the administrator of the vault to perform an action that is timelocked:

# Sends ETH to the account to impersonate
cast send 0x2566f66f68ed438726AD904524FB306A03FdB80B --value 1ether --private-key 0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80

# Perform the action - Here decreasing the timelock from 96h to 95h59m59s
cast send 0x38989BBA00BDF8181F4082995b3DEAe96163aC5D --from 0x2566f66f68ed438726AD904524FB306A03FdB80B "submitTimelock(uint256)" 345599 --unlocked

And you should see a log similar to the following appear in your terminal:

sentinel-1  | time="2024-12-19T19:05:23Z" level=info
sentinel-1  | time="2024-12-19T19:05:23Z" level=info msg="     _____            __  _            __"
sentinel-1  | time="2024-12-19T19:05:23Z" level=info msg="    / ___/___  ____  / /_(_)___  ___  / /"
sentinel-1  | time="2024-12-19T19:05:23Z" level=info msg="    \\__ \\/ _ \\/ __ \\/ __/ / __ \\/ _ \\/ / "
sentinel-1  | time="2024-12-19T19:05:23Z" level=info msg="   ___/ /  __/ / / / /_/ / / / /  __/ /  "
sentinel-1  | time="2024-12-19T19:05:23Z" level=info msg="  /____/\\___/_/ /_/\\__/_/_/ /_/\\___/_/   "
sentinel-1  | time="2024-12-19T19:05:23Z" level=info
sentinel-1  | time="2024-12-19T19:05:23Z" level=info msg="                                         "
sentinel-1  | time="2024-12-19T19:05:23Z" level=info msg="All services initialized, starting sentinel.."
sentinel-1  | time="2024-12-19T19:05:23Z" level=info msg="Fetched new block from EL Client" block_number=21429072
sentinel-1  | time="2024-12-19T19:05:23Z" level=info msg="Capturing events logs emitted by contracts at block" block_number=21429072 contract_addresses="[0xA9c3D3a366466Fa809d1Ae982Fb2c46E5fC41101 0x38989BBA00BDF8181F4082995b3DEAe96163aC5D]"
sentinel-1  | time="2024-12-19T19:05:23Z" level=info msg="Captured events logs emitted at block" block_number=21429072 captured_events_logs=1
sentinel-1  | time="2024-12-19T19:05:23Z" level=info msg="Decoding captured event log emitted by contract" event_contract_address=0x38989BBA00BDF8181F4082995b3DEAe96163aC5D
sentinel-1  | time="2024-12-19T19:05:23Z" level=info msg="Decoded timelocked action" kind="Timelock Decrease"
sentinel-1  | time="2024-12-19T19:05:23Z" level=info msg="A new timelocked-action has been detected!" block_number=21429072 chain=mainnet current_timelock=96h0m0s description="Timelock decreased to 95h59m59s" kind="Timelock Decrease" valid_at="2024-12-22 11:19:34 +0000 UTC" vault=0x38989BBA00BDF8181F4082995b3DEAe96163aC5D

Production

Coming soon.

Contributing

We welcome all contributions from the community!

Our top priority is to support more notifications connectors, feel free to take a look at the implementation for the Discord integration as a reference:

  • Telegram
  • Slack

So here is a list of the tasks left to do to improve Sentinel, ordered by priority:

  • Implement Telegram notification connector.
  • Implement Slack notification connector.
  • Implement the indexer service.
  • Reduce RPC calls.
  • Implement WebHook service.
  • Add more logging.

Check out the dedicated file for more.

Authors

This project is currently being maintained by the 🛡️ at Quartz Technology.