Project system brief
A fault-tolerant, event-driven Go 1.27 orchestration engine for accepting, scheduling, signing, broadcasting, retrying, and reconciling EVM blockchain transactions with durable PostgreSQL 17 state, NATS JetStream work queues, and multi-provider RPC failover.
Product Context
Product Context
A fault-tolerant, event-driven Go 1.27 orchestration engine for accepting, scheduling, signing, broadcasting, retrying, and reconciling EVM blockchain transactions with durable PostgreSQL 17 state, NATS JetStream work queues, and multi-provider RPC failover.
System Problem & Scope
System Problem & Scope
Broadcasting EVM blockchain transactions at production scale fails when services rely on in-memory nonce mutexes, fire-and-forget RPC calls, or flat status enums. Worker crashes mid-broadcast, ambiguous RPC timeouts, underpriced mempool stalls, and chain reorganizations easily cause stuck nonces, duplicate transactions, or lost auditability.
Engineering Constraints
Engineering Constraints
Coordinating strict per-wallet sequential nonces across distributed worker replicas without holding database locks during network RPC calls, recovering safely from ambiguous broadcast timeouts without allocating duplicate nonces, and detecting chain reorgs or external nonce consumption before declaring finality.
System Architecture Flow
System Architecture Flow
Clean-boundary Go workspace split into four role binaries (api, orchestrator, tx-worker, confirmation-worker) with zero infrastructure imports inside internal/domain. The HTTP ingress persists transaction_intents and outbox_events atomically in PostgreSQL 17; the Outbox Relay publishes to NATS JetStream; bounded worker pools acquire 30-second fencing leases, reserve nonces, sign EIP-1559 payloads via an isolated Signer, persist raw signed transactions in PREPARED state before broadcast, and rely on a stateless DB-driven Confirmation Monitor for finality and reorg checks.
Idempotent API Ingress
Active StageTransactional Outbox & JetStream
Nonce Reservation & Isolated Signer
Multi-Provider RPC Router
Confirmation & Reorg Monitor
Idempotent API Ingress
Validates API keys, sender permissions, rate limits, and Idempotency-Key headers, then commits intent and outbox_event atomically in PostgreSQL 17.
Transactional Outbox & JetStream
Polls unpublished outbox rows and dispatches deduplicated tx.dispatch events into NATS JetStream work queues while a sweeper reclaims expired leases.
Nonce Reservation & Isolated Signer
TxProcessor acquires a fencing lease, reserves sequential wallet nonces in PostgreSQL, signs EIP-1559 payloads within fee caps, and persists PREPARED raw_signed_tx.
Multi-Provider RPC Router
Broadcasts signed transactions through ProviderGuard circuit breakers and reconciles ambiguous timeouts via TransactionByHash before any retry.
Confirmation & Reorg Monitor
Polls BROADCASTED and CONFIRMING executions, cross-checks block hashes against reorgs, triggers 15% RBF retries when stale, and finalizes settled intents.
Execution & Failure-Mode Explorer
How the architecture behaves under real faults
TxProcessor persists the signed payload in PREPARED state, broadcasts via the priority RPC provider, and advances the execution to BROADCASTED.
Key Engineering Contributions
Key Engineering Contributions
Engineered two-level IntentStatus and ExecutionStatus state machines with optimistic version fencing, immutable transaction_state_events logs, and numeric(78,0) uint256 PostgreSQL storage. Built the Transactional Outbox relay, NATS JetStream pull-based worker pool, expired-lease sweeper, and TxProcessor supporting 15% Replace-By-Fee (RBF) bumping on the original nonce. Implemented a priority-ordered EVM RPC Router with per-provider ProviderGuard circuit breakers, cross-provider block hash verification against reorgs, and an isolated DevSigner enforcing fee caps and mainnet chain-ID guards.
Reliability & Integrity Guarantees
Reliability & Integrity Guarantees
Verified through unit and race-tested integration suites across domain state transitions, PostgreSQL repositories, JetStream messaging, RPC failover, and isolated signing, alongside simulated EVM (go-ethereum/ethclient/simulated) confirmation E2E tests, chaos fault-injection tests, and burst load tests with Prometheus, Loki, and Grafana observability.