Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
124 commits
Select commit Hold shift + click to select a range
f9f2aa5
feat: ctoken pinocchio
ananas-block Jul 2, 2025
0c86cdc
refator: fn set_compressed_lamports
ananas-block Aug 21, 2025
ba53e75
feat: add create ata idempotent
ananas-block Aug 21, 2025
a514e0c
feat: add reinit cpi context ix
ananas-block Aug 21, 2025
f38a830
regenerated accounts
ananas-block Aug 21, 2025
38a9f73
chore: revert process_mint.rs changes
ananas-block Aug 21, 2025
76ccfcc
feat: ctoken to spl token transfer
ananas-block Aug 24, 2025
7e6b3d3
remove md files
ananas-block Aug 24, 2025
ccbf115
test: delegated transfer2
ananas-block Aug 25, 2025
283cb9d
cleanups, add Sha256BE
ananas-block Aug 25, 2025
5601be6
refactor: rename with_delegate -> has_delegate
ananas-block Aug 25, 2025
dddbe4d
refactor: rename TokenAccountVersion -> TokenDataVersion
ananas-block Aug 25, 2025
9edc7b9
refactor: light-ctoken-types
ananas-block Aug 25, 2025
573f7e1
format
ananas-block Aug 25, 2025
32ff2ab
refactor: unify hash fns
ananas-block Aug 25, 2025
2e21277
stash
ananas-block Aug 26, 2025
f702f3d
unify mint hashing
ananas-block Aug 26, 2025
33e0fe5
unified mint hashing
ananas-block Aug 26, 2025
3f14b16
test: mint
ananas-block Aug 26, 2025
7c7514b
feat: add top up calculation
ananas-block Aug 27, 2025
42968bc
stash refactored hashing to sha256
ananas-block Aug 27, 2025
bfdbeb8
feat: add profiling ctoken
ananas-block Aug 28, 2025
e9775ca
perf: add profiling to system program
ananas-block Aug 28, 2025
2d14a1c
stash perf
ananas-block Aug 28, 2025
3aec9a9
refactor: cpi context and add tests
ananas-block Aug 28, 2025
76defb8
cleanup
ananas-block Aug 28, 2025
e4b66d1
test: account iterator
ananas-block Aug 29, 2025
9d4cd3b
feat: CompressAndClose in transfer2
ananas-block Sep 2, 2025
849f272
feat: highlevel CompressAndClose sdk abstraction
ananas-block Sep 3, 2025
2e57db9
fix amount
ananas-block Sep 3, 2025
81a7c5c
test: compress and close sdk
ananas-block Sep 3, 2025
b48bb44
refactor: transfer2 extract_tree_accounts
ananas-block Sep 3, 2025
fdc9690
test: CompressAndClose with cpi context
ananas-block Sep 3, 2025
df7e5f1
fix tests
ananas-block Sep 4, 2025
5d8b609
refactor: transfer2 add hotpath spl -> ctoken transfer
ananas-block Sep 4, 2025
b5b5282
feat: sdk decompress full transfer2
ananas-block Sep 4, 2025
0744425
feat: Transfer2CpiAccounts
ananas-block Sep 4, 2025
07ab785
feat: mint action instruction data builder
ananas-block Sep 4, 2025
d021728
refactor: compressible ext
ananas-block Sep 5, 2025
8ac478e
fix: sdk token tests
ananas-block Sep 8, 2025
eee1fd9
stash sdk token tests fix
ananas-block Sep 8, 2025
6879fac
feat: LightProgramTest add pre context
ananas-block Sep 8, 2025
0c2e35e
stash adapt asserts
ananas-block Sep 8, 2025
f7e33e8
feat: add claim ix
ananas-block Sep 8, 2025
aa4e8be
feat: add withdrawal instruction
ananas-block Sep 8, 2025
7c4c97a
stash refactor tokenmetadata for spl compatibility
ananas-block Sep 10, 2025
685e67a
refactor sdks
ananas-block Sep 10, 2025
c047123
fix tests
ananas-block Sep 10, 2025
f24c035
stash
ananas-block Sep 10, 2025
484d572
feat: add sha256 token data hashing
ananas-block Sep 10, 2025
865d444
chore: remove cpi context pubkey from Transfer2Config
ananas-block Sep 10, 2025
4e6694e
refactor: tests create compressible tests
ananas-block Sep 10, 2025
df08751
test: claim_and_compress
ananas-block Sep 11, 2025
15eee14
feat: add compression on forwarding slots to LightProgramTest
ananas-block Sep 11, 2025
51bade3
refactor: CompressibleExtension include rent config
ananas-block Sep 11, 2025
c3c863c
stash config
ananas-block Sep 12, 2025
706acae
stash config counter
ananas-block Sep 12, 2025
4df85c4
added some compressible registry instructions stash
ananas-block Sep 12, 2025
fff4278
stash registry program withdraw from pool
ananas-block Sep 12, 2025
9e62bcb
ctoken program remove withdraw
ananas-block Sep 12, 2025
315e6aa
add claim to registry
ananas-block Sep 12, 2025
36ce2af
add registry compress and close wrapper
ananas-block Sep 12, 2025
d65e8d5
stash fixed account.rs tests
ananas-block Sep 13, 2025
5f932ef
compress and close with registry program
ananas-block Sep 13, 2025
c7bfde4
feat: claim with registry
ananas-block Sep 13, 2025
ee4f8f3
Revert "ctoken program remove withdraw"
ananas-block Sep 13, 2025
fdffd43
fix: withdraw functing pool
ananas-block Sep 13, 2025
5fa296b
fix sdk-token-test
ananas-block Sep 13, 2025
29dfcc0
feat: zero copy impl ZeroCopyAt for array vec
ananas-block Sep 14, 2025
0f83953
feat: add compressible to ctoken pubkey
ananas-block Sep 14, 2025
10cacd5
refactor: rent authority, recipient and config account seeds
ananas-block Sep 14, 2025
5d181c1
feat: enable custom compressible rent payer
ananas-block Sep 14, 2025
27afdd0
chore: add create mint address tree check
ananas-block Sep 15, 2025
2f5044e
bump pinocchio deps to 0.9
ananas-block Sep 15, 2025
267f645
refactored create token account accounts
ananas-block Sep 15, 2025
e84d22b
stash create token account refactor
ananas-block Sep 15, 2025
a317364
stash add docs
ananas-block Sep 15, 2025
02fea74
refactor: move lamport transfer functions into shared
ananas-block Sep 15, 2025
efe9f4f
refactor: add token version to compressible extension
ananas-block Sep 15, 2025
ec4b14d
feat: add config state check
ananas-block Sep 15, 2025
d7fe036
reorg docs
ananas-block Sep 15, 2025
3820755
stash add close token account doc
ananas-block Sep 16, 2025
24b82dd
refactor: add rent recipient account to compress and close and close …
ananas-block Sep 16, 2025
1f8f96f
feat: DOCS.md
ananas-block Sep 16, 2025
96898cf
fix: transfer compression incentive correctly
ananas-block Sep 16, 2025
0ae7dda
stash
ananas-block Sep 17, 2025
1e15d5d
stash
ananas-block Sep 17, 2025
a1543de
feat: enforce no top up beyond max epochs
ananas-block Sep 17, 2025
0782e30
perf: multi lamports transfer
ananas-block Sep 17, 2025
0bd1e18
cleanup compressible naming
ananas-block Sep 17, 2025
c70f0ff
feat: update rent config in claim
ananas-block Sep 18, 2025
8ad8b33
add decompressed transfer docs
ananas-block Sep 18, 2025
5d7880f
add withdraw funding doc
ananas-block Sep 18, 2025
e007452
adapt error docs
ananas-block Sep 18, 2025
4ce0c99
stash transfer2 docs and refactor
ananas-block Sep 18, 2025
40c3650
refactor: native compression to ctoken and split it up into folder
ananas-block Sep 18, 2025
04c5b1d
feat: partly functional transfer2 tests
ananas-block Sep 19, 2025
89c0691
refactor: light-ctoken-types
ananas-block Sep 19, 2025
108b0a3
stash mint to refactor
ananas-block Sep 19, 2025
65f86a9
refactor mint action accounts add Address tree
ananas-block Sep 19, 2025
6b19a14
rename is_decompressed -> spl_mint_initialized
ananas-block Sep 19, 2025
5b35cab
feat: check authority unit test
ananas-block Sep 19, 2025
c1a895a
test: rnd mint action AccountsConfig
ananas-block Sep 19, 2025
a28f947
refactor: QueueIndices, AccountsConfig
ananas-block Sep 20, 2025
666ec07
rename CompressedToken remainders to CToken
ananas-block Sep 20, 2025
0440125
remove dead code
ananas-block Sep 20, 2025
f866b67
renaming decompressed to ctoken
ananas-block Sep 20, 2025
97bdd2c
stash tests and refactors
ananas-block Sep 20, 2025
02a5660
add randomized borsh zero copy mint test
ananas-block Sep 20, 2025
c909b7f
stash refactor mint action borsh instead of zero copy mut
ananas-block Sep 20, 2025
fe5e833
stash review refactors
ananas-block Sep 21, 2025
9c1e3b6
test: add token data constant test cases
ananas-block Sep 21, 2025
34804fd
implement todos and cleanups
ananas-block Sep 21, 2025
618d72b
add registry functional and failing tests
ananas-block Sep 21, 2025
4628e0e
test mint action failing
ananas-block Sep 21, 2025
c2382ee
test: functional_all_in_one_instruction
ananas-block Sep 21, 2025
cc96e81
add assert_mint_action
ananas-block Sep 21, 2025
0432dbb
test: add randomized mint action test and fix multipl mint to bug
ananas-block Sep 22, 2025
ffd23e2
add add metadata keys
ananas-block Sep 22, 2025
47990ca
add functional compress decompress ctokens
ananas-block Sep 22, 2025
e56c54a
stash transfer2 tests
ananas-block Sep 22, 2025
79fb69e
account compression program add error logging
ananas-block Sep 24, 2025
66f0840
stash
ananas-block Sep 25, 2025
fbe5d03
refactor: add root index placeholder to mint action ix data
ananas-block Oct 7, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
40 changes: 0 additions & 40 deletions .cargo/config.toml

