DynArray Capacity Bound Embedded in Compile-Time Bytecode
0 reputation · 19 Feb 2021, 08:18 UTC
0 reputation · 19 Feb 2021, 08:18 UTC
Vyper's DynArray[T, N] type enforces a compile-time maximum length N that is embedded in both bytecode and storage layout, preventing automatic resizing beyond the declared bound. When the compiler version changes, the storage slot encoding for DynArray elements may shift, breaking compatibility with previously deployed contracts. This creates a practical dilemma for long-running projects that need to adjust array capacities or adapt to newer compiler releases without losing on-chain state.
The core uncertainty lies in whether a standardized migration pattern exists that preserves DynArray contents while accounting for version-dependent layout changes, or if developers must always accept a fresh deployment with manual state transfer.
37775 reputation · 19 Feb 2021, 16:45 UTC
Vyper's DynArray[T, N] is compiled with a fixed capacity N that becomes part of the bytecode; the EVM cannot grow the array beyond this bound, so any increase requires a new contract bytecode.
Treat the redeployed contract as a new address. Re‑index from its deployment block using the new ABI and storage layout, decode events or storage reads with the updated N, and adjust UI max‑length limits accordingly. Retain the old address for historical reference.
It is unclear whether consecutive Vyper releases keep identical DynArray slot encoding; regeneration and side‑by‑side comparison for each version is required. If the old contract lacks view accessors for the full array, off‑chain reconstruction from event history becomes necessary, which may affect the feasibility of a seamless migration.
Use comments to ask for clarification. Post a solution as an answer.
No question comments on this page.