Architecture

Request lifecycle

What happens, step by step, from the moment your agent sends a simulation request to the moment it gets a verdict.

1
Agent / DeveloperCloudflare EdgePOST /api/v1/simulate

HTTPS request with API key and transaction payload arrives at the nearest Cloudflare data centre.

2
Cloudflare EdgeCloudflare KVKey lookup

The edge Worker reads the API key prefix from KV (< 5ms). KV holds a mirror of tier + rate limit counters for hot-path decisions without a Postgres roundtrip.

3
Cloudflare EdgeNode GatewayForward valid request

If the key is valid and under rate limit, the request is forwarded to the Node.js gateway over HTTPS. Invalid or throttled requests are rejected at the edge with 401 or 429.

4
Node GatewayNeon PostgresINSERT into simulation_queue

The gateway writes the job to Postgres with status=PENDING and returns 202 Accepted + job_id to the caller immediately.

5
Python WorkerNeon PostgresSELECT FOR UPDATE SKIP LOCKED

The Python worker polls the queue every 500ms. It claims a job atomically using Postgres advisory locks — multiple workers can run safely without double-claiming.

6
Python WorkerAnvil (forked chain)eth_call / eth_sendTransaction

Anvil holds a persistent fork of the target chain. The worker takes an evm_snapshot, executes the transaction batch, then evm_reverts to the snapshot for the next job.

7
AnvilPython WorkerExecution trace + gas

Anvil returns the full trace: opcodes, storage changes, events, gas consumed. The analytical engine parses this into the 10 safety check results.

8
Python WorkerMongoDBINSERT telemetry document

The full trace and check results are stored append-only in MongoDB for debugging, analytics, and future model training.

9
Python WorkerNeon PostgresUPDATE simulation_queue SET status=APPROVED/REJECTED

The job status is written back to Postgres. The gateway's polling endpoint will now return the terminal state.

10
Developer / AgentNode GatewayGET /api/v1/simulate/:jobId

The caller polls the result endpoint. When status is terminal (APPROVED, REJECTED, FAILED, TIMED_OUT), they get the full verdict and stop polling.

< 10ms

Edge validation

API key + rate limit at Cloudflare

< 300ms

Fork + execution

Snapshot reuse; no cold start

< 400ms

End-to-end median

Including queue + polling overhead

Request Lifecycle — ArbiSim Guard Docs