Skip to content

Commit aa5c5a5

Browse files
committed
Merge branch 'solana_repo' of github.com:wen-coding/solana into solana_repo
2 parents 22414c6 + 9b1243e commit aa5c5a5

File tree

13 files changed

+4177
-4581
lines changed

13 files changed

+4177
-4581
lines changed

accounts-db/Cargo.toml

Lines changed: 30 additions & 83 deletions
Original file line numberDiff line numberDiff line change
@@ -10,72 +10,56 @@ license = { workspace = true }
1010
edition = { workspace = true }
1111

1212
[dependencies]
13-
ahash = { workspace = true }
13+
arrayref = { workspace = true }
1414
bincode = { workspace = true }
1515
blake3 = { workspace = true }
1616
bv = { workspace = true, features = ["serde"] }
1717
bytemuck = { workspace = true }
18-
bytemuck_derive = { workspace = true }
18+
byteorder = { workspace = true }
1919
bzip2 = { workspace = true }
2020
crossbeam-channel = { workspace = true }
2121
dashmap = { workspace = true, features = ["rayon", "raw-api"] }
22+
flate2 = { workspace = true }
23+
fnv = { workspace = true }
24+
im = { workspace = true, features = ["rayon", "serde"] }
25+
index_list = { workspace = true }
2226
indexmap = { workspace = true }
2327
itertools = { workspace = true }
28+
lazy_static = { workspace = true }
2429
log = { workspace = true }
2530
lz4 = { workspace = true }
2631
memmap2 = { workspace = true }
2732
modular-bitfield = { workspace = true }
33+
num-derive = { workspace = true }
34+
num-traits = { workspace = true }
2835
num_cpus = { workspace = true }
2936
num_enum = { workspace = true }
30-
qualifier_attr = { workspace = true, optional = true }
37+
percentage = { workspace = true }
38+
qualifier_attr = { workspace = true }
3139
rand = { workspace = true }
3240
rayon = { workspace = true }
41+
regex = { workspace = true }
3342
seqlock = { workspace = true }
3443
serde = { workspace = true, features = ["rc"] }
3544
serde_derive = { workspace = true }
36-
smallvec = { workspace = true, features = ["const_generics"] }
37-
solana-account = { workspace = true, features = ["serde"] }
38-
solana-address-lookup-table-interface = { workspace = true, features = [
39-
"bincode",
40-
"bytemuck",
41-
] }
45+
smallvec = { workspace = true }
4246
solana-bucket-map = { workspace = true }
43-
solana-clock = { workspace = true }
44-
solana-epoch-schedule = { workspace = true }
45-
solana-fee-calculator = { workspace = true }
46-
solana-frozen-abi = { workspace = true, optional = true, features = [
47-
"frozen-abi",
48-
] }
49-
solana-frozen-abi-macro = { workspace = true, optional = true, features = [
50-
"frozen-abi",
51-
] }
52-
solana-genesis-config = { workspace = true, features = ["serde"] }
53-
solana-hash = { workspace = true, features = ["serde"] }
54-
solana-keypair = { workspace = true, optional = true }
55-
solana-lattice-hash = { workspace = true }
47+
solana-config-program = { workspace = true }
48+
solana-frozen-abi = { workspace = true }
49+
solana-frozen-abi-macro = { workspace = true }
5650
solana-measure = { workspace = true }
57-
solana-message = { workspace = true }
5851
solana-metrics = { workspace = true }
5952
solana-nohash-hasher = { workspace = true }
60-
solana-pubkey = { workspace = true }
53+
solana-program-runtime = { workspace = true }
6154
solana-rayon-threadlimit = { workspace = true }
62-
solana-rent = { workspace = true, optional = true }
63-
solana-rent-collector = { workspace = true }
64-
solana-reward-info = { workspace = true, features = ["serde"] }
65-
solana-sha256-hasher = { workspace = true }
66-
solana-signer = { workspace = true, optional = true }
67-
solana-slot-hashes = { workspace = true }
68-
solana-stake-program = { workspace = true, optional = true }
69-
solana-svm-transaction = { workspace = true }
70-
solana-system-interface = { workspace = true }
71-
solana-sysvar = { workspace = true }
72-
solana-time-utils = { workspace = true }
73-
solana-transaction = { workspace = true }
74-
solana-transaction-context = { workspace = true }
75-
solana-transaction-error = { workspace = true }
76-
solana-vote-program = { workspace = true, optional = true }
77-
spl-generic-token = { workspace = true }
55+
solana-sdk = { workspace = true }
56+
solana-stake-program = { workspace = true }
57+
solana-svm = { workspace = true }
58+
solana-system-program = { workspace = true }
59+
solana-vote-program = { workspace = true }
7860
static_assertions = { workspace = true }
61+
strum = { workspace = true, features = ["derive"] }
62+
strum_macros = { workspace = true }
7963
tar = { workspace = true }
8064
tempfile = { workspace = true }
8165
thiserror = { workspace = true }
@@ -87,63 +71,26 @@ name = "solana_accounts_db"
8771
[dev-dependencies]
8872
assert_matches = { workspace = true }
8973
criterion = { workspace = true }
74+
ed25519-dalek = { workspace = true }
9075
libsecp256k1 = { workspace = true }
9176
memoffset = { workspace = true }
9277
rand_chacha = { workspace = true }
93-
serde_bytes = { workspace = true }
9478
# See order-crates-for-publishing.py for using this unusual `path = "."`
9579
solana-accounts-db = { path = ".", features = ["dev-context-only-utils"] }
96-
solana-compute-budget = { workspace = true }
97-
solana-instruction = { workspace = true }
9880
solana-logger = { workspace = true }
99-
solana-sdk-ids = { workspace = true }
100-
solana-slot-history = { workspace = true }
81+
solana-sdk = { workspace = true, features = ["dev-context-only-utils"] }
10182
static_assertions = { workspace = true }
102-
strum = { workspace = true, features = ["derive"] }
103-
strum_macros = { workspace = true }
10483
test-case = { workspace = true }
10584

