Skip to content
This repository has been archived by the owner on Jan 22, 2025. It is now read-only.

Commit

Permalink
Merge branch 'master' into wen_restart_aggregate_last_voted_fork_slots
Browse files Browse the repository at this point in the history
  • Loading branch information
wen-coding authored Jan 31, 2024
2 parents 0620aaf + 0569304 commit 1ceda56
Show file tree
Hide file tree
Showing 15 changed files with 101 additions and 137 deletions.
20 changes: 10 additions & 10 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ bzip2 = "0.4.4"
caps = "0.5.5"
cargo_metadata = "0.15.4"
cc = "1.0.83"
chrono = { version = "0.4.32", default-features = false }
chrono = { version = "0.4.33", default-features = false }
chrono-humanize = "0.2.3"
clap = "2.33.1"
console = "0.15.8"
Expand Down Expand Up @@ -212,7 +212,7 @@ gethostname = "0.2.3"
getrandom = "0.2.10"
goauth = "0.13.1"
hex = "0.4.3"
hidapi = { version = "2.5.0", default-features = false }
hidapi = { version = "2.5.1", default-features = false }
histogram = "0.6.9"
hmac = "0.12.1"
http = "0.2.11"
Expand Down Expand Up @@ -292,10 +292,10 @@ rustversion = "1.0.14"
scopeguard = "1.2.0"
semver = "1.0.21"
seqlock = "0.2.0"
serde = "1.0.195"
serde = "1.0.196"
serde_bytes = "0.11.14"
serde_derive = "1.0.103"
serde_json = "1.0.111"
serde_json = "1.0.113"
serde_with = { version = "2.3.3", default-features = false }
serde_yaml = "0.9.30"
serial_test = "2.0.0"
Expand Down
2 changes: 1 addition & 1 deletion accounts-db/src/cache_hash_data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ impl CacheHashData {
cache_dir,
pre_existing_cache_files: Arc::new(Mutex::new(HashSet::default())),
deletion_policy,
stats: Arc::default(),
stats: Arc::new(CacheHashDataStats::default()),
};

result.get_cache_files();
Expand Down
2 changes: 1 addition & 1 deletion accounts-db/src/tiered_storage/hot.rs
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,7 @@ impl HotStorageReader {
}

