diff --git a/magicblock-committor-service/src/persist/commit_persister.rs b/magicblock-committor-service/src/persist/commit_persister.rs index 4fe800347..c522d8029 100644 --- a/magicblock-committor-service/src/persist/commit_persister.rs +++ b/magicblock-committor-service/src/persist/commit_persister.rs @@ -585,14 +585,14 @@ mod tests { persister.set_commit_id(1, &pubkey, 100).unwrap(); persister - .set_commit_strategy(100, &pubkey, CommitStrategy::Args) + .set_commit_strategy(100, &pubkey, CommitStrategy::StateArgs) .unwrap(); let updated = persister .get_commit_status_by_message(1, &pubkey) .unwrap() .unwrap(); - assert_eq!(updated.commit_strategy, CommitStrategy::Args); + assert_eq!(updated.commit_strategy, CommitStrategy::StateArgs); } #[test] diff --git a/magicblock-committor-service/src/persist/db.rs b/magicblock-committor-service/src/persist/db.rs index 3d0f60fa1..d8eee2b5a 100644 --- a/magicblock-committor-service/src/persist/db.rs +++ b/magicblock-committor-service/src/persist/db.rs @@ -772,7 +772,7 @@ mod tests { commit_type: CommitType::DataAccount, created_at: 1000, commit_status: CommitStatus::Pending, - commit_strategy: CommitStrategy::Args, + commit_strategy: CommitStrategy::StateArgs, last_retried_at: 1000, retries_count: 0, } @@ -907,7 +907,7 @@ mod tests { db.insert_commit_status_rows(std::slice::from_ref(&row)) .unwrap(); - let new_strategy = CommitStrategy::FromBuffer; + let new_strategy = CommitStrategy::StateBuffer; db.set_commit_strategy(100, &row.pubkey, new_strategy) .unwrap(); diff --git a/magicblock-committor-service/src/persist/types/commit_strategy.rs b/magicblock-committor-service/src/persist/types/commit_strategy.rs index c9261f70d..3bf007333 100644 --- a/magicblock-committor-service/src/persist/types/commit_strategy.rs +++ b/magicblock-committor-service/src/persist/types/commit_strategy.rs @@ -4,39 +4,46 @@ use crate::persist::error::CommitPersistError; pub enum CommitStrategy { /// Args without the use of a lookup table #[default] - Args, + StateArgs, /// Args with the use of a lookup table - ArgsWithLookupTable, + StateArgsWithLookupTable, /// Buffer and chunks which has the most overhead - FromBuffer, + StateBuffer, /// Buffer and chunks with the use of a lookup table - FromBufferWithLookupTable, + StateBufferWithLookupTable, + + /// Args without the use of a lookup table + DiffArgs, + /// Args with the use of a lookup table + DiffArgsWithLookupTable, + /// Buffer and chunks which has the most overhead + DiffBuffer, + /// Buffer and chunks with the use of a lookup table + DiffBufferWithLookupTable, } impl CommitStrategy { - pub fn args(use_lookup: bool) -> Self { - if use_lookup { - Self::ArgsWithLookupTable - } else { - Self::Args - } - } - pub fn as_str(&self) -> &str { use CommitStrategy::*; match self { - Args => "Args", - ArgsWithLookupTable => "ArgsWithLookupTable", - FromBuffer => "FromBuffer", - FromBufferWithLookupTable => "FromBufferWithLookupTable", + StateArgs => "StateArgs", + StateArgsWithLookupTable => "StateArgsWithLookupTable", + StateBuffer => "StateBuffer", + StateBufferWithLookupTable => "StateBufferWithLookupTable", + DiffArgs => "DiffArgs", + DiffArgsWithLookupTable => "DiffArgsWithLookupTable", + DiffBuffer => "DiffBuffer", + DiffBufferWithLookupTable => "DiffBufferWithLookupTable", } } pub fn uses_lookup(&self) -> bool { matches!( self, - CommitStrategy::ArgsWithLookupTable - | CommitStrategy::FromBufferWithLookupTable + CommitStrategy::StateArgsWithLookupTable + | CommitStrategy::StateBufferWithLookupTable + | CommitStrategy::DiffArgsWithLookupTable + | CommitStrategy::DiffBufferWithLookupTable ) } } @@ -45,10 +52,18 @@ impl TryFrom<&str> for CommitStrategy { type Error = CommitPersistError; fn try_from(value: &str) -> Result { match value { - "Args" => Ok(Self::Args), - "ArgsWithLookupTable" => Ok(Self::ArgsWithLookupTable), - "FromBuffer" => Ok(Self::FromBuffer), - "FromBufferWithLookupTable" => Ok(Self::FromBufferWithLookupTable), + "Args" | "StateArgs" => Ok(Self::StateArgs), + "ArgsWithLookupTable" | "StateArgsWithLookupTable" => { + Ok(Self::StateArgsWithLookupTable) + } + "FromBuffer" | "StateBuffer" => Ok(Self::StateBuffer), + "FromBufferWithLookupTable" | "StateBufferWithLookupTable" => { + Ok(Self::StateBufferWithLookupTable) + } + "DiffArgs" => Ok(Self::DiffArgs), + "DiffArgsWithLookupTable" => Ok(Self::DiffArgsWithLookupTable), + "DiffBuffer" => Ok(Self::DiffBuffer), + "DiffBufferWithLookupTable" => Ok(Self::DiffBufferWithLookupTable), _ => Err(CommitPersistError::InvalidCommitStrategy( value.to_string(), )), diff --git a/magicblock-committor-service/src/tasks/args_task.rs b/magicblock-committor-service/src/tasks/args_task.rs index 1bd5f1e5d..1aec8326e 100644 --- a/magicblock-committor-service/src/tasks/args_task.rs +++ b/magicblock-committor-service/src/tasks/args_task.rs @@ -122,7 +122,7 @@ impl BaseTask for ArgsTask { } } - fn optimize( + fn try_optimize_tx_size( self: Box, ) -> Result, Box> { match self.task_type { @@ -132,16 +132,8 @@ impl BaseTask for ArgsTask { ))) } ArgsTaskType::CommitDiff(value) => { - // TODO (snawaz): Currently, we do not support executing CommitDiff - // as BufferTask, which is why we're forcing CommitDiffTask to become CommitTask - // before converting this task into BufferTask. Once CommitDiff is supported - // by BufferTask, we do not have to do this, as it's essentially a downgrade. Ok(Box::new(BufferTask::new_preparation_required( - BufferTaskType::Commit(CommitTask { - commit_id: value.commit_id, - allow_undelegation: value.allow_undelegation, - committed_account: value.committed_account, - }), + BufferTaskType::CommitDiff(value), ))) } ArgsTaskType::BaseAction(_) diff --git a/magicblock-committor-service/src/tasks/buffer_task.rs b/magicblock-committor-service/src/tasks/buffer_task.rs index 7a1fb1890..19c59b7ac 100644 --- a/magicblock-committor-service/src/tasks/buffer_task.rs +++ b/magicblock-committor-service/src/tasks/buffer_task.rs @@ -1,4 +1,4 @@ -use dlp::args::CommitStateFromBufferArgs; +use dlp::{args::CommitStateFromBufferArgs, compute_diff}; use magicblock_committor_program::Chunks; use magicblock_metrics::metrics::LabelValue; use solana_instruction::Instruction; @@ -11,8 +11,9 @@ use crate::tasks::TaskStrategy; use crate::{ consts::MAX_WRITE_CHUNK_SIZE, tasks::{ - visitor::Visitor, BaseTask, BaseTaskError, BaseTaskResult, CommitTask, - PreparationState, PreparationTask, TaskType, + visitor::Visitor, BaseTask, BaseTaskError, BaseTaskResult, + CommitDiffTask, CommitTask, PreparationState, PreparationTask, + TaskType, }, }; @@ -20,6 +21,7 @@ use crate::{ #[derive(Clone)] pub enum BufferTaskType { Commit(CommitTask), + CommitDiff(CommitDiffTask), // Action in the future } @@ -48,19 +50,37 @@ impl BufferTask { } fn preparation_required(task_type: &BufferTaskType) -> PreparationState { - let BufferTaskType::Commit(ref commit_task) = task_type; - let committed_data = commit_task.committed_account.account.data.clone(); - let chunks = Chunks::from_data_length( - committed_data.len(), - MAX_WRITE_CHUNK_SIZE, - ); - - PreparationState::Required(PreparationTask { - commit_id: commit_task.commit_id, - pubkey: commit_task.committed_account.pubkey, - committed_data, - chunks, - }) + match task_type { + BufferTaskType::Commit(task) => { + let data = task.committed_account.account.data.clone(); + let chunks = + Chunks::from_data_length(data.len(), MAX_WRITE_CHUNK_SIZE); + + PreparationState::Required(PreparationTask { + commit_id: task.commit_id, + pubkey: task.committed_account.pubkey, + committed_data: data, + chunks, + }) + } + + BufferTaskType::CommitDiff(task) => { + let diff = compute_diff( + &task.base_account.data, + &task.committed_account.account.data, + ) + .to_vec(); + let chunks = + Chunks::from_data_length(diff.len(), MAX_WRITE_CHUNK_SIZE); + + PreparationState::Required(PreparationTask { + commit_id: task.commit_id, + pubkey: task.committed_account.pubkey, + committed_data: diff, + chunks, + }) + } + } } } @@ -69,38 +89,64 @@ impl From for BufferTaskType { fn from(value: ArgsTaskType) -> Self { match value { ArgsTaskType::Commit(task) => BufferTaskType::Commit(task), - ArgsTaskType::CommitDiff(_) => panic!("BufferTask doesn't support CommitDiff yet. Disable your tests (if any) temporarily till the next PR"), - _ => unimplemented!("Only commit task can be BufferTask currently. Fix your tests"), + ArgsTaskType::CommitDiff(task) => BufferTaskType::CommitDiff(task), + _ => unimplemented!( + "Only commit task can be BufferTask currently. Fix your tests" + ), } } } impl BaseTask for BufferTask { fn instruction(&self, validator: &Pubkey) -> Instruction { - let BufferTaskType::Commit(ref value) = self.task_type; - let commit_id_slice = value.commit_id.to_le_bytes(); - let (commit_buffer_pubkey, _) = - magicblock_committor_program::pdas::buffer_pda( - validator, - &value.committed_account.pubkey, - &commit_id_slice, - ); - - dlp::instruction_builder::commit_state_from_buffer( - *validator, - value.committed_account.pubkey, - value.committed_account.account.owner, - commit_buffer_pubkey, - CommitStateFromBufferArgs { - nonce: value.commit_id, - lamports: value.committed_account.account.lamports, - allow_undelegation: value.allow_undelegation, - }, - ) + match &self.task_type { + BufferTaskType::Commit(task) => { + let commit_id_slice = task.commit_id.to_le_bytes(); + let (commit_buffer_pubkey, _) = + magicblock_committor_program::pdas::buffer_pda( + validator, + &task.committed_account.pubkey, + &commit_id_slice, + ); + + dlp::instruction_builder::commit_state_from_buffer( + *validator, + task.committed_account.pubkey, + task.committed_account.account.owner, + commit_buffer_pubkey, + CommitStateFromBufferArgs { + nonce: task.commit_id, + lamports: task.committed_account.account.lamports, + allow_undelegation: task.allow_undelegation, + }, + ) + } + BufferTaskType::CommitDiff(task) => { + let commit_id_slice = task.commit_id.to_le_bytes(); + let (commit_buffer_pubkey, _) = + magicblock_committor_program::pdas::buffer_pda( + validator, + &task.committed_account.pubkey, + &commit_id_slice, + ); + + dlp::instruction_builder::commit_diff_from_buffer( + *validator, + task.committed_account.pubkey, + task.committed_account.account.owner, + commit_buffer_pubkey, + CommitStateFromBufferArgs { + nonce: task.commit_id, + lamports: task.committed_account.account.lamports, + allow_undelegation: task.allow_undelegation, + }, + ) + } + } } /// No further optimizations - fn optimize( + fn try_optimize_tx_size( self: Box, ) -> Result, Box> { Err(self) @@ -125,6 +171,7 @@ impl BaseTask for BufferTask { fn compute_units(&self) -> u32 { match self.task_type { BufferTaskType::Commit(_) => 70_000, + BufferTaskType::CommitDiff(_) => 70_000, } } @@ -136,6 +183,7 @@ impl BaseTask for BufferTask { fn task_type(&self) -> TaskType { match self.task_type { BufferTaskType::Commit(_) => TaskType::Commit, + BufferTaskType::CommitDiff(_) => TaskType::Commit, } } @@ -145,12 +193,15 @@ impl BaseTask for BufferTask { } fn reset_commit_id(&mut self, commit_id: u64) { - let BufferTaskType::Commit(commit_task) = &mut self.task_type; - if commit_id == commit_task.commit_id { - return; - } + match &mut self.task_type { + BufferTaskType::Commit(task) => { + task.commit_id = commit_id; + } + BufferTaskType::CommitDiff(task) => { + task.commit_id = commit_id; + } + }; - commit_task.commit_id = commit_id; self.preparation_state = Self::preparation_required(&self.task_type) } } @@ -159,6 +210,7 @@ impl LabelValue for BufferTask { fn value(&self) -> &str { match self.task_type { BufferTaskType::Commit(_) => "buffer_commit", + BufferTaskType::CommitDiff(_) => "buffer_commit_diff", } } } diff --git a/magicblock-committor-service/src/tasks/mod.rs b/magicblock-committor-service/src/tasks/mod.rs index ea8b5c17a..d8b4a178e 100644 --- a/magicblock-committor-service/src/tasks/mod.rs +++ b/magicblock-committor-service/src/tasks/mod.rs @@ -46,7 +46,6 @@ pub enum PreparationState { Cleanup(CleanupTask), } -#[cfg(test)] #[derive(Copy, Clone, PartialEq, Eq, Debug)] pub enum TaskStrategy { Args, @@ -67,8 +66,9 @@ pub trait BaseTask: Send + Sync + DynClone + LabelValue { /// Gets instruction for task execution fn instruction(&self, validator: &Pubkey) -> Instruction; - /// Optimizes Task strategy if possible, otherwise returns itself - fn optimize( + /// Optimize for transaction size so that more instructions can be buddled together in a single + /// transaction. Return Ok(new_tx_optimized_task), else Err(self) if task cannot be optimized. + fn try_optimize_tx_size( self: Box, ) -> Result, Box>; diff --git a/magicblock-committor-service/src/tasks/task_strategist.rs b/magicblock-committor-service/src/tasks/task_strategist.rs index edbbd74d3..33bbd29e4 100644 --- a/magicblock-committor-service/src/tasks/task_strategist.rs +++ b/magicblock-committor-service/src/tasks/task_strategist.rs @@ -171,7 +171,8 @@ impl TaskStrategist { persistor: &Option