10685
[package.metadata.docs.rs]
10786
targets = ["x86_64-unknown-linux-gnu"]
10887

109-
[features]
110-
dev-context-only-utils = [
111-
"dep:qualifier_attr",
112-
"dep:solana-keypair",
113-
"dep:solana-rent",
114-
"dep:solana-signer",
115-
"dep:solana-stake-program",
116-
"dep:solana-vote-program",
117-
"solana-account/dev-context-only-utils",
118-
"solana-pubkey/rand",
119-
"solana-transaction/dev-context-only-utils",
120-
]
121-
frozen-abi = [
122-
"dep:solana-frozen-abi",
123-
"dep:solana-frozen-abi-macro",
124-
"solana-fee-calculator/frozen-abi",
125-
"solana-vote-program/frozen-abi",
126-
]
88+
[build-dependencies]
89+
rustc_version = { workspace = true }
12790

128-
[[bench]]
129-
name = "bench_accounts_file"
130-
harness = false
91+
[features]
92+
dev-context-only-utils = []
13193

13294
[[bench]]
13395
name = "bench_hashing"
13496
harness = false
135-
136-
[[bench]]
137-
name = "read_only_accounts_cache"
138-
harness = false
139-
140-
[[bench]]
141-
name = "bench_serde"
142-
harness = false
143-
144-
[[bench]]
145-
name = "bench_lock_accounts"
146-
harness = false
147-
148-
[lints]
149-
workspace = true
Lines changed: 6 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,7 @@
11
use {
2-
criterion::{criterion_group, criterion_main, BatchSize, BenchmarkId, Criterion, Throughput},
3-
rand::seq::SliceRandom,
4-
solana_account::AccountSharedData,
5-
solana_accounts_db::{
6-
accounts_db::AccountsDb,
7-
accounts_hash::{AccountHash, AccountsHasher},
8-
},
9-
solana_hash::Hash,
10-
solana_pubkey::Pubkey,
2+
criterion::{criterion_group, criterion_main, BenchmarkId, Criterion, Throughput},
3+
solana_accounts_db::accounts_db::AccountsDb,
4+
solana_sdk::{account::AccountSharedData, pubkey::Pubkey},
115
};
126

