Skip to main content

V2 Improvements

v1v2
CU consumptionBaselineUp to 70% less
Merkle tree typeConcurrentBatched
State tree depth26 (~67M leaves)32 (~4B leaves)
Address tree depth2640
Address tree accountsSeparate tree + queueSingle batch tree

Update Cargo.toml

In 0.17.x onward, v2 is a default feature of light-sdk. Make sure it stays enabled.
When you specify features = [...] in Cargo.toml, Cargo disables default features. If you need extra features like keccak or anchor, either keep defaults explicitly or add v2 to your features list:
Without v2, add_system_accounts_v2 and cpi::v2 are not available.
On-chain program:
For Anchor programs, add the anchor feature:
Off-chain client:

Update imports

Update address derivation

The derive_address function signature remains the same, but the internal derivation logic differs. No code changes needed beyond updating the import path.

Update address params

Replace into_new_address_params_packed() with into_new_address_params_assigned_packed():
The second parameter specifies the output queue index. Use Some(0) to assign the address to the first available queue.

Update tree validation

If your program validates the address tree pubkey, update the constant:

Update client-side account packing

Full v2 client example

Update client code (light-client)

Tree info methods:
Validity proofs:

View Program Examples

Program examples


Didn’t find what you were looking for?

Reach out! Telegram | email | Discord