/// Returns the offset to the account given the specified index.
fn get_account_offset(
pub(super) fn get_account_offset(
&self,
index_offset: IndexOffset,
) -> TieredStorageResult<HotAccountOffset> {
Expand Down
37 changes: 37 additions & 0 deletions accounts-db/src/tiered_storage/readable.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
use {
crate::{
account_storage::meta::StoredAccountMeta,
accounts_file::MatchAccountOwnerError,
accounts_hash::AccountHash,
tiered_storage::{
footer::{AccountMetaFormat, TieredStorageFooter},
hot::HotStorageReader,
index::IndexOffset,
meta::TieredAccountMeta,
TieredStorageResult,
},
Expand Down Expand Up @@ -111,4 +114,38 @@ impl TieredStorageReader {
Self::Hot(hot) => hot.num_accounts(),
}
}

/// Returns the account located at the specified index offset.
pub fn get_account(
&self,
index_offset: u32,
) -> TieredStorageResult<Option<(StoredAccountMeta<'_>, usize)>> {
match self {
Self::Hot(hot) => hot.get_account(IndexOffset(index_offset)),
}
}

/// Returns Ok(index_of_matching_owner) if the account owner at
/// `account_offset` is one of the pubkeys in `owners`.
///
/// Returns Err(MatchAccountOwnerError::NoMatch) if the account has 0
/// lamports or the owner is not one of the pubkeys in `owners`.
///
/// Returns Err(MatchAccountOwnerError::UnableToLoad) if there is any internal
/// error that causes the data unable to load, including `account_offset`
/// causes a data overrun.
pub fn account_matches_owners(
&self,
index_offset: u32,
owners: &[Pubkey],
) -> Result<usize, MatchAccountOwnerError> {
match self {
Self::Hot(hot) => {
let account_offset = hot
.get_account_offset(IndexOffset(index_offset))
.map_err(|_| MatchAccountOwnerError::UnableToLoad)?;
hot.account_matches_owners(account_offset, owners)
}
}
}
}
38 changes: 3 additions & 35 deletions gossip/src/cluster_info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ use {
CrdsFilter, CrdsTimeouts, ProcessPullStats, CRDS_GOSSIP_PULL_CRDS_TIMEOUT_MS,
},
crds_value::{
self, AccountsHashes, CrdsData, CrdsValue, CrdsValueLabel, EpochSlotsIndex, LowestSlot,
NodeInstance, SnapshotHashes, Version, Vote, MAX_WALLCLOCK,
self, CrdsData, CrdsValue, CrdsValueLabel, EpochSlotsIndex, LowestSlot, NodeInstance,
SnapshotHashes, Version, Vote, MAX_WALLCLOCK,
},
duplicate_shred::DuplicateShred,
epoch_slots::EpochSlots,
Expand Down Expand Up @@ -259,14 +259,6 @@ struct PullData {
filter: CrdsFilter,
}

pub fn make_accounts_hashes_message(
keypair: &Keypair,
accounts_hashes: Vec<(Slot, Hash)>,
) -> Option<CrdsValue> {
let message = CrdsData::AccountsHashes(AccountsHashes::new(keypair.pubkey(), accounts_hashes));
Some(CrdsValue::new_signed(message, keypair))
}

pub(crate) type Ping = ping_pong::Ping<[u8; GOSSIP_PING_TOKEN_SIZE]>;

// TODO These messages should go through the gpu pipeline for spam filtering
Expand Down Expand Up @@ -392,7 +384,6 @@ fn retain_staked(values: &mut Vec<CrdsValue>, stakes: &HashMap<Pubkey, u64>) {
// the various dashboards.
CrdsData::Version(_) => true,
CrdsData::NodeInstance(_) => true,
// getHealth fails if account hashes are not propagated.
CrdsData::AccountsHashes(_) => true,
CrdsData::LowestSlot(_, _)
| CrdsData::LegacyVersion(_)
Expand Down Expand Up @@ -1021,19 +1012,6 @@ impl ClusterInfo {
.push(message);
}

pub fn push_accounts_hashes(&self, accounts_hashes: Vec<(Slot, Hash)>) {
if accounts_hashes.len() > MAX_ACCOUNTS_HASHES {
warn!(
"accounts hashes too large, ignored: {}",
accounts_hashes.len(),
);
return;
}

let message = CrdsData::AccountsHashes(AccountsHashes::new(self.id(), accounts_hashes));
self.push_message(CrdsValue::new_signed(message, &self.keypair()));
}

pub fn push_snapshot_hashes(
&self,
full: (Slot, Hash),
Expand Down Expand Up @@ -1221,16 +1199,6 @@ impl ClusterInfo {
Ok(())
}

pub fn get_accounts_hash_for_node<F, Y>(&self, pubkey: &Pubkey, map: F) -> Option<Y>
where
F: FnOnce(&Vec<(Slot, Hash)>) -> Y,
{
self.time_gossip_read_lock("get_accounts_hash", &self.stats.get_accounts_hash)
.get::<&CrdsValue>(&CrdsValueLabel::AccountsHashes(*pubkey))
.map(|x| &x.accounts_hash().unwrap().hashes)
.map(map)
}

pub fn get_snapshot_hashes_for_node(&self, pubkey: &Pubkey) -> Option<SnapshotHashes> {
self.gossip
.crds
Expand Down Expand Up @@ -3185,7 +3153,7 @@ mod tests {
super::*,
crate::{
crds_gossip_pull::tests::MIN_NUM_BLOOM_FILTERS,
crds_value::{CrdsValue, CrdsValueLabel, Vote as CrdsVote},
crds_value::{AccountsHashes, CrdsValue, CrdsValueLabel, Vote as CrdsVote},
duplicate_shred::{self, tests::new_rand_shred, MAX_DUPLICATE_SHREDS},
},
itertools::izip,
Expand Down
9 changes: 1 addition & 8 deletions gossip/src/crds_value.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ pub enum CrdsData {
Vote(VoteIndex, Vote),
LowestSlot(/*DEPRECATED:*/ u8, LowestSlot),
LegacySnapshotHashes(LegacySnapshotHashes), // Deprecated
AccountsHashes(AccountsHashes),
AccountsHashes(AccountsHashes), // Deprecated
EpochSlots(EpochSlotsIndex, EpochSlots),
LegacyVersion(LegacyVersion),
Version(Version),
Expand Down Expand Up @@ -663,13 +663,6 @@ impl CrdsValue {
}
}

pub(crate) fn accounts_hash(&self) -> Option<&AccountsHashes> {
match &self.data {
CrdsData::AccountsHashes(slots) => Some(slots),
_ => None,
}
}

pub(crate) fn epoch_slots(&self) -> Option<&EpochSlots> {
match &self.data {
CrdsData::EpochSlots(_, slots) => Some(slots),
Expand Down
9 changes: 5 additions & 4 deletions ledger-tool/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -819,12 +819,13 @@ fn main() {
),
)
.arg(
Arg::with_name("snapshot_archive_path")
.long("snapshot-archive-path")
Arg::with_name("snapshots")
.long("snapshots")
.alias("snapshot-archive-path")
.value_name("DIR")
.takes_value(true)
.global(true)
.help("Use DIR for snapshot location"),
.help("Use DIR for snapshot location [default: --ledger value]"),
)
.arg(
Arg::with_name("incremental_snapshot_archive_path")
Expand Down Expand Up @@ -1420,7 +1421,7 @@ fn main() {
info!("{} {}", crate_name!(), solana_version::version!());

let ledger_path = PathBuf::from(value_t_or_exit!(matches, "ledger_path", String));
let snapshot_archive_path = value_t!(matches, "snapshot_archive_path", String)
let snapshot_archive_path = value_t!(matches, "snapshots", String)
.ok()
.map(PathBuf::from);
let incremental_snapshot_archive_path =
Expand Down
2 changes: 1 addition & 1 deletion ledger-tool/src/program.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ fn load_accounts(path: &Path) -> Result<Input> {

fn load_blockstore(ledger_path: &Path, arg_matches: &ArgMatches<'_>) -> Arc<Bank> {
let process_options = parse_process_options(ledger_path, arg_matches);
let snapshot_archive_path = value_t!(arg_matches, "snapshot_archive_path", String)
let snapshot_archive_path = value_t!(arg_matches, "snapshots", String)
.ok()
.map(PathBuf::from);
let incremental_snapshot_archive_path =
Expand Down
16 changes: 8 additions & 8 deletions programs/sbf/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 1 addition & 13 deletions runtime/src/bank.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1853,7 +1853,7 @@ impl Bank {
fields.epoch,
))),
check_program_modification_slot: false,
epoch_reward_status: EpochRewardStatus::default(),
epoch_reward_status: fields.epoch_reward_status,
};
bank.finish_init(
genesis_config,
Expand Down Expand Up @@ -5370,7 +5370,6 @@ impl Bank {
self.get_reward_interval(),
&program_accounts_map,
&programs_loaded_for_tx_batch.borrow(),
self.should_collect_rent(),
);
load_time.stop();

Expand Down Expand Up @@ -6720,17 +6719,6 @@ impl Bank {
&self.runtime_config.compute_budget.unwrap_or_default(),
false, /* debugging_features */
));

// genesis_config loaded by accounts_db::open_genesis_config() from ledger
// has it's lamports_per_signature set to zero; bank sets its value correctly
// after the first block with a transaction in it. This is a hack to mimic
// the process.
let derived_fee_rate_governor =
FeeRateGovernor::new_derived(&genesis_config.fee_rate_governor, 0);
// new bank's fee_structure.lamports_per_signature should be inline with
// what's configured in GenesisConfig
self.fee_structure.lamports_per_signature =
derived_fee_rate_governor.lamports_per_signature;
}

pub fn set_inflation(&self, inflation: Inflation) {
Expand Down
Loading

0 comments on commit 1ceda56

Please sign in to comment.