|
1 | | -use dlp::{ |
2 | | - args::{CallHandlerArgs, CommitDiffArgs, CommitStateArgs}, |
3 | | - compute_diff, |
4 | | -}; |
5 | | -use solana_account::ReadableAccount; |
| 1 | +use dlp::args::CallHandlerArgs; |
6 | 2 | use solana_pubkey::Pubkey; |
7 | | -use solana_rpc_client::rpc_client::RpcClient; |
8 | | -use solana_sdk::{ |
9 | | - commitment_config::CommitmentConfig, |
10 | | - instruction::{AccountMeta, Instruction}, |
11 | | -}; |
| 3 | +use solana_sdk::instruction::{AccountMeta, Instruction}; |
12 | 4 |
|
13 | 5 | #[cfg(test)] |
14 | 6 | use crate::tasks::TaskStrategy; |
15 | | -use crate::{ |
16 | | - config::ChainConfig, |
17 | | - tasks::{ |
18 | | - buffer_task::{BufferTask, BufferTaskType}, |
19 | | - visitor::Visitor, |
20 | | - BaseActionTask, BaseTask, BaseTaskError, BaseTaskResult, CommitTask, |
21 | | - FinalizeTask, PreparationState, TaskType, UndelegateTask, |
22 | | - }, |
23 | | - ComputeBudgetConfig, |
| 7 | +use crate::tasks::{ |
| 8 | + buffer_task::{BufferTask, BufferTaskType}, |
| 9 | + visitor::Visitor, |
| 10 | + BaseActionTask, BaseTask, BaseTaskError, BaseTaskResult, CommitTask, |
| 11 | + FinalizeTask, PreparationState, TaskType, UndelegateTask, |
24 | 12 | }; |
25 | 13 |
|
26 | 14 | /// Task that will be executed on Base layer via arguments |
@@ -57,68 +45,14 @@ impl BaseTask for ArgsTask { |
57 | 45 | fn instruction(&self, validator: &Pubkey) -> Instruction { |
58 | 46 | match &self.task_type { |
59 | 47 | ArgsTaskType::Commit(value) => { |
60 | | - let args = CommitStateArgs { |
61 | | - nonce: value.commit_id, |
62 | | - lamports: value.committed_account.account.lamports, |
63 | | - data: value.committed_account.account.data.clone(), |
64 | | - allow_undelegation: value.allow_undelegation, |
65 | | - }; |
66 | | - dlp::instruction_builder::commit_state( |
67 | | - *validator, |
68 | | - value.committed_account.pubkey, |
69 | | - value.committed_account.account.owner, |
70 | | - args, |
71 | | - ) |
| 48 | + if value.committed_account.account.data.len() |
| 49 | + <= CommitTask::COMMIT_STATE_SIZE_THRESHOLD |
| 50 | + { |
| 51 | + value.create_commit_state_ix(validator) |
| 52 | + } else { |
| 53 | + value.create_commit_diff_ix(validator) |
| 54 | + } |
72 | 55 | } |
73 | | - // ArgsTaskType::CommitDiff(value) => { |
74 | | - // let chain_config = |
75 | | - // ChainConfig::local(ComputeBudgetConfig::new(1_000_000)); |
76 | | - |
77 | | - // let rpc_client = RpcClient::new_with_commitment( |
78 | | - // chain_config.rpc_uri.to_string(), |
79 | | - // CommitmentConfig { |
80 | | - // commitment: chain_config.commitment, |
81 | | - // }, |
82 | | - // ); |
83 | | - |
84 | | - // let account = match rpc_client |
85 | | - // .get_account(&value.committed_account.pubkey) |
86 | | - // { |
87 | | - // Ok(account) => account, |
88 | | - // Err(e) => { |
89 | | - // log::warn!("Fallback to commit_state and send full-bytes, as rpc failed to fetch the delegated-account from base chain, commmit_id: {} , error: {}", value.commit_id, e); |
90 | | - // let args = CommitStateArgs { |
91 | | - // nonce: value.commit_id, |
92 | | - // lamports: value.committed_account.account.lamports, |
93 | | - // data: value.committed_account.account.data.clone(), |
94 | | - // allow_undelegation: value.allow_undelegation, |
95 | | - // }; |
96 | | - // return dlp::instruction_builder::commit_state( |
97 | | - // *validator, |
98 | | - // value.committed_account.pubkey, |
99 | | - // value.committed_account.account.owner, |
100 | | - // args, |
101 | | - // ); |
102 | | - // } |
103 | | - // }; |
104 | | - |
105 | | - // let args = CommitDiffArgs { |
106 | | - // nonce: value.commit_id, |
107 | | - // lamports: value.committed_account.account.lamports, |
108 | | - // diff: compute_diff( |
109 | | - // account.data(), |
110 | | - // value.committed_account.account.data(), |
111 | | - // ) |
112 | | - // .to_vec(), |
113 | | - // allow_undelegation: value.allow_undelegation, |
114 | | - // }; |
115 | | - // dlp::instruction_builder::commit_diff( |
116 | | - // *validator, |
117 | | - // value.committed_account.pubkey, |
118 | | - // value.committed_account.account.owner, |
119 | | - // args, |
120 | | - // ) |
121 | | - // } |
122 | 56 | ArgsTaskType::Finalize(value) => { |
123 | 57 | dlp::instruction_builder::finalize( |
124 | 58 | *validator, |
|
0 commit comments