-
Notifications
You must be signed in to change notification settings - Fork 40
feat: Handle post delegation actions: detect actions, parse and execute on the ER #999
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
base: master
Are you sure you want to change the base?
Changes from all commits
1014cde
d17162a
d219a76
7b3ec82
30d45fc
b0163a8
102b6a8
41a5eb1
a45f7a6
ccfda83
7f916ce
60d8e53
d96f590
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -19,7 +19,9 @@ use magicblock_committor_service::{ | |||||||||
| BaseIntentCommittor, CommittorService, | ||||||||||
| }; | ||||||||||
| use magicblock_config::config::ChainLinkConfig; | ||||||||||
| use magicblock_core::link::transactions::TransactionSchedulerHandle; | ||||||||||
| use magicblock_core::link::transactions::{ | ||||||||||
| SanitizeableTransaction, TransactionSchedulerHandle, | ||||||||||
| }; | ||||||||||
| use magicblock_ledger::LatestBlock; | ||||||||||
| use magicblock_magic_program_api::instruction::AccountModification; | ||||||||||
| use magicblock_program::{ | ||||||||||
|
|
@@ -38,7 +40,7 @@ use solana_sdk_ids::loader_v4; | |||||||||
| use solana_signature::Signature; | ||||||||||
| use solana_signer::{Signer, SignerError}; | ||||||||||
| use solana_sysvar::rent::Rent; | ||||||||||
| use solana_transaction::Transaction; | ||||||||||
| use solana_transaction::{sanitized::SanitizedTransaction, Transaction}; | ||||||||||
| use tokio::sync::oneshot; | ||||||||||
| use tracing::*; | ||||||||||
|
|
||||||||||
|
|
@@ -84,6 +86,15 @@ impl ChainlinkCloner { | |||||||||
| Ok(sig) | ||||||||||
| } | ||||||||||
|
|
||||||||||
| async fn send_sanitized_transaction( | ||||||||||
snawaz marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||
| &self, | ||||||||||
| tx: SanitizedTransaction, | ||||||||||
| sig: Signature, | ||||||||||
| ) -> ClonerResult<Signature> { | ||||||||||
| self.tx_scheduler.execute(tx).await?; | ||||||||||
| Ok(sig) | ||||||||||
| } | ||||||||||
|
|
||||||||||
| fn build_clone_message(request: &AccountCloneRequest) -> Option<String> { | ||||||||||
| if request.account.delegated() { | ||||||||||
| // Account is delegated to us | ||||||||||
|
|
@@ -122,7 +133,7 @@ impl ChainlinkCloner { | |||||||||
| message, | ||||||||||
| ); | ||||||||||
| // Defined positive commit frequency means commits should be scheduled | ||||||||||
| let ixs = match request.commit_frequency_ms { | ||||||||||
| let mut ixs = match request.commit_frequency_ms { | ||||||||||
| // TODO(GabrielePicco): Hotfix. Do not schedule frequency commits until we impose limits. | ||||||||||
| // 1. Allow configuring a higher minimum. | ||||||||||
| // 2. Stop committing accounts if they have been committed more than X times, | ||||||||||
|
|
@@ -162,6 +173,9 @@ impl ChainlinkCloner { | |||||||||
| } | ||||||||||
| _ => vec![modify_ix], | ||||||||||
| }; | ||||||||||
| if !request.delegation_actions.is_empty() { | ||||||||||
| ixs.extend(request.delegation_actions.clone()); | ||||||||||
| } | ||||||||||
|
Comment on lines
+176
to
+178
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No transaction size guard before appending Appending arbitrary instructions from Consider computing the serialized size of 🤖 Prompt for AI Agents🧹 Nitpick | 🔵 Trivial Unnecessary full-Vec clone; prefer
♻️ Proposed refactor- if !request.delegation_actions.is_empty() {
- ixs.extend(request.delegation_actions.clone());
- }
+ ixs.extend_from_slice(&request.delegation_actions);📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||
|
|
||||||||||
| let mut tx = | ||||||||||
| Transaction::new_with_payer(&ixs, Some(&validator_authority_id())); | ||||||||||
|
|
@@ -407,13 +421,24 @@ impl Cloner for ChainlinkCloner { | |||||||||
| let recent_blockhash = self.block.load().blockhash; | ||||||||||
| let tx = self | ||||||||||
| .transaction_to_clone_regular_account(&request, recent_blockhash)?; | ||||||||||
| let bypass_sigverify_for_replay_actions = | ||||||||||
| !request.delegation_actions.is_empty(); | ||||||||||
| let sig = tx.signatures[0]; | ||||||||||
|
|
||||||||||
| let send_res = if bypass_sigverify_for_replay_actions { | ||||||||||
| let sanitized_tx = tx.sanitize(false)?; | ||||||||||
| self.send_sanitized_transaction(sanitized_tx, sig).await | ||||||||||
| } else { | ||||||||||
| self.send_transaction(tx).await | ||||||||||
| }; | ||||||||||
|
|
||||||||||
| if request.account.delegated() { | ||||||||||
| self.maybe_prepare_lookup_tables( | ||||||||||
| request.pubkey, | ||||||||||
| *request.account.owner(), | ||||||||||
| ); | ||||||||||
| } | ||||||||||
| self.send_transaction(tx).await.map_err(|err| { | ||||||||||
| send_res.map_err(|err| { | ||||||||||
| ClonerError::FailedToCloneRegularAccount( | ||||||||||
| request.pubkey, | ||||||||||
| Box::new(err), | ||||||||||
|
|
||||||||||
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.
Local path dependency
../delegation-programwill break CI and isolated checkouts.path = "../delegation-program"references a sibling directory outside this repository. Any developer or CI runner without that exact directory layout will get a build failure. The previous git-based reference (withrev) was portable. This should either stay as a git dependency (possibly pointing to a local branch) or the delegation-program should be vendored/subtree'd into this repo before merging.🤖 Prompt for AI Agents