Expand description
Stack-allocated variable-length CPI builder.
The existing hopper_runtime::cpi::invoke_signed::<N> family is
const-generic over the account count, which is perfect for CPI
shapes known at compile time and about ninety percent of real
cases. The exceptions are:
- Aggregators that invoke the same program with a runtime- decided account count (fanout fee routers, batch settlement cranks).
- Forwarders that pass through the caller’s remaining accounts after splicing in a known prefix.
- Generic instruction builders that construct the data buffer byte-by-byte from user input (priority-fee overrides, optional bump seeds) and do not know the final length until build time.
DynCpi covers those cases. It is parameterised on two
compile-time capacities, MAX_ACCTS and MAX_DATA, so the whole
buffer lives on the stack in a single MaybeUninit array. No
heap, no Vec, no panic on overflow: DynCpi::push_account
and DynCpi::push_data return errors when the declared
capacity would be exceeded.
§Innovation vs. Quasar
Quasar’s DynCpiCall is conceptually the same shape but expects
the caller to hand-roll seed threading. Hopper’s builder carries
a typed Signer slice through the invoke call so a PDA-authored
CPI reads like a single method chain. The overflow discipline
also differs: Hopper propagates Err(ProgramError::InvalidArgument)
rather than panicking, which keeps the handler’s error surface
uniform.
Structs§
- DynCpi
- Variable-length CPI builder with compile-time stack capacity.