Skip to content

Base layer actions - #75

Merged
GabrielePicco merged 21 commits into
mainfrom
feat/base-layer-ix/main
Sep 3, 2025
Merged

GabrielePicco merged 21 commits into
mainfrom
feat/base-layer-ix/main

Conversation

@taco-paco

@taco-paco taco-paco commented Apr 29, 2025 •

Copy link
Copy Markdown
Contributor

Problem

What problem are you trying to solve?
Support of baselayer actions via added CallHandler endpoint. Validator would be able to call it after finalize/undelegate or just execute standalone action

Solution

How did you solve the problem?
Introduced process_call_handler entrypoint that calls a hook in destination program.

Greptile Summary

This PR introduces a CallHandler feature that enables validators to execute cross-program invocations (CPIs) to external programs after finalization/undelegate operations or as standalone actions. The implementation adds a new instruction type CallHandler (discriminator 0xf) that allows the delegation program to act as a middleware for triggering custom logic in destination programs.

Key changes include:

  • New CallHandler instruction: Added process_call_handler function in src/processor/call_handler.rs that validates validators through fees vault verification, checks escrow account PDA derivation, and performs signed CPIs using the escrow account as signer
  • Arguments and builders: Created CallHandlerArgs struct with context enum (Commit, Undelegate, Standalone), escrow index, and arbitrary data payload for flexible program interactions
  • Sequential slot validation: Modified commit state processor to enforce strict sequential ordering (slot = last_update_external_slot + 1) instead of silently skipping out-of-order commits, changing the behavior from warning to hard error
  • Test infrastructure: Added comprehensive tests for CallHandler functionality and updated existing tests to use slot value 1 instead of 100 to align with new sequential validation
  • Documentation updates: Marked slot-related fields as deprecated in favor of "nonce" terminology while maintaining backward compatibility

The CallHandler uses an escrow account pattern where the delegation program can sign for operations in external programs through deterministic PDA derivation. This enables composable DeFi workflows where delegation state changes can atomically trigger downstream actions in other programs while maintaining security boundaries through validator authentication.

Confidence score: 2/5

  • This PR introduces significant breaking changes with potential security implications that require careful review
  • Score lowered due to incomplete semantic changes (slot vs nonce), breaking behavioral changes in commit validation, and potential security issues in the CallHandler CPI mechanism
  • Pay close attention to src/processor/call_handler.rs, src/processor/commit_state.rs, src/state/delegation_metadata.rs, and tests/integration/programs/test-delegation/src/lib.rs

@taco-paco
taco-paco requested a review from GabrielePicco April 29, 2025 09:42
@taco-paco
taco-paco force-pushed the feat/base-layer-ix/main branch from 8da6d4b to fa4ac06 Compare July 28, 2025 05:16
@taco-paco
taco-paco marked this pull request as ready for review August 5, 2025 08:22
@taco-paco
taco-paco requested review from bmuddha and thlorenz August 5, 2025 08:22
@taco-paco taco-paco changed the title Action after finalization Base layer actions Aug 5, 2025

@greptile-apps greptile-apps Bot left a comment

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.

23 files reviewed, 6 comments

Edit Code Review Bot Settings | Greptile

Comment thread src/args/commit_state.rs
Comment thread tests/integration/programs/test-delegation/src/lib.rs Outdated
Comment thread src/state/delegation_metadata.rs Outdated
Comment thread src/instruction_builder/call_handler.rs Outdated
Comment thread src/processor/commit_state.rs Outdated
Comment thread src/processor/call_handler.rs Outdated

@GabrielePicco GabrielePicco left a comment

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.

Overall LGMT. Left some comments and questions to be addressed before merging

Comment thread src/instruction_builder/call_handler.rs Outdated
Comment thread src/instruction_builder/finalize_with_handler.rs Outdated
Comment thread src/processor/call_handler.rs Outdated
Comment thread tests/integration/programs/test-delegation/src/lib.rs Outdated
Comment thread src/processor/call_handler.rs Outdated
Comment thread src/processor/call_handler.rs Outdated
Comment thread src/processor/call_handler.rs Outdated
Comment thread src/processor/commit_state.rs
Comment thread src/state/delegation_metadata.rs Outdated
Comment thread src/consts.rs

@GabrielePicco GabrielePicco left a comment

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.

LGTM!
Suggested one more rename to perform before merging

Comment thread src/args/commit_state.rs Outdated
@GabrielePicco
GabrielePicco merged commit 43e1e46 into main Sep 3, 2025
3 checks passed
@GabrielePicco
GabrielePicco deleted the feat/base-layer-ix/main branch September 3, 2025 11:37
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