Skip to content

Commit

Permalink
bump again...
Browse files Browse the repository at this point in the history
  • Loading branch information
t-nelson committed Aug 24, 2023
1 parent 182645e commit 4e17f71
Show file tree
Hide file tree
Showing 13 changed files with 43 additions and 47 deletions.
4 changes: 2 additions & 2 deletions bucket_map/src/bucket.rs
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ impl<'b, T: Clone + Copy + 'static> Bucket<T> {
/// if entry does not exist, return just the index of an empty entry appropriate for this key
/// returns (existing entry, index of the found or empty entry)
fn find_index_entry_mut(
index: &mut BucketStorage<IndexBucket<T>>,
index: &BucketStorage<IndexBucket<T>>,
key: &Pubkey,
random: u64,
) -> Result<(Option<IndexEntryPlaceInBucket<T>>, u64), BucketMapError> {
Expand Down Expand Up @@ -410,7 +410,7 @@ impl<'b, T: Clone + Copy + 'static> Bucket<T> {
return Err(BucketMapError::DataNoSpace((best_fit_bucket, 0)));
}
let max_search = self.index.max_search();
let (elem, elem_ix) = Self::find_index_entry_mut(&mut self.index, key, self.random)?;
let (elem, elem_ix) = Self::find_index_entry_mut(&self.index, key, self.random)?;
let elem = if let Some(elem) = elem {
elem
} else {
Expand Down
2 changes: 1 addition & 1 deletion bucket_map/src/bucket_storage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -409,7 +409,7 @@ impl<O: BucketOccupied> BucketStorage<O> {

unsafe {
let dst = dst_slice.as_ptr() as *mut u8;
let src = src_slice.as_ptr() as *const u8;
let src = src_slice.as_ptr();
std::ptr::copy_nonoverlapping(src, dst, old_bucket.cell_size as usize);
};
}
Expand Down
2 changes: 1 addition & 1 deletion ci/rust-version.sh
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ fi
if [[ -n $RUST_NIGHTLY_VERSION ]]; then
nightly_version="$RUST_NIGHTLY_VERSION"
else
nightly_version=2023-05-31
nightly_version=2023-08-16
fi


Expand Down
6 changes: 3 additions & 3 deletions clap-utils/src/keypair.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1121,7 +1121,7 @@ mod tests {
super::*,
crate::offline::OfflineArgs,
clap::{value_t_or_exit, App, Arg},
solana_remote_wallet::{locator::Manufacturer, remote_wallet::initialize_wallet_manager},
solana_remote_wallet::locator::Manufacturer,
solana_sdk::{signer::keypair::write_keypair_file, system_instruction},
tempfile::{NamedTempFile, TempDir},
};
Expand Down Expand Up @@ -1307,13 +1307,13 @@ mod tests {
let clap_matches = clap_app.get_matches_from(args);
let keypair_str = value_t_or_exit!(clap_matches, "keypair", String);

let wallet_manager = initialize_wallet_manager()?;
//let wallet_manager: Option<Arc<RemoteWalletManager>> = None;

let signer = signer_from_path(
&clap_matches,
&keypair_str,
"signer",
&mut Some(wallet_manager),
&mut None,
)?;

assert_eq!(keypair.pubkey(), signer.pubkey());
Expand Down
6 changes: 2 additions & 4 deletions clap-v3-utils/src/keypair.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1267,7 +1267,7 @@ mod tests {
super::*,
crate::offline::OfflineArgs,
clap::{Arg, Command},
solana_remote_wallet::{locator::Manufacturer, remote_wallet::initialize_wallet_manager},
solana_remote_wallet::locator::Manufacturer,
solana_sdk::{signer::keypair::write_keypair_file, system_instruction},
tempfile::{NamedTempFile, TempDir},
};
Expand Down Expand Up @@ -1453,13 +1453,11 @@ mod tests {
let clap_matches = clap_app.get_matches_from(args);
let keypair_str: String = clap_matches.value_of_t_or_exit("keypair");

let wallet_manager = initialize_wallet_manager()?;

let signer = signer_from_path(
&clap_matches,
&keypair_str,
"signer",
&mut Some(wallet_manager),
&mut None,
)?;

assert_eq!(keypair.pubkey(), signer.pubkey());
Expand Down
2 changes: 1 addition & 1 deletion merkle-tree/src/merkle_tree.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ impl<'a> Proof<'a> {
None
}
});
matches!(result, Some(_))
result.is_some()
}
}

Expand Down
2 changes: 1 addition & 1 deletion metrics/src/metrics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -530,7 +530,7 @@ pub mod test_mocks {
self.points_written
.lock()
.unwrap()
.extend(points.into_iter());
.extend(points);

info!(
"Writing {} points ({} total)",
Expand Down
2 changes: 1 addition & 1 deletion program-runtime/src/loaded_programs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -443,7 +443,7 @@ impl LoadedPrograms {
key: Pubkey,
entry: Arc<LoadedProgram>,
) -> (bool, Arc<LoadedProgram>) {
let second_level = self.entries.entry(key).or_insert_with(Vec::new);
let second_level = self.entries.entry(key).or_default();
let index = second_level
.iter()
.position(|at| at.effective_slot >= entry.effective_slot);
Expand Down
27 changes: 14 additions & 13 deletions remote-wallet/src/remote_wallet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,12 @@ pub struct RemoteWalletManager {
devices: RwLock<Vec<Device>>,
}

// `Send` and `Sync` are not automatically derived on `RemoteWalletManager`.
// maybe due to `hidapi::HidDevice` being `!Sync`? both members are wrapped with
// locks, so should be fine to manually implement.
unsafe impl Send for RemoteWalletManager { }
unsafe impl Sync for RemoteWalletManager { }

impl RemoteWalletManager {
/// Create a new instance.
#[cfg(feature = "hidapi")]
Expand Down Expand Up @@ -307,21 +313,11 @@ pub fn is_valid_hid_device(usage_page: u16, interface_number: i32) -> bool {
usage_page == HID_GLOBAL_USAGE_PAGE || interface_number == HID_USB_DEVICE_CLASS as i32
}

/// Helper to initialize hidapi and RemoteWalletManager
#[cfg(feature = "hidapi")]
pub fn initialize_wallet_manager() -> Result<Arc<RemoteWalletManager>, RemoteWalletError> {
let hidapi = Arc::new(Mutex::new(hidapi::HidApi::new()?));
Ok(RemoteWalletManager::new(hidapi))
}
#[cfg(not(feature = "hidapi"))]
pub fn initialize_wallet_manager() -> Result<Arc<RemoteWalletManager>, RemoteWalletError> {
Err(RemoteWalletError::Hid(
"hidapi crate compilation disabled in solana-remote-wallet.".to_string(),
))
}

pub fn maybe_wallet_manager() -> Result<Option<Arc<RemoteWalletManager>>, RemoteWalletError> {
let wallet_manager = initialize_wallet_manager()?;
let wallet_manager = RemoteWalletManager::new(
Arc::new(Mutex::new(hidapi::HidApi::new()?))
);
let device_count = wallet_manager.update_devices()?;
if device_count > 0 {
Ok(Some(wallet_manager))
Expand All @@ -331,6 +327,11 @@ pub fn maybe_wallet_manager() -> Result<Option<Arc<RemoteWalletManager>>, Remote
}
}

#[cfg(not(feature = "hidapi"))]
pub fn maybe_wallet_manager() -> Result<Option<Arc<RemoteWalletManager>>, RemoteWalletError> {
Ok(None)
}

#[cfg(test)]
mod tests {
use super::*;
Expand Down
7 changes: 3 additions & 4 deletions sdk/src/recent_blockhashes_account.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ mod tests {

#[test]
fn test_create_account_empty() {
let account = create_account_with_data_for_test(vec![].into_iter());
let account = create_account_with_data_for_test(vec![]);
let recent_blockhashes = from_account::<RecentBlockhashes, _>(&account).unwrap();
assert_eq!(recent_blockhashes, RecentBlockhashes::default());
}
Expand All @@ -107,7 +107,7 @@ mod tests {
let def_hash = Hash::default();
let def_lamports_per_signature = 0;
let account = create_account_with_data_for_test(
vec![IterItem(0u64, &def_hash, def_lamports_per_signature); MAX_ENTRIES].into_iter(),
vec![IterItem(0u64, &def_hash, def_lamports_per_signature); MAX_ENTRIES],
);
let recent_blockhashes = from_account::<RecentBlockhashes, _>(&account).unwrap();
assert_eq!(recent_blockhashes.len(), MAX_ENTRIES);
Expand All @@ -118,8 +118,7 @@ mod tests {
let def_hash = Hash::default();
let def_lamports_per_signature = 0;
let account = create_account_with_data_for_test(
vec![IterItem(0u64, &def_hash, def_lamports_per_signature); MAX_ENTRIES + 1]
.into_iter(),
vec![IterItem(0u64, &def_hash, def_lamports_per_signature); MAX_ENTRIES + 1],
);
let recent_blockhashes = from_account::<RecentBlockhashes, _>(&account).unwrap();
assert_eq!(recent_blockhashes.len(), MAX_ENTRIES);
Expand Down
16 changes: 7 additions & 9 deletions sdk/src/secp256k1_instruction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -860,15 +860,13 @@ pub fn new_secp256k1_instruction(
let signature_arr = signature.serialize();
assert_eq!(signature_arr.len(), SIGNATURE_SERIALIZED_SIZE);

let mut instruction_data = vec![];
instruction_data.resize(
DATA_START
.saturating_add(eth_pubkey.len())
.saturating_add(signature_arr.len())
.saturating_add(message_arr.len())
.saturating_add(1),
0,
);
let instruction_data_len = DATA_START
.saturating_add(eth_pubkey.len())
.saturating_add(signature_arr.len())
.saturating_add(message_arr.len())
.saturating_add(1);
let mut instruction_data = vec![0; instruction_data_len];

let eth_address_offset = DATA_START;
instruction_data[eth_address_offset..eth_address_offset.saturating_add(eth_pubkey.len())]
.copy_from_slice(&eth_pubkey);
Expand Down
12 changes: 6 additions & 6 deletions sdk/src/transaction_context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ use {
cell::{Ref, RefCell, RefMut},
collections::HashSet,
pin::Pin,
sync::Arc,
rc::Rc,
},
};

Expand Down Expand Up @@ -142,7 +142,7 @@ impl TransactionAccounts {
#[derive(Debug, Clone, PartialEq)]
pub struct TransactionContext {
account_keys: Pin<Box<[Pubkey]>>,
accounts: Arc<TransactionAccounts>,
accounts:Rc<TransactionAccounts>,
instruction_stack_capacity: usize,
instruction_trace_capacity: usize,
instruction_stack: Vec<usize>,
Expand Down Expand Up @@ -173,7 +173,7 @@ impl TransactionContext {
.unzip();
Self {
account_keys: Pin::new(account_keys.into_boxed_slice()),
accounts: Arc::new(TransactionAccounts::new(accounts, rent.is_some())),
accounts: Rc::new(TransactionAccounts::new(accounts, rent.is_some())),
instruction_stack_capacity,
instruction_trace_capacity,
instruction_stack: Vec::with_capacity(instruction_stack_capacity),
Expand All @@ -194,13 +194,13 @@ impl TransactionContext {
return Err(InstructionError::CallDepth);
}

Ok(Arc::try_unwrap(self.accounts)
Ok(Rc::try_unwrap(self.accounts)
.expect("transaction_context.accounts has unexpected outstanding refs")
.into_accounts())
}

#[cfg(not(target_os = "solana"))]
pub fn accounts(&self) -> &Arc<TransactionAccounts> {
pub fn accounts(&self) -> &Rc<TransactionAccounts> {
&self.accounts
}

Expand Down Expand Up @@ -1208,7 +1208,7 @@ pub struct ExecutionRecord {
#[cfg(not(target_os = "solana"))]
impl From<TransactionContext> for ExecutionRecord {
fn from(context: TransactionContext) -> Self {
let accounts = Arc::try_unwrap(context.accounts)
let accounts = Rc::try_unwrap(context.accounts)
.expect("transaction_context.accounts has unexpectd outstanding refs");
let touched_account_count = accounts.touched_count() as u64;
let accounts = accounts.into_accounts();
Expand Down
2 changes: 1 addition & 1 deletion storage-proto/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ fn main() -> Result<(), std::io::Error> {
let mut protos = Vec::new();
for proto_file in &proto_files {
let proto = proto_base_path.join(proto_file);
println!("cargo::rerun-if-changed={}", proto.display());
println!("cargo:rerun-if-changed={}", proto.display());
protos.push(proto);
}

Expand Down

0 comments on commit 4e17f71

Please sign in to comment.