This file was deleted.

2 changes: 1 addition & 1 deletion .github/workflows/light-examples-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ jobs:
matrix:
include:
- program: sdk-test-program
sub-tests: '["cargo-test-sbf -p sdk-test"]'
sub-tests: '["cargo-test-sbf -p sdk-native-test"]'
- program: sdk-anchor-test-program
sub-tests: '["cargo-test-sbf -p sdk-anchor-test", "cargo-test-sbf -p sdk-pinocchio-test"]'

Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ jobs:
cargo test -p aligned-sized
cargo test -p light-hasher --all-features
cargo test -p light-compressed-account --all-features
cargo test -p light-compressed-account --features new-unique
cargo test -p light-account-checks --all-features
cargo test -p light-verifier --all-features
cargo test -p light-merkle-tree-metadata --all-features
Expand All @@ -71,7 +72,7 @@ jobs:
cargo test -p light-sdk
cargo test -p light-program-test
cargo test -p light-client
cargo test-sbf -p client-test
cargo test -p client-test
cargo test -p light-sparse-merkle-tree
cargo test -p light-batched-merkle-tree --features test-only -- --skip test_simulate_transactions --skip test_e2e

Expand Down
105 changes: 105 additions & 0 deletions CLAUDE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@



# Repository Structure
1. Solana programs (programs/*)
2. crates used in programs (program-libs/)
3. integration tests and test utilities for programs (program-tests)
4. sdks for programs (sdk-libs/)
5. integration tests for sdks (sdk-tests/)
6. circuits used in programs, prover server, and rust prover client crate (prover/)
7. forester server (forester/)






# Testing

This repository uses a comprehensive two-tier testing strategy:

- **[Unit Testing Guide](./UNIT_TESTING.md)** - For testing individual functions in isolation using mock account infos. Tests are located in `tests/` directories within each crate.

- **[Integration Testing Guide](./INTEGRATION_TESTING.md)** - For testing complete program workflows using full SVM simulation. Tests are located in the `program-tests/` directory.

Comment on lines +22 to +25
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

🧩 Analysis chain

Verify that referenced docs exist and links resolve.

Ensure UNIT_TESTING.md and INTEGRATION_TESTING.md exist at these paths; prevent dead links.


🏁 Script executed:

#!/bin/bash
# Verify referenced guides and example test locations exist.

set -euo pipefail

echo "Checking guides..."
fd -a '^UNIT_TESTING\.md$' -HI | sed 's/^/ - /'
fd -a '^INTEGRATION_TESTING\.md$' -HI | sed 's/^/ - /'

echo "Checking for crate-level tests/ directories..."
fd -Ht directory '^tests$' | sed 's/^/ - /'

echo "Checking program-tests/ directory..."
fd -a '^program-tests$' -HI | sed 's/^/ - /'

Length of output: 1398


Broken links — UNIT_TESTING.md and INTEGRATION_TESTING.md are missing

CLAUDE.md (lines 22–25) links ./UNIT_TESTING.md and ./INTEGRATION_TESTING.md but those files were not found (fd returned no matches); program-tests/ exists and there are many crate-level tests. Add the two guide files at the repo root or update CLAUDE.md to point to the correct locations so the links resolve.

🤖 Prompt for AI Agents
In CLAUDE.md around lines 22 to 25, the links to ./UNIT_TESTING.md and
./INTEGRATION_TESTING.md are broken because those files don't exist; either add
UNIT_TESTING.md and INTEGRATION_TESTING.md at the repo root with the described
guides, or update the links to point to the actual locations (e.g., crate-level
tests or program-tests/) and adjust the link text accordingly so they resolve
correctly.

## Key Testing Requirements

All tests must follow these mandatory requirements:
- **Functional test for every usage flow**
- **Failing test for every error condition**
- **Complete output verification** with single `assert_eq!` against expected structs
- **1k iteration randomized tests** for complex functions and ZeroCopy structs

# Debugging with LightProgramTest

## Transaction Log File

The light-program-test library automatically creates detailed transaction logs in:
```
target/light_program_test.log
```

### Features

- **Always enabled**: Logs are written to file regardless of environment variables
- **Clean format**: Plain text without ANSI color codes for easy reading and processing
- **Session-based**: Each test session starts with a timestamp header, transactions append to the same file
- **Comprehensive details**: Includes transaction signatures, fees, compute usage, instruction hierarchies, Light Protocol instruction parsing, and compressed account information

### Configuration

Enhanced logging is enabled by default. To disable:
```rust
let mut config = ProgramTestConfig::default();
config.enhanced_logging.enabled = false;
```

Console output requires `RUST_BACKTRACE` environment variable and can be controlled separately from file logging.

### Log File Location

The log file is automatically placed in the cargo workspace target directory, making it consistent across different test environments and working directories.

# Program Performance
- send bump seeds
- avoid deriving addresses
- avoid vectors stack over heap use ArrayVec

# Program Security

- every input (instruction data and account infos) must be checked
- inclusion of instruction data in an input compressed account data hash counts as checked

### Account checks
- ownership is checked
- cpis should use hardcoded

Comment on lines +74 to +77
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Incomplete bullet and heading level jump under “Account checks”

The bullet “cpis should use hardcoded” is unfinished, and the heading jumps from H1 to H3 (MD001). Clarify the guidance and fix the heading level.

Apply this diff:

-### Account checks
-- ownership is checked
-- cpis should use hardcoded
+## Account checks
+- Account ownership must be verified before any read or write.
+- CPIs must use hardcoded program IDs and fixed account indices to avoid dynamic resolution.
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
### Account checks
- ownership is checked
- cpis should use hardcoded
## Account checks
- Account ownership must be verified before any read or write.
- CPIs must use hardcoded program IDs and fixed account indices to avoid dynamic resolution.
🤖 Prompt for AI Agents
In CLAUDE.md around lines 57 to 60, the "Account checks" section has an
incomplete bullet "cpis should use hardcoded" and an incorrect heading level
jump; update the heading to the appropriate level (e.g., change H3 to H2 or make
surrounding headings consistent) and replace the incomplete bullet with a clear,
complete instruction such as "CPIs should use hardcoded values for X and Y to
ensure Z" (tailor X/Y/Z to the intended configuration), ensuring punctuation and
parallel structure with the other bullets.

### Compressed accounts
Comment on lines +74 to +78
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Complete the “Account checks” bullet.

“cpis should use hardcoded” is incomplete. Clarify what must be hardcoded (program IDs / indexes).

-### Account checks
-- ownership is checked
-- cpis should use hardcoded
+### Account checks
+- Verify ownership for all accounts you read or write.
+- CPIs should use hardcoded program IDs and fixed account indices wherever feasible.
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
### Account checks
- ownership is checked
- cpis should use hardcoded
### Compressed accounts
### Account checks
- Verify ownership for all accounts you read or write.
- CPIs should use hardcoded program IDs and fixed account indices wherever feasible.
### Compressed accounts
🧰 Tools
🪛 markdownlint-cli2 (0.17.2)

57-57: Heading levels should only increment by one level at a time
Expected: h2; Actual: h3

(MD001, heading-increment)

🤖 Prompt for AI Agents
In CLAUDE.md around lines 57 to 61, the "Account checks" bullet "cpis should use
hardcoded" is incomplete; update it to explicitly state that CPI targets must
reference hardcoded program IDs and fixed account index positions (e.g., use
explicit program IDs and stable account indices for CPIs rather than dynamic
resolution), and reword the bullet into a clear sentence such as "CPIs must use
hardcoded program IDs and fixed account indexes to avoid dynamic account
resolution." Ensure the other "ownership is checked" bullet is similarly a full
sentence like "Account ownership must be verified" for consistency.

- the program id is the owner of the compressed account
- data hash must be computed in the owning program
- all data that is in an input compressed account is checked implicitly by inclusion in the data hash, the data hash is part of the compressed account hash that is in the Merkle tree or queue which we prove inclusion in by zkp or index
- input compressed account
- is existing state
- validity is proven by index (zkp is None) or zkp
- no data is sent to the system program
- data hash must be computed in the owning program
- output compressed account
- this is new state, no validity proof
- data hash must be computed in the owning program
- no changes to data after data hash has been computed
- minimize use of instruction data, ie do not send data twice.
1. example, owner pubkey
if a compressed account has an owner pubkey field which should be a tx signer, send it as signer account info, set it in the custom program, and do not sending it as instruction data. No comparison in the program is required.
2. example, values from accounts

-

- a compressed account the state update is atomic through the cpi to the light system program, writes to the cpi context can produce non atomic transactions if solana accounts are involved and instantly updated for compressed accounts atomicity still applies, in case that a written cpi context account is not executed the state update is never actually applied only prepared.


# Zero Copies
- the derive macros ZeroCopy and ZeroCopyMut derive zero copy deserialization methods and should be used in programs
- in client code borsh is preferable
- ZeroCopy is borsh compatible
- Z and Z*Mut structs are derived by the ZeroCopy and ZeroCopyMut macros and cannot be searched with grep or rg, search for the non prefixed struct instead the zero copy struct has the same structure with zero copy types.
Loading
Loading