Docs · Build
Keeper
A small Node service that watches the Alarm and flips every Vault account as soon as it trips. Anyone can run one.
What it does
The time between the alarm tripping and an account flipping is the window in which a stolen ECDSA key still works. The keeper exists to make that window as short as the chain allows.
- It indexes
Installed,UninstalledandFlippedevents from the Vault validator, so it always knows which accounts still need flipping. - It polls
Alarm.tripped()on a short interval. - The moment that returns true, it sends
flipForManyin batches until nothing is pending.
The keeper needs no permission. After a trip, flipFor and flipForMany are open to any caller, so several independent keepers can run at once and an account owner can always flip their own account.
Running it
cp keeper/.env.example keeper/.env # then fill it in
npm run build -w @enquantum/keeper
npm run start -w @enquantum/keeper
To watch the whole sequence on a local chain first, run ./keeper/scripts/anvil-e2e.sh.
Configuration
| Variable | Default | Purpose |
|---|---|---|
RPC_URL | Mainnet public RPC | JSON-RPC endpoint. Use a provider endpoint in production. |
KEEPER_PRIVATE_KEY | none | Key of the account that pays for the flips. |
ALARM_ADDRESS | From the ABI package | Alarm contract. |
VALIDATOR_ADDRESS | From the ABI package | Vault validator contract. |
START_BLOCK | 0 | Block to index events from. Use the validator's deployment block. |
POLL_MS | 500 | How often to check the alarm. |
BATCH_SIZE | 50 | Accounts per flipForMany transaction. |
LOG_CHUNK | 5000 | Blocks per event query. |
DRY_RUN | 0 | Set to 1 to log what would be sent without sending. |
The key belongs in the keeper's own environment. Never put it in a variable that starts with NEXT_PUBLIC_, because those are shipped to every browser.
Operating notes
- Fund the keeper account with a little ETH. It only spends when the alarm trips.
- Blocks on Robinhood Chain are fast, so keep the poll interval short and use an RPC without tight rate limits.
- Run with
DRY_RUN=1first to confirm it finds the accounts you expect. - Run more than one, in different places. They do not need to coordinate: an account that is already flipped is skipped.
Known limits
- There is no automatic fee bumping yet. A flip transaction that is underpriced during congestion is not replaced.
- The account list is rebuilt from events at start, so a long history on a slow RPC delays readiness. Set
START_BLOCK.
The trust this places in keepers is covered in the security model.