KeeperAll pages

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.

  1. It indexes Installed, Uninstalled and Flipped events from the Vault validator, so it always knows which accounts still need flipping.
  2. It polls Alarm.tripped() on a short interval.
  3. The moment that returns true, it sends flipForMany in 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

bash
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

VariableDefaultPurpose
RPC_URLMainnet public RPCJSON-RPC endpoint. Use a provider endpoint in production.
KEEPER_PRIVATE_KEYnoneKey of the account that pays for the flips.
ALARM_ADDRESSFrom the ABI packageAlarm contract.
VALIDATOR_ADDRESSFrom the ABI packageVault validator contract.
START_BLOCK0Block to index events from. Use the validator's deployment block.
POLL_MS500How often to check the alarm.
BATCH_SIZE50Accounts per flipForMany transaction.
LOG_CHUNK5000Blocks per event query.
DRY_RUN0Set to 1 to log what would be sent without sending.
Keep the keeper key out of the site.

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=1 first 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.