Skip to content

Commit

Permalink
Update to rust 1.40.0 (solana-labs#7572)
Browse files Browse the repository at this point in the history
* Update to rust 1.40.0

* fixups
  • Loading branch information
rob-solana authored Dec 20, 2019
1 parent 2ebfab8 commit a704089
Show file tree
Hide file tree
Showing 33 changed files with 198 additions and 139 deletions.
3 changes: 1 addition & 2 deletions banking-bench/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,6 @@ fn main() {
// If it is dropped before poh_service, then poh_service will error when
// calling send() on the channel.
let signal_receiver = Arc::new(signal_receiver);
let signal_receiver2 = signal_receiver.clone();
let mut total = 0;
let mut tx_total = 0;
let mut txs_processed = 0;
Expand Down Expand Up @@ -215,7 +214,7 @@ fn main() {
sleep(Duration::from_millis(5));
}
}
if check_txs(&signal_receiver2, txes / CHUNKS, &poh_recorder) {
if check_txs(&signal_receiver, txes / CHUNKS, &poh_recorder) {
debug!(
"resetting bank {} tx count: {} txs_proc: {}",
bank.slot(),
Expand Down
2 changes: 1 addition & 1 deletion bench-exchange/src/bench.rs
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ where
trace!("Start trader thread");
let trader_thread = {
let exit_signal = exit_signal.clone();
let shared_txs = shared_txs.clone();

let client = clients[0].clone();
Builder::new()
.name("solana-exchange-trader".to_string())
Expand Down
2 changes: 1 addition & 1 deletion ci/docker-rust-nightly/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM solanalabs/rust:1.39.0
FROM solanalabs/rust:1.40.0
ARG date

RUN set -x \
Expand Down
2 changes: 1 addition & 1 deletion ci/docker-rust/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Note: when the rust version is changed also modify
# ci/rust-version.sh to pick up the new image tag
FROM rust:1.39.0
FROM rust:1.40.0

# Add Google Protocol Buffers for Libra's metrics library.
ENV PROTOC_VERSION 3.8.0
Expand Down
4 changes: 2 additions & 2 deletions ci/rust-version.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@
if [[ -n $RUST_STABLE_VERSION ]]; then
stable_version="$RUST_STABLE_VERSION"
else
stable_version=1.39.0
stable_version=1.40.0
fi

if [[ -n $RUST_NIGHTLY_VERSION ]]; then
nightly_version="$RUST_NIGHTLY_VERSION"
else
nightly_version=2019-11-13
nightly_version=2019-12-19
fi


Expand Down
4 changes: 2 additions & 2 deletions ci/test-checks.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,15 @@ _ cargo +"$rust_stable" clippy --all --exclude solana-sdk-c -- --deny=warnings
_ cargo +"$rust_stable" clippy --manifest-path sdk-c/Cargo.toml -- --deny=warnings

_ cargo +"$rust_stable" audit --version
_ cargo +"$rust_stable" audit --ignore RUSTSEC-2019-0013 --ignore RUSTSEC-2018-0015
_ cargo +"$rust_stable" audit --ignore RUSTSEC-2019-0013 --ignore RUSTSEC-2018-0015 --ignore RUSTSEC-2019-0031
_ ci/nits.sh
_ ci/order-crates-for-publishing.py
_ book/build.sh
_ ci/check-ssh-keys.sh

{
cd programs/bpf
_ cargo +"$rust_stable" audit
_ cargo +"$rust_stable" audit --ignore RUSTSEC-2019-0031
for project in rust/*/ ; do
echo "+++ do_bpf_checks $project"
(
Expand Down
4 changes: 2 additions & 2 deletions cli/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -802,11 +802,11 @@ fn process_deploy(
) -> ProcessResult {
let program_id = Keypair::new();
let mut file = File::open(program_location).map_err(|err| {
CliError::DynamicProgramError(format!("Unable to open program file: {}", err).to_string())
CliError::DynamicProgramError(format!("Unable to open program file: {}", err))
})?;
let mut program_data = Vec::new();
file.read_to_end(&mut program_data).map_err(|err| {
CliError::DynamicProgramError(format!("Unable to read program file: {}", err).to_string())
CliError::DynamicProgramError(format!("Unable to read program file: {}", err))
})?;

// Build transactions to calculate fees
Expand Down
14 changes: 8 additions & 6 deletions cli/src/nonce.rs
Original file line number Diff line number Diff line change
Expand Up @@ -357,9 +357,10 @@ pub fn process_create_nonce_account(
pub fn process_get_nonce(rpc_client: &RpcClient, nonce_account_pubkey: &Pubkey) -> ProcessResult {
let nonce_account = rpc_client.get_account(nonce_account_pubkey)?;
if nonce_account.owner != nonce_program::id() {
return Err(CliError::RpcRequestError(
format!("{:?} is not a nonce account", nonce_account_pubkey).to_string(),
)
return Err(CliError::RpcRequestError(format!(
"{:?} is not a nonce account",
nonce_account_pubkey
))
.into());
}
match nonce_account.state() {
Expand Down Expand Up @@ -417,9 +418,10 @@ pub fn process_show_nonce_account(
) -> ProcessResult {
let nonce_account = rpc_client.get_account(nonce_account_pubkey)?;
if nonce_account.owner != nonce_program::id() {
return Err(CliError::RpcRequestError(
format!("{:?} is not a nonce account", nonce_account_pubkey).to_string(),
)
return Err(CliError::RpcRequestError(format!(
"{:?} is not a nonce account",
nonce_account_pubkey
))
.into());
}
let print_account = |hash: Option<Hash>| {
Expand Down
7 changes: 4 additions & 3 deletions cli/src/stake.rs
Original file line number Diff line number Diff line change
Expand Up @@ -658,9 +658,10 @@ pub fn process_show_stake_account(
) -> ProcessResult {
let stake_account = rpc_client.get_account(stake_account_pubkey)?;
if stake_account.owner != solana_stake_program::id() {
return Err(CliError::RpcRequestError(
format!("{:?} is not a stake account", stake_account_pubkey).to_string(),
)
return Err(CliError::RpcRequestError(format!(
"{:?} is not a stake account",
stake_account_pubkey
))
.into());
}
fn show_authorized(authorized: &Authorized) {
Expand Down
13 changes: 6 additions & 7 deletions cli/src/storage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ pub fn process_claim_storage_reward(
&tx.message,
)?;
let signature_str = rpc_client.send_and_confirm_transaction(&mut tx, &signers)?;
Ok(signature_str.to_string())
Ok(signature_str)
}

pub fn process_show_storage_account(
Expand All @@ -225,17 +225,16 @@ pub fn process_show_storage_account(
let account = rpc_client.get_account(storage_account_pubkey)?;

if account.owner != solana_storage_program::id() {
return Err(CliError::RpcRequestError(
format!("{:?} is not a storage account", storage_account_pubkey).to_string(),
)
return Err(CliError::RpcRequestError(format!(
"{:?} is not a storage account",
storage_account_pubkey
))
.into());
}

use solana_storage_program::storage_contract::StorageContract;
let storage_contract: StorageContract = account.state().map_err(|err| {
CliError::RpcRequestError(
format!("Unable to deserialize storage account: {:?}", err).to_string(),
)
CliError::RpcRequestError(format!("Unable to deserialize storage account: {:?}", err))
})?;
println!("{:#?}", storage_contract);
println!("account lamports: {}", account.lamports);
Expand Down
7 changes: 4 additions & 3 deletions cli/src/vote.rs
Original file line number Diff line number Diff line change
Expand Up @@ -402,9 +402,10 @@ fn get_vote_account(
let vote_account = rpc_client.get_account(vote_account_pubkey)?;

if vote_account.owner != solana_vote_program::id() {
return Err(CliError::RpcRequestError(
format!("{:?} is not a vote account", vote_account_pubkey).to_string(),
)
return Err(CliError::RpcRequestError(format!(
"{:?} is not a vote account",
vote_account_pubkey
))
.into());
}
let vote_state = VoteState::deserialize(&vote_account.data).map_err(|_| {
Expand Down
10 changes: 5 additions & 5 deletions core/src/archiver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ fn create_request_processor(
let t_receiver = receiver(storage_socket.clone(), exit, s_reader, recycler, "archiver");
thread_handles.push(t_receiver);

let t_responder = responder("archiver-responder", storage_socket.clone(), r_responder);
let t_responder = responder("archiver-responder", storage_socket, r_responder);
thread_handles.push(t_responder);

let exit = exit.clone();
Expand Down Expand Up @@ -428,7 +428,7 @@ impl Archiver {
"collected mining rewards: Account balance {:?}",
client.get_balance_with_commitment(
&archiver_keypair.pubkey(),
client_commitment.clone()
client_commitment
)
);
}
Expand Down Expand Up @@ -493,7 +493,7 @@ impl Archiver {

let _sigverify_stage = SigVerifyStage::new(
shred_fetch_receiver,
verified_sender.clone(),
verified_sender,
DisabledSigVerifier::default(),
);

Expand Down Expand Up @@ -650,7 +650,7 @@ impl Archiver {
let tx = Transaction::new_signed_instructions(&[keypair], ix, blockhash);
let signature = client.async_send_transaction(tx)?;
client
.poll_for_signature_with_commitment(&signature, client_commitment.clone())
.poll_for_signature_with_commitment(&signature, client_commitment)
.map_err(|err| match err {
TransportError::IoError(e) => e,
TransportError::TransactionError(_) => io::Error::new(
Expand Down Expand Up @@ -866,7 +866,7 @@ impl Archiver {
let t_receiver = receiver(
repair_socket.clone(),
&exit,
s_reader.clone(),
s_reader,
Recycler::default(),
"archiver_reeciver",
);
Expand Down
11 changes: 5 additions & 6 deletions core/src/cluster_info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -203,8 +203,7 @@ impl ClusterInfo {

pub fn insert_self(&mut self, contact_info: ContactInfo) {
if self.id() == contact_info.id {
let value =
CrdsValue::new_signed(CrdsData::ContactInfo(contact_info.clone()), &self.keypair);
let value = CrdsValue::new_signed(CrdsData::ContactInfo(contact_info), &self.keypair);
let _ = self.gossip.crds.insert(value, timestamp());
}
}
Expand Down Expand Up @@ -831,19 +830,19 @@ impl ClusterInfo {
}

pub fn window_index_request_bytes(&self, slot: Slot, shred_index: u64) -> Result<Vec<u8>> {
let req = Protocol::RequestWindowIndex(self.my_data().clone(), slot, shred_index);
let req = Protocol::RequestWindowIndex(self.my_data(), slot, shred_index);
let out = serialize(&req)?;
Ok(out)
}

fn window_highest_index_request_bytes(&self, slot: Slot, shred_index: u64) -> Result<Vec<u8>> {
let req = Protocol::RequestHighestWindowIndex(self.my_data().clone(), slot, shred_index);
let req = Protocol::RequestHighestWindowIndex(self.my_data(), slot, shred_index);
let out = serialize(&req)?;
Ok(out)
}

fn orphan_bytes(&self, slot: Slot) -> Result<Vec<u8>> {
let req = Protocol::RequestOrphan(self.my_data().clone(), slot);
let req = Protocol::RequestOrphan(self.my_data(), slot);
let out = serialize(&req)?;
Ok(out)
}
Expand Down Expand Up @@ -1501,7 +1500,7 @@ impl ClusterInfo {
.gossip
.crds
.update_record_timestamp(&from.id, timestamp());
let my_info = me.read().unwrap().my_data().clone();
let my_info = me.read().unwrap().my_data();

let (res, label) = {
match &request {
Expand Down
2 changes: 1 addition & 1 deletion core/src/retransmit_stage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ fn retransmit(
.read()
.unwrap()
.sorted_retransmit_peers_and_stakes(stakes);
let me = cluster_info.read().unwrap().my_data().clone();
let me = cluster_info.read().unwrap().my_data();
let mut discard_total = 0;
let mut repair_total = 0;
let mut retransmit_total = 0;
Expand Down
16 changes: 8 additions & 8 deletions core/src/rpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -95,15 +95,15 @@ impl JsonRpcRequestProcessor {
block_commitment_cache: Arc<RwLock<BlockCommitmentCache>>,
blocktree: Arc<Blocktree>,
storage_state: StorageState,
validator_exit: &Arc<RwLock<Option<ValidatorExit>>>,
validator_exit: Arc<RwLock<Option<ValidatorExit>>>,
) -> Self {
JsonRpcRequestProcessor {
config,
bank_forks,
block_commitment_cache,
blocktree,
storage_state,
validator_exit: validator_exit.clone(),
validator_exit,
}
}

Expand Down Expand Up @@ -1207,7 +1207,7 @@ pub mod tests {
block_commitment_cache.clone(),
blocktree,
StorageState::default(),
&validator_exit,
validator_exit,
)));
let cluster_info = Arc::new(RwLock::new(ClusterInfo::new_with_invalid_keypair(
ContactInfo::default(),
Expand Down Expand Up @@ -1259,7 +1259,7 @@ pub mod tests {
block_commitment_cache,
Arc::new(blocktree),
StorageState::default(),
&validator_exit,
validator_exit,
);
thread::spawn(move || {
let blockhash = bank.confirmed_last_blockhash().0;
Expand Down Expand Up @@ -1756,7 +1756,7 @@ pub mod tests {
block_commitment_cache,
Arc::new(blocktree),
StorageState::default(),
&validator_exit,
validator_exit,
);
Arc::new(RwLock::new(request_processor))
},
Expand Down Expand Up @@ -1854,7 +1854,7 @@ pub mod tests {
block_commitment_cache,
Arc::new(blocktree),
StorageState::default(),
&validator_exit,
validator_exit,
);
assert_eq!(request_processor.validator_exit(), Ok(false));
assert_eq!(exit.load(Ordering::Relaxed), false);
Expand All @@ -1875,7 +1875,7 @@ pub mod tests {
block_commitment_cache,
Arc::new(blocktree),
StorageState::default(),
&validator_exit,
validator_exit,
);
assert_eq!(request_processor.validator_exit(), Ok(true));
assert_eq!(exit.load(Ordering::Relaxed), true);
Expand Down Expand Up @@ -1928,7 +1928,7 @@ pub mod tests {
block_commitment_cache,
Arc::new(blocktree),
StorageState::default(),
&validator_exit,
validator_exit,
);
assert_eq!(
request_processor.get_block_commitment(0),
Expand Down
Loading

0 comments on commit a704089

Please sign in to comment.