@@ -5,12 +5,11 @@ use pinocchio_log::log;
55use crate :: args:: CommitBumps ;
66use crate :: error:: DlpError ;
77use crate :: pod_view:: PodView ;
8- use crate :: processor:: fast:: { to_pinocchio_program_error , NewState } ;
9- use crate :: state:: { DelegationMetadataFast , DelegationRecord , ProgramConfig } ;
8+ use crate :: processor:: fast:: NewState ;
9+ use crate :: state:: { DelegationMetadataFast , DelegationRecord } ;
1010use crate :: {
1111 apply_diff_in_place, pda, require, require_eq, require_eq_keys, require_ge,
12- require_initialized_pda, require_initialized_pda_fast, require_owned_by,
13- require_program_config, require_program_config_fast, require_signer,
12+ require_initialized_pda_fast, require_owned_by, require_signer,
1413} ;
1514
1615/// Arguments for the commit state internal function
@@ -24,7 +23,6 @@ pub(crate) struct CommitFinalizeInternalArgs<'a> {
2423 pub ( crate ) delegation_record_account : & ' a AccountInfo ,
2524 pub ( crate ) delegation_metadata_account : & ' a AccountInfo ,
2625 pub ( crate ) validator_fees_vault : & ' a AccountInfo ,
27- pub ( crate ) program_config_account : & ' a AccountInfo ,
2826}
2927
3028/// Commit a new state of a delegated Pda
@@ -36,77 +34,41 @@ pub(crate) fn process_commit_finalize_internal(
3634
3735 require_signer ! ( args. validator) ;
3836
39- // additional cost: 4105
40- if false {
41- require_initialized_pda ! (
42- args. delegation_record_account,
43- & [
44- pda:: DELEGATION_RECORD_TAG ,
45- args. delegated_account. key( ) ,
46- & [ args. bumps. delegation_record]
47- ] ,
37+ require_initialized_pda_fast ! (
38+ args. delegation_record_account,
39+ & [
40+ pda:: DELEGATION_RECORD_TAG ,
41+ args. delegated_account. key( ) ,
42+ & [ args. bumps. delegation_record] ,
4843 & crate :: fast:: ID ,
49- false
50- ) ;
44+ PDA_MARKER
45+ ] ,
46+ false
47+ ) ;
5148
52- require_initialized_pda ! (
53- args. delegation_metadata_account,
54- & [
55- pda:: DELEGATION_METADATA_TAG ,
56- args. delegated_account. key( ) ,
57- & [ args. bumps. delegation_metadata]
58- ] ,
49+ require_initialized_pda_fast ! (
50+ args. delegation_metadata_account,
51+ & [
52+ pda:: DELEGATION_METADATA_TAG ,
53+ args. delegated_account. key( ) ,
54+ & [ args. bumps. delegation_metadata] ,
5955 & crate :: fast:: ID ,
60- true
61- ) ;
56+ PDA_MARKER
57+ ] ,
58+ true
59+ ) ;
6260
63- require_initialized_pda ! (
64- args. validator_fees_vault,
65- & [
66- pda:: VALIDATOR_FEES_VAULT_TAG ,
67- args. validator. key( ) ,
68- & [ args. bumps. validator_fees_vault]
69- ] ,
61+ require_initialized_pda_fast ! (
62+ args. validator_fees_vault,
63+ & [
64+ pda:: VALIDATOR_FEES_VAULT_TAG ,
65+ args. validator. key( ) ,
66+ & [ args. bumps. validator_fees_vault] ,
7067 & crate :: fast:: ID ,
71- false
72- ) ;
73- } else {
74- require_initialized_pda_fast ! (
75- args. delegation_record_account,
76- & [
77- pda:: DELEGATION_RECORD_TAG ,
78- args. delegated_account. key( ) ,
79- & [ args. bumps. delegation_record] ,
80- & crate :: fast:: ID ,
81- PDA_MARKER
82- ] ,
83- false
84- ) ;
85-
86- require_initialized_pda_fast ! (
87- args. delegation_metadata_account,
88- & [
89- pda:: DELEGATION_METADATA_TAG ,
90- args. delegated_account. key( ) ,
91- & [ args. bumps. delegation_metadata] ,
92- & crate :: fast:: ID ,
93- PDA_MARKER
94- ] ,
95- true
96- ) ;
97-
98- require_initialized_pda_fast ! (
99- args. validator_fees_vault,
100- & [
101- pda:: VALIDATOR_FEES_VAULT_TAG ,
102- args. validator. key( ) ,
103- & [ args. bumps. validator_fees_vault] ,
104- & crate :: fast:: ID ,
105- PDA_MARKER
106- ] ,
107- false
108- ) ;
109- }
68+ PDA_MARKER
69+ ] ,
70+ false
71+ ) ;
11072
11173 // validate and update metadata
11274 {
@@ -148,41 +110,6 @@ pub(crate) fn process_commit_finalize_internal(
148110 // .invoke()?;
149111 // }
150112
151- // cost = 197 CU
152- if false {
153- // Load the program configuration and validate it, if any
154- let has_program_config = if false {
155- require_program_config ! (
156- args. program_config_account,
157- delegation_record. owner. as_array( ) ,
158- args. bumps. program_config,
159- false
160- )
161- } else {
162- require_program_config_fast ! (
163- args. program_config_account,
164- delegation_record. owner. as_array( ) ,
165- args. bumps. program_config,
166- false
167- )
168- } ;
169- if has_program_config {
170- let program_config_data = args. program_config_account . try_borrow_data ( ) ?;
171-
172- let program_config =
173- ProgramConfig :: try_from_bytes_with_discriminator ( & program_config_data)
174- . map_err ( to_pinocchio_program_error) ?;
175- if !program_config
176- . approved_validators
177- . contains ( & ( * args. validator . key ( ) ) . into ( ) )
178- {
179- log ! ( "validator is not whitelisted in the program config: " ) ;
180- pubkey:: log ( args. validator . key ( ) ) ;
181- return Err ( DlpError :: InvalidWhitelistProgramConfig . into ( ) ) ;
182- }
183- }
184- }
185-
186113 args. delegated_account . resize ( args. new_state . data_len ( ) ) ?;
187114
188115 // copy the new state to the delegated account
0 commit comments