dlp_api/args/commit_state.rs
1use std::mem::size_of;
2
3use borsh::{BorshDeserialize, BorshSerialize};
4use bytemuck::{Pod, Zeroable};
5
6use crate::args::{ArgsWithBuffer, Boolean};
7
8/// bumps of the PDA accounts to be validated by ix
9#[repr(C)]
10#[derive(Copy, Clone, Pod, Zeroable, Default)]
11pub struct CommitBumps {
12 pub delegation_record: u8,
13 pub delegation_metadata: u8,
14 pub validator_fees_vault: u8,
15}
16
17#[repr(C)]
18#[derive(Copy, Clone, Pod, Zeroable)]
19pub struct CommitFinalizeArgs {
20 /// the commit_id ensures correct ordering of commits
21 pub commit_id: u64,
22
23 /// the lamports that the delegated account holds in the ephemeral validator
24 pub lamports: u64,
25
26 /// whether the account can be undelegated after the commit completes
27 pub allow_undelegation: Boolean,
28
29 /// whether the data (in the ixdata or in the data account) is diff or full state.
30 pub data_is_diff: Boolean,
31
32 /// bumps of the PDA accounts to be validated by the ix
33 pub bumps: CommitBumps,
34
35 pub reserved_padding: [u8; 3],
36}
37
38pub type CommitFinalizeArgsWithBuffer<'a> =
39 ArgsWithBuffer<'a, CommitFinalizeArgs>;
40
41#[derive(Default, Debug, BorshSerialize, BorshDeserialize)]
42pub struct CommitStateArgs {
43 /// "Nonce" of an account. Updates are submitted historically and nonce incremented by 1
44 /// Deprecated: The ephemeral slot at which the account data is committed
45 pub nonce: u64,
46 /// The lamports that the account holds in the ephemeral validator
47 pub lamports: u64,
48 /// Whether the account can be undelegated after the commit completes
49 pub allow_undelegation: bool,
50 /// The account data
51 pub data: Vec<u8>,
52}
53
54#[derive(Default, Debug, BorshSerialize, BorshDeserialize)]
55pub struct CommitStateFromBufferArgs {
56 /// "Nonce" of an account. Updates are submitted historically and nonce incremented by 1
57 /// Deprecated: The ephemeral slot at which the account data is committed
58 pub nonce: u64,
59 /// The lamports that the account holds in the ephemeral validator
60 pub lamports: u64,
61 /// Whether the account can be undelegated after the commit completes
62 pub allow_undelegation: bool,
63}
64
65#[derive(Default, Debug, BorshSerialize)]
66pub struct CommitDiffArgs {
67 /// The account diff
68 /// SAFETY: this must be the FIRST field in the struct because the serialized format
69 /// is manually split: the diff (with Borsh Vec prefix) followed by the fixed-size
70 /// fields. The processor uses `data.split_at(data.len() - SIZE_COMMIT_DIFF_ARGS_WITHOUT_DIFF)`
71 /// to separate them during deserialization.
72 pub diff: Vec<u8>,
73
74 /// "Nonce" of an account. Updates are submitted historically and nonce incremented by 1
75 /// Deprecated: The ephemeral slot at which the account data is committed
76 pub nonce: u64,
77
78 /// The lamports that the account holds in the ephemeral validator
79 pub lamports: u64,
80
81 /// Whether the account can be undelegated after the commit completes
82 pub allow_undelegation: bool,
83}
84
85#[derive(Default, Debug, BorshDeserialize)]
86pub struct CommitDiffArgsWithoutDiff {
87 /// "Nonce" of an account. Updates are submitted historically and nonce incremented by 1
88 /// Deprecated: The ephemeral slot at which the account data is committed
89 pub nonce: u64,
90 /// The lamports that the account holds in the ephemeral validator
91 pub lamports: u64,
92 /// Whether the account can be undelegated after the commit completes
93 pub allow_undelegation: bool,
94}
95
96pub const SIZE_COMMIT_DIFF_ARGS_WITHOUT_DIFF: usize =
97 size_of::<u64>() + size_of::<u64>() + size_of::<bool>();