fix(solana): align network-fee buckets and deterministic samples

Supersedes !5292 (closed) (closed; same source branch). This revision adds a guard against truncated block listings from load-balanced RPC backends.

Problem

SOL network-fee votes are keyed by chain, exact reporting slot, fee rate and transaction size. Bifrost can produce different votes from otherwise identical finalized chain data:

  • The scanner jumps directly to the latest 50-slot boundary, skipping intermediate boundaries after delayed scans.
  • The fee estimator combines the new sample with a rolling cache populated by that node's previous scans. Different scan histories can yield different fees for the same reporting slot.
  • The deferred fee publication runs even when sampling fails, relabeling stale or partial cache data with a new slot. The scheduling cursor was already advanced, preventing a retry of that bucket.
  • getSlot and getBlocks can be served by different backends behind a load balancer. Agave clamps a finalized getBlocks range to the serving node's root without reporting truncation, so a lagging backend can return a listing that silently omits the top of the sample window, or an empty one.

Changes

  • Sample deterministic finalized history for each report, with no rolling cross-report cache. Keep the existing median-of-block-medians and lamport rounding, using GasCacheBlocks as the SOL eligible-transaction target within FeeSampleSlots.
  • Process crossed boundaries in order with one sampling attempt per scanner pass. Bound catch-up to the two most recent crossed boundaries so a long outage does not replay ancient fee reports. Startup anchors near the finalized tip instead of replaying from zero.
  • Advance the fee cursor only after successful handling. Temporary RPC, block or agreed-fee lookup failures preserve the pending boundary for retry. Never publish a partial or previous sample under a new slot.
  • A complete sparse window can produce a fee without reaching the transaction target; verify retained-history coverage before accepting that fallback. Empty windows advance without inventing a fee. Missing blocks listed by the RPC are errors, not silently dropped samples.
  • Request the fee window's block listing with the boundary slot as minContextSlot. A backend whose finalized root has not reached the boundary rejects the request (-32016) instead of returning a truncated listing; the error is retried like any other temporary sampling failure. GetBlockHeights is unchanged for the signing path.
  • Reject null/missing getFirstAvailableBlock results instead of treating unknown coverage as a valid genesis retention floor. A real zero remains valid.
  • Preserve no-change suppression against a fresh THORChain agreed fee. Do not publish unchanged fees every bucket or use the previous local report as the suppression baseline.
  • Keep vault/solvency scanning independent of fee-sampling failures and make blocked fee publication interruptible on shutdown.

No protocol state, voter identity, slash/refund rules, transaction construction, signing or production configuration changes. This does not include the scanner-sleep change in !5277 (merged). The sequential-boundary idea has a related solvency-only precedent in !4920 (merged).

Verification

Regression tests were written first and reproduced the original failures before implementation. They exercise the scanner and actual JSON-RPC client against local HTTP fixtures, rather than a separate model of the algorithm. The lagging-backend regression simulates Agave's root clamp and minContextSlot rejection; before the fix it published a fee from a lower block (truncated listing) and completed the boundary without voting (empty listing).

All selected local checks passed with Go 1.26.10 on the MR head:

go test -race -tags=mocknet ./bifrost/pkg/chainclients/solana/... -count=1 -timeout=10m
go test -tags=mainnet ./bifrost/pkg/chainclients/solana/... -run '^$' -timeout=10m
go vet -tags=mocknet ./bifrost/pkg/chainclients/solana/...
golangci-lint run --config .trunk/configs/.golangci.yaml --build-tags mocknet \
  --timeout 10m --concurrency 2 --exclude gofmt --allow-parallel-runners \
  ./bifrost/pkg/chainclients/solana/...
git diff --check

Formatting was checked separately with gofumpt -d on all five changed Go files (no output). The lint check used the repository-pinned golangci-lint 1.63.4, built with Go 1.26.10. The mainnet command is compilation only, not a mainnet test execution.

Added 20 fee-reporting tests and a table-driven retention-result decoder regression, alongside adapted existing fee tests. Coverage includes different prior histories, skipped boundaries, catch-up bounds, sampling and agreed-fee failures, partial/pruned/empty windows, truncated or empty listings from a lagging backend, malformed listings, unchanged-fee suppression, shutdown backpressure, and startup/recovery. The full Solana package tree passed under the race detector.

Full-repository CI, simulation and live multi-validator convergence were not run locally. The lagging-backend behavior is verified against a fixture that mirrors Agave's getBlocks, not a live load-balanced provider. The dependency qualification below applies to every Go-based local check.

Rollout And Limits

  • The estimator intentionally no longer smooths over a node's historical cache. It uses only the report's finalized lookback, so fee responsiveness changes and old/new Bifrost instances can disagree during rollout. Coordinate adoption through an upstream release; this is not a recommendation to deploy a custom build on one validator.
  • Sampling contents are deterministic for matching configuration and complete, consistent finalized RPC data. Participation still depends on when each node reads THORChain's agreed fee; this MR does not guarantee every fee vote reaches quorum or eliminate every SOL slash.
  • The two-boundary limit deliberately skips obsolete buckets after a long outage. It does not change THORNode's handling of out-of-order quorums or provide durable queue acknowledgements.
  • Local dependency-based checks use the verified reconstructed RC6 TSS library through an external Go workspace. This is a best local approximation, not exact organization CI or production signing compatibility. Tracked dependency files are unchanged; the reconstructed source is not included.
  • No running validator or RPC routing was changed.

🤖 Generated with Claude Code

Merge request reports

Loading
Loading