-
Notifications
You must be signed in to change notification settings - Fork 92
feat: ctoken pinocchio #1861
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
feat: ctoken pinocchio #1861
Changes from all commits
f9f2aa5
0c86cdc
ba53e75
a514e0c
f38a830
38a9f73
76ccfcc
7e6b3d3
ccbf115
283cb9d
5601be6
dddbe4d
9edc7b9
573f7e1
32ff2ab
2e21277
f702f3d
33e0fe5
3f14b16
7c7514b
42968bc
bfdbeb8
e9775ca
2d14a1c
3aec9a9
76defb8
e4b66d1
9d4cd3b
849f272
2e57db9
81a7c5c
b48bb44
fdc9690
df7e5f1
5d8b609
b5b5282
0744425
07ab785
d021728
8ac478e
eee1fd9
6879fac
0c2e35e
f7e33e8
aa4e8be
7c4c97a
685e67a
c047123
f24c035
484d572
865d444
4e6694e
df08751
15eee14
51bade3
c3c863c
706acae
4df85c4
fff4278
9e62bcb
315e6aa
36ce2af
d65e8d5
5f932ef
c7bfde4
ee4f8f3
fdffd43
5fa296b
29dfcc0
0f83953
10cacd5
5d181c1
27afdd0
2f5044e
267f645
e84d22b
a317364
02fea74
efe9f4f
ec4b14d
d7fe036
3820755
24b82dd
1f8f96f
96898cf
0ae7dda
1e15d5d
a1543de
0782e30
0bd1e18
c70f0ff
8ad8b33
5d7880f
e007452
4ce0c99
40c3650
04c5b1d
89c0691
108b0a3
65f86a9
6b19a14
5b35cab
c1a895a
a28f947
666ec07
0440125
f866b67
97bdd2c
02a5660
c909b7f
fe5e833
9c1e3b6
34804fd
618d72b
4628e0e
c2382ee
cc96e81
0432dbb
ffd23e2
47990ca
e56c54a
79fb69e
66f0840
fbe5d03
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
| 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. | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| ## 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
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 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
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||
| ### Compressed accounts | ||||||||||||||||||||||
|
Comment on lines
+74
to
+78
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 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
Suggested change
🧰 Tools🪛 markdownlint-cli2 (0.17.2)57-57: Heading levels should only increment by one level at a time (MD001, heading-increment) 🤖 Prompt for AI Agents |
||||||||||||||||||||||
| - 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. | ||||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧩 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:
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