Repository navigation
Base layer actions - #75
Merged
Merged
Conversation
taco-paco
force-pushed
the
feat/base-layer-ix/main
branch
from
July 28, 2025 05:16
8da6d4b to
fa4ac06
Compare
GabrielePicco
requested changes
Aug 26, 2025
GabrielePicco
left a comment
Contributor
There was a problem hiding this comment.
Overall LGMT. Left some comments and questions to be addressed before merging
GabrielePicco
approved these changes
Aug 27, 2025
GabrielePicco
left a comment
Contributor
There was a problem hiding this comment.
LGTM!
Suggested one more rename to perform before merging
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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_handlerentrypoint 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:
process_call_handlerfunction insrc/processor/call_handler.rsthat validates validators through fees vault verification, checks escrow account PDA derivation, and performs signed CPIs using the escrow account as signerCallHandlerArgsstruct with context enum (Commit, Undelegate, Standalone), escrow index, and arbitrary data payload for flexible program interactionsslot = last_update_external_slot + 1) instead of silently skipping out-of-order commits, changing the behavior from warning to hard errorThe 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
src/processor/call_handler.rs,src/processor/commit_state.rs,src/state/delegation_metadata.rs, andtests/integration/programs/test-delegation/src/lib.rs