Skip to content

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

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

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

Conversation

@EvgenyNasretdinov

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.
  • Operator docsservices/bridge/docs/ARCH_DESTINATION.md runbook, config/examples/arch-testnet.*.yaml config samples, README section.

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.

Why draft

The branch is implementation-complete and tests pass, but it's opened in draft so DIA can review the discriminator/factory shape and the schema additions before we mark it ready. Happy to rebase / split commits if a different structure is preferred.

Test plan

  • go test ./services/bridge/... passes (unit tests, mock write-client tests)
  • Live integration test passes against a local Arch v0.6.5 validator with deployed receiver + fee-hook programs
  • 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)
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