Skip to content

Commit 618b99c

Browse files
committed
fix: encode internal transactions
1 parent a142414 commit 618b99c

File tree

6 files changed

+30
-16
lines changed

6 files changed

+30
-16
lines changed

magicblock-account-cloner/src/lib.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,9 @@ use magicblock_chainlink::{
4040
};
4141
use magicblock_committor_service::{BaseIntentCommittor, CommittorService};
4242
use magicblock_config::config::ChainLinkConfig;
43-
use magicblock_core::link::transactions::TransactionSchedulerHandle;
43+
use magicblock_core::link::transactions::{
44+
with_encoded, TransactionSchedulerHandle,
45+
};
4446
use magicblock_ledger::LatestBlock;
4547
use magicblock_magic_program_api::{
4648
args::ScheduleTaskArgs,
@@ -102,7 +104,7 @@ impl ChainlinkCloner {
102104

103105
async fn send_tx(&self, tx: Transaction) -> ClonerResult<Signature> {
104106
let sig = tx.signatures[0];
105-
self.tx_scheduler.execute(tx).await?;
107+
self.tx_scheduler.execute(with_encoded(tx)?).await?;
106108
Ok(sig)
107109
}
108110

magicblock-accounts/src/scheduled_commits_processor.rs

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,9 @@ use magicblock_committor_service::{
1818
intent_execution_manager::BroadcastedIntentExecutionResult,
1919
intent_executor::ExecutionOutput, BaseIntentCommittor, CommittorService,
2020
};
21-
use magicblock_core::link::transactions::TransactionSchedulerHandle;
21+
use magicblock_core::link::transactions::{
22+
with_encoded, TransactionSchedulerHandle,
23+
};
2224
use magicblock_program::{
2325
magic_scheduled_base_intent::ScheduledIntentBundle,
2426
register_scheduled_commit_sent, SentCommit, TransactionScheduler,
@@ -199,10 +201,12 @@ impl ScheduledCommitsProcessorImpl {
199201
let sent_commit =
200202
Self::build_sent_commit(intent_id, intent_meta, result);
201203
register_scheduled_commit_sent(sent_commit);
202-
match internal_transaction_scheduler
203-
.execute(intent_sent_transaction)
204-
.await
205-
{
204+
let Ok(txn) = with_encoded(intent_sent_transaction) else {
205+
// Unreachable case, all intent transactions are smaller than 64KB by construction
206+
error!("Failed to bincode intent transaction");
207+
return;
208+
};
209+
match internal_transaction_scheduler.execute(txn).await {
206210
Ok(()) => {
207211
debug!("Sent commit signaled")
208212
}

magicblock-aperture/src/requests/http/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ impl HttpDispatcher {
216216
}
217217

218218
/// Ensures all accounts required for a transaction are present in the `AccountsDb`.
219-
#[instrument(skip(self, transaction), fields(signature = %transaction.signature()))]
219+
#[instrument(skip_all)]
220220
async fn ensure_transaction_accounts(
221221
&self,
222222
transaction: &SanitizedTransaction,
@@ -231,7 +231,7 @@ impl HttpDispatcher {
231231
{
232232
Ok(res) if res.is_ok() => Ok(()),
233233
Ok(res) => {
234-
debug!(result = %res, "Transaction account resolution encountered issues");
234+
debug!(%res, "Transaction account resolution encountered issues");
235235
Ok(())
236236
}
237237
Err(err) => {

magicblock-aperture/src/requests/http/request_airdrop.rs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use magicblock_core::link::transactions::SanitizeableTransaction;
1+
use magicblock_core::link::transactions::with_encoded;
22

33
use super::prelude::*;
44

@@ -35,11 +35,13 @@ impl HttpDispatcher {
3535
lamports,
3636
self.blocks.get_latest().hash,
3737
);
38-
// we don't need to verify transaction that we just signed
39-
let txn = txn.sanitize(false)?;
40-
let signature = SerdeSignature(*txn.signature());
38+
// we just signed the transaction, it must have a signature
39+
let signature =
40+
SerdeSignature(txn.signatures.first().cloned().unwrap_or_default());
4141

42-
self.transactions_scheduler.execute(txn).await?;
42+
self.transactions_scheduler
43+
.execute(with_encoded(txn)?)
44+
.await?;
4345

4446
Ok(ResponsePayload::encode_no_context(&request.id, signature))
4547
}

magicblock-aperture/src/requests/http/simulate_transaction.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ impl HttpDispatcher {
5252
// Submit the transaction to the scheduler for simulation.
5353
let result = self
5454
.transactions_scheduler
55-
.simulate(transaction)
55+
.simulate(transaction.txn)
5656
.await
5757
.map_err(RpcError::transaction_simulation)?;
5858

magicblock-api/src/tickers.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@ use std::{
99
use magicblock_accounts::ScheduledCommitsProcessor;
1010
use magicblock_accounts_db::{traits::AccountsBank, AccountsDb};
1111
use magicblock_core::link::{
12-
blocks::BlockUpdateTx, transactions::TransactionSchedulerHandle,
12+
blocks::BlockUpdateTx,
13+
transactions::{with_encoded, TransactionSchedulerHandle},
1314
};
1415
use magicblock_ledger::{LatestBlock, Ledger};
1516
use magicblock_magic_program_api as magic_program;
@@ -89,6 +90,11 @@ async fn handle_scheduled_commits<C: ScheduledCommitsProcessor>(
8990
let tx = InstructionUtils::accept_scheduled_commits(
9091
latest_block.load().blockhash,
9192
);
93+
let Ok(tx) = with_encoded(tx) else {
94+
// Unreachable case, all schedule commit txns are smaller than 64KB by construction
95+
error!("Failed to bincode intent transaction");
96+
return;
97+
};
9298
if let Err(err) = transaction_scheduler.execute(tx).await {
9399
error!(error = ?err, "Failed to accept scheduled commits");
94100
return;

0 commit comments

Comments
 (0)