Bifrost: make Asgard address caching concurrency-safe (UTXO + Ethereum)

Closing in favor of !4594 (merged).

Reason: same changes were reopened from an upstream source branch instead of a fork. Please continue review/discussion in !4594 (merged).

Summary

Make Asgard address caching concurrency-safe in Bifrost UTXO and Ethereum clients by replacing unsynchronized mutable state with an atomic cache and shared cache helper logic.

Problem

isAsgardAddress / getAsgardAddress previously depended on shared mutable fields (asgardAddresses, lastAsgard) without synchronization. These paths are reachable concurrently, so races and inconsistent reads were possible.

Where concurrent calls can happen

  1. Block scanner runs scanBlocks and scanMempool in separate goroutines.
  2. Block prefetch starts additional goroutines that call FetchTxs concurrently.
  3. Observer worker pool processes txins in parallel and calls GetConfirmationCount.
  4. OnObservedTxIn processing can overlap with the above execution paths.

This means getAsgardAddress / isAsgardAddress can be hit from multiple goroutines during normal operation.

Why this should be solved

This removes a real concurrency hazard in hot scanner/observer paths and makes Asgard address reads deterministic and thread-safe under parallel load.

Test plan

  • make test passes
  • make lint passes
  • make test-simulation passes
Edited by ZlyDevMaya

Merge request reports

Loading
Loading