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

chore: bump rust version to 1.81 #1645

Merged
merged 16 commits into from
Sep 26, 2024
Merged
Show file tree
Hide file tree
Changes from 6 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
2 changes: 1 addition & 1 deletion Cargo.Bazel.Fuzzing.json.lock
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"checksum": "2debd702b24f7c7c56d40695d32c74e12a292344893ba7f1a2441756723febfc",
"checksum": "f5026c7a40e78a70b51f4b198bb812011d948439fd6b9031696128a040190590",
"crates": {
"abnf 0.12.0": {
"name": "abnf",
Expand Down
2 changes: 1 addition & 1 deletion Cargo.Bazel.json.lock
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"checksum": "ef752013465c4aa89c0749caba4ca2cd50f4fdbc0c61e65e3cdc9d6010222704",
"checksum": "7065cd712fb971a438cffb1c5d86c455a1ef31197340b958bcba5637e4aa8190",
"crates": {
"abnf 0.12.0": {
"name": "abnf",
Expand Down
4 changes: 2 additions & 2 deletions WORKSPACE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -227,8 +227,8 @@ rust_register_toolchains(
# The nightly version is required to compile fuzz tests from Bazel.
# The version below is chosen so that it is in sync with the non-nightly version.
versions = [
"1.80.0",
"nightly/2024-06-06",
"1.81.0",
"nightly/2024-07-18",
],
)

Expand Down
2 changes: 1 addition & 1 deletion ci/container/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ ENV PYTHONPATH=/ic/ci/src:/ic/ci/src/dependencies:$PYTHONPATH
RUN cd /tmp/bazel && bazel version

# Add Rust/Cargo support
ARG RUST_VERSION=1.80.0
ARG RUST_VERSION=1.81.0
RUN curl --fail https://sh.rustup.rs -sSf \
| sh -s -- -y --default-toolchain ${RUST_VERSION}-x86_64-unknown-linux-gnu --no-modify-path && \
rustup default ${RUST_VERSION}-x86_64-unknown-linux-gnu && \
Expand Down
3 changes: 1 addition & 2 deletions rs/artifact_pool/src/inmemory_pool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -121,9 +121,8 @@ impl<T: IntoInner<ConsensusMessage> + HasTimestamp + Clone> InMemoryPoolSection<

/// Get a consensus message by its hash
pub fn remove_by_hash(&mut self, hash: &CryptoHash) -> Option<T> {
self.artifacts.remove(hash).map(|artifact| {
self.artifacts.remove(hash).inspect(|artifact| {
self.indexes.remove(artifact.as_ref(), hash);
artifact
})
}

Expand Down
6 changes: 3 additions & 3 deletions rs/boundary_node/prober/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -575,7 +575,7 @@ impl Install for Installer {
0,
);

install_call
() = install_call
.call_and_wait()
.await
.context("failed to install canister")?;
DSharifi marked this conversation as resolved.
Show resolved Hide resolved
Expand Down Expand Up @@ -674,7 +674,7 @@ impl Stop for Stopper {
0,
);

stop_call
() = stop_call
.call_and_wait()
.await
.context("failed to stop canister")?;
Expand Down Expand Up @@ -724,7 +724,7 @@ impl Delete for Deleter {
0,
);

delete_call
() = delete_call
.call_and_wait()
.await
.context("failed to delete canister")?;
Expand Down
3 changes: 1 addition & 2 deletions rs/consensus/src/consensus/block_maker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ impl BlockMaker {
Some(&self.metrics),
)
{
self.propose_block(pool, rank, parent).map(|proposal| {
self.propose_block(pool, rank, parent).inspect(|proposal| {
debug!(
self.log,
"Make proposal {:?} {:?} {:?}",
Expand All @@ -147,7 +147,6 @@ impl BlockMaker {
proposal.as_ref().payload.as_ref()
);
self.log_block(proposal.as_ref());
proposal
})
} else {
None
Expand Down
5 changes: 0 additions & 5 deletions rs/cross-chain/proposal-cli/src/git/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -187,11 +187,6 @@ impl GitRepository {
canister.iter().map(|c| self.sha256_artifact(c)).collect()
}

pub fn build_canister_artifact(&mut self, canister: &TargetCanister) -> CompressedWasmHash {
DSharifi marked this conversation as resolved.
Show resolved Hide resolved
self.build_canisters();
self.sha256_artifact(canister)
}

fn build_canisters(&mut self) {
let build = Command::new("./ci/container/build-ic.sh")
.arg("--canisters")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,16 @@ proptest! {
})]

#[test]
fn debug_trait_on_public_key_bytes_works(public_key_bytes: PublicKeyBytes) { format!("{:?}", public_key_bytes); }
fn debug_trait_on_public_key_bytes_works(public_key_bytes: PublicKeyBytes) { let _ = format!("{:?}", public_key_bytes); }

#[test]
fn debug_trait_on_individual_signature_bytes_works(individual_signature_bytes: IndividualSignatureBytes) { format!("{:?}", individual_signature_bytes); }
fn debug_trait_on_individual_signature_bytes_works(individual_signature_bytes: IndividualSignatureBytes) { let _ = format!("{:?}", individual_signature_bytes); }

#[test]
fn debug_trait_on_pop_bytes_works(pop_bytes: PopBytes) { format!("{:?}", pop_bytes); }
fn debug_trait_on_pop_bytes_works(pop_bytes: PopBytes) { let _ = format!("{:?}", pop_bytes); }

#[test]
fn debug_trait_on_combined_signature_bytes_works(combined_signature_bytes: CombinedSignatureBytes) { format!("{:?}", combined_signature_bytes); }
fn debug_trait_on_combined_signature_bytes_works(combined_signature_bytes: CombinedSignatureBytes) { let _ = format!("{:?}", combined_signature_bytes); }

#[test]
fn debug_should_redact_secretkey_bytes(secret_key_bytes: SecretKeyBytes) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@ proptest! {
})]

#[test]
fn debug_trait_on_public_key_bytes_works(public_key_bytes in threshold_sig_public_key_bytes()) { format!("{:?}", public_key_bytes); }
fn debug_trait_on_public_key_bytes_works(public_key_bytes in threshold_sig_public_key_bytes()) { let _ =format!("{:?}", public_key_bytes); }

#[test]
fn debug_trait_on_individual_signature_bytes_works(individual_signature_bytes: IndividualSignatureBytes) { format!("{:?}", individual_signature_bytes); }
fn debug_trait_on_individual_signature_bytes_works(individual_signature_bytes: IndividualSignatureBytes) { let _ = format!("{:?}", individual_signature_bytes); }

#[test]
fn debug_trait_on_combined_signature_bytes_works(combined_signature_bytes: CombinedSignatureBytes) { format!("{:?}", combined_signature_bytes); }
fn debug_trait_on_combined_signature_bytes_works(combined_signature_bytes: CombinedSignatureBytes) { let _ = format!("{:?}", combined_signature_bytes); }

#[test]
fn debug_should_redact_secretkey_bytes(secret_key_bytes: SecretKeyBytes) {
Expand Down
4 changes: 2 additions & 2 deletions rs/ethereum/ledger-suite-orchestrator/src/management/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ impl CanisterRuntime for IcCanisterRuntime {
sender_canister_version: None,
};

self.call("install_code", 0, &install_code).await?;
() = self.call("install_code", 0, &install_code).await?;

Ok(())
}
Expand All @@ -288,7 +288,7 @@ impl CanisterRuntime for IcCanisterRuntime {
sender_canister_version: None,
};

self.call("install_code", 0, &install_code).await?;
() = self.call("install_code", 0, &install_code).await?;

Ok(())
}
Expand Down
3 changes: 1 addition & 2 deletions rs/https_outcalls/adapter/src/rpc_server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -162,12 +162,11 @@ impl HttpsOutcallsService for CanisterHttp {
})?;

// Build Http Request.
let mut headers = validate_headers(req.headers).map_err(|err| {
let mut headers = validate_headers(req.headers).inspect_err(|_| {
self.metrics
.request_errors
.with_label_values(&[LABEL_REQUEST_HEADERS])
.inc();
err
})?;

// Add user-agent header if not present.
Expand Down
2 changes: 1 addition & 1 deletion rs/nervous_system/root/src/change_canister.rs
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ where
{
// stop_canister returns the candid empty type, which cannot be parsed using
// dfn_candid::candid
Rt::call_with_cleanup(
() = Rt::call_with_cleanup(
CanisterId::ic_00(),
"stop_canister",
(CanisterIdRecord::from(canister_id),),
Expand Down
4 changes: 2 additions & 2 deletions rs/nns/integration_tests/src/governance_time_warp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ fn test_time_warp() {
// disbursal.
let duration_since_start_s = get_timestamp_s() - start_timestamp_s;
let mut delta_s = (TWELVE_MONTHS_SECONDS - duration_since_start_s - 100) as i64;
nns_canisters
() = nns_canisters
.governance
.update_("set_time_warp", candid_one, TimeWarp { delta_s })
.await?;
Expand Down Expand Up @@ -138,7 +138,7 @@ fn test_time_warp() {
// Advance time slightly (200 s) such that that the neuron should be fully
// dissolved.
delta_s += 200;
nns_canisters
() = nns_canisters
.governance
.update_("set_time_warp", candid_one, TimeWarp { delta_s })
.await?;
Expand Down
2 changes: 1 addition & 1 deletion rs/nns/integration_tests/src/wait_for_quiet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ fn test_deadline_is_extended_with_wait_for_quiet() {
// Set the TimeWarp one day in the future so a change to the WFQ deadline has a measurable
// effect
let delta_s = ONE_DAY_SECONDS as i64;
nns_canisters
() = nns_canisters
.governance
.update_("set_time_warp", candid_one, TimeWarp { delta_s })
.await?;
Expand Down
2 changes: 1 addition & 1 deletion rs/nns/sns-wasm/canister/canister.rs
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ fn handle_call_error(prefix: String) -> impl FnOnce((Option<i32>, String)) -> St

impl CanisterApiImpl {
async fn stop_canister(&self, canister: CanisterId) -> Result<(), String> {
dfn_core::call(
() = dfn_core::call(
CanisterId::ic_00(),
"stop_canister",
candid_one,
Expand Down
15 changes: 5 additions & 10 deletions rs/p2p/quic_transport/src/connection_handle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,11 +90,10 @@ impl ConnectionHandle {
.connection_handle_bytes_received_total
.with_label_values(&[request.uri().path()]);

let (send_stream, recv_stream) = self.connection.open_bi().await.map_err(|err| {
let (send_stream, recv_stream) = self.connection.open_bi().await.inspect_err(|_| {
self.metrics
.connection_handle_errors_total
.with_label_values(&[REQUEST_TYPE_RPC, ERROR_TYPE_OPEN]);
err
})?;

let mut send_stream_guard = SendStreamDropGuard::new(send_stream);
Expand All @@ -107,36 +106,32 @@ impl ConnectionHandle {
.unwrap_or_default();
let _ = send_stream.set_priority(priority.into());

write_request(send_stream, request).await.map_err(|err| {
write_request(send_stream, request).await.inspect_err(|_| {
self.metrics
.connection_handle_errors_total
.with_label_values(&[REQUEST_TYPE_RPC, ERROR_TYPE_WRITE])
.inc();
err
})?;

send_stream.finish().map_err(|err| {
send_stream.finish().inspect_err(|_| {
self.metrics
.connection_handle_errors_total
.with_label_values(&[REQUEST_TYPE_RPC, ERROR_TYPE_FINISH])
.inc();
err
})?;

send_stream.stopped().await.map_err(|err| {
send_stream.stopped().await.inspect_err(|_| {
self.metrics
.connection_handle_errors_total
.with_label_values(&[REQUEST_TYPE_PUSH, ERROR_TYPE_STOPPED])
.inc();
err
})?;

let mut response = read_response(recv_stream).await.map_err(|err| {
let mut response = read_response(recv_stream).await.inspect_err(|_| {
self.metrics
.connection_handle_errors_total
.with_label_values(&[REQUEST_TYPE_RPC, ERROR_TYPE_READ])
.inc();
err
})?;

// Propagate PeerId from this request to upper layers.
Expand Down
3 changes: 1 addition & 2 deletions rs/query_stats/src/payload_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -375,12 +375,11 @@ impl QueryStatsPayloadBuilderImpl {
// Deserialize the payload
.filter_map(|past_payload| {
QueryStatsPayload::deserialize(past_payload.payload)
.map_err(|err| {
.inspect_err(|_| {
error!(
self.log,
"Failed to deserialize past payload, this is a bug"
);
err
})
.ok()
.flatten()
Expand Down
3 changes: 1 addition & 2 deletions rs/replica/src/setup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,11 @@ use std::{env, path::PathBuf, sync::Arc};
pub fn parse_args() -> Result<ReplicaArgs, clap::Error> {
let args_result = ReplicaArgs::try_parse_from(env::args());

args_result.map(|args| {
args_result.inspect(|args| {
if args.print_sample_config {
print!("{}", SAMPLE_CONFIG);
std::process::exit(0);
}
args
})
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -811,15 +811,13 @@ impl CallContextManager {
/// If we get a response for one of the outstanding calls, we unregister
/// the callback and return it.
pub fn unregister_callback(&mut self, callback_id: CallbackId) -> Option<Arc<Callback>> {
self.callbacks.remove(&callback_id).map(|callback| {
self.stats.on_unregister_callback(&callback);
self.callbacks.remove(&callback_id).inspect(|callback| {
self.stats.on_unregister_callback(callback);
if callback.deadline != NO_DEADLINE {
self.unexpired_callbacks
.remove(&(callback.deadline, callback_id));
}
debug_assert!(self.stats_ok());

callback
})
}

Expand Down
1 change: 1 addition & 0 deletions rs/rosetta-api/icrc1/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ ic-icrc1-index-ng = { path = "index-ng" }
ic-icrc1-ledger = { path = "ledger" }
ic-icrc1-ledger-sm-tests = { path = "ledger/sm-tests" }
ic-icrc1-test-utils = { path = "test_utils" }
ic-icrc1-tokens-u256 = { path = "tokens_u256" }
ic-nns-test-utils = { path = "../../nns/test_utils" }
ic-nns-test-utils-golden-nns-state = { path = "../../nns/test_utils/golden_nns_state" }
ic-registry-subnet-type = { path = "../../registry/subnet_type" }
Expand Down
2 changes: 1 addition & 1 deletion rs/rosetta-api/ledger_canister_core/src/spawn.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ where
sender_canister_version: None,
};

Rt::call(IC_00, "install_code", /*cycles=*/ 0, (install_code,)).await?;
() = Rt::call(IC_00, "install_code", /*cycles=*/ 0, (install_code,)).await?;

Ok(())
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,7 @@ impl RosettaTestingEnvironmentBuilder {
self
}

#[allow(dead_code)]
pub fn with_initial_balances(
mut self,
initial_balances: HashMap<AccountIdentifier, icp_ledger::Tokens>,
Expand Down
1 change: 1 addition & 0 deletions rs/rosetta-api/tests/test_utils/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ impl TestLedger {
}
}

#[allow(dead_code)]
pub async fn add_block(&self, hb: HashedBlock) -> Result<(), ApiError> {
let mut blockchain = self.blockchain.write().await;
blockchain.push(&hb).map_err(ApiError::from)?;
Expand Down
3 changes: 2 additions & 1 deletion rs/rust_canisters/canister_test/src/canister.rs
Original file line number Diff line number Diff line change
Expand Up @@ -811,7 +811,8 @@ impl<'a> Canister<'a> {

/// Tries to delete this canister.
pub async fn delete(&self) -> Result<(), String> {
self.runtime
() = self
.runtime
.get_management_canister_with_effective_canister_id(self.canister_id().into())
.update_("delete_canister", candid_multi_arity, (self.as_record(),))
.await?;
Expand Down
4 changes: 2 additions & 2 deletions rs/sns/root/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2805,15 +2805,15 @@ mod tests {
async fn test_get_sns_canisters_summary_reports_settings() {
// Step 1: Prepare the world.
thread_local! {
static SNS_ROOT_CANISTER: RefCell<SnsRootCanister> = RefCell::new(SnsRootCanister {
static SNS_ROOT_CANISTER: RefCell<SnsRootCanister> = const { RefCell::new(SnsRootCanister {
governance_canister_id: Some(PrincipalId::new_user_test_id(1)),
ledger_canister_id: Some(PrincipalId::new_user_test_id(2)),
swap_canister_id: Some(PrincipalId::new_user_test_id(3)),
dapp_canister_ids: vec![],
archive_canister_ids: vec![],
index_canister_id: Some(PrincipalId::new_user_test_id(4)),
testflight: false,
});
}) };
}

let root_canister_id = CanisterId::from_u64(4);
Expand Down
10 changes: 3 additions & 7 deletions rs/state_layout/src/state_layout.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2298,13 +2298,9 @@ impl TryFrom<pb_canister_state_bits::CanisterStateBits> for CanisterStateBits {
.map(|c| c.try_into())
.transpose()?;

let consumed_cycles = match try_from_option_field(
value.consumed_cycles,
"CanisterStateBits::consumed_cycles",
) {
Ok(consumed_cycles) => consumed_cycles,
Err(_) => NominalCycles::default(),
};
let consumed_cycles =
try_from_option_field(value.consumed_cycles, "CanisterStateBits::consumed_cycles")
.unwrap_or_default();

let mut controllers = BTreeSet::new();
for controller in value.controllers.into_iter() {
Expand Down
Loading
Loading