PR: #28 (feat/03-lending-protocol-trait)
File: crates/charon-core/src/traits.rs, line 19; Cargo.toml line 34
Workspace declares edition = "2024" (Rust 1.85). Native async-fn-in-trait stable since 1.75. #[async_trait] boxes every future (Pin<Box<dyn Future + Send>>), adds heap alloc per call, and forces dyn-compatible lifetime. Hot path is fetch_positions called per block — boxing cost is measurable.
Native AFIT caveat: async fn in trait is object-safe only with return_type_notation or impl Trait bounds. For Arc<dyn LendingProtocol> use, either (a) keep #[async_trait] with a rustdoc comment explaining the dyn requirement, or (b) use the newer trait_variant::make / AsyncLendingProtocol split.
Fix: Choose one:
- Keep
#[async_trait] but document why in trait rustdoc.
- Switch to native AFIT +
trait_variant::make(Send) pattern.
- Drop
dyn requirement; accept impl LendingProtocol generics throughout.
Default to option 1 for now (simplest), revisit when dyn overhead shows in profiling.
PR: #28 (feat/03-lending-protocol-trait)
File: crates/charon-core/src/traits.rs, line 19; Cargo.toml line 34
Workspace declares edition = "2024" (Rust 1.85). Native async-fn-in-trait stable since 1.75.
#[async_trait]boxes every future (Pin<Box<dyn Future + Send>>), adds heap alloc per call, and forcesdyn-compatible lifetime. Hot path isfetch_positionscalled per block — boxing cost is measurable.Native AFIT caveat:
async fnin trait is object-safe only withreturn_type_notationorimpl Traitbounds. ForArc<dyn LendingProtocol>use, either (a) keep#[async_trait]with a rustdoc comment explaining the dyn requirement, or (b) use the newertrait_variant::make/AsyncLendingProtocolsplit.Fix: Choose one:
#[async_trait]but document why in trait rustdoc.trait_variant::make(Send)pattern.dynrequirement; acceptimpl LendingProtocolgenerics throughout.Default to option 1 for now (simplest), revisit when dyn overhead shows in profiling.