137
const KB: usize = 1024;
@@ -26,7 +20,7 @@ const DATA_SIZES: [usize; 6] = [
2620
/// part of computing an account's hash.
2721
///
2822
/// Ensure this constant stays in sync with the value of `META_SIZE` in
29-
/// AccountsDb::hash_account_helper().
23+
/// AccountsDb::hash_account_data().
3024
const META_SIZE: usize = 81;
3125

3226
fn bench_hash_account(c: &mut Criterion) {
@@ -39,52 +33,11 @@ fn bench_hash_account(c: &mut Criterion) {
3933
let num_bytes = META_SIZE.checked_add(data_size).unwrap();
4034
group.throughput(Throughput::Bytes(num_bytes as u64));
4135
let account = AccountSharedData::new(lamports, data_size, &owner);
42-
group.bench_function(BenchmarkId::new("blake3", data_size), |b| {
36+
group.bench_function(BenchmarkId::new("data_size", data_size), |b| {
4337
b.iter(|| AccountsDb::hash_account(&account, &address));
4438
});
45-
group.bench_function(BenchmarkId::new("lattice", data_size), |b| {
46-
b.iter(|| AccountsDb::lt_hash_account(&account, &address));
47-
});
48-
}
49-
}
50-
51-
fn bench_accounts_delta_hash(c: &mut Criterion) {
52-
const ACCOUNTS_COUNTS: [usize; 4] = [
53-
1, // the smallest count; will bench overhead
54-
100, // number of accounts written per slot on mnb (with *no* rent rewrites)
55-
1_000, // number of accounts written slot on mnb (with rent rewrites)
56-
10_000, // reasonable largest number of accounts written per slot
57-
];
58-
59-
fn create_account_hashes(accounts_count: usize) -> Vec<(Pubkey, AccountHash)> {
60-
let mut account_hashes: Vec<_> = std::iter::repeat_with(|| {
61-
let address = Pubkey::new_unique();
62-
let hash = AccountHash(Hash::new_unique());
63-
(address, hash)
64-
})
65-
.take(accounts_count)
66-
.collect();
67-
68-
// since the accounts delta hash needs to sort the accounts first, ensure we're not
69-
// creating a pre-sorted vec.
70-
let mut rng = rand::thread_rng();
71-
account_hashes.shuffle(&mut rng);
72-
account_hashes
73-
}
74-
75-
let mut group = c.benchmark_group("accounts_delta_hash");
76-
for accounts_count in ACCOUNTS_COUNTS {
77-
group.throughput(Throughput::Elements(accounts_count as u64));
78-
let account_hashes = create_account_hashes(accounts_count);
79-
group.bench_function(BenchmarkId::new("accounts_count", accounts_count), |b| {
80-
b.iter_batched(
81-
|| account_hashes.clone(),
82-
AccountsHasher::accumulate_account_hashes,
83-
BatchSize::SmallInput,
84-
);
85-
});
8639
}
8740
}
8841

89-
criterion_group!(benches, bench_hash_account, bench_accounts_delta_hash);
42+
criterion_group!(benches, bench_hash_account,);
9043
criterion_main!(benches);

accounts-db/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ mod rolling_bit_field;
4040
pub mod shared_buffer_reader;
4141
pub mod sorted_storages;
4242
pub mod stake_rewards;
43+
pub mod starting_snapshot_storages;
4344
pub mod storable_accounts;
4445
pub mod tiered_storage;
4546
pub mod utils;
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
use {crate::accounts_db::AccountStorageEntry, std::sync::Arc};
2+
3+
/// Snapshot storages that the node loaded from
4+
///
5+
/// This is used to support fastboot. Since fastboot reuses existing storages, we must carefully
6+
/// handle the storages used to load at startup. If we do not handle these storages properly,
7+
/// restarting from the same local state (i.e. bank snapshot) may fail.
8+
#[derive(Debug)]
9+
pub enum StartingSnapshotStorages {
10+
/// Starting from genesis has no storages yet
11+
Genesis,
12+
/// Starting from a snapshot archive always extracts the storages from the archive, so no
13+
/// special handling is necessary to preserve them.
14+
Archive,
15+
/// Starting from local state must preserve the loaded storages. These storages must *not* be
16+
/// recycled or removed prior to taking the next snapshot, otherwise restarting from the same
17+
/// bank snapshot may fail.
18+
Fastboot(Vec<Arc<AccountStorageEntry>>),
19+
}

0 commit comments

Comments
 (0)