Skip to content

feat: csdk + ctoken #1908

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

Draft
wants to merge 6 commits into
base: jorrit/feat-opt-ctoken-mint-pinocchio
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/ci-lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@ jobs:
shell: bash
- name: Check workflow files
run: ${{ steps.get_actionlint.outputs.executable }} -color
shell: bash
shell: bash
10 changes: 6 additions & 4 deletions .github/workflows/light-examples-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,16 @@ on:
- main
paths:
- "examples/**"
- "program-tests/sdk-anchor-test/**"
- "program-tests/sdk-pinocchio-test/**"
- "sdk-libs/**"
pull_request:
branches:
- "*"
paths:
- "examples/**"
- "program-tests/sdk-anchor-test/**"
- "program-tests/sdk-pinocchio-test/**"
- "sdk-libs/**"
types:
- opened
Expand All @@ -24,8 +28,8 @@ concurrency:
cancel-in-progress: true

jobs:
system-programs:
name: system-programs
examples-tests:
name: examples-tests
if: github.event.pull_request.draft == false
runs-on: ubuntu-latest
timeout-minutes: 60
Expand All @@ -47,8 +51,6 @@ jobs:
strategy:
matrix:
include:
- program: sdk-test-program
sub-tests: '["cargo-test-sbf -p sdk-test"]'
- program: sdk-anchor-test-program
sub-tests: '["cargo-test-sbf -p sdk-anchor-test", "cargo-test-sbf -p sdk-pinocchio-test"]'

Expand Down
89 changes: 89 additions & 0 deletions .github/workflows/sdk-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
on:
push:
branches:
- main
paths:
- "sdk-tests/**"
- "sdk-libs/**"
- "program-libs/**"
- ".github/workflows/sdk-tests.yml"
pull_request:
branches:
- "*"
paths:
- "sdk-tests/**"
- "sdk-libs/**"
- "program-libs/**"
- ".github/workflows/sdk-tests.yml"
types:
- opened
- synchronize
- reopened
- ready_for_review

name: sdk-tests

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
sdk-tests:
name: sdk-tests
if: github.event.pull_request.draft == false
runs-on: warp-ubuntu-latest-x64-4x
timeout-minutes: 60

services:
redis:
image: redis:8.0.1
ports:
- 6379:6379
options: >-
--health-cmd "redis-cli ping"
--health-interval 10s
--health-timeout 5s
--health-retries 5

env:
REDIS_URL: redis://localhost:6379
RUST_MIN_STACK: 8388608

steps:
- name: Checkout sources
uses: actions/checkout@v4

- name: Setup and build
uses: ./.github/actions/setup-and-build
with:
skip-components: "redis"

- name: Build CLI
run: |
source ./scripts/devenv.sh
npx nx build @lightprotocol/zk-compression-cli

- name: Build core programs
run: |
source ./scripts/devenv.sh
npx nx build @lightprotocol/programs

- name: Build and test all sdk-tests programs
run: |
source ./scripts/devenv.sh
# Increase stack size for SBF compilation to avoid regex_automata stack overflow
export RUST_MIN_STACK=16777216
# Remove -D warnings flag for SBF compilation to avoid compilation issues
export RUSTFLAGS=""

echo "Building and testing all sdk-tests programs sequentially..."
# Build and test each program one by one to ensure .so files exist

echo "Building and testing native-compressible"
cargo-test-sbf -p native-compressible

echo "Building and testing anchor-compressible"
cargo-test-sbf -p anchor-compressible

echo "Building and testing anchor-compressible-derived"
cargo-test-sbf -p anchor-compressible-derived
33 changes: 20 additions & 13 deletions CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ This repository uses a comprehensive two-tier testing strategy:
## 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
Expand All @@ -19,6 +20,7 @@ All tests must follow these mandatory requirements:
## Transaction Log File

The light-program-test library automatically creates detailed transaction logs in:

```
target/light_program_test.log
```
Expand All @@ -33,6 +35,7 @@ target/light_program_test.log
### Configuration

Enhanced logging is enabled by default. To disable:

```rust
let mut config = ProgramTestConfig::default();
config.enhanced_logging.enabled = false;
Expand All @@ -45,6 +48,7 @@ Console output requires `RUST_BACKTRACE` environment variable and can be control
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
Expand All @@ -55,34 +59,37 @@ The log file is automatically placed in the cargo workspace target directory, ma
- inclusion of instruction data in an input compressed account data hash counts as checked

### Account checks

- ownership is checked
- cpis should use hardcoded

### Compressed accounts

- 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
- 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
- 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

-
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.
- # 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.
- 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.
> > > > > > > eeb1ded20 (feat: ctoken pinocchio)
Loading