Skip to content

Conversation

@GabrielePicco
Copy link
Contributor

@GabrielePicco GabrielePicco commented Oct 29, 2025

Summary by CodeRabbit

Release Notes

  • New Features

    • Added delegation support for ephemeral ATAs, enabling delegation workflows with undelegation callbacks.
  • Documentation

    • Expanded README with comprehensive setup guide, including prerequisites, build instructions, test procedures, and detailed program functionality overview.
  • Chores

    • Updated project metadata and transitioned to MIT license.

@coderabbitai
Copy link

coderabbitai bot commented Oct 29, 2025

Walkthrough

This PR introduces delegation functionality to the Ephemeral SPL Token program by adding new processors for delegating and undelegating ephemeral ATAs, integrating with Pinocchio-based ephemeral rollups infrastructure. Workspace metadata is updated to reflect MagicBlock Labs ownership, and new dependencies are added to support the delegation operations. Documentation is expanded with build, test, and architecture details. Integration tests validate the delegation and undelegation workflows.

Changes

Cohort / File(s) Summary
Workspace and Metadata
Cargo.toml, README.md
Updated workspace authors, repository URL, and license (Apache-2.0 → MIT). Added dependencies: ephemeral-rollups-pinocchio, solana-program, solana-account, spl-token-interface, magicblock-delegation-program. Expanded README with architecture overview, prerequisites, build/test instructions, and key functionalities.
API Layer
e-token-api/Cargo.toml, e-token-api/src/lib.rs
Added ephemeral-rollups-pinocchio dependency. Re-exported DELEGATION_PROGRAM_ID constant; added instruction discriminators DELEGATE_EPHEMERAL_ATA (4) and UNDELEGATE_EPHEMERAL_ATA (5).
Core Program Manifest
e-token/Cargo.toml
Added workspace dependencies: ephemeral-rollups-pinocchio, pinocchio-token, solana-account, spl-token-interface. Added dev dependencies: solana-program, magicblock-delegation-program.
Entrypoint
e-token/src/entrypoint.rs
Added three new instruction discriminator cases (4, 5, 196) dispatching to process_delegate_ephemeral_ata, process_undelegate_ephemeral_ata, and process_undelegation_callback with conditional logging.
Processor Modules
e-token/src/processor/delegate_ephemeral_ata.rs, e-token/src/processor/undelegate_ephemeral_ata.rs, e-token/src/processor/undelegation_callback.rs
Three new processor files implementing delegation logic: DelegateArgs struct parsing (bump and optional validator); PDA derivation and validation; delegation/undelegation account orchestration with ephemeral-rollups-pinocchio instructions.
Processor Registration
e-token/src/processor/mod.rs
Added module declarations and public re-exports for the three new processors.
Integration Tests
e-token/tests/delegate_ephemeral_ata.rs, e-token/tests/undelegation_callback.rs
Two new test files exercising delegation and undelegation workflows: program setup, account initialization, PDA derivation, transaction construction and submission, state verification.
Test Utilities
e-token/tests/utils.rs
Added #[allow(dead_code)] attribute to TokenSetup struct.

Sequence Diagram(s)

sequenceDiagram
    participant User as User/Payer
    participant EToken as e-token Program
    participant DLP as Delegation Program
    participant Pinocchio as ephemeral-rollups-pinocchio
    
    rect rgb(230, 240, 255)
    Note over User,Pinocchio: Delegation Flow
    User->>EToken: DelegateEphemeralAta Instruction<br/>(payer, ephemeral_ata, validator)
    activate EToken
    EToken->>EToken: Parse DelegateArgs<br/>(bump, validator)
    EToken->>EToken: Validate accounts &<br/>derive PDA seeds
    EToken->>Pinocchio: delegate_account()<br/>(ephemeral_ata, config)
    activate Pinocchio
    Pinocchio->>DLP: Change account owner<br/>to delegation program
    deactivate Pinocchio
    EToken-->>User: Success
    deactivate EToken
    end
    
    rect rgb(240, 230, 255)
    Note over User,Pinocchio: Undelegation Flow
    DLP->>EToken: UndelegationCallback Instruction<br/>(delegated_ata, buffer, payer)
    activate EToken
    EToken->>EToken: Validate accounts<br/>&& verify PDA
    EToken->>Pinocchio: undelegate()<br/>(delegated_acc, buffer_acc, payer)
    activate Pinocchio
    Pinocchio->>EToken: Restore account ownership<br/>to e-token program
    deactivate Pinocchio
    EToken-->>DLP: Success
    deactivate EToken
    end
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

  • e-token/src/processor/delegate_ephemeral_ata.rs: New processor with DelegateArgs parsing, PDA derivation, and cross-program invocation to Pinocchio; requires careful validation of account structure and instruction data format.
  • e-token/src/processor/undelegate_ephemeral_ata.rs: Undelegation logic with PDA verification and commit/undelegate orchestration; PDA derivation correctness is critical.
  • e-token/tests/delegate_ephemeral_ata.rs and e-token/tests/undelegation_callback.rs: Complex integration tests with multiple PDA derivations, program deployments, and delegation record setup; verify account state transitions and test environment configuration.
  • e-token/src/entrypoint.rs: New instruction dispatch cases; verify discriminator mappings and processor wiring.
  • Dependency compatibility: New Pinocchio and delegation program integrations; verify version alignment and API conformance.

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: ASSERTIVE

Plan: Free

📥 Commits

Reviewing files that changed from the base of the PR and between d44d453 and baa1087.

⛔ Files ignored due to path filters (2)
  • Cargo.lock is excluded by !**/*.lock
  • e-token/tests/fixtures/dlp.so is excluded by !**/*.so
📒 Files selected for processing (13)
  • Cargo.toml (3 hunks)
  • README.md (1 hunks)
  • e-token-api/Cargo.toml (1 hunks)
  • e-token-api/src/lib.rs (2 hunks)
  • e-token/Cargo.toml (2 hunks)
  • e-token/src/entrypoint.rs (1 hunks)
  • e-token/src/processor/delegate_ephemeral_ata.rs (1 hunks)
  • e-token/src/processor/mod.rs (1 hunks)
  • e-token/src/processor/undelegate_ephemeral_ata.rs (1 hunks)
  • e-token/src/processor/undelegation_callback.rs (1 hunks)
  • e-token/tests/delegate_ephemeral_ata.rs (1 hunks)
  • e-token/tests/undelegation_callback.rs (1 hunks)
  • e-token/tests/utils.rs (1 hunks)

Note

🎁 Summarized by CodeRabbit Free

Your organization is on the Free plan. CodeRabbit will generate a high-level summary and a walkthrough for each pull request. For a comprehensive line-by-line review, please upgrade your subscription to CodeRabbit Pro by visiting https://app.coderabbit.ai/login.

Comment @coderabbitai help to get the list of available commands and usage tips.

@GabrielePicco GabrielePicco merged commit 67f3489 into main Oct 29, 2025
2 checks passed
@GabrielePicco GabrielePicco deleted the feat/fix-delegation-undelegation branch October 29, 2025 03:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants