11use dlp:: {
2- args:: { CallHandlerArgs , CommitDiffArgs , CommitStateArgs } ,
2+ args:: {
3+ CallHandlerArgs , CommitDiffArgs , CommitFinalizeArgs , CommitStateArgs ,
4+ } ,
35 compute_diff,
46 instruction_builder:: {
5- call_handler_size_budget, commit_diff_size_budget, commit_size_budget,
6- finalize_size_budget, undelegate_size_budget,
7+ call_handler_size_budget, commit_diff_size_budget,
8+ commit_finalize_size_budget, commit_size_budget, finalize_size_budget,
9+ undelegate_size_budget,
710 } ,
811 AccountSizeClass ,
912} ;
@@ -18,14 +21,16 @@ use crate::tasks::{
1821 buffer_task:: { BufferTask , BufferTaskType } ,
1922 visitor:: Visitor ,
2023 BaseActionTask , BaseTask , BaseTaskError , BaseTaskResult , CommitDiffTask ,
21- CommitTask , FinalizeTask , PreparationState , TaskType , UndelegateTask ,
24+ CommitFinalizeTask , CommitTask , FinalizeTask , PreparationState , TaskType ,
25+ UndelegateTask ,
2226} ;
2327
2428/// Task that will be executed on Base layer via arguments
2529#[ derive( Clone ) ]
2630pub enum ArgsTaskType {
2731 Commit ( CommitTask ) ,
2832 CommitDiff ( CommitDiffTask ) ,
33+ CommitFinalize ( CommitFinalizeTask ) ,
2934 Finalize ( FinalizeTask ) ,
3035 Undelegate ( UndelegateTask ) , // Special action really
3136 BaseAction ( BaseActionTask ) ,
@@ -88,6 +93,41 @@ impl BaseTask for ArgsTask {
8893 args,
8994 )
9095 }
96+ ArgsTaskType :: CommitFinalize ( value) => {
97+ let args = CommitFinalizeArgs {
98+ nonce : value. commit_id ,
99+ lamports : value. committed_account . account . lamports ,
100+
101+ data : if let Some ( base_account) = & value. base_account {
102+ compute_diff (
103+ base_account. data ( ) ,
104+ value. committed_account . account . data ( ) ,
105+ )
106+ . to_vec ( )
107+ } else {
108+ value. committed_account . account . data . clone ( )
109+ } ,
110+
111+ data_is_diff : value
112+ . base_account
113+ . as_ref ( )
114+ . map ( |_| 1 )
115+ . unwrap_or ( 0 ) ,
116+
117+ allow_undelegation : if value. allow_undelegation {
118+ 1
119+ } else {
120+ 0
121+ } ,
122+ } ;
123+
124+ dlp:: instruction_builder:: commit_finalize (
125+ * validator,
126+ value. committed_account . pubkey ,
127+ value. committed_account . account . owner ,
128+ args,
129+ )
130+ }
91131 ArgsTaskType :: Finalize ( value) => {
92132 dlp:: instruction_builder:: finalize (
93133 * validator,
@@ -141,7 +181,8 @@ impl BaseTask for ArgsTask {
141181 BufferTaskType :: CommitDiff ( value) ,
142182 ) ) )
143183 }
144- ArgsTaskType :: BaseAction ( _)
184+ ArgsTaskType :: CommitFinalize ( _)
185+ | ArgsTaskType :: BaseAction ( _)
145186 | ArgsTaskType :: Finalize ( _)
146187 | ArgsTaskType :: Undelegate ( _) => Err ( self ) ,
147188 }
@@ -168,6 +209,7 @@ impl BaseTask for ArgsTask {
168209 match & self . task_type {
169210 ArgsTaskType :: Commit ( _) => 70_000 ,
170211 ArgsTaskType :: CommitDiff ( _) => 70_000 ,
212+ ArgsTaskType :: CommitFinalize ( _) => 25000 ,
171213 ArgsTaskType :: BaseAction ( task) => task. action . compute_units ,
172214 ArgsTaskType :: Undelegate ( _) => 70_000 ,
173215 ArgsTaskType :: Finalize ( _) => 70_000 ,
@@ -186,6 +228,11 @@ impl BaseTask for ArgsTask {
186228 task. committed_account . account . data . len ( ) as u32 ,
187229 ) )
188230 }
231+ ArgsTaskType :: CommitFinalize ( task) => {
232+ commit_finalize_size_budget ( AccountSizeClass :: Dynamic (
233+ task. committed_account . account . data . len ( ) as u32 ,
234+ ) )
235+ }
189236 ArgsTaskType :: BaseAction ( task) => {
190237 // assume all other accounts are Small accounts.
191238 let other_accounts_budget =
@@ -215,6 +262,7 @@ impl BaseTask for ArgsTask {
215262 match & self . task_type {
216263 ArgsTaskType :: Commit ( _) => TaskType :: Commit ,
217264 ArgsTaskType :: CommitDiff ( _) => TaskType :: Commit ,
265+ ArgsTaskType :: CommitFinalize ( _) => TaskType :: CommitFinalize ,
218266 ArgsTaskType :: BaseAction ( _) => TaskType :: Action ,
219267 ArgsTaskType :: Undelegate ( _) => TaskType :: Undelegate ,
220268 ArgsTaskType :: Finalize ( _) => TaskType :: Finalize ,
@@ -234,6 +282,9 @@ impl BaseTask for ArgsTask {
234282 ArgsTaskType :: CommitDiff ( task) => {
235283 task. commit_id = commit_id;
236284 }
285+ ArgsTaskType :: CommitFinalize ( task) => {
286+ task. commit_id = commit_id;
287+ }
237288 ArgsTaskType :: BaseAction ( _)
238289 | ArgsTaskType :: Finalize ( _)
239290 | ArgsTaskType :: Undelegate ( _) => { }
@@ -246,6 +297,7 @@ impl LabelValue for ArgsTask {
246297 match self . task_type {
247298 ArgsTaskType :: Commit ( _) => "args_commit" ,
248299 ArgsTaskType :: CommitDiff ( _) => "args_commit_diff" ,
300+ ArgsTaskType :: CommitFinalize ( _) => "args_commit_finalize" ,
249301 ArgsTaskType :: BaseAction ( _) => "args_action" ,
250302 ArgsTaskType :: Finalize ( _) => "args_finalize" ,
251303 ArgsTaskType :: Undelegate ( _) => "args_undelegate" ,
0 commit comments