Skip to content

infra(Tier 3): pre-signed bundle tx template pool #112

@0xfandom

Description

@0xfandom

Context

Signing cost on the submission hot path is 1–5 ms of deterministic jitter. Currently cmd/executor/bundle.go constructs and signs each arbitrage transaction fresh per opportunity. Pre-signing templates for expected input-amount buckets removes this jitter and lets the executor ship whichever template matches the observed opportunity immediately.

This work is purely in-binary — no external service dependencies, no new credentials, no recurring cost.

Scope

Pre-signed transaction template pool

  • New module: cmd/executor/template.go
  • Template keyed by (token_pair, protocol_mix, amount_bucket)
  • Amount buckets (tunable): 10, 25, 50, 100, 250, 500, 1000 WETH equivalent
  • Signed at startup + rotation ticker (e.g., every N blocks or on nonce advance)
  • Nonce pre-allocation window: reserve next K nonces for templates, track in cmd/executor/nonce.go
  • Submitter picks closest template by (pair, protocol_mix, amount_bucket), mutates only slippage-independent fields (deadline, tipBps, minProfitOut)

Metrics

  • aether_template_pool_size gauge
  • aether_template_cache_hit_ratio gauge (rolling 1-minute window)
  • aether_template_rotation_duration_ms histogram (rotation should not stall hot path)

Safety

  • Template signing happens on a background goroutine, never on the arb-dispatch path
  • If template cache misses (unusual pair or amount out of bucket), fall back to fresh signing path — no regression
  • On reorg detection, invalidate templates with nonces ≤ last confirmed

Acceptance criteria

  • Template pool rebuilds every N blocks without stalling hot path (measured: < 1 ms stall in aether_template_rotation_duration_ms)
  • Cache-hit ratio ≥ 70 % after warmup on replay corpus of 100 historical arbs
  • Unit tests for template selection, nonce rotation, reorg invalidation
  • Bench: median submission time drops by ≥ 1 ms vs baseline
  • No regression in gRPC test suite, Go test suite, contract test suite

Files touched (expected)

  • cmd/executor/template.go (new)
  • cmd/executor/nonce.go (expose reservation API)
  • cmd/executor/submitter.go (template-path branch)
  • cmd/executor/executor.go (wire template cache into submit flow)
  • cmd/executor/template_test.go (new)

Out of scope

  • L2 / non-Ethereum submit paths (explicitly not part of this effort)
  • Private mempool integration (deferred, under discussion)

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions