- 
                Notifications
    
You must be signed in to change notification settings  - Fork 19
 
fix: allow users to directly set AccountMeta(shorter version) for base layer action #561
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
fix: allow users to directly set AccountMeta(shorter version) for base layer action #561
Conversation
          Manual Deploy AvailableYou can trigger a manual deploy of this PR branch to testnet: Alternative: Comment  
 Comment updated automatically when the PR is synchronized.  | 
    
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.
14 files reviewed, 1 comment
Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
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.
LGTM aside from the minor comment nit.
I trust that there are enough tests that guarantee the new behavior.
| committee.into(), | ||
| ShortAccountMeta { | ||
| pubkey: *transfer_destination.key, | ||
| is_writable: true, // writable on base chain | 
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.
I'm not sure those  comments are needed, just put a Rust doc  on top of ShortAccountMeta::is_writable that explains that this refers to main chain.
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.
Sure, done
| committee.into(), | ||
| ShortAccountMeta { | ||
| pubkey: *destination_program.key, | ||
| is_writable: true, // writable on base chain | 
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.
ditto redundant comment
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.
done
…account-metas' into feat/base-layer-ix/actions-with-account-metas
* thlorenz/chainlink: (59 commits) fix: sync accountsdb slot after ledger replay fix: for failed txns use meta defaults that are explorer compatible chore: update progress chore: rename test to proper name chore: allow overriding ephem port while running single test chore: all non-skipped ledger tests passing in parallel chore: true random port picking for ledger tests chore: initial changes to allow running ledger tests in parallel feat: ledger test validators start at different ports chore: fix compile issue due to merge chore: fix merge issues for test-integration chore: fix more merge issues to build validator chore: fix merge conflicts in cargo lock chore: ignore undelegate between restarts test for now chore: fix resume strategies test chore: fix restore ledger with new keypair test chore: fix timestamp ledger test chore: fix ledger account flush test fix: allow users to directly set AccountMeta(shorter version) for base layer action (#561) Hotfix: don't clone and cache not existing accounts (#560) ...
Reason
Prior, to form Base layer action users had to include in ER transaction list of accounts they would use in it(Base layer action), now users can form actions using meta information which they could pass as arguments or store for actions in some other account.
Initial apporach had a flaw:
Say user wanted to perform an action: transfer from A to B on base chain. Now say, B is not delegated. This would mean that user would have to explicitly send account B in ER transaction as writable. This would result in him getting an error since we allow only delegated accounts to be writable
Right now user can write:
When validator will send this action to Base chain send account B as writable.
Implementation details
To avoid false hopes from the user instead of
AccountMetawe useShortAccountMeta, where latter doesn't haveis_signerfield.Since we can only sign on behalf of validator we don't allow user to provide is_signer flag, meaning that it is always false.
Additionally, some unnecessary copying in magic-program was removed
Greptile Overview
Updated On: 2025-10-02 16:07:56 UTC
Summary
This PR introduces a significant architectural improvement to the MagicBlock validator by allowing users to directly specify account metadata (`ShortAccountMeta`) for base layer actions instead of requiring all accounts to be included in Ephemeral Runtime (ER) transactions. Previously, users faced a critical limitation: when performing actions like transfers to non-delegated accounts, they had to include the destination account as writable in the ER transaction, which would fail validation since only delegated accounts can be writable in ER transactions.The solution introduces
ShortAccountMeta, a simplified version ofAccountMetathat excludes theis_signerfield (since the validator always signs on behalf of users). This allows users to specify "when you execute this action on the base chain, include account B as writable" without having to make account B writable in the ER transaction itself.The changes span multiple components:
BaseActionArgsnow usesVec<ShortAccountMeta>andPubkeyfor destination program instead of indicesShortAccountMetastruct with proper conversion traits fromAccountMetaandAccountInfoThe refactoring also includes consolidation of the schedule base intent processing logic, moving functionality from a separate processor module directly into the main processing flow, and cleanup of debug statements and typo fixes in test programs.
Important Files Changed
Changed Files
magicblock-magic-program-api/src/args.rsShortAccountMetastruct and updatingBaseActionArgsto use direct metadata instead of indicesprograms/magicblock/src/magic_scheduled_base_intent.rsShortAccountMetadirectly and remove account validation during constructionprograms/magicblock/src/schedule_transactions/process_schedule_base_intent.rstest-integration/programs/flexi-counter/src/processor/schedule_intent.rsShortAccountMetaconversions for better base layer action flexibilitytest-integration/programs/flexi-counter/src/processor/schedule_redelegation_intent.rsShortAccountMetainstead ofAccountInfoclones for redelegation actionsprograms/magicblock/src/utils/accounts.rsShortAccountMetafunctionality moved to args modulemagicblock-committor-service/src/tasks/mod.rsShortAccountMetafrom args moduletest-integration/test-committor-service/tests/test_transaction_preparator.rsShortAccountMetalocation in args moduleprograms/magicblock/src/schedule_transactions/mod.rsprograms/magicblock/src/schedule_transactions/schedule_base_intent_processor.rstest-integration/Cargo.tomlShortAccountMetafunctionalitytest-integration/programs/flexi-counter/src/instruction.rstest-integration/programs/flexi-counter/src/processor.rstest-integration/test-schedule-intent/tests/test_schedule_intents.rsConfidence score: 4/5
is_signerfield) and comprehensive test coveragemagicblock-magic-program-api/src/args.rsandprograms/magicblock/src/magic_scheduled_base_intent.rsfor core API changesSequence Diagram
sequenceDiagram participant User participant "ER Program" participant "MagicBlock Program" participant "Base Layer" participant "DLP (Delegation Program)" User->>+"ER Program": "Create intent with ShortAccountMetas" "ER Program"->>+"MagicBlock Program": "process_schedule_base_intent(args with ShortAccountMetas)" "MagicBlock Program"->>+"MagicBlock Program": "BaseAction::try_from_args()" Note over "MagicBlock Program": "Validate escrow authority signature" Note over "MagicBlock Program": "Create BaseAction with ShortAccountMetas" "MagicBlock Program"-->>-"MagicBlock Program": "BaseAction created" "MagicBlock Program"->>+"MagicBlock Program": "ScheduledBaseIntent::try_new()" Note over "MagicBlock Program": "Create scheduled intent with base actions" "MagicBlock Program"-->>-"MagicBlock Program": "Intent scheduled" alt Undelegate Intent "MagicBlock Program"->>+DLP: "set_account_owner_to_delegation_program()" Note over DLP: "Make accounts immutable in validator" DLP-->>-"MagicBlock Program": "Ownership changed" end "MagicBlock Program"->>+"MagicContext": "add_scheduled_action()" "MagicContext"-->>-"MagicBlock Program": "Action added" "MagicBlock Program"-->>-"ER Program": "Intent scheduled" "ER Program"-->>-User: "Transaction confirmed" Note over "Base Layer": "Later, committor service processes intent" "Base Layer"->>+"Base Layer": "ArgsTask::BaseAction execution" Note over "Base Layer": "Convert ShortAccountMetas to AccountMetas" Note over "Base Layer": "is_signer always set to false" "Base Layer"->>+"Target Program": "dlp::call_handler with AccountMetas" "Target Program"-->>-"Base Layer": "Action executed" "Base Layer"-->>-"Base Layer": "Transaction completed"