Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Override builtins #10

Closed
wants to merge 16 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
273 changes: 136 additions & 137 deletions Cargo.lock

Large diffs are not rendered by default.

168 changes: 84 additions & 84 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ exclude = ["programs/sbf"]
resolver = "2"

[workspace.package]
version = "1.18.0"
version = "1.19.0"
authors = ["Solana Labs Maintainers <[email protected]>"]
repository = "https://github.com/solana-labs/solana"
homepage = "https://solanalabs.com/"
Expand All @@ -139,7 +139,7 @@ Inflector = "0.11.4"
aquamarine = "0.3.3"
aes-gcm-siv = "0.10.3"
ahash = "0.8.8"
anyhow = "1.0.79"
anyhow = "1.0.80"
arbitrary = "1.3.2"
ark-bn254 = "0.4.0"
ark-ec = "0.4.0"
Expand Down Expand Up @@ -291,14 +291,14 @@ rustc_version = "0.4"
rustls = { version = "0.21.10", default-features = false, features = ["quic"] }
rustversion = "1.0.14"
scopeguard = "1.2.0"
semver = "1.0.21"
semver = "1.0.22"
seqlock = "0.2.0"
serde = "1.0.196"
serde_bytes = "0.11.14"
serde_derive = "1.0.103"
serde_json = "1.0.113"
serde_with = { version = "2.3.3", default-features = false }
serde_yaml = "0.9.31"
serde_yaml = "0.9.32"
serial_test = "2.0.0"
sha2 = "0.10.8"
sha3 = "0.10.4"
Expand All @@ -308,87 +308,87 @@ smallvec = "1.13.1"
smpl_jwt = "0.7.1"
socket2 = "0.5.5"
soketto = "0.7"
solana-account-decoder = { path = "account-decoder", version = "=1.18.0" }
solana-accounts-db = { path = "accounts-db", version = "=1.18.0" }
solana-address-lookup-table-program = { path = "programs/address-lookup-table", version = "=1.18.0" }
solana-banks-client = { path = "banks-client", version = "=1.18.0" }
solana-banks-interface = { path = "banks-interface", version = "=1.18.0" }
solana-banks-server = { path = "banks-server", version = "=1.18.0" }
solana-bench-tps = { path = "bench-tps", version = "=1.18.0" }
solana-bloom = { path = "bloom", version = "=1.18.0" }
solana-bpf-loader-program = { path = "programs/bpf_loader", version = "=1.18.0" }
solana-bucket-map = { path = "bucket_map", version = "=1.18.0" }
solana-cargo-registry = { path = "cargo-registry", version = "=1.18.0" }
solana-clap-utils = { path = "clap-utils", version = "=1.18.0" }
solana-clap-v3-utils = { path = "clap-v3-utils", version = "=1.18.0" }
solana-cli = { path = "cli", version = "=1.18.0" }
solana-cli-config = { path = "cli-config", version = "=1.18.0" }
solana-cli-output = { path = "cli-output", version = "=1.18.0" }
solana-client = { path = "client", version = "=1.18.0" }
solana-compute-budget-program = { path = "programs/compute-budget", version = "=1.18.0" }
solana-config-program = { path = "programs/config", version = "=1.18.0" }
solana-connection-cache = { path = "connection-cache", version = "=1.18.0", default-features = false }
solana-core = { path = "core", version = "=1.18.0" }
solana-cost-model = { path = "cost-model", version = "=1.18.0" }
solana-download-utils = { path = "download-utils", version = "=1.18.0" }
solana-entry = { path = "entry", version = "=1.18.0" }
solana-faucet = { path = "faucet", version = "=1.18.0" }
solana-frozen-abi = { path = "frozen-abi", version = "=1.18.0" }
solana-frozen-abi-macro = { path = "frozen-abi/macro", version = "=1.18.0" }
solana-genesis = { path = "genesis", version = "=1.18.0" }
solana-genesis-utils = { path = "genesis-utils", version = "=1.18.0" }
solana-geyser-plugin-interface = { path = "geyser-plugin-interface", version = "=1.18.0" }
solana-geyser-plugin-manager = { path = "geyser-plugin-manager", version = "=1.18.0" }
solana-gossip = { path = "gossip", version = "=1.18.0" }
solana-ledger = { path = "ledger", version = "=1.18.0" }
solana-loader-v4-program = { path = "programs/loader-v4", version = "=1.18.0" }
solana-local-cluster = { path = "local-cluster", version = "=1.18.0" }
solana-logger = { path = "logger", version = "=1.18.0" }
solana-measure = { path = "measure", version = "=1.18.0" }
solana-merkle-tree = { path = "merkle-tree", version = "=1.18.0" }
solana-metrics = { path = "metrics", version = "=1.18.0" }
solana-net-utils = { path = "net-utils", version = "=1.18.0" }
solana-account-decoder = { path = "account-decoder", version = "=1.19.0" }
solana-accounts-db = { path = "accounts-db", version = "=1.19.0" }
solana-address-lookup-table-program = { path = "programs/address-lookup-table", version = "=1.19.0" }
solana-banks-client = { path = "banks-client", version = "=1.19.0" }
solana-banks-interface = { path = "banks-interface", version = "=1.19.0" }
solana-banks-server = { path = "banks-server", version = "=1.19.0" }
solana-bench-tps = { path = "bench-tps", version = "=1.19.0" }
solana-bloom = { path = "bloom", version = "=1.19.0" }
solana-bpf-loader-program = { path = "programs/bpf_loader", version = "=1.19.0" }
solana-bucket-map = { path = "bucket_map", version = "=1.19.0" }
solana-cargo-registry = { path = "cargo-registry", version = "=1.19.0" }
solana-clap-utils = { path = "clap-utils", version = "=1.19.0" }
solana-clap-v3-utils = { path = "clap-v3-utils", version = "=1.19.0" }
solana-cli = { path = "cli", version = "=1.19.0" }
solana-cli-config = { path = "cli-config", version = "=1.19.0" }
solana-cli-output = { path = "cli-output", version = "=1.19.0" }
solana-client = { path = "client", version = "=1.19.0" }
solana-compute-budget-program = { path = "programs/compute-budget", version = "=1.19.0" }
solana-config-program = { path = "programs/config", version = "=1.19.0" }
solana-connection-cache = { path = "connection-cache", version = "=1.19.0", default-features = false }
solana-core = { path = "core", version = "=1.19.0" }
solana-cost-model = { path = "cost-model", version = "=1.19.0" }
solana-download-utils = { path = "download-utils", version = "=1.19.0" }
solana-entry = { path = "entry", version = "=1.19.0" }
solana-faucet = { path = "faucet", version = "=1.19.0" }
solana-frozen-abi = { path = "frozen-abi", version = "=1.19.0" }
solana-frozen-abi-macro = { path = "frozen-abi/macro", version = "=1.19.0" }
solana-genesis = { path = "genesis", version = "=1.19.0" }
solana-genesis-utils = { path = "genesis-utils", version = "=1.19.0" }
solana-geyser-plugin-interface = { path = "geyser-plugin-interface", version = "=1.19.0" }
solana-geyser-plugin-manager = { path = "geyser-plugin-manager", version = "=1.19.0" }
solana-gossip = { path = "gossip", version = "=1.19.0" }
solana-ledger = { path = "ledger", version = "=1.19.0" }
solana-loader-v4-program = { path = "programs/loader-v4", version = "=1.19.0" }
solana-local-cluster = { path = "local-cluster", version = "=1.19.0" }
solana-logger = { path = "logger", version = "=1.19.0" }
solana-measure = { path = "measure", version = "=1.19.0" }
solana-merkle-tree = { path = "merkle-tree", version = "=1.19.0" }
solana-metrics = { path = "metrics", version = "=1.19.0" }
solana-net-utils = { path = "net-utils", version = "=1.19.0" }
solana-nohash-hasher = "0.2.1"
solana-notifier = { path = "notifier", version = "=1.18.0" }
solana-perf = { path = "perf", version = "=1.18.0" }
solana-poh = { path = "poh", version = "=1.18.0" }
solana-program = { path = "sdk/program", version = "=1.18.0" }
solana-program-runtime = { path = "program-runtime", version = "=1.18.0" }
solana-program-test = { path = "program-test", version = "=1.18.0" }
solana-pubsub-client = { path = "pubsub-client", version = "=1.18.0" }
solana-quic-client = { path = "quic-client", version = "=1.18.0" }
solana-rayon-threadlimit = { path = "rayon-threadlimit", version = "=1.18.0" }
solana-remote-wallet = { path = "remote-wallet", version = "=1.18.0", default-features = false }
solana-unified-scheduler-logic = { path = "unified-scheduler-logic", version = "=1.18.0" }
solana-unified-scheduler-pool = { path = "unified-scheduler-pool", version = "=1.18.0" }
solana-rpc = { path = "rpc", version = "=1.18.0" }
solana-rpc-client = { path = "rpc-client", version = "=1.18.0", default-features = false }
solana-rpc-client-api = { path = "rpc-client-api", version = "=1.18.0" }
solana-rpc-client-nonce-utils = { path = "rpc-client-nonce-utils", version = "=1.18.0" }
solana-runtime = { path = "runtime", version = "=1.18.0" }
solana-runtime-transaction = { path = "runtime-transaction", version = "=1.18.0" }
solana-sdk = { path = "sdk", version = "=1.18.0" }
solana-sdk-macro = { path = "sdk/macro", version = "=1.18.0" }
solana-send-transaction-service = { path = "send-transaction-service", version = "=1.18.0" }
solana-stake-program = { path = "programs/stake", version = "=1.18.0" }
solana-storage-bigtable = { path = "storage-bigtable", version = "=1.18.0" }
solana-storage-proto = { path = "storage-proto", version = "=1.18.0" }
solana-streamer = { path = "streamer", version = "=1.18.0" }
solana-svm = { path = "svm", version = "=1.18.0" }
solana-system-program = { path = "programs/system", version = "=1.18.0" }
solana-test-validator = { path = "test-validator", version = "=1.18.0" }
solana-thin-client = { path = "thin-client", version = "=1.18.0" }
solana-tpu-client = { path = "tpu-client", version = "=1.18.0", default-features = false }
solana-transaction-status = { path = "transaction-status", version = "=1.18.0" }
solana-turbine = { path = "turbine", version = "=1.18.0" }
solana-udp-client = { path = "udp-client", version = "=1.18.0" }
solana-version = { path = "version", version = "=1.18.0" }
solana-vote = { path = "vote", version = "=1.18.0" }
solana-vote-program = { path = "programs/vote", version = "=1.18.0" }
solana-wen-restart = { path = "wen-restart", version = "=1.18.0" }
solana-zk-keygen = { path = "zk-keygen", version = "=1.18.0" }
solana-zk-token-proof-program = { path = "programs/zk-token-proof", version = "=1.18.0" }
solana-zk-token-sdk = { path = "zk-token-sdk", version = "=1.18.0" }
solana-notifier = { path = "notifier", version = "=1.19.0" }
solana-perf = { path = "perf", version = "=1.19.0" }
solana-poh = { path = "poh", version = "=1.19.0" }
solana-program = { path = "sdk/program", version = "=1.19.0" }
solana-program-runtime = { path = "program-runtime", version = "=1.19.0" }
solana-program-test = { path = "program-test", version = "=1.19.0" }
solana-pubsub-client = { path = "pubsub-client", version = "=1.19.0" }
solana-quic-client = { path = "quic-client", version = "=1.19.0" }
solana-rayon-threadlimit = { path = "rayon-threadlimit", version = "=1.19.0" }
solana-remote-wallet = { path = "remote-wallet", version = "=1.19.0", default-features = false }
solana-unified-scheduler-logic = { path = "unified-scheduler-logic", version = "=1.19.0" }
solana-unified-scheduler-pool = { path = "unified-scheduler-pool", version = "=1.19.0" }
solana-rpc = { path = "rpc", version = "=1.19.0" }
solana-rpc-client = { path = "rpc-client", version = "=1.19.0", default-features = false }
solana-rpc-client-api = { path = "rpc-client-api", version = "=1.19.0" }
solana-rpc-client-nonce-utils = { path = "rpc-client-nonce-utils", version = "=1.19.0" }
solana-runtime = { path = "runtime", version = "=1.19.0" }
solana-runtime-transaction = { path = "runtime-transaction", version = "=1.19.0" }
solana-sdk = { path = "sdk", version = "=1.19.0" }
solana-sdk-macro = { path = "sdk/macro", version = "=1.19.0" }
solana-send-transaction-service = { path = "send-transaction-service", version = "=1.19.0" }
solana-stake-program = { path = "programs/stake", version = "=1.19.0" }
solana-storage-bigtable = { path = "storage-bigtable", version = "=1.19.0" }
solana-storage-proto = { path = "storage-proto", version = "=1.19.0" }
solana-streamer = { path = "streamer", version = "=1.19.0" }
solana-svm = { path = "svm", version = "=1.19.0" }
solana-system-program = { path = "programs/system", version = "=1.19.0" }
solana-test-validator = { path = "test-validator", version = "=1.19.0" }
solana-thin-client = { path = "thin-client", version = "=1.19.0" }
solana-tpu-client = { path = "tpu-client", version = "=1.19.0", default-features = false }
solana-transaction-status = { path = "transaction-status", version = "=1.19.0" }
solana-turbine = { path = "turbine", version = "=1.19.0" }
solana-udp-client = { path = "udp-client", version = "=1.19.0" }
solana-version = { path = "version", version = "=1.19.0" }
solana-vote = { path = "vote", version = "=1.19.0" }
solana-vote-program = { path = "programs/vote", version = "=1.19.0" }
solana-wen-restart = { path = "wen-restart", version = "=1.19.0" }
solana-zk-keygen = { path = "zk-keygen", version = "=1.19.0" }
solana-zk-token-proof-program = { path = "programs/zk-token-proof", version = "=1.19.0" }
solana-zk-token-sdk = { path = "zk-token-sdk", version = "=1.19.0" }
solana_rbpf = "=0.8.0"
spl-associated-token-account = "=2.3.1"
spl-instruction-padding = "0.1"
Expand Down
61 changes: 20 additions & 41 deletions accounts-db/src/accounts_db.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9924,11 +9924,11 @@ pub mod tests {
.store(data.len(), Ordering::Relaxed);

let genesis_config = GenesisConfig::default();
assert!(db.accounts_index.get_account_read_entry(&pubkey).is_none());
assert!(!db.accounts_index.contains(&pubkey));
let result = db.generate_index(None, false, &genesis_config);
// index entry should only contain a single entry for the pubkey since index cannot hold more than 1 entry per slot
let entry = db.accounts_index.get_account_read_entry(&pubkey).unwrap();
assert_eq!(entry.slot_list().len(), 1);
let entry = db.accounts_index.get_cloned(&pubkey).unwrap();
assert_eq!(entry.slot_list.read().unwrap().len(), 1);
assert_eq!(append_vec.alive_bytes(), expected_alive_bytes);
// total # accounts in append vec
assert_eq!(append_vec.approx_stored_count(), 2);
Expand Down Expand Up @@ -11409,16 +11409,14 @@ pub mod tests {
let key = Pubkey::default();
let account0 = AccountSharedData::new(1, 0, &key);
let ancestors = vec![(unrooted_slot, 1)].into_iter().collect();
assert!(!db.accounts_index.contains(&key));
if is_cached {
db.store_cached((unrooted_slot, &[(&key, &account0)][..]), None);
} else {
db.store_for_tests(unrooted_slot, &[(&key, &account0)]);
}
assert!(db.get_bank_hash_stats(unrooted_slot).is_some());
assert!(db
.accounts_index
.get(&key, Some(&ancestors), None)
.is_some());
assert!(db.accounts_index.contains(&key));
db.assert_load_account(unrooted_slot, key, 1);

// Purge the slot
Expand All @@ -11427,11 +11425,7 @@ pub mod tests {
assert!(db.get_bank_hash_stats(unrooted_slot).is_none());
assert!(db.accounts_cache.slot_cache(unrooted_slot).is_none());
assert!(db.storage.get_slot_storage_entry(unrooted_slot).is_none());
assert!(db.accounts_index.get_account_read_entry(&key).is_none());
assert!(db
.accounts_index
.get(&key, Some(&ancestors), None)
.is_none());
assert!(!db.accounts_index.contains(&key));

// Test we can store for the same slot again and get the right information
let account0 = AccountSharedData::new(2, 0, &key);
Expand Down Expand Up @@ -12189,11 +12183,8 @@ pub mod tests {

// The earlier entry for pubkey in the account index is purged,
let (slot_list_len, index_slot) = {
let account_entry = accounts
.accounts_index
.get_account_read_entry(&pubkey)
.unwrap();
let slot_list = account_entry.slot_list();
let account_entry = accounts.accounts_index.get_cloned(&pubkey).unwrap();
let slot_list = account_entry.slot_list.read().unwrap();
(slot_list.len(), slot_list[0].0)
};
assert_eq!(slot_list_len, 1);
Expand Down Expand Up @@ -12258,10 +12249,7 @@ pub mod tests {
accounts.print_accounts_stats("post_purge");

// Make sure the index is for pubkey cleared
assert!(accounts
.accounts_index
.get_account_read_entry(&pubkey)
.is_none());
assert!(!accounts.accounts_index.contains(&pubkey));

// slot 1 & 2 should not have any stores
assert_no_stores(&accounts, 1);
Expand Down Expand Up @@ -13833,10 +13821,7 @@ pub mod tests {
assert!(db
.load_without_fixed_root(&ancestors, &unrooted_key)
.is_some());
assert!(db
.accounts_index
.get_account_read_entry(&unrooted_key)
.is_some());
assert!(db.accounts_index.contains(&unrooted_key));
assert_eq!(db.accounts_cache.num_slots(), 1);
assert!(db.accounts_cache.slot_cache(unrooted_slot).is_some());
assert_eq!(
Expand Down Expand Up @@ -14368,12 +14353,13 @@ pub mod tests {
let before_size = storage0.alive_bytes.load(Ordering::Acquire);
let account_info = accounts_db
.accounts_index
.get_account_read_entry(account.pubkey())
.map(|locked_entry| {
// Should only be one entry per key, since every key was only stored to slot 0
locked_entry.slot_list()[0]
})
.unwrap();
.get_cloned(account.pubkey())
.unwrap()
.slot_list
.read()
.unwrap()
// Should only be one entry per key, since every key was only stored to slot 0
[0];
assert_eq!(account_info.0, slot);
let reclaims = [account_info];
accounts_db.remove_dead_accounts(reclaims.iter(), None, None, true);
Expand Down Expand Up @@ -15335,8 +15321,7 @@ pub mod tests {
assert_no_storages_at_slot(&db, *slot);
assert!(db.accounts_cache.slot_cache(*slot).is_none());
let account_in_slot = slot_to_pubkey_map[slot];
let item = db.accounts_index.get_account_read_entry(&account_in_slot);
assert!(item.is_none(), "item: {item:?}");
assert!(!db.accounts_index.contains(&account_in_slot));
}

// Wait for flush to finish before starting next trial
Expand Down Expand Up @@ -15722,20 +15707,14 @@ pub mod tests {
// The later rooted zero-lamport update to `shared_key` cannot be cleaned
// because it is kept alive by the unrooted slot.
accounts.clean_accounts_for_tests();
assert!(accounts
.accounts_index
.get_account_read_entry(&shared_key)
.is_some());
assert!(accounts.accounts_index.contains(&shared_key));

// Simulate purge_slot() all from AccountsBackgroundService
accounts.purge_slot(slot0, 0, true);

// Now clean should clean up the remaining key
accounts.clean_accounts_for_tests();
assert!(accounts
.accounts_index
.get_account_read_entry(&shared_key)
.is_none());
assert!(!accounts.accounts_index.contains(&shared_key));
assert_no_storages_at_slot(&accounts, slot0);
}

Expand Down
24 changes: 24 additions & 0 deletions accounts-db/src/accounts_index.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1138,6 +1138,30 @@ impl<T: IndexValue, U: DiskIndexValue + From<T> + Into<T>> AccountsIndex<T, U> {
.map(ReadAccountMapEntry::from_account_map_entry)
}

/// Gets the index's entry for `pubkey` and applies `callback` to it
///
/// If `callback`'s boolean return value is true, add this entry to the in-mem cache.
pub fn get_and_then<R>(
&self,
pubkey: &Pubkey,
callback: impl FnOnce(Option<&AccountMapEntry<T>>) -> (bool, R),
) -> R {
self.get_bin(pubkey).get_internal(pubkey, callback)
}

/// Gets the index's entry for `pubkey` and clones it
///
/// Prefer `get_and_then()` whenever possible.
/// NOTE: The entry is *not* added to the in-mem cache.
pub fn get_cloned(&self, pubkey: &Pubkey) -> Option<AccountMapEntry<T>> {
self.get_and_then(pubkey, |entry| (false, entry.cloned()))
}

/// Is `pubkey` in the index?
pub fn contains(&self, pubkey: &Pubkey) -> bool {
self.get_and_then(pubkey, |entry| (false, entry.is_some()))
}

fn slot_list_mut<RT>(
&self,
pubkey: &Pubkey,
Expand Down
Loading
Loading