You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
refactor(sdk): replace #[async_trait] with explicit BoxFuture on SDK traits
Replace #[async_trait] with explicit Pin<Box<dyn Future + Send + 'a>>
returns on Fetch, FetchMany, FetchUnproved, BroadcastStateTransition,
and all 21 transition traits in the SDK.
## Problem
The Rust compiler has a known HRTB Send inference bug
(rust-lang/rust#96865) that prevents it from proving async futures are
Send when the number of generic trait implementations exceeds a
threshold. With 28 Fetch impl types (after adding shielded pool
support), any consumer using tokio::spawn with SDK operations gets:
error: implementation of Send is not general enough
This forced consumers (e.g. dash-evo-tool) to use spawn_blocking +
block_on as a workaround, wasting threads and blocking the async
executor.
## Solution
By returning BoxFuture explicitly instead of relying on #[async_trait],
the compiler sees Box<dyn Future + Send> and stops analyzing the inner
state machine. Send is proven by construction via the boxed trait
object. This is the same boxing that #[async_trait] performed — we just
make it explicit so the compiler's inference engine is not involved.
## Impact
- ALL SDK consumers can use tokio::spawn directly
- No spawn_blocking workaround needed
- No unsafe AssertSend wrapper needed
- No performance regression (same boxing as #[async_trait])
- WASM builds unaffected (verified)
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
0 commit comments