Skip to content

Commit 8f5242a

Browse files
committed
add account proof crate
1 parent 623dec4 commit 8f5242a

File tree

11 files changed

+733
-1
lines changed

11 files changed

+733
-1
lines changed

Cargo.lock

Lines changed: 15 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ split-debuginfo = "packed"
66
[workspace]
77
members = [
88
"account-decoder",
9+
"account-proof",
910
"accounts-bench",
1011
"accounts-cluster-bench",
1112
"accounts-db",
@@ -307,6 +308,7 @@ smpl_jwt = "0.7.1"
307308
socket2 = "0.5.5"
308309
soketto = "0.7"
309310
solana-account-decoder = { path = "account-decoder", version = "=1.18.0" }
311+
solana-account-proof = {path = "account-proof", version = "=1.18.0"}
310312
solana-accounts-db = { path = "accounts-db", version = "=1.18.0" }
311313
solana-address-lookup-table-program = { path = "programs/address-lookup-table", version = "=1.18.0" }
312314
solana-banks-client = { path = "banks-client", version = "=1.18.0" }

account-proof/Cargo.toml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
[package]
2+
name = "solana-account-proof"
3+
version.workspace = true
4+
authors.workspace = true
5+
repository.workspace = true
6+
homepage.workspace = true
7+
license.workspace = true
8+
edition.workspace = true
9+
10+
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
11+
12+
[dependencies]
13+
borsh = {workspace = true}
14+
solana-sdk={workspace = true}
15+
blake3={workspace=true}
16+
rayon={worksapce=true}
17+
rand={workspace=true}
18+
solana-accounts-db={workspace=true}
19+
solana-runtime={workspace=true}
20+
anyhow={workspace=true}
21+
22+
23+
[package.metadata.docs.rs]
24+
targets = ["x86_64-unknown-linux-gnu"]

account-proof/src/lib.rs

Lines changed: 114 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
1+
// use solana_geyser_plugin_interface::geyser_plugin_interface::{ReplicaBlockInfoV2, SlotStatus};
2+
use {
3+
borsh::{BorshDeserialize, BorshSerialize},
4+
solana_sdk::{hash::Hash, message::legacy::Message, pubkey::Pubkey, signature::Signature},
5+
std::collections::HashMap,
6+
};
7+
pub mod utils;
8+
pub type AccountHashAccumulator = HashMap<u64, AccountHashMap>;
9+
pub type TransactionSigAccumulator = HashMap<u64, u64>;
10+
pub type SlotHashProofAccumulator = HashMap<u64, (Hash, BankHashProof)>;
11+
pub type VoteAccumulator = HashMap<u64, VoteHashMap>;
12+
pub type VoteHashMap = HashMap<Signature, VoteInfo>;
13+
pub type AccountHashMap = HashMap<Pubkey, (u64, Hash, AccountInfo)>;
14+
15+
#[derive(Clone, Debug, BorshSerialize, BorshDeserialize)]
16+
pub struct Proof {
17+
pub path: Vec<usize>, // Position in the chunk (between 0 and 15) for each level.
18+
pub siblings: Vec<Vec<Hash>>, // Sibling hashes at each level.
19+
}
20+
21+
#[derive(Clone, Debug, BorshSerialize, BorshDeserialize)]
22+
pub struct BankHashComponents {
23+
parent_bankhash: Hash,
24+
accounts_delta_hash: Hash,
25+
num_sigs: u64,
26+
current_blockhash: Hash,
27+
}
28+
29+
#[derive(Clone, Debug, BorshSerialize, BorshDeserialize)]
30+
pub struct Data {
31+
pub pubkey: Pubkey,
32+
pub hash: Hash,
33+
pub account: AccountInfo,
34+
}
35+
36+
#[derive(Clone, Debug, BorshSerialize, BorshDeserialize)]
37+
pub struct AccountDeltaProof(pub Pubkey, pub (Data, Proof));
38+
39+
#[derive(Clone, Debug, BorshSerialize, BorshDeserialize)]
40+
pub struct BankHashProof {
41+
pub proofs: Vec<AccountDeltaProof>,
42+
pub num_sigs: u64,
43+
pub account_delta_root: Hash,
44+
pub parent_bankhash: Hash,
45+
pub blockhash: Hash,
46+
}
47+
48+
#[derive(Clone, Debug, BorshSerialize, BorshDeserialize)]
49+
pub struct Update {
50+
pub slot: u64,
51+
pub root: Hash,
52+
pub proof: BankHashProof,
53+
}
54+
55+
#[derive(Debug, Clone, BorshSerialize, BorshDeserialize)]
56+
pub struct AccountInfo {
57+
/// The Pubkey for the account
58+
pub pubkey: Pubkey,
59+
60+
/// The lamports for the account
61+
pub lamports: u64,
62+
63+
/// The Pubkey of the owner program account
64+
pub owner: Pubkey,
65+
66+
/// This account's data contains a loaded program (and is now read-only)
67+
pub executable: bool,
68+
69+
/// The epoch at which this account will next owe rent
70+
pub rent_epoch: u64,
71+
72+
/// The data held in this account.
73+
pub data: Vec<u8>,
74+
75+
/// A global monotonically increasing atomic number, which can be used
76+
/// to tell the order of the account update. For example, when an
77+
/// account is updated in the same slot multiple times, the update
78+
/// with higher write_version should supersede the one with lower
79+
/// write_version.
80+
pub write_version: u64,
81+
82+
/// Slot number for this update
83+
pub slot: u64,
84+
}
85+
86+
impl Default for AccountInfo {
87+
fn default() -> Self {
88+
AccountInfo {
89+
pubkey: Pubkey::default(),
90+
lamports: 0,
91+
owner: Pubkey::default(),
92+
executable: false,
93+
rent_epoch: 0,
94+
data: Vec::new(),
95+
write_version: 0,
96+
slot: 0,
97+
}
98+
}
99+
}
100+
101+
#[derive(Debug, Clone)]
102+
pub struct TransactionInfo {
103+
pub slot: u64,
104+
pub num_sigs: u64,
105+
}
106+
107+
#[derive(Debug, Clone)]
108+
pub struct VoteInfo {
109+
pub slot: u64,
110+
pub signature: Signature,
111+
pub vote_for_slot: u64,
112+
pub vote_for_hash: Hash,
113+
pub message: Message,
114+
}

0 commit comments

Comments
 (0)