Skip to content

Commit

Permalink
chore: bump rust toolchain version from 1.71.0 to 1.74.0
Browse files Browse the repository at this point in the history
Signed-off-by: Phoeniix Zhao <[email protected]>
  • Loading branch information
Phoenix500526 committed Apr 9, 2024
1 parent 1fa58e5 commit 90e826b
Show file tree
Hide file tree
Showing 65 changed files with 398 additions and 268 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/benchmark.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ on:
- cron: "00 00 * * 1"

env:
CI_RUST_TOOLCHAIN: 1.71.0
CI_RUST_TOOLCHAIN: 1.74.0

jobs:
benchmark:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/build_xline.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: Build Xline
env:
CI_RUST_TOOLCHAIN: 1.71.0
CI_RUST_TOOLCHAIN: 1.74.0
on:
workflow_call:
inputs:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/docker_image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ on:
workflow_dispatch: { }

env:
CI_RUST_TOOLCHAIN: 1.71.0
CI_RUST_TOOLCHAIN: 1.74.0
IMAGE_ID: ghcr.io/xline-kv/xline

jobs:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ on:
- "v*"

env:
CI_RUST_TOOLCHAIN: 1.71.0
CI_RUST_TOOLCHAIN: 1.74.0
IMAGE_ID: ghcr.io/xline-kv/xline