, ) -> TaskStrategistResult { // Attempt optimizing tasks themselves(using buffers) - if Self::optimize_strategy(&mut tasks)? <= MAX_ENCODED_TRANSACTION_SIZE + if Self::try_optimize_tx_size_if_needed(&mut tasks)? + <= MAX_ENCODED_TRANSACTION_SIZE { // Persist tasks strategy if let Some(persistor) = persistor { @@ -268,9 +269,11 @@ impl TaskStrategist { ) } - /// Optimizes set of [`TaskDeliveryStrategy`] to fit [`MAX_ENCODED_TRANSACTION_SIZE`] - /// Returns size of tx after optimizations - fn optimize_strategy( + /// Optimizes tasks so as to bring the transaction size within the limit [`MAX_ENCODED_TRANSACTION_SIZE`] + /// Returns Ok(size of tx after optimizations) else Err(SignerError). + /// Note that the returned size, though possibly optimized one, may still not be under + /// the limit MAX_ENCODED_TRANSACTION_SIZE. The caller needs to check and make decision accordingly. + fn try_optimize_tx_size_if_needed( tasks: &mut [Box], ) -> Result { // Get initial transaction size @@ -325,7 +328,7 @@ impl TaskStrategist { let tmp_task = Box::new(tmp_task) as Box; std::mem::replace(&mut tasks[index], tmp_task) }; - match task.optimize() { + match task.try_optimize_tx_size() { // If we can decrease: // 1. Calculate new tx size & ix size // 2. Insert item's data back in the heap @@ -704,7 +707,7 @@ mod tests { Box::new(create_test_commit_task(3, 1000, 0)) as Box, // Larger task ]; - let _ = TaskStrategist::optimize_strategy(&mut tasks); + let _ = TaskStrategist::try_optimize_tx_size_if_needed(&mut tasks); // The larger task should have been optimized first assert!(matches!(tasks[0].strategy(), TaskStrategy::Args)); assert!(matches!(tasks[1].strategy(), TaskStrategy::Buffer)); diff --git a/magicblock-committor-service/src/tasks/task_visitors/persistor_visitor.rs b/magicblock-committor-service/src/tasks/task_visitors/persistor_visitor.rs index c608f2ef9..2f216c869 100644 --- a/magicblock-committor-service/src/tasks/task_visitors/persistor_visitor.rs +++ b/magicblock-committor-service/src/tasks/task_visitors/persistor_visitor.rs @@ -26,20 +26,38 @@ where fn visit_args_task(&mut self, task: &ArgsTask) { match self.context { PersistorContext::PersistStrategy { uses_lookup_tables } => { - let ArgsTaskType::Commit(ref commit_task) = task.task_type - else { - return; + let commit_strategy = |is_diff: bool| { + if is_diff { + if uses_lookup_tables { + CommitStrategy::DiffArgsWithLookupTable + } else { + CommitStrategy::DiffArgs + } + } else if uses_lookup_tables { + CommitStrategy::StateArgsWithLookupTable + } else { + CommitStrategy::StateArgs + } }; - let commit_strategy = if uses_lookup_tables { - CommitStrategy::ArgsWithLookupTable - } else { - CommitStrategy::Args + let (commit_id, pubkey, commit_strategy) = match &task.task_type + { + ArgsTaskType::Commit(task) => ( + task.commit_id, + &task.committed_account.pubkey, + commit_strategy(false), + ), + ArgsTaskType::CommitDiff(task) => ( + task.commit_id, + &task.committed_account.pubkey, + commit_strategy(true), + ), + _ => return, }; if let Err(err) = self.persistor.set_commit_strategy( - commit_task.commit_id, - &commit_task.committed_account.pubkey, + commit_id, + pubkey, commit_strategy, ) { error!( @@ -55,16 +73,37 @@ where fn visit_buffer_task(&mut self, task: &BufferTask) { match self.context { PersistorContext::PersistStrategy { uses_lookup_tables } => { - let BufferTaskType::Commit(ref commit_task) = task.task_type; - let commit_strategy = if uses_lookup_tables { - CommitStrategy::FromBufferWithLookupTable - } else { - CommitStrategy::FromBuffer + let commit_strategy = |is_diff: bool| { + if is_diff { + if uses_lookup_tables { + CommitStrategy::DiffBufferWithLookupTable + } else { + CommitStrategy::DiffBuffer + } + } else if uses_lookup_tables { + CommitStrategy::StateBufferWithLookupTable + } else { + CommitStrategy::StateBuffer + } + }; + + let (commit_id, pubkey, commit_strategy) = match &task.task_type + { + BufferTaskType::Commit(task) => ( + task.commit_id, + &task.committed_account.pubkey, + commit_strategy(false), + ), + BufferTaskType::CommitDiff(task) => ( + task.commit_id, + &task.committed_account.pubkey, + commit_strategy(true), + ), }; if let Err(err) = self.persistor.set_commit_strategy( - commit_task.commit_id, - &commit_task.committed_account.pubkey, + commit_id, + pubkey, commit_strategy, ) { error!( diff --git a/magicblock-committor-service/src/tasks/task_visitors/utility_visitor.rs b/magicblock-committor-service/src/tasks/task_visitors/utility_visitor.rs index fef7cade1..470e25341 100644 --- a/magicblock-committor-service/src/tasks/task_visitors/utility_visitor.rs +++ b/magicblock-committor-service/src/tasks/task_visitors/utility_visitor.rs @@ -19,23 +19,39 @@ impl Visitor for TaskVisitorUtils { fn visit_args_task(&mut self, task: &ArgsTask) { let Self::GetCommitMeta(commit_meta) = self; - if let ArgsTaskType::Commit(ref commit_task) = task.task_type { - *commit_meta = Some(CommitMeta { - committed_pubkey: commit_task.committed_account.pubkey, - commit_id: commit_task.commit_id, - }) - } else { - *commit_meta = None + match &task.task_type { + ArgsTaskType::Commit(task) => { + *commit_meta = Some(CommitMeta { + committed_pubkey: task.committed_account.pubkey, + commit_id: task.commit_id, + }) + } + ArgsTaskType::CommitDiff(task) => { + *commit_meta = Some(CommitMeta { + committed_pubkey: task.committed_account.pubkey, + commit_id: task.commit_id, + }) + } + _ => *commit_meta = None, } } fn visit_buffer_task(&mut self, task: &BufferTask) { let Self::GetCommitMeta(commit_meta) = self; - let BufferTaskType::Commit(ref commit_task) = task.task_type; - *commit_meta = Some(CommitMeta { - committed_pubkey: commit_task.committed_account.pubkey, - commit_id: commit_task.commit_id, - }) + match &task.task_type { + BufferTaskType::Commit(task) => { + *commit_meta = Some(CommitMeta { + committed_pubkey: task.committed_account.pubkey, + commit_id: task.commit_id, + }) + } + BufferTaskType::CommitDiff(task) => { + *commit_meta = Some(CommitMeta { + committed_pubkey: task.committed_account.pubkey, + commit_id: task.commit_id, + }) + } + } } } diff --git a/test-integration/schedulecommit/test-scenarios/tests/02_commit_and_undelegate.rs b/test-integration/schedulecommit/test-scenarios/tests/02_commit_and_undelegate.rs index f2d9c7ba0..e0a6e6126 100644 --- a/test-integration/schedulecommit/test-scenarios/tests/02_commit_and_undelegate.rs +++ b/test-integration/schedulecommit/test-scenarios/tests/02_commit_and_undelegate.rs @@ -309,13 +309,13 @@ fn test_committing_and_undelegating_huge_order_book_account() { println!("Important: use {rng_seed} as seed to regenerate the random inputs in case of test failure"); let mut random = StdRng::seed_from_u64(rng_seed); let mut update = BookUpdate::default(); - update.bids.extend((0..random.gen_range(5..10)).map(|_| { + update.bids.extend((0..random.gen_range(5..100)).map(|_| { OrderLevel { price: random.gen_range(75000..90000), size: random.gen_range(1..10), } })); - update.asks.extend((0..random.gen_range(5..10)).map(|_| { + update.asks.extend((0..random.gen_range(5..100)).map(|_| { OrderLevel { price: random.gen_range(125000..150000), size: random.gen_range(1..10), diff --git a/test-integration/test-committor-service/tests/test_ix_commit_local.rs b/test-integration/test-committor-service/tests/test_ix_commit_local.rs index 6af953d47..989ae53a5 100644 --- a/test-integration/test-committor-service/tests/test_ix_commit_local.rs +++ b/test-integration/test-committor-service/tests/test_ix_commit_local.rs @@ -67,42 +67,62 @@ fn expect_strategies( #[tokio::test] async fn test_ix_commit_single_account_100_bytes() { - commit_single_account(100, CommitStrategy::Args, false).await; + commit_single_account(100, CommitStrategy::StateArgs, false).await; } #[tokio::test] async fn test_ix_commit_single_account_100_bytes_and_undelegate() { - commit_single_account(100, CommitStrategy::Args, true).await; + commit_single_account(100, CommitStrategy::StateArgs, true).await; +} + +#[tokio::test] +async fn test_ix_commit_single_account_256_bytes() { + commit_single_account(256, CommitStrategy::StateArgs, false).await; +} + +#[tokio::test] +async fn test_ix_commit_single_account_257_bytes() { + commit_single_account(257, CommitStrategy::DiffArgs, false).await; +} + +#[tokio::test] +async fn test_ix_commit_single_account_256_bytes_and_undelegate() { + commit_single_account(256, CommitStrategy::StateArgs, true).await; +} + +#[tokio::test] +async fn test_ix_commit_single_account_257_bytes_and_undelegate() { + commit_single_account(257, CommitStrategy::DiffArgs, true).await; } #[tokio::test] async fn test_ix_commit_single_account_800_bytes() { - commit_single_account(800, CommitStrategy::Args, false).await; + commit_single_account(800, CommitStrategy::DiffArgs, false).await; } #[tokio::test] async fn test_ix_commit_single_account_800_bytes_and_undelegate() { - commit_single_account(800, CommitStrategy::Args, true).await; + commit_single_account(800, CommitStrategy::DiffArgs, true).await; } #[tokio::test] async fn test_ix_commit_single_account_one_kb() { - commit_single_account(1024, CommitStrategy::Args, false).await; + commit_single_account(1024, CommitStrategy::DiffArgs, false).await; } #[tokio::test] async fn test_ix_commit_single_account_ten_kb() { - commit_single_account(10 * 1024, CommitStrategy::Args, false).await; + commit_single_account(10 * 1024, CommitStrategy::DiffArgs, false).await; } #[tokio::test] async fn test_ix_commit_order_book_change_100_bytes() { - commit_book_order_account(100, CommitStrategy::Args, false).await; + commit_book_order_account(100, CommitStrategy::DiffArgs, false).await; } #[tokio::test] async fn test_ix_commit_order_book_change_679_bytes() { - commit_book_order_account(679, CommitStrategy::Args, false).await; + commit_book_order_account(679, CommitStrategy::DiffArgs, false).await; } #[tokio::test] @@ -111,12 +131,12 @@ async fn test_ix_commit_order_book_change_680_bytes() { // of size 1644 (which is the max limit), but while the size of raw bytes for 679 is within // 1232 limit, the size for 680 execeds by 1 (1233). That is why we used // 681 as changed_len where CommitStrategy goes from Args to FromBuffer. - commit_book_order_account(681, CommitStrategy::FromBuffer, false).await; + commit_book_order_account(681, CommitStrategy::DiffBuffer, false).await; } #[tokio::test] async fn test_ix_commit_order_book_change_10k_bytes() { - commit_book_order_account(10 * 1024, CommitStrategy::FromBuffer, false) + commit_book_order_account(10 * 1024, CommitStrategy::DiffBuffer, false) .await; } @@ -264,7 +284,7 @@ async fn test_ix_commit_two_accounts_1kb_2kb() { &[1024, 2048], 1, false, - expect_strategies(&[(CommitStrategy::Args, 2)]), + expect_strategies(&[(CommitStrategy::DiffArgs, 2)]), ) .await; } @@ -276,7 +296,7 @@ async fn test_ix_commit_two_accounts_512kb() { &[512, 512], 1, false, - expect_strategies(&[(CommitStrategy::Args, 2)]), + expect_strategies(&[(CommitStrategy::DiffArgs, 2)]), ) .await; } @@ -288,7 +308,7 @@ async fn test_ix_commit_three_accounts_512kb() { &[512, 512, 512], 1, false, - expect_strategies(&[(CommitStrategy::Args, 3)]), + expect_strategies(&[(CommitStrategy::DiffArgs, 3)]), ) .await; } @@ -300,7 +320,7 @@ async fn test_ix_commit_six_accounts_512kb() { &[512, 512, 512, 512, 512, 512], 1, false, - expect_strategies(&[(CommitStrategy::Args, 6)]), + expect_strategies(&[(CommitStrategy::DiffArgs, 6)]), ) .await; } @@ -312,22 +332,25 @@ async fn test_ix_commit_four_accounts_1kb_2kb_5kb_10kb_single_bundle() { &[1024, 2 * 1024, 5 * 1024, 10 * 1024], 1, false, - expect_strategies(&[(CommitStrategy::Args, 4)]), + expect_strategies(&[(CommitStrategy::DiffArgs, 4)]), ) .await; } #[tokio::test] async fn test_commit_20_accounts_1kb_bundle_size_2() { - commit_20_accounts_1kb(2, expect_strategies(&[(CommitStrategy::Args, 20)])) - .await; + commit_20_accounts_1kb( + 2, + expect_strategies(&[(CommitStrategy::DiffArgs, 20)]), + ) + .await; } #[tokio::test] async fn test_commit_5_accounts_1kb_bundle_size_3() { commit_5_accounts_1kb( 3, - expect_strategies(&[(CommitStrategy::Args, 5)]), + expect_strategies(&[(CommitStrategy::DiffArgs, 5)]), false, ) .await; @@ -339,8 +362,7 @@ async fn test_commit_5_accounts_1kb_bundle_size_3_undelegate_all() { 3, expect_strategies(&[ // Intent fits in 1 TX only with ALT, see IntentExecutorImpl::try_unite_tasks - (CommitStrategy::FromBufferWithLookupTable, 3), - (CommitStrategy::Args, 2), + (CommitStrategy::DiffArgs, 5), ]), true, ) @@ -352,8 +374,8 @@ async fn test_commit_5_accounts_1kb_bundle_size_4() { commit_5_accounts_1kb( 4, expect_strategies(&[ - (CommitStrategy::Args, 1), - (CommitStrategy::FromBufferWithLookupTable, 4), + (CommitStrategy::DiffArgs, 1), + (CommitStrategy::DiffBufferWithLookupTable, 4), ]), false, ) @@ -365,8 +387,8 @@ async fn test_commit_5_accounts_1kb_bundle_size_4_undelegate_all() { commit_5_accounts_1kb( 4, expect_strategies(&[ - (CommitStrategy::Args, 1), - (CommitStrategy::FromBufferWithLookupTable, 4), + (CommitStrategy::DiffArgs, 1), + (CommitStrategy::DiffBufferWithLookupTable, 4), ]), true, ) @@ -377,7 +399,7 @@ async fn test_commit_5_accounts_1kb_bundle_size_4_undelegate_all() { async fn test_commit_5_accounts_1kb_bundle_size_5_undelegate_all() { commit_5_accounts_1kb( 5, - expect_strategies(&[(CommitStrategy::FromBufferWithLookupTable, 5)]), + expect_strategies(&[(CommitStrategy::DiffBufferWithLookupTable, 5)]), true, ) .await; @@ -385,15 +407,18 @@ async fn test_commit_5_accounts_1kb_bundle_size_5_undelegate_all() { #[tokio::test] async fn test_commit_20_accounts_1kb_bundle_size_3() { - commit_20_accounts_1kb(3, expect_strategies(&[(CommitStrategy::Args, 20)])) - .await; + commit_20_accounts_1kb( + 3, + expect_strategies(&[(CommitStrategy::DiffArgs, 20)]), + ) + .await; } #[tokio::test] async fn test_commit_20_accounts_1kb_bundle_size_4() { commit_20_accounts_1kb( 4, - expect_strategies(&[(CommitStrategy::FromBufferWithLookupTable, 20)]), + expect_strategies(&[(CommitStrategy::DiffBufferWithLookupTable, 20)]), ) .await; } @@ -403,9 +428,9 @@ async fn test_commit_20_accounts_1kb_bundle_size_6() { commit_20_accounts_1kb( 6, expect_strategies(&[ - (CommitStrategy::FromBufferWithLookupTable, 18), + (CommitStrategy::DiffBufferWithLookupTable, 18), // Two accounts don't make it into the bundles of size 6 - (CommitStrategy::Args, 2), + (CommitStrategy::DiffArgs, 2), ]), ) .await; @@ -415,7 +440,7 @@ async fn test_commit_20_accounts_1kb_bundle_size_6() { async fn test_commit_20_accounts_1kb_bundle_size_20() { commit_20_accounts_1kb( 20, - expect_strategies(&[(CommitStrategy::FromBufferWithLookupTable, 20)]), + expect_strategies(&[(CommitStrategy::DiffBufferWithLookupTable, 20)]), ) .await; } @@ -427,7 +452,7 @@ async fn test_commit_8_accounts_1kb_bundle_size_8() { expect_strategies(&[ // Four accounts don't make it into the bundles of size 8, but // that bundle also needs lookup tables - (CommitStrategy::FromBufferWithLookupTable, 8), + (CommitStrategy::DiffBufferWithLookupTable, 8), ]), ) .await; @@ -440,7 +465,7 @@ async fn test_commit_20_accounts_1kb_bundle_size_8() { expect_strategies(&[ // Four accounts don't make it into the bundles of size 8, but // that bundle also needs lookup tables - (CommitStrategy::FromBufferWithLookupTable, 20), + (CommitStrategy::DiffBufferWithLookupTable, 20), ]), ) .await;