Skip to content

Allows for quickly pausing withdrawals if suspicious activity is detected

License

Notifications You must be signed in to change notification settings

SimplyStaking/fuel-canary-watchtower

 
 

Repository files navigation

Fuel Canary Watchtower

A tool to monitor both the Fuel and Ethereum chains and the bridge activities occurring between the two chains.

Project Layout

├── fuel_watcher: handles a thread that watches the Fuel chain
│   ├── fuel_chain: reads basic data from the Fuel chain
│   ├── fuel_utils: helper functions for fuel data
│   ├── extended_provider: extended provider for full block querying using graphql
├── ethereum_watcher: handles a thread that watches the Ethereum chain
│   ├── ethereum_chain: reads basic data from the Ethereum chain
│   ├── ethereum_utils: helper functions for ethereum data
│   ├── state_contract: handles interacting with and monitoring events from the Fuel chain state contract
│   ├── portal_contract: handles interacting with and monitoring events from the Fuel message portal contract
│   ├── gateway_contract: handles interacting with and monitoring events from the ERC-20 gateway contract
├── ethereum_actions: handles interactions with the Ethereum chain (pausing contracts)
├── alerter: handles logging and pushing out info/alerts
├── pagerduty: handles sending notifications to pagerduty
├── config: reads configuration set in the watchtower_config.json file

Running

Clone the repository:

git clone https://github.com/FuelLabs/fuel-canary-watchtower
cd fuel-canary-watchtower

Copy the config file and remove the .example part, now edit the watchtower_config.json file with the details as needed.

If you require alerting you must set your PagerDuty key as such in your terminal:

export WATCHTOWER_PAGERDUTY_KEY=KEY-HERE

If you require automated pausing of contracts you must set your Ethereum private key as such:

export WATCHTOWER_ETH_PRIVATE_KEY=KEY-HERE

Build the project and run it:

cargo build
cargo run

Config File

An example config file can be found at watchtower_config.json.example. You can configure alerts by alert level and by action here is an example portal deposit alert:

"portal_deposit_alerts": [
    {
    "alert_action": "PausePortal",
    "alert_level": "Info",
    "time_frame": 300,
    "token_name": "ETH",
    "token_address": "0x0000000000000000000000000000000000000000",
    "token_decimals": 18,
    "amount": 250
  }
]

In the above configuration, ETH has exceeded the threshold of 250ETH being deposited over a period of 300 seconds, an alert of type INFO is sent, and the Portal contract will be paused.

ABI

The abi is generated from compiling the fuel-bridge contracts

Alerts Module

The alerts module is responsible for pushing alerts through to some monitoring service as well as logging data to a log file. Logging is configured in logging_config.yaml.

Might Want to Add

  • We currently only check that committed blocks match what's in the fuel chain. This does not protect us from a bug in the client that might screw up MessageOut receipts and allow for more ETH or tokens to be withdrawn than should be. We might want a setup that keeps a running log of all asset balances that have been approved for withdrawal and then trigger a pause if more are somehow withdrawn than expected. This would require some kind of persistent data store to work efficiently (like the current "alert" concept but with a timing window that spans from the start of the chain to now).

About

Allows for quickly pausing withdrawals if suspicious activity is detected

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Rust 100.0%