Skip to content

feat(bridge): Arch Network destination for Spectra#18

Open
EvgenyNasretdinov wants to merge 21 commits into
diadata-org:loggingfrom
protofire:arch-destination
Open

feat(bridge): Arch Network destination for Spectra#18
EvgenyNasretdinov wants to merge 21 commits into
diadata-org:loggingfrom
protofire:arch-destination

Conversation

@EvgenyNasretdinov

@EvgenyNasretdinov EvgenyNasretdinov commented Jun 30, 2026

Copy link
Copy Markdown

Summary

Adds Arch Network as a destination chain for the Spectra bridge, alongside the existing EVM destinations. The bridge node can now publish DIA oracle intents to an Arch program (PushOracleReceiverV2 Rust port) by calling HandleIntentUpdate, pay the per-call protocol fee, observe DIA_ORACLE.* program logs for rejections/staleness, and surface metrics + health for the new path.

Implementation is gated by chain.kind in the chain config (evm keeps current behavior; arch activates the new path), so existing deployments are unaffected.

What's in the branch

  • services/bridge/internal/arch/ — self-contained Arch client: Borsh codec for OracleIntent, PDA derivation with the Solana off-curve check, BIP-340 Schnorr signer (btcec/v2/schnorr), JSON-RPC client (get_account_info, send_transaction, get_processed_transaction, block helpers), HandleIntentUpdate instruction encoder, DIA_ORACLE.* log parser (update/stale/rejected).
  • services/bridge/internal/bridge/Destination interface, EvmWriteClient adapter (no rename of existing code), new ArchWriteClient, chain.Kind discriminator + buildDestination factory, background poller for fee_vault / payer balance gauges, arch_logs JSONB column and dia_arch_rejections row write in TransactionHandler.
  • Metrics — Prometheus collectors for tx confirmation latency, rejection count by reason, fee-vault and payer balances.
  • Tests — 30+ unit tests with parity fixtures from sub-projects 1 (oracle program) and 2 (CLI), mock-based write-client tests, and a live integration test (services/bridge/test/integration/arch_test.go) verified end-to-end against a local Arch v0.6.5 validator with the deployed receiver + fee-hook programs. The bridge-side tests live in internal/bridge/archtest (a separate package) so the new coverage is self-contained.
  • Operator docsservices/bridge/docs/ARCH_DESTINATION.md runbook, config/examples/arch-testnet.*.yaml config samples, README section.

Review focus

The branch is implementation-complete and the Arch-path tests pass. Feedback most welcome on:

  1. The chain.Kind discriminator + buildDestination factory shape (internal/bridge/) — whether this is the seam you'd want for future non-EVM destinations.
  2. The additive DB changes — the arch_logs JSONB column and the new dia_arch_rejections table.
  3. The negative-sentinel Arch chain-ID convention (-1 testnet / -2 mainnet), documented as Arch-only in the bridge README.

Happy to rebase / split commits if a different structure is preferred.

Known deferred items (TODOs in code, not blockers)

  • processed_events.status column is referenced but the schema column itself is added on a different branch (cross-team gap).
  • arch_logs JSONB write is wired but the lookup that decides which event row to attach to is still TODO.
  • Rejection rows persist with eventID = 0 (FK is NULL) since rejected intents have no upstream event yet.

Test plan

  • Arch-path packages pass: go test ./internal/arch/... ./internal/bridge/archtest/... ./internal/database/... ./internal/metrics/...
  • Live integration test passes against a local Arch v0.6.5 validator with deployed receiver + fee-hook programs
  • Deployed + exercised end-to-end on Arch testnet via the companion CLI + e2e suite (EIP-712 sign → on-chain verify → store → read)
  • Reviewer feedback addressed
  • CI green on this PR

- Add ChainConfig.Kind, ContractConfig.FeeHookProgramID, DestinationMethodConfig.Kind
  yaml fields to config structs (empty/"evm" preserves existing behaviour)
- Add buildDestination factory (unexported) switching on chain.Kind; Arch path
  calls newArchDestinationFromConfig; EVM path delegates to NewWriteClient
- Add BuildDestinationForTest exported thin wrapper for archtest package use
- Update NewBridge construction loop: Arch chains routed through buildDestination,
  EVM chains keep existing NewWriteClient path with full contract slice
- Fix Task-9 forward concern: TransactionHandler.Process short-circuits for
  arch destinations, calling dest.Send directly (TODO(task-13) for DB/metrics)
- Add factory_test.go in archtest: ArchKind, MissingSigner, MissingFeeHook
…tion histogram, poller symmetry, single-contract guard)
@EvgenyNasretdinov
EvgenyNasretdinov marked this pull request as ready for review July 13, 2026 14:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant