Skip to content

Commit 08241fc

Browse files
docs: document oracle modes in README
1 parent 4df146a commit 08241fc

1 file changed

Lines changed: 31 additions & 4 deletions

File tree

README.md

Lines changed: 31 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,19 @@ 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+
All modes include a **heartbeat mechanism** (except `push`, which inherently submits regularly) that periodically stores a checkpoint block header even when no activity is detected, bounding sync time on oracle restart.
33+
2134
## Requirements
2235

2336
- Docker and Docker Compose
@@ -33,9 +46,9 @@ The oracle is configured through environment variables defined in `compose.yaml`
3346

3447
### Environment Variables
3548

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.
49+
The oracle supports four modes: **event_listener**, **push**, **watcher**,
50+
and **token_watcher**. Some environment variables are required for all
51+
modes, while others are specific to a mode.
3952

4053
#### **Common Variables (All Modes)**
4154

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

5468
---
5569

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

85100
**Internal Transaction Detection:**
86101

@@ -100,6 +115,18 @@ addresses are detected.
100115

101116
---
102117

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

105132
| Variable | Description | Default | Required |

0 commit comments

Comments
 (0)