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 ruct toolchain version from 1.71.0 to 1.74.0 #758

Merged
merged 1 commit into from
Apr 18, 2024
Merged
Show file tree
Hide file tree
Changes from all 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 .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 .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ repos:
- id: conventional-commit-msg-validation
name: commit message conventional validation
language: pygrep
entry: '^(breaking|build|chore|ci|docs|feat|fix|perf|refactor|revert|style|test){1}(\([\w\-\.]+\))?(!)?: ([\w `])+([\s\S]*)'
entry: '^(breaking|build|chore|ci|docs|feat|fix|perf|refactor|revert|style|test|squash|fixup){1}(\([\w\-\.]+\))?(!)?: ([\w `])+([\s\S]*)'
args: [--multiline, --negate]
stages: [commit-msg]
- id: commit-msg-needs-to-be-signed-off
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"]
22 changes: 14 additions & 8 deletions crates/benchmark/src/lib.rs
Original file line number Diff line number Diff line change
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,
bsbds marked this conversation as resolved.
Show resolved Hide resolved
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` goes 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` goes 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` goes 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
12 changes: 6 additions & 6 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())
Phoenix500526 marked this conversation as resolved.
Show resolved Hide resolved
.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
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)] // tokio select internal triggered
bsbds marked this conversation as resolved.
Show resolved Hide resolved
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)] // tokio select internal triggered
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
Loading