jobs:
Expand Down
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ Check the code format.
cargo fmt --all -- --check
```

**Note**: The current version of the Rust toolchain used for CI is **1.71.0** .
**Note**: The current version of the Rust toolchain used for CI is **1.74.0** .
Please use this version to run the above command, otherwise you may get
different results with CI.

Expand Down
2 changes: 1 addition & 1 deletion ci/rust-toolchain.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[toolchain]
channel = "1.71.0"
channel = "1.74.0"
components = ["rustfmt", "clippy", "rust-src"]
24 changes: 15 additions & 9 deletions crates/benchmark/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
clippy::all,
clippy::pedantic,
clippy::cargo,
clippy::cargo,
// The followings are selected restriction lints for rust 1.57
clippy::as_conversions,
Expand Down Expand Up @@ -126,17 +126,23 @@
clippy::impl_trait_in_params,
clippy::let_underscore_untyped,
clippy::missing_assert_message,
clippy::multiple_unsafe_ops_per_block,
clippy::semicolon_inside_block,
// clippy::semicolon_outside_block, already used `semicolon_inside_block`
clippy::tests_outside_test_module,
// 1.71.0
clippy::default_constructed_unit_structs,
clippy::items_after_test_module,
clippy::manual_next_back,
clippy::manual_while_let_some,
clippy::needless_bool_assign,
clippy::non_minimal_cfg,
// The followings are selected lints from 1.71.0 to 1.74.0
clippy::large_stack_frames,
clippy::tuple_array_conversions,
clippy::pub_without_shorthand,
clippy::needless_raw_strings,
clippy::redundant_type_annotations,
clippy::host_endian_bytes,
clippy::big_endian_bytes,
clippy::error_impl_error,
clippy::string_lit_chars_any,
clippy::needless_pass_by_ref_mut,
clippy::redundant_as_str,
clippy::missing_asserts_for_indexing,
)]
#![allow(
clippy::multiple_crate_versions, // caused by the dependency, can't be fixed
Expand Down
32 changes: 31 additions & 1 deletion crates/curp-external-api/src/cmd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@ pub trait Command: pri::Serializable + ConflictCheck + PbCodec {
fn keys(&self) -> &[Self::K];

/// Prepare the command
///
/// # Errors
/// Return `Self::Error` when `CommandExecutor::prepare` go wrong
#[inline]
fn prepare<E>(&self, e: &E) -> Result<Self::PR, Self::Error>
where
Expand All @@ -56,6 +59,9 @@ pub trait Command: pri::Serializable + ConflictCheck + PbCodec {
}

/// Execute the command according to the executor
///
/// # Errors
/// Return `Self::Error` when `CommandExecutor::execute` go wrong
#[inline]
async fn execute<E>(&self, e: &E) -> Result<Self::ER, Self::Error>
where
Expand All @@ -65,6 +71,9 @@ pub trait Command: pri::Serializable + ConflictCheck + PbCodec {
}

/// Execute the command after_sync callback
///
/// # Errors
/// Return `Self::Error` when `CommandExecutor::after_sync` go wrong
#[inline]
async fn after_sync<E>(
&self,
Expand Down Expand Up @@ -111,12 +120,21 @@ where
C: Command,
{
/// Prepare the command
///
/// # Errors
/// This function may return an error if there is a problem preparing the command.
fn prepare(&self, cmd: &C) -> Result<C::PR, C::Error>;

/// Execute the command
///
/// # Errors
/// This function may return an error if there is a problem executing the command.
async fn execute(&self, cmd: &C) -> Result<C::ER, C::Error>;

/// Execute the after_sync callback
///
/// # Errors
/// This function may return an error if there is a problem executing the after_sync callback.
async fn after_sync(
&self,
cmd: &C,
Expand All @@ -125,15 +143,27 @@ where
) -> Result<C::ASR, C::Error>;

/// Set the index of the last log entry that has been successfully applied to the command executor
///
/// # Errors
/// Returns an error if setting the last applied log entry fails.
fn set_last_applied(&self, index: LogIndex) -> Result<(), C::Error>;

/// Index of the last log entry that has been successfully applied to the command executor
/// Get the index of the last log entry that has been successfully applied to the command executor
///
/// # Errors
/// Returns an error if retrieval of the last applied log entry fails.
fn last_applied(&self) -> Result<LogIndex, C::Error>;

/// Take a snapshot
///
/// # Errors
/// This function may return an error if there is a problem taking a snapshot.
async fn snapshot(&self) -> Result<Snapshot, C::Error>;

/// Reset the command executor using the snapshot or to the initial state if None
///
/// # Errors
/// This function may return an error if there is a problem resetting the command executor.
async fn reset(&self, snapshot: Option<(Snapshot, LogIndex)>) -> Result<(), C::Error>;

/// Trigger the barrier of the given trigger id (based on propose id) and log index.
Expand Down
23 changes: 15 additions & 8 deletions crates/curp-external-api/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
clippy::pedantic,
clippy::cargo,
// The followings are selected restriction lints for rust 1.57
clippy::as_conversions,
clippy::clone_on_ref_ptr,
Expand Down Expand Up @@ -126,17 +127,23 @@
clippy::impl_trait_in_params,
clippy::let_underscore_untyped,
clippy::missing_assert_message,
clippy::multiple_unsafe_ops_per_block,
clippy::semicolon_inside_block,
// clippy::semicolon_outside_block, already used `semicolon_inside_block`
clippy::tests_outside_test_module,
// 1.71.0
clippy::default_constructed_unit_structs,
clippy::items_after_test_module,
clippy::manual_next_back,
clippy::manual_while_let_some,
clippy::needless_bool_assign,
clippy::non_minimal_cfg,
// The followings are selected lints from 1.71.0 to 1.74.0
clippy::large_stack_frames,
clippy::tuple_array_conversions,
clippy::pub_without_shorthand,
clippy::needless_raw_strings,
clippy::redundant_type_annotations,
clippy::host_endian_bytes,
clippy::big_endian_bytes,
clippy::error_impl_error,
clippy::string_lit_chars_any,
clippy::needless_pass_by_ref_mut,
clippy::redundant_as_str,
clippy::missing_asserts_for_indexing,
)]

/// Log Index
Expand Down
20 changes: 12 additions & 8 deletions crates/curp-test-utils/src/test_cmd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ impl CommandExecutor<TestCommand> for TestCE {
let keys = cmd
.keys
.iter()
.map(|k| k.to_be_bytes().to_vec())
.map(|k| k.to_le_bytes().to_vec())
.collect_vec();
let result: TestCommandResult = match cmd.cmd_type {
TestCommandType::Get => {
Expand All @@ -275,15 +275,15 @@ impl CommandExecutor<TestCommand> for TestCE {
.map_err(|e| ExecuteError(e.to_string()))?
.into_iter()
.flatten()
.map(|v| u32::from_be_bytes(v.as_slice().try_into().unwrap()))
.map(|v| u32::from_le_bytes(v.as_slice().try_into().unwrap()))
.collect();
let revision = self
.store
.get_multi(REVISION_TABLE, &keys)
.map_err(|e| ExecuteError(e.to_string()))?
.into_iter()
.flatten()
.map(|v| i64::from_be_bytes(v.as_slice().try_into().unwrap()))
.map(|v| i64::from_le_bytes(v.as_slice().try_into().unwrap()))
.collect_vec();
TestCommandResult::new(value, revision)
}
Expand Down Expand Up @@ -316,11 +316,11 @@ impl CommandExecutor<TestCommand> for TestCE {
)];
if let TestCommandType::Put(v) = cmd.cmd_type {
debug!("cmd {:?}-{:?} revision is {}", cmd.cmd_type, cmd, revision);
let value = v.to_be_bytes().to_vec();
let value = v.to_le_bytes().to_vec();
let keys = cmd
.keys
.iter()
.map(|k| k.to_be_bytes().to_vec())
.map(|k| k.to_le_bytes().to_vec())
.collect_vec();
wr_ops.extend(
keys.clone()
Expand All @@ -330,7 +330,7 @@ impl CommandExecutor<TestCommand> for TestCE {
WriteOperation::new_put(
REVISION_TABLE,
key,
revision.to_be_bytes().to_vec(),
revision.to_le_bytes().to_vec(),
)
})),
);
Expand Down Expand Up @@ -361,7 +361,8 @@ impl CommandExecutor<TestCommand> for TestCE {
let Some(index) = self
.store
.get(META_TABLE, APPLIED_INDEX_KEY)
.map_err(|e| ExecuteError(e.to_string()))? else {
.map_err(|e| ExecuteError(e.to_string()))?
else {
return Ok(0);
};
let index = LogIndex::from_le_bytes(index.as_slice().try_into().unwrap());
Expand All @@ -379,7 +380,10 @@ impl CommandExecutor<TestCommand> for TestCE {
snapshot: Option<(Snapshot, LogIndex)>,
) -> Result<(), <TestCommand as Command>::Error> {
let Some((mut snapshot, index)) = snapshot else {
let ops = vec![WriteOperation::new_delete_range(TEST_TABLE, &[], &[0xff]),WriteOperation::new_delete(META_TABLE, APPLIED_INDEX_KEY.as_ref())];
let ops = vec![
WriteOperation::new_delete_range(TEST_TABLE, &[], &[0xff]),
WriteOperation::new_delete(META_TABLE, APPLIED_INDEX_KEY.as_ref()),
];
self.store
.write_batch(ops, true)
.map_err(|e| ExecuteError(e.to_string()))?;
Expand Down
20 changes: 10 additions & 10 deletions crates/curp/src/client/retry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -143,30 +143,30 @@ where

match err {
// some errors that should not retry
CurpError::Duplicated(_)
| CurpError::ShuttingDown(_)
| CurpError::InvalidConfig(_)
| CurpError::NodeNotExists(_)
| CurpError::NodeAlreadyExists(_)
| CurpError::LearnerNotCatchUp(_) => {
CurpError::Duplicated(())
| CurpError::ShuttingDown(())
| CurpError::InvalidConfig(())
| CurpError::NodeNotExists(())
| CurpError::NodeAlreadyExists(())
| CurpError::LearnerNotCatchUp(()) => {
return Err(tonic::Status::from(err));
}

// some errors that could have a retry
CurpError::ExpiredClientId(_)
| CurpError::KeyConflict(_)
CurpError::ExpiredClientId(())
| CurpError::KeyConflict(())
| CurpError::Internal(_)
| CurpError::LeaderTransfer(_) => {}

// update leader state if we got a rpc transport error
CurpError::RpcTransport(_) => {
CurpError::RpcTransport(()) => {
if let Err(e) = self.inner.fetch_leader_id(true).await {
warn!("fetch leader failed, error {e:?}");
}
}

// update the cluster state if got WrongClusterVersion
CurpError::WrongClusterVersion(_) => {
CurpError::WrongClusterVersion(()) => {
// the inner client should automatically update cluster state when fetch_cluster
if let Err(e) = self.inner.fetch_cluster(true).await {
warn!("fetch cluster failed, error {e:?}");
Expand Down
6 changes: 3 additions & 3 deletions crates/curp/src/client/stream.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ impl Streaming {
pub(super) async fn keep_heartbeat(&self) {
/// Prevent lock contention when leader crashed or some unknown errors
const RETRY_DELAY: Duration = Duration::from_millis(100);

#[allow(clippy::ignored_unit_patterns)]
loop {
let heartbeat = self.map_remote_leader::<(), _>(|conn| async move {
loop {
Expand All @@ -78,13 +78,13 @@ impl Streaming {
CurpError::Redirect(Redirect { leader_id, term }) => {
let _ig = self.state.check_and_update_leader(leader_id, term).await;
}
CurpError::WrongClusterVersion(_) => {
CurpError::WrongClusterVersion(()) => {
warn!(
"cannot find the leader in connects, wait for leadership update"
);
self.state.leader_notifier().listen().await;
}
CurpError::ShuttingDown(_) => {
CurpError::ShuttingDown(()) => {
debug!("shutting down stream client background task");
break Err(err);
}
Expand Down
3 changes: 2 additions & 1 deletion crates/curp/src/client/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,7 @@ async fn test_unary_fast_round_less_quorum() {
/// TODO: fix in subsequence PR
#[traced_test]
#[tokio::test]
#[should_panic]
#[should_panic(expected = "should not set exe result twice")]
async fn test_unary_fast_round_with_two_leader() {
let connects = init_mocked_connects(5, |id, conn| {
conn.expect_propose()
Expand Down Expand Up @@ -928,6 +928,7 @@ async fn test_stream_client_keep_alive_hang_up_on_bypassed() {

#[traced_test]
#[tokio::test]
#[allow(clippy::ignored_unit_patterns)]
async fn test_stream_client_keep_alive_resume_on_leadership_changed() {
let connects = init_mocked_stream_connects(5, 1, 2, move |client_id| {
Box::pin(async move {
Expand Down
Loading

0 comments on commit 90e826b

Please sign in to comment.