Skip to content

Commit 57869d2

Browse files
docs: document oracle modes in README
1 parent 4df146a commit 57869d2

1 file changed

Lines changed: 33 additions & 4 deletions

File tree

README.md

Lines changed: 33 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,21 @@ work as part of a Hashi-based cross-chain bridge system.
1818
- **ROFL Runtime**: Uses Oasis confidential compute for secure oracle operations
1919
- **Event-Driven**: Processes `BlockHeaderRequested` events in real-time
2020

21+
## Oracle Modes
22+
23+
The oracle supports four operating modes, configured via `ORACLE_MODE`:
24+
25+
| Mode | Use When | How It Works |
26+
|------|----------|-------------|
27+
| `event_listener` | A `BlockHeaderRequester` contract exists on the source chain and emits requests for specific block headers | Polls for `BlockHeaderRequested` events and submits only the requested headers |
28+
| `push` | You need continuous, unconditional block header availability on Sapphire (e.g., for a bridge that may need any recent header) | Pushes the latest block headers at a fixed interval, regardless of demand |
29+
| `watcher` | You want headers only for blocks where specific addresses have on-chain activity (transactions to/from) | Scans blocks for interactions with watched addresses and submits only those block headers. Supports optional internal transaction detection via `debug_traceTransaction` |
30+
| `token_watcher` | You want headers only for blocks containing ERC-20 transfers to specific recipients (e.g., bridge deposit addresses) | Monitors `Transfer` events on configured token contracts filtered by recipient addresses, and submits headers for blocks with matching transfers |
31+
32+
The `watcher` and `token_watcher` modes include a **heartbeat
33+
mechanism** that periodically stores a checkpoint block header even
34+
when no activity is detected, bounding sync time on oracle restart.
35+
2136
## Requirements
2237

2338
- Docker and Docker Compose
@@ -33,9 +48,9 @@ The oracle is configured through environment variables defined in `compose.yaml`
3348

3449
### Environment Variables
3550

36-
The oracle supports three modes: **event_listener**, **push**, and
37-
**watcher**. Some environment variables are required for all modes, while
38-
others are specific to a mode.
51+
The oracle supports four modes: **event_listener**, **push**, **watcher**,
52+
and **token_watcher**. Some environment variables are required for all
53+
modes, while others are specific to a mode.
3954

4055
#### **Common Variables (All Modes)**
4156

@@ -47,9 +62,10 @@ others are specific to a mode.
4762
| `ROFL_ADAPTER_ADDRESS` | Address of the ROFLAdapter contract on Oasis Sapphire | - | **Yes** |
4863
| `REQUEST_TIMEOUT` | HTTP request timeout (seconds) | `30` | No |
4964
| `RETRY_COUNT` | Number of retry attempts for operations | `3` | No |
50-
| `ORACLE_MODE` | Operating mode: `event_listener`, `push`, or `watcher` | `event_listener` | No |
65+
| `ORACLE_MODE` | Operating mode (see [Oracle Modes](#oracle-modes)) | `event_listener` | No |
5166
| `LOG_LEVEL` | Logging level: DEBUG, INFO, WARNING, ERROR, CRITICAL | `INFO` | No |
5267
| `JSON_LOGS` | Enable JSON-formatted structured logging | `false` | No |
68+
| `MIN_REPORTER_BALANCE` | Minimum reporter balance in native tokens before startup | `0.001` | No |
5369

5470
---
5571

@@ -81,6 +97,7 @@ others are specific to a mode.
8197
| `WATCHER_BATCH_SIZE` | Max blocks to scan per iteration | `50` | No |
8298
| `LOOKBACK_BLOCKS` | Number of blocks to look back on startup | `100` | No |
8399
| `ENABLE_INTERNAL_TX_DETECTION` | Enable internal transaction detection | `false` | No |
100+
| `HEARTBEAT_INTERVAL_SECONDS` | Seconds between heartbeat checkpoint submissions | `3600` | No |
84101

85102
**Internal Transaction Detection:**
86103

@@ -100,6 +117,18 @@ addresses are detected.
100117

101118
---
102119

120+
#### **Token Watcher Mode (`ORACLE_MODE=token_watcher`)**
121+
122+
| Variable | Description | Default | Required |
123+
|------------------------------|----------------------------------------------------------|---------|----------|
124+
| `TOKEN_ADDRESSES` | Comma-separated list of ERC-20 token contract addresses | - | **Yes** |
125+
| `RECIPIENT_ADDRESSES` | Comma-separated list of recipient addresses to watch | - | **Yes** |
126+
| `SCAN_INTERVAL` | Seconds between scanning for token transfers | `5` | No |
127+
| `MAX_BLOCKS_PER_SCAN` | Max blocks to scan per iteration | `10` | No |
128+
| `HEARTBEAT_INTERVAL_SECONDS` | Seconds between heartbeat checkpoint submissions | `3600` | No |
129+
130+
---
131+
103132
#### **Local Mode (Testing Only)**
104133

105134
| Variable | Description | Default | Required |

0 commit comments

Comments
 (0)