archon

Archon Ethereum mediator

The Ethereum mediator anchors Archon DID batches on EVM chains through a canonical ArchonRegistry smart contract. It is designed for registries such as ETH:sepolia, ETH:mainnet, or EVM L2 variants configured with their own registry names and contract addresses.

The mediator has two responsibilities:

The smart contract intentionally does not validate Archon DID semantics. Gatekeeper remains the validation authority; Ethereum is used as a publication, ordering, and timestamping layer.

An ArchonBatch anchor commits to the batch DID’s signed create operation. Import uses gatekeeper.getGenesis(did) and reads the ordered didDocumentData.batch.ops list. Retrieval checks identity/shape without requiring publisher authorization or accepted DID history; contained operations are still authorized normally. A later batch-asset update cannot change the operations or their opidx values for the existing anchor. Missing genesis content is retried rather than replaced with latest asset state.

Canonical contract

Each public EVM registry should use one canonical contract address. For example, every ETH:sepolia node should scan the same Sepolia ArchonRegistry deployment. Custom deployments should use a distinct registry name or be clearly marked as non-canonical in node configuration.

The reference contract is in services/mediators/ethereum/contracts/ArchonRegistry.sol.

Environment variables

variable default description
ARCHON_NODE_ID none Keymaster agent name used as batch controller
ARCHON_GATEKEEPER_URL http://localhost:4224 Gatekeeper service URL
ARCHON_KEYMASTER_URL none Keymaster service URL
ARCHON_WALLET_URL none Ethereum wallet service URL
ARCHON_ADMIN_API_KEY none Admin API key for service-to-service calls
ARCHON_ETH_CHAIN network derived Gatekeeper registry name, e.g. ETH:sepolia
ARCHON_ETH_NETWORK mainnet mainnet, sepolia, holesky, or local
ARCHON_ETH_CHAIN_ID network derived EVM chain ID
ARCHON_ETH_RPC_URL http://localhost:8545 Ethereum JSON-RPC endpoint
ARCHON_ETH_CONTRACT none Canonical ArchonRegistry contract address
ARCHON_ETH_START_BLOCK 0 First block to scan
ARCHON_ETH_CONFIRMATIONS 2 Blocks deep a block must be before an anchor in it is imported; a whole number, 0 or more, or the mediator does not start
ARCHON_ETH_LOG_CHUNK_SIZE 2000 Blocks per eth_getLogs query
ARCHON_ETH_PENDING_TX_TIMEOUT_BLOCKS 120 Blocks to wait before bumping a pending anchor transaction
ARCHON_ETH_MIN_GAS_BALANCE_WEI 1000000000000000 Minimum wallet balance required before anchoring
ARCHON_ETH_IMPORT_INTERVAL 0 Minutes between import cycles; 0 disables importing
ARCHON_ETH_EXPORT_INTERVAL 0 Minutes between export cycles; 0 makes the mediator read-only
ARCHON_ETH_REIMPORT true Reprocess discovered batches on startup
ARCHON_ETH_DB json Database adapter: json, sqlite, mongodb, or redis
ARCHON_ETH_DB_NAME chain derived Persister file/key name, derived from the registry chain by default
ARCHON_ETH_METRICS_PORT 4239 Metrics server port

ethereum_wallet_insufficient_funds is 1 while the last balance check found the wallet below ARCHON_ETH_MIN_GAS_BALANCE_WEI, which is when the mediator skips anchoring. ethereum_wallet_unreachable is 1 while the last balance check could not reach the wallet service; the funds gauge keeps its last reading in that case. Grafana alerts on the funds gauge; see Alerts.

Batch completion and pending events

Gatekeeper’s processEvents().pending is a global queue count. When nonzero, pendingBatches identifies the batch DIDs still represented in that queue. After importing every CID, the mediator completes a batch only after a non-busy processing result that has no pending events for that batch. Unrelated pending events do not trigger reimports. This records processing completion, not final authorization; retained history can still be replayed when missing evidence arrives.

Batch import logs report batchImport and batchComplete for this batch; gatekeeperQueueAfterImport and gatekeeperProcessing describe the node-global inbound queue. Persisted imported and processed keep the raw API responses.

Unavailable content, incomplete CID results, processing failures, and batches with their own pending events remain retryable. Older Gatekeepers that omit pendingBatches retain the conservative global-pending behavior. Persisted “No progress” errors recover through the normal retry pass without database edits.

Reorganization recovery

A changed scan-checkpoint hash triggers a rewind: the mediator checks stored Gatekeeper checkpoints backward from the scan cursor until one still matches the canonical chain, or the configured start is reached. An unavailable canonical checkpoint pauses recovery. Before saving the new scan position, the mediator calls Gatekeeper rewindRegistry and removes discovered items in the rescanned suffix. Gatekeeper withdraws those receipts and blocks, retains signed operations as unconfirmed hints, and replays dependent histories. Failure leaves the old scan position in place so the operation is retried.

Coming from finalized imports

Releases 0.13 to 0.15 imported an anchor only once its block was finalized, about 13 minutes after it was mined. A node upgraded from one of them needs no migration: its scan cursor is at a finalized height, which is behind the confirmation boundary, so the scan goes on from there. The finalizedImports marker those releases wrote to the mediator’s database is no longer read. Ethereum import RPC endpoints no longer need to support the finalized block tag.