1- use dlp:: args:: { CallHandlerArgs , CommitStateArgs } ;
1+ use dlp:: args:: { CallHandlerArgs , CommitDiffArgs , CommitStateArgs } ;
22use solana_pubkey:: Pubkey ;
33use solana_sdk:: instruction:: { AccountMeta , Instruction } ;
44
@@ -15,6 +15,7 @@ use crate::tasks::{
1515#[ derive( Clone ) ]
1616pub enum ArgsTaskType {
1717 Commit ( CommitTask ) ,
18+ CommitDiff ( CommitTask ) ,
1819 Finalize ( FinalizeTask ) ,
1920 Undelegate ( UndelegateTask ) , // Special action really
2021 BaseAction ( BaseActionTask ) ,
@@ -51,21 +52,51 @@ impl BaseTask for ArgsTask {
5152 data : value. committed_account . account . data . clone ( ) ,
5253 allow_undelegation : value. allow_undelegation ,
5354 } ;
54- if value. commit_diff {
55- dlp:: instruction_builder:: commit_diff (
56- * validator,
57- value. committed_account . pubkey ,
58- value. committed_account . account . owner ,
59- args,
60- )
61- } else {
62- dlp:: instruction_builder:: commit_state (
63- * validator,
64- value. committed_account . pubkey ,
65- value. committed_account . account . owner ,
66- args,
67- )
68- }
55+ dlp:: instruction_builder:: commit_state (
56+ * validator,
57+ value. committed_account . pubkey ,
58+ value. committed_account . account . owner ,
59+ args,
60+ )
61+ }
62+ // algo:
63+ // - delegated_account, prev
64+ // - changed delegated_account
65+ // - diff = prev - delegated_account
66+ // - commit
67+ // - prev = delegated_account
68+ // - update cache with prev
69+ //
70+ // relevant files/modules/crates:
71+ // -
72+ // - https://docs.rs/scc/latest/scc/#hashcache
73+ //
74+ // diff:
75+ // - [offset1][offset2]data
76+ //
77+ // 100
78+ //
79+ // 11..15
80+ //
81+ // 31...40
82+ //
83+ // - complete: [2] [5][11] [10][31] [11..15 31 ..40]
84+ //
85+ // - [3][8][11..15 31 ..40]
86+ //
87+ ArgsTaskType :: CommitDiff ( value) => {
88+ let args = CommitDiffArgs {
89+ nonce : value. commit_id ,
90+ lamports : value. committed_account . account . lamports ,
91+ diff : vec ! [ ] , // compute diff for this field
92+ allow_undelegation : value. allow_undelegation ,
93+ } ;
94+ dlp:: instruction_builder:: commit_diff (
95+ * validator,
96+ value. committed_account . pubkey ,
97+ value. committed_account . account . owner ,
98+ args,
99+ )
69100 }
70101 ArgsTaskType :: Finalize ( value) => {
71102 dlp:: instruction_builder:: finalize (
@@ -116,7 +147,8 @@ impl BaseTask for ArgsTask {
116147 BufferTaskType :: Commit ( value) ,
117148 ) ) )
118149 }
119- ArgsTaskType :: BaseAction ( _)
150+ ArgsTaskType :: CommitDiff ( _)
151+ | ArgsTaskType :: BaseAction ( _)
120152 | ArgsTaskType :: Finalize ( _)
121153 | ArgsTaskType :: Undelegate ( _) => Err ( self ) ,
122154 }
@@ -142,6 +174,7 @@ impl BaseTask for ArgsTask {
142174 fn compute_units ( & self ) -> u32 {
143175 match & self . task_type {
144176 ArgsTaskType :: Commit ( _) => 65_000 ,
177+ ArgsTaskType :: CommitDiff ( _) => 40_000 ,
145178 ArgsTaskType :: BaseAction ( task) => task. action . compute_units ,
146179 ArgsTaskType :: Undelegate ( _) => 70_000 ,
147180 ArgsTaskType :: Finalize ( _) => 40_000 ,
@@ -156,6 +189,9 @@ impl BaseTask for ArgsTask {
156189 fn task_type ( & self ) -> TaskType {
157190 match & self . task_type {
158191 ArgsTaskType :: Commit ( _) => TaskType :: Commit ,
192+ // TODO (snawaz): What should we use here? Commit (in the sense of "category of task"), or add a
193+ // new variant "CommitDiff" to indicate a specific instruction?
194+ ArgsTaskType :: CommitDiff ( _) => TaskType :: Commit ,
159195 ArgsTaskType :: BaseAction ( _) => TaskType :: Action ,
160196 ArgsTaskType :: Undelegate ( _) => TaskType :: Undelegate ,
161197 ArgsTaskType :: Finalize ( _) => TaskType :: Finalize ,
@@ -168,6 +204,7 @@ impl BaseTask for ArgsTask {
168204 }
169205
170206 fn reset_commit_id ( & mut self , commit_id : u64 ) {
207+ // TODO (snawaz): handle CommitDiff as well?
171208 let ArgsTaskType :: Commit ( commit_task) = & mut self . task_type else {
172209 return ;
173210 } ;
0 commit comments