Repository navigation
Description
Goal
After #255 separates the repository into program, interface, and client crates, promote the current v2 implementation to the root module layout. Move the old implementation under legacy so its purpose is explicit.
This is a structural change only. Move files, update module declarations and imports, and make the minimum compilation fixes required by those moves. Keep code-level cleanup and refactoring for separate issues.
Target interface structure
interface/src/
├── lib.rs
├── args/ # current v2 instruction arguments
├── instruction.rs # current v2 instruction enum
├── instruction_builder/ # current v2 builders
├── pda.rs # current v2 PDAs
├── state/ # current v2 account layouts
├── compact/ # shared wire types from #255
├── diff/ # shared diff format from #255
├── compat.rs # temporarily shared by v2 and legacy code
├── error.rs # shared program errors
├── requires.rs # temporarily shared validation helpers
└── legacy/
├── mod.rs
├── account_size_class.rs
├── args/
├── consts.rs
├── cpi/
├── discriminator.rs
├── instruction_builder/
├── pda.rs
├── pod_view.rs
└── state/
Promote the modules under interface/src/v2/ to the interface root. Move the old root modules that describe the v1 protocol under public interface::legacy.
The client code separated by #255, including encryption and off-chain diff generation, is not part of this module move.
Target program structure
program/src/
├── lib.rs
├── entrypoint.rs
├── cu.rs
├── processor/ # current v2 processors
│ ├── mod.rs
│ ├── bootstrap/
│ └── fraud_proofs/
└── legacy/
├── mod.rs
└── processor/ # current v1 processors
├── mod.rs
├── fast/
└── ...
Promote program/src/v2/processor/ to program/src/processor/. Move the old program/src/processor/ implementation to program/src/legacy/processor/.
Update instruction dispatch so one-byte instructions use the v2 processor and old discriminator-based instructions use legacy::processor. Preserve the root entrypoint functions used by deployment and tests.
Required path changes
- Replace v2
interface::v2::...imports with the corresponding interface-root paths. - Replace old interface-root v1 imports with
interface::legacy::...paths. - Replace v2 program
v2::processorpaths withprocessorpaths. - Replace old program
processorpaths withlegacy::processorpaths. - Keep current v2 processors' dependencies on legacy delegation accounts, PDA helpers, and processor utilities. Point those imports to
legacy; do not redesign them here. - Keep existing exported macro names. Update only their internal
$cratepaths when required by the move. - Do not add a temporary
v2compatibility module or aliases.
Boundaries
- Keep
DlpV2Instructionand all other types, functions, tests, fixtures, comments, and instruction names unchanged unless a module path must change for compilation. - Do not refactor implementations or extract shared helpers.
- Do not replace the v2 processors' temporary use of legacy
DelegationRecordorDelegationMetadatain this issue. - Preserve the program ID, instruction tags, serialized arguments, account layouts, PDA seeds, error values, feature behavior, and generated instructions.
- Keep
compat,error, andrequiresat the interface root while both v2 and legacy code depend on them. Their cleanup belongs in later issues.
Verification
- Production source contains no
mod v2,pub mod v2,crate::v2, or interface::v2paths. - Formatting and Clippy checks pass.
- The workspace builds.
- Interface tests pass with default features and with
backward-compat. cargo test-sbf --features unit_test_configpasses.- The SBF build passes.
- The final diff contains file moves, module declarations, imports, and necessary path corrections only.
Activity
refactor: Reorganize repository crates (#259)
[-]Move v1 code under legacy and make v2 modules primary[/-][+]Move v1 code under legacy and promote v2 modules to the root